1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/state-C7hNOihD.js","assets/app-F39tXj7K.js","assets/app-OQuk6CE5.css"])))=>i.map(i=>d[i]); 2import{a as An,_ as Ig}from"./app-F39tXj7K.js";import{o as Oo,a as Dg}from"./state-C7hNOihD.js";import{b as Pg,c as $g}from"./info-BM0dH7bn.js";import{r as zg,b as Oh}from"./index-okwOQ6Bo.js";import{_ as Bg,D as _g,E as Hg}from"./src-pages-app-index-CBI1rolp.js";import{r as Fg,n as Mr,a as Vg,b as jg,d as Lh,l as Wg,c as Ih,s as Yl}from"./styles-C1f9_jsa.js";import{j as ma,k as Ug}from"./index-DL1oSN-7.js";import{k as qg,b as Kg}from"./index-Vcq4gwWv.js";import{S as au,T as Jg,V as Dh,W as Ph,X as Gg,Y as $h,Z as Qt,_ as Yg,$ as Qg,m as Wn,a0 as Pi,a1 as ga,a2 as zh,D as Bh,a3 as lu,a4 as Xg,a5 as cu,a6 as _h,a7 as Hh,a8 as uu,a9 as rs,aa as ya,ab as Zt,ac as tl,ad as nl,ae as Zg,af as ey,ag as ty,ah as ny,ai as ry,s as Fh,aj as sy,ak as iy,al as oy,am as ay,an as ly,ao as cy,ap as uy,j as dy,n as hy,aq as fy,ar as py,a as my,e as du}from"./yjs-BceEKs5w.js";import{c as gy,W as yy,I as by}from"./y-indexeddb-CODnnE1s.js";import Vh from"./katex-HP8lGamR.js";import{m as ky}from"./index-qeTFkAGI.js";import{i as rl}from"./index-HYjaO52u.js";import xy from"./index-CzTpxCJR.js";
vendor: 19,809 bytes, line 2
2import{n as xs,p as jh,G as yr,b as wy,P as Sy}from"./prism-tomorrow-C49veqKq.js";import{c as vy}from"./index-DtljZvJM.js";import{g as Cy}from"./_commonjsHelpers-CE1G-McA.js";import{b as My,D as Wh}from"./index-FRaZuSR_.js";import{s as Bn}from"./search-CO9mTpNT.js";import{g as FA}from"./search-CO9mTpNT.js";import{m as Cn}from"./index-B9fViuMG.js";import"./index-B79LEOz5.js";import"./utils-BZQ5PvAP.js";import"./router-B4-bvdrn.js";import"./index-CFenC0TT.js";import"./index-DqRvP2h-.js";import"./index-DDlvirwQ.js";import"./MorphSVGPlugin-B-vk8YRp.js";import"./urls-Dlhz5ZoX.js";import"./haptics-EMPnpCo7.js";import"./init-BMyMGI5-.js";import"./index-D9tXI2hI.js";import"./route-resolver-B7oJAapS.js";import"./datetime-DB4dKE0E.js";import"./deep-links-B_JhV1Lb.js";/* empty css *//* empty css */import"./index-DXT6OdaW.js";import"./index.esm-DVXwz09-.js";import"./card-DoC5SNzl.js";import"./index-Cf6pUz87.js";import"./purify.es-Cz4mVeUR.js";import"./chip-D1B9yXwC.js";import"./nfc-Czb1hNmf.js";import"./ble-protocol-Bz9lw6YH.js";import"./review-BJ2TxDyf.js";import"./index-B2zDUSUP.js";import"./window-CSfQsvbn.js";import"./index-C3r2inTX.js";import"./select-mHgn3TAd.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./file-optimizer-DGQWhrpO.js";import"./index-BD6S4voc.js";import"./base-Cxvbrg-u.js";function je(t){this.content=t}je.prototype={constructor:je,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new je(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new je(n)},addToStart:function(t,e){return new je([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new je(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new je(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=je.from(t),t.size?new je(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=je.from(t),t.size?new je(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=je.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};je.from=function(t){if(t instanceof je)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new je(e)};function Uh(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=Uh(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function qh(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),a=e.child(--i),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let c=0,u=Math.min(o.text.length,a.text.length);for(;c<u&&o.text[o.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let c=qh(o.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class A{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,a=0;a<n;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&r(l,s+a,i||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,s+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new A(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let a=this.content[i],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),s+=a.nodeSize),o=l}return new A(r,s)}cutByIndex(e,n){return e==n?A.empty:e==0&&n==this.content.length?this:new A(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new A(s,i)}addToStart(e){return new A([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new A(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Uh(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return qh(this,e,n,r)}findIndex(e){if(e==0)return ni(0,e);if(e==this.size)return ni(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?ni(n+1,i):ni(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return A.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return A.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return A.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new A(n||e,r)}static from(e){if(!e)return A.empty;if(e instanceof A)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new A([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}A.empty=new A([],0);const ba={index:0,offset:0};function ni(t,e){return ba.index=t,ba.offset=e,ba}function $i(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!$i(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!$i(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ge=class sl{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&$i(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return sl.none;if(e instanceof sl)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};ge.none=[];class zi extends Error{}class D{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Jh(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new D(r,this.openStart,this.openEnd)}removeBetween(e,n){return new D(Kh(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return D.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new D(A.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new D(e,r,s)}}D.empty=new D(A.empty,0,0);function Kh(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(s==e||i.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Kh(i.content,e-s-1,n-s-1)))}function Jh(t,e,n,r,s,i){let{index:o,offset:a}=t.findIndex(e),l=t.maybeChild(o);if(a==e||l.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Jh(l.content,e-a-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,l);return c&&t.replaceChild(o,l.copy(c))}function Ty(t,e,n){if(n.openStart>t.depth)throw new zi("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new zi("Inconsistent open depths");return Gh(t,e,n,0)}function Gh(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=Gh(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,a=o.content;return qn(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=Ey(n,t);return qn(i,Qh(t,o,a,e,r))}else return qn(i,Bi(t,e,r))}function Yh(t,e){if(!e.type.compatibleContent(t.type))throw new zi("Cannot join "+e.type.name+" onto "+t.type.name)}function il(t,e,n){let r=t.node(n);return Yh(r,e.node(n)),r}function Un(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function ss(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Un(t.nodeAfter,r),i++));for(let a=i;a<o;a++)Un(s.child(a),r);e&&e.depth==n&&e.textOffset&&Un(e.nodeBefore,r)}function qn(t,e){return t.type.checkContent(e),t.copy(e)}function Qh(t,e,n,r,s){let i=t.depth>s&&il(t,e,s+1),o=r.depth>s&&il(n,r,s+1),a=[];return ss(null,t,s,a),i&&o&&e.index(s)==n.index(s)?(Yh(i,o),Un(qn(i,Qh(t,e,n,r,s+1)),a)):(i&&Un(qn(i,Bi(t,e,s+1)),a),ss(e,n,s,a),o&&Un(qn(o,Bi(n,r,s+1)),a)),ss(r,null,s,a),new A(a)}function Bi(t,e,n){let r=[];if(ss(null,t,n,r),t.depth>n){let s=il(t,e,n+1);Un(qn(s,Bi(t,e,n+1)),r)}return ss(e,null,n,r),new A(r)}function Ey(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(A.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class ws{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ge.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let a=r;r=s,s=a}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new _i(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(i),c=i-l;if(r.push(o,a,s+l),!c||(o=o.child(a),o.isText))break;i=c-1,s+=l+1}return new ws(n,r,i)}static resolveCached(e,n){let r=hu.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else hu.set(e,r=new Ay);let s=r.elts[r.i]=ws.resolve(e,n);return r.i=(r.i+1)%Ny,s}}class Ay{constructor(){this.elts=[],this.i=0}}const Ny=12,hu=new WeakMap;class _i{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Ry=Object.create(null);class Et{constructor(e,n,r,s=ge.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&$i(this.attrs,n||e.defaultAttrs||Ry)&&ge.sameSet(this.marks,r||ge.none)}copy(e=null){return e==this.content?this:new Et(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Et(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return D.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),a=s.start(o),c=s.node(o).content.cut(s.pos-a,i.pos-a);return new D(c,s.depth-o,i.depth-o)}replace(e,n,r){return Ty(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return ws.resolveCached(this,e)}resolveNoCache(e){return ws.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),Xh(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=A.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=s;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.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=ge.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ge.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}
2`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=A.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}Et.prototype.text=void 0;class Hi extends Et{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Xh(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Hi(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Hi(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Xh(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class tr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Oy(e,n);if(r.next==null)return tr.empty;let s=Zh(r);r.next&&r.err("Unexpected trailing text");let i=By(zy(s));return _y(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,a){let l=o.matchFragment(e,r);if(l&&(!n||l.validEnd))return A.from(a.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let h=i(d,a.concat(u));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let a=s;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:a,next:l}=i.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!s.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:s}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(` 3`)}}tr.empty=new tr(!0);class Oy{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Zh(t){let e=[];do e.push(Ly(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ly(t){let e=[];do e.push(Iy(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Iy(t){let e=$y(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Dy(t,e);else break;return e}function fu(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");
vendor: 15,204 bytes, lines 3-5
3let e=Number(t.next);return t.pos++,e}function Dy(t,e){let n=fu(t),r=n;return t.eat(",")&&(t.next!="}"?r=fu(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Py(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function $y(t){if(t.eat("(")){let e=Zh(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Py(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function zy(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,a,l){let c={term:l,to:a};return e[o].push(c),c}function s(o,a){o.forEach(l=>l.to=a)}function i(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(i(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=i(o.exprs[l],a);if(l==o.exprs.length-1)return c;s(c,a=n())}else if(o.type=="star"){let l=n();return r(a,l),s(i(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=n();return s(i(o.expr,a),l),s(i(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(i(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c<o.min;c++){let u=n();s(i(o.expr,l),u),l=u}if(o.max==-1)s(i(o.expr,l),l);else for(let c=o.min;c<o.max;c++){let u=n();r(l,u),s(i(o.expr,l),u),l=u}return[r(l)]}else{if(o.type=="name")return[r(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function ef(t,e){return e-t}function pu(t,e){let n=[];return r(e),n.sort(ef);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:a,to:l}=i[o];!a&&n.indexOf(l)==-1&&r(l)}}}function By(t){let e=Object.create(null);return n(pu(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<s.length;u++)s[u][0]==a&&(c=s[u][1]);pu(t,l).forEach(u=>{c||s.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new tr(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let a=s[o][1].sort(ef);i.next.push({type:s[o][0],next:e[a.join(",")]||n(a)})}return i}}function _y(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let a=0;a<s.next.length;a++){let{type:l,next:c}=s.next[a];o.push(l.name),i&&!(l.isText||l.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function tf(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function nf(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function rf(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let i=t[s];i.validate&&i.validate(e[s])}}function sf(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Fy(t,r,e[r]);return n}let mu=class of{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=sf(e,r.attrs),this.defaultAttrs=tf(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==tr.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:nf(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Et(this,this.computeAttrs(e),A.from(n),ge.setFrom(r))}createChecked(e=null,n,r){return n=A.from(n),this.checkContent(n),new Et(this,this.computeAttrs(e),n,ge.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=A.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(A.empty,!0);return i?new Et(this,e,n.append(i),ge.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){rf(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:ge.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new of(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Hy(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class Fy{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Hy(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Lo{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=sf(e,s.attrs),this.excluded=null;let i=tf(this.attrs);this.instance=i?new ge(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ge(this,nf(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new Lo(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){rf(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class af{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=je.from(e.nodes),n.marks=je.from(e.marks||{}),this.nodes=mu.compile(this.spec.nodes,this),this.marks=Lo.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",a=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=tr.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=a=="_"?null:a?gu(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:gu(this,o.split(" "))}this.nodeFromJSON=s=>Et.fromJSON(this,s),this.markFromJSON=s=>ge.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof mu){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Hi(r,r.defaultAttrs,e,ge.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function gu(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let a in t.marks){let l=t.marks[a];(s=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Vy(t){return t.tag!=null}function jy(t){return t.style!=null}class en{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Vy(s))this.tags.push(s);else if(jy(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new bu(this,n,!1);return r.addAll(e,ge.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new bu(this,n,!0);return r.addAll(e,ge.none,n.from,n.to),D.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(qy(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let a=n[o];if((a.priority==null?50:a.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=ku(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=ku(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new en(e,en.schemaRules(e)))}}const lf={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},Wy={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},cf={ol:!0,ul:!0},Ss=1,ol=2,is=4;function yu(t,e,n){return e!=null?(e?Ss:0)|(e==="full"?ol:0):t&&t.whitespace=="pre"?Ss|ol:n&~is}class ri{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=ge.none,this.match=i||(o&is?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(A.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ss)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=A.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(A.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!lf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class bu{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=yu(null,n.preserveWhitespace,0)|(r?is:0);s?i=new ri(s.type,s.attrs,ge.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new ri(null,null,ge.none,!0,null,o):i=new ri(e.schema.topNodeType,null,ge.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&ol?"full":this.localPreserveWS||(s.options&Ss)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,` 4`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(o.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(o.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=s.content[s.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;cf.hasOwnProperty(o)&&this.parser.normalizeLists&&Uy(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:Wy.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(lf.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=l&&l.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` 5`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(i,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,s){let i,o;
vendor: 4,119 bytes, line 5
5if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,n.attrs||null,r,n.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(a)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=s==null?null:e.childNodes[s];o!=a;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(e);if(c&&(!s||s.length>c.length+a)&&(s=c,i=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=ge.none;for(let a of s.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):xu(a.type,e.type))&&(o=a.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=yu(e,i,o.options);o.options&is&&o.content.length==0&&(a|=is);let l=ge.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):xu(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new ri(e,n,l,s,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ss)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=i;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&s?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];
vendor: 22,798 bytes, lines 5-6
5if(r.isTextblock&&r.defaultAttrs)return r}}}function Uy(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&cf.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function qy(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ku(t){let e={};for(let n in t)e[n]=t[n];return e}function xu(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=a=>{i.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class cr{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=si(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let a=0,l=0;for(;a<i.length&&l<o.marks.length;){let c=o.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(i[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<i.length;)s=i.pop()[1];for(;l<o.marks.length;){let c=o.marks[l++],u=this.serializeMark(c,o.isInline,n);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return si(n).createTextNode(e.text);let{dom:r,contentDOM:s}=Ti(si(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Ti(si(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:Ti(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new cr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=wu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return wu(e.marks)}}function wu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function si(t){return t.document||window.document}const Su=new WeakMap;function Ky(t){let e=Su.get(t);return e===void 0&&Su.set(t,e=Jy(t)),e}function Jy(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Ti(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Ky(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let a,l=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?l.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&l.style?l.style.cssText=c[d]:l.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else if(typeof h=="string")l.appendChild(t.createTextNode(h));else{let{dom:f,contentDOM:p}=Ti(t,h,n,r);if(l.appendChild(f),p){if(a)throw new RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}const uf=65535,df=Math.pow(2,16);function Gy(t,e){return t+e*df}function vu(t){return t&uf}function Yy(t){return(t-(t&uf))/df}const hf=1,ff=2,Ei=4,pf=8;class al{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&pf)>0}get deletedBefore(){return(this.delInfo&(hf|Ei))>0}get deletedAfter(){return(this.delInfo&(ff|Ei))>0}get deletedAcross(){return(this.delInfo&Ei)>0}}class ct{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ct.empty)return ct.empty}recover(e){let n=0,r=vu(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+Yy(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?s:0);if(l>e)break;let c=this.ranges[a+i],u=this.ranges[a+o],d=l+c;if(e<=d){let h=c?e==l?-1:e==d?1:n:n,f=l+s+(h<0?0:u);if(r)return f;let p=e==(n<0?l:d)?null:Gy(a/3,e-l),m=e==l?ff:e==d?hf:Ei;return(n<0?e!=l:e!=d)&&(m|=pf),new al(f,m,p)}s+=u-c}return r?e+s:new al(e+s,0,null)}touches(e,n){let r=0,s=vu(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+i],u=l+c;if(e<=u&&a==s*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],a=o-(this.inverted?i:0),l=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(a,a+c,l,l+u),i+=u-c}}invert(){return new ct(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ct.empty:new ct(e<0?[0,-e,0]:[0,0,e])}}ct.empty=new ct([]);class vs{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new vs(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new vs;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],a=o.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(a.recover);continue}}s|=a.delInfo,e=a.pos}return r?e:new al(e,s,null)}}const ka=Object.create(null);class Xe{getMap(){return ct.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ka[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ka)throw new RangeError("Duplicate use of step JSON ID "+e);return ka[e]=n,n.prototype.jsonID=e,n}}class Pe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Pe(e,null)}static fail(e){return new Pe(null,e)}static fromReplace(e,n,r,s){try{return Pe.ok(e.replace(n,r,s))}catch(i){if(i instanceof zi)return Pe.fail(i.message);throw i}}}function Ql(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Ql(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return A.fromArray(r)}class wn extends Xe{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new D(Ql(n.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return Pe.fromReplace(e,this.from,this.to,i)}invert(){return new Mt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new wn(n.pos,r.pos,this.mark)}merge(e){return e instanceof wn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new wn(n.from,n.to,e.markFromJSON(n.mark))}}Xe.jsonID("addMark",wn);class Mt extends Xe{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new D(Ql(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return Pe.fromReplace(e,this.from,this.to,r)}invert(){return new wn(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Mt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Mt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Mt(n.from,n.to,e.markFromJSON(n.mark))}}Xe.jsonID("removeMark",Mt);class Sn extends Xe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Pe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Pe.fromReplace(e,this.pos,this.pos+1,new D(A.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Sn(this.pos,n.marks[s]);return new Sn(this.pos,this.mark)}}return new nr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Sn(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Sn(n.pos,e.markFromJSON(n.mark))}}Xe.jsonID("addNodeMark",Sn);class nr extends Xe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Pe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Pe.fromReplace(e,this.pos,this.pos+1,new D(A.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Sn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new nr(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new nr(n.pos,e.markFromJSON(n.mark))}}Xe.jsonID("removeNodeMark",nr);class De extends Xe{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&ll(e,this.from,this.to)?Pe.fail("Structure replace would overwrite content"):Pe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ct([this.from,this.to-this.from,this.slice.size])}invert(e){return new De(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&De.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new De(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof De)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?D.empty:new D(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new De(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?D.empty:new D(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new De(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new De(n.from,n.to,D.fromJSON(e,n.slice),!!n.structure)}}De.MAP_BIAS=1;Xe.jsonID("replace",De);class He extends Xe{constructor(e,n,r,s,i,o,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=a}apply(e){if(this.structure&&(ll(e,this.from,this.gapFrom)||ll(e,this.gapTo,this.to)))return Pe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Pe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Pe.fromReplace(e,this.from,this.to,r):Pe.fail("Content does not fit in gap")}getMap(){return new ct([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new He(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new He(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new He(n.from,n.to,n.gapFrom,n.gapTo,D.fromJSON(e,n.slice),n.insert,!!n.structure)}}Xe.jsonID("replaceAround",He);function ll(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function Qy(t,e,n,r){let s=[],i=[],o,a;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+l.nodeSize,n),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(o&&o.to==h&&o.mark.eq(d[m])?o.to=f:s.push(o=new Mt(h,f,d[m])));a&&a.to==h?a.to=f:i.push(a=new wn(h,f,r))}}),s.forEach(l=>t.step(l)),i.forEach(l=>t.step(l))}function Xy(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,a)=>{if(!o.isInline)return;i++;let l=null;if(r instanceof Lo){let c=o.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let c=Math.min(a+o.nodeSize,n);for(let u=0;u<l.length;u++){let d=l[u],h;for(let f=0;f<s.length;f++){let p=s[f];p.step==i-1&&d.eq(s[f].style)&&(h=p)}h?(h.to=c,h.step=i):s.push({style:d,from:Math.max(a,e),to:c,step:i})}}}),s.forEach(o=>t.step(new Mt(o.from,o.to,o.style)))}function Xl(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<i.childCount;l++){let c=i.child(l),u=a+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new De(a,u,D.empty));else{r=d;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Mt(a,u,c.marks[h]));if(s&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new D(A.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new De(a+h.index,a+h.index+h[0].length,p))}}a=u}if(!r.validEnd){let l=r.fillBefore(A.empty,!0);t.replace(a,a,new D(l,0,0))}for(let l=o.length-1;l>=0;l--)t.step(o[l])}function Zy(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function $r(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),a=t.$from.index(r)+s,l=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(a,l,n))return r;if(r==0||o.type.spec.isolating||!Zy(o,a,l))break;a&&(s=1),l<o.childCount&&(i=1)}return null}function eb(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),a=s.after(i+1),l=o,c=a,u=A.empty,d=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=A.from(r.node(p).copy(u)),d++):l--;let h=A.empty,f=0;for(let p=i,m=!1;p>n;p--)m||s.after(p+1)<s.end(p)?(m=!0,h=A.from(s.node(p).copy(h)),f++):c++;t.step(new He(l,c,o,a,new D(u.append(h),d,f),u.size-d,!0))}function Zl(t,e,n=null,r=t){let s=tb(t,e),i=s&&nb(r,e);return i?s.map(Cu).concat({type:e,attrs:n}).concat(i.map(Cu)):null}function Cu(t){return{type:t,attrs:null}}function tb(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function nb(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;l&&c<s;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:o}function rb(t,e,n){let r=A.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let a=n[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=A.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new He(s,i,s,i,new D(r,0,0),n.length,!0))}function sb(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,a)=>{let l=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,l)&&ib(t.doc,t.mapping.slice(i).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&gf(t,o,a,i),Xl(t,t.mapping.slice(i).map(a,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(a,1),h=u.map(a+o.nodeSize,1);return t.step(new He(d,h,d+1,h-1,new D(A.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&mf(t,o,a,i),!1}})}function mf(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(s.text);){let l=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function gf(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(` 6`))}})}function ib(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function ob(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new He(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new D(A.from(o),0,0),1,!0))}function tn(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>i;c--,u--){let d=s.node(c),h=s.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(h+1,d.childCount)||!m.type.validContent(f))return!1}let a=s.indexAfter(i),l=r&&r[0];return s.node(i).canReplaceWith(a,a,l?l.type:s.node(i+1).type)}function ab(t,e,n=1,r){let s=t.doc.resolve(e),i=A.empty,o=A.empty;for(let a=s.depth,l=s.depth-n,c=n-1;a>l;a--,c--){i=A.from(s.node(a).copy(i));let u=r&&r[c];o=A.from(u?u.type.create(u.attrs,o):s.node(a).copy(o))}t.step(new De(e,e,new D(i.append(o),n,n),!0))}function On(t,e){let n=t.resolve(e),r=n.index();return yf(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function lb(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function yf(t,e){return!!(t&&e&&!t.isLeaf&&lb(t,e))}function Io(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,a=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),a++,o=r.node(s).maybeChild(a)):(i=r.node(s).maybeChild(a-1),o=r.node(s+1)),i&&!i.isTextblock&&yf(i,o)&&r.node(s).canReplace(a,a+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function cb(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let a=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);gf(t,u.node(),u.before(),a)}o.inlineContent&&Xl(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new De(c,l.map(e+n,-1),D.empty,!0)),r===!0){let u=t.doc.resolve(c);mf(t,u.node(),u.before(),t.steps.length)}return t}function ub(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function bf(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.
vendor: 11,684 bytes, line 6
6index(o)+(a>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(l,l,s);else{let d=c.contentMatchAt(l).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function Do(t,e,n=e,r=D.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return kf(s,i,r)?new De(e,n,r):new db(s,i,r).fit()}function kf(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class db{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=A.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=A.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,a=s.depth;for(;o&&a&&i.childCount==1;)i=i.firstChild.content,o--,a--;let l=new D(i,o,a);return e>-1?new He(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new De(r.pos,s.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=xa(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(A.from(o),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:a,parent:i,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=xa(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new D(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=xa(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new D(Yr(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new D(Yr(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let o=this.unplaced,a=r?r.content:o.content,l=o.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[n];if(s){for(let m=0;m<s.childCount;m++)u.push(s.child(m));d=d.matchFragment(s)}let f=a.size+e-(o.content.size-o.openEnd);for(;c<a.childCount;){let m=a.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||l==0||m.content.size)&&(d=g,u.push(xf(m.mark(h.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?f:-1)))}let p=c==a.childCount;p||(f=-1),this.placed=Qr(this.placed,n,A.from(u)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m<f;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?D.empty:new D(Yr(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new D(Yr(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!wa(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=wa(e,n,s,r,i);if(o){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=wa(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Qr(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Qr(this.placed,this.depth,A.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(A.empty,!0);n.childCount&&(this.placed=Qr(this.placed,this.frontier.length,n))}}function Yr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Yr(t.firstChild.content,e-1,n)))}function Qr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Qr(t.lastChild.content,e-1,n)))}function xa(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function xf(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,xf(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(A.empty,!0)))),t.copy(r)}function wa(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,o);return a&&!hb(n,i.content,o)?a:null}function hb(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function fb(t){return t.spec.defining||t.spec.definingForContent}function pb(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(kf(s,i,r))return t.step(new De(e,n,r));let o=Sf(s,i);o[o.length-1]==0&&o.pop();let a=-(s.depth+1);o.unshift(a);for(let h=s.depth,f=s.pos-1;h>0;h--,f--){let p=s.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(h)>-1?a=h:s.before(h)==f&&o.splice(1,0,-h)}let l=o.indexOf(a),c=[],u=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=u-1;h>=0;h--){let f=c[h],p=fb(f.type);if(p&&!f.sameMarkup(s.node(Math.abs(a)-1)))u=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+u+1)%(r.openStart+1),p=c[f];if(p)for(let m=0;m<o.length;m++){let g=o[(m+l)%o.length],y=!0;g<0&&(y=!1,g=-g);let v=s.node(g-1),C=s.index(g-1);if(v.canReplaceWith(C,C,p.type,p.marks))return t.replace(s.before(g),y?i.after(g):n,new D(wf(r.content,0,r.openStart,f),f,r.openEnd))}}let d=t.steps.length;for(let h=o.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=o[h];f<0||(e=s.before(f),n=i.after(f))}}function wf(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(wf(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(A.empty,!0))}return t}function mb(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=ub(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new D(A.from(r),0,0))}function gb(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(n),a=!1;for(let l=r.depth;l>o;l--)r.node(l).type.spec.isolating&&(a=!0);for(let l=s.depth;l>o;l--)s.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=r.depth;l>0&&e==r.start(l);l--)e=r.before(l);for(let l=s.depth;l>0&&n==s.start(l);l--)n=s.before(l);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=Sf(r,s);for(let o=0;o<i.length;o++){let a=i[o],l=o==i.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return t.delete(r.start(a),s.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),s.indexAfter(a-1))))return t.delete(r.before(a),s.after(a))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Sf(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class Tr extends Xe{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Pe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return Pe.fromReplace(e,this.pos,this.pos+1,new D(A.from(s),0,n.isLeaf?0:1))}getMap(){return ct.empty}invert(e){return new Tr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Tr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Tr(n.pos,n.attr,n.value)}}Xe.jsonID("attr",Tr);class Cs extends Xe{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Pe.ok(r)}getMap(){return ct.empty}invert(e){return new Cs(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Cs(n.attr,n.value)}}Xe.jsonID("docAttr",Cs);let Nr=class extends Error{};Nr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Nr.prototype=Object.create(Error.prototype);Nr.prototype.constructor=Nr;Nr.prototype.name="TransformError";class ec{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new vs}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Nr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,a,l)=>{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=D.empty){let s=Do(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new D(A.from(r),0,0))}delete(e,n){return this.replace(e,n,D.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return pb(this,e,n,r),this}replaceRangeWith(e,n,r){return mb(this,e,n,r),this}deleteRange(e,n){return gb(this,e,n),this}lift(e,n){return eb(this,e,n),this}join(e,n=1){return cb(this,e,n),this}wrap(e,n){return rb(this,e,n),this}setBlockType(e,n=e,r,s=null){return sb(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return ob(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Tr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Cs(e,n)),this}addNodeMark(e,n){return this.step(new Sn(e,n)),this}
vendor: 24,502 bytes, lines 6-7
6removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ge)n.isInSet(r.marks)&&this.step(new nr(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new nr(e,i)),s=i.removeFromSet(s);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(e,n=1,r){return ab(this,e,n,r),this}addMark(e,n,r){return Qy(this,e,n,r),this}removeMark(e,n,r){return Xy(this,e,n,r),this}clearIncompatible(e,n,r){return Xl(this,e,n,r),this}}const Sa=Object.create(null);class Q{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new vf(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=D.empty){let r=n.content.lastChild,s=null;for(let a=0;a<n.openEnd;a++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:c}=o[a],u=e.mapping.slice(i);e.replaceRange(u.map(l.pos),u.map(c.pos),a?D.empty:n),a==0&&Eu(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:a}=s[i],l=e.mapping.slice(r),c=l.map(o.pos),u=l.map(a.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Eu(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new U(e):xr(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?xr(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):xr(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new it(e.node(0))}static atStart(e){return xr(e,e,0,0,1)||new it(e)}static atEnd(e){return xr(e,e,e.content.size,e.childCount,-1)||new it(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Sa[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Sa)throw new RangeError("Duplicate use of selection JSON ID "+e);return Sa[e]=n,n.prototype.jsonID=e,n}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}Q.prototype.visible=!0;class vf{constructor(e,n){this.$from=e,this.$to=n}}let Mu=!1;function Tu(t){!Mu&&!t.parent.inlineContent&&(Mu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class U extends Q{constructor(e,n=e){Tu(e),Tu(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Q.near(r);let s=e.resolve(n.map(this.anchor));return new U(s.parent.inlineContent?s:r,r)}replace(e,n=D.empty){if(super.replace(e,n),n==D.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof U&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Po(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new U(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=Q.findFrom(n,r,!0)||Q.findFrom(n,-r,!0);if(i)n=i.$head;else return Q.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Q.findFrom(e,-r,!0)||Q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new U(e,n)}}Q.jsonID("text",U);class Po{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Po(e.map(this.anchor),e.map(this.head))}resolve(e){return U.between(e.resolve(this.anchor),e.resolve(this.head))}}class j extends Q{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?Q.near(i):new j(i)}content(){return new D(A.from(this.node),0,0)}eq(e){return e instanceof j&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new tc(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new j(e.resolve(n.anchor))}static create(e,n){return new j(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}j.prototype.visible=!1;Q.jsonID("node",j);class tc{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Po(r,r):new tc(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&j.isSelectable(r)?new j(n):Q.near(n)}}class it extends Q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=D.empty){if(n==D.empty){e.delete(0,e.doc.content.size);let r=Q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new it(e)}map(e){return new it(e)}eq(e){return e instanceof it}getBookmark(){return yb}}Q.jsonID("all",it);const yb={map(){return this},resolve(t){return new it(t)}};function xr(t,e,n,r,s,i=!1){if(e.inlineContent)return U.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let a=e.child(o);if(a.isAtom){if(!i&&j.isSelectable(a))return j.create(t,n-(s<0?a.nodeSize:0))}else{let l=xr(t,a,n+s,s<0?a.childCount:0,s,i);if(l)return l}n+=a.nodeSize*s}return null}function Eu(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof De||s instanceof He))return;let i=t.mapping.maps[r],o;i.forEach((a,l,c,u)=>{o==null&&(o=u)}),t.setSelection(Q.near(t.doc.resolve(o),n))}const Au=1,ii=2,Nu=4;class bb extends ec{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|Au)&~ii,this.storedMarks=null,this}get selectionSet(){return(this.updated&Au)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ii,this}ensureMarks(e){return ge.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&ii)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~ii,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ge.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Q.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Nu,this}get scrolledIntoView(){return(this.updated&Nu)>0}}function Ru(t,e){return!e||!t?t:t.bind(e)}class Xr{constructor(e,n,r){this.name=e,this.init=Ru(n.init,r),this.apply=Ru(n.apply,r)}}const kb=[new Xr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Xr("selection",{init(t,e){return t.selection||Q.atStart(e.doc)},apply(t){return t.selection}}),new Xr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Xr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class va{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=kb.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Xr(r.key,r.spec.state,r))})}}class Cr{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let a=this.config.plugins[o];if(a.spec.appendTransaction){let l=s?s[o].n:0,c=s?s[o].state:this,u=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Cr(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new bb(this)}static create(e){let n=new va(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Cr(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new va(this.schema,e.plugins),r=n.fields,s=new Cr(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new va(e.schema,e.plugins),i=new Cr(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Et.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=Q.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){i[o.name]=c.fromJSON.call(l,e,n[a],i);return}}i[o.name]=o.init(e,i)}}),i}}function Cf(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Cf(s,e,{})),n[r]=s}return n}class ue{constructor(e){this.spec=e,this.props={},e.props&&Cf(e.props,this,this.props),this.key=e.key?e.key.key:Mf("plugin")}getState(e){return e[this.key]}}const Ca=Object.create(null);function Mf(t){return t in Ca?t+"$"+ ++Ca[t]:(Ca[t]=0,t+"$")}class fe{constructor(e="key"){this.key=Mf(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Tf=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ef(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Af=(t,e,n)=>{let r=Ef(t,n);if(!r)return!1;let s=nc(r);if(!s){let o=r.blockRange(),a=o&&$r(o);return a==null?!1:(e&&e(t.tr.lift(o,a).scrollIntoView()),!0)}let i=s.nodeBefore;if(zf(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Rr(i,"end")||j.isSelectable(i)))for(let o=r.depth;;o--){let a=Do(t.doc,r.before(o),r.after(o),D.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(Rr(i,"end")?Q.findFrom(l.doc.resolve(l.mapping.map(s.pos,-1)),-1):j.create(l.doc,s.pos-i.nodeSize)),e(l.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},xb=(t,e,n)=>{let r=Ef(t,n);if(!r)return!1;let s=nc(r);return s?Nf(t,s,e):!1},wb=(t,e,n)=>{let r=Of(t,n);if(!r)return!1;let s=rc(r);return s?Nf(t,s,e):!1};function Nf(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=Do(t.doc,i,l,D.empty);if(!c||c.from!=i||c instanceof De&&c.slice.size>=l-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(U.create(u.doc,i)),n(u.scrollIntoView())}return!0}function Rr(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Rf=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=nc(r)}let o=i&&i.nodeBefore;return!o||!j.isSelectable(o)?!1:(e&&e(t.tr.setSelection(j.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function nc(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Of(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Lf=(t,e,n)=>{let r=Of(t,n);if(!r)return!1;let s=rc(r);if(!s)return!1;let i=s.nodeAfter;if(zf(t,s,e,1))return!0;if(r.parent.content.size==0&&(Rr(i,"start")||j.isSelectable(i))){let o=Do(t.doc,r.before(),r.after(),D.empty);if(o&&o.slice.size<o.to-o.from){if(e){let a=t.tr.step(o);a.setSelection(Rr(i,"start")?Q.findFrom(a.doc.resolve(a.mapping.map(s.pos)),1):j.create(a.doc,a.mapping.map(s.pos))),e(a.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},If=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=rc(r)}let o=i&&i.nodeAfter;return!o||!j.isSelectable(o)?!1:(e&&e(t.tr.setSelection(j.create(t.doc,i.pos)).scrollIntoView()),!0)};function rc(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const Sb=(t,e)=>{let n=t.selection,r=n instanceof j,s;if(r){if(n.node.isTextblock||!On(t.doc,n.from))return!1;s=n.from}else if(s=Io(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(j.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},vb=(t,e)=>{let n=t.selection,r;if(n instanceof j){if(n.node.isTextblock||!On(t.doc,n.to))return!1;r=n.to}else if(r=Io(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Cb=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&$r(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},Df=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` 7`).scrollIntoView()),!0)};function sc(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Mb=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=sc(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,o.createAndFill());l.setSelection(Q.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Pf=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof it||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=sc(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,a=t.tr.insert(o,i.createAndFill());a.setSelection(U.create(a.doc,o+1)),e(a.scrollIntoView())}return!0},$f=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(tn(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&$r(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function Tb(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof j&&e.selection.node.isBlock)return!r.parentOffset||!tn(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,a,l=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){l=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),a=sc(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),i.unshift(l&&a?{type:a}:null),o=f;break}else{if(f==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof U||e.selection instanceof it)&&u.deleteSelection();let d=u.mapping.map(r.pos),h=tn(u.doc,d,i.length,i);if(h||(i[0]=a?{type:a}:null,h=tn(u.doc,d,i.length,i)),!h)return!1;if(u.split(d,i.length,i),!l&&c&&r.node(o).type!=a){let f=u.mapping.map(r.before(o)),p=u.doc.resolve(f);a&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(o)),a)}return n&&n(u.scrollIntoView()),!0}}const Eb=Tb(),Ab=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(j.create(t.doc,s))),!0)};function Nb(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||On(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function zf(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,a,l=s.type.spec.isolating||i.type.spec.isolating;if(!l&&Nb(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(a=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&a.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,p=A.empty;for(let y=o.length-1;y>=0;y--)p=A.from(o[y].create(null,p));p=A.from(s.copy(p));let m=t.tr.step(new He(e.pos-1,f,e.pos,f,new D(p,1,0),o.length,!0)),g=m.doc.resolve(f+2*o.length);g.nodeAfter&&g.nodeAfter.type==s.type&&On(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&l?null:Q.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&$r(d);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(d,h).scrollIntoView()),!0;if(c&&Rr(i,"start",!0)&&Rr(s,"end")){let f=s,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(n){let y=A.empty;for(let C=p.length-1;C>=0;C--)y=A.from(p[C].copy(y));let v=t.tr.step(new He(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new D(y,p.length,0),0,!0));n(v.scrollIntoView())}return!0}}return!1}function Bf(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(U.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const Rb=Bf(-1),Ob=Bf(1);function Lb(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),a=o&&Zl(o,t,e);return a?(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0):!1}}function Ou(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:a}}=n.selection.ranges[i];n.doc.nodesBetween(o,a,(l,c)=>{if(s)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[o];i.setBlockType(a,l,t,e)}r(i.scrollIntoView())}return!0}}function ic(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}ic(Tf,Af,Rf);ic(Tf,Lf,If);ic(Df,Pf,$f,Eb);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Ib(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let a=r?n.tr:null;return Db(a,o,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function Db(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=o.resolve(e.start-2);i=new _i(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new _i(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let a=Zl(i,n,r,e);return a?(t&&Pb(t,e,a,s,n),!0):!1}function Pb(t,e,n,r,s){let i=A.empty;for(let u=n.length-1;u>=0;u--)i=A.from(n[u].type.create(n[u].attrs,i));t.step(new He(e.start-(r?2:0),e.end,e.start,e.end,new D(i,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==s&&(o=u+1);let a=n.length-o,l=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,h=!0;u<d;u++,h=!1)!h&&tn(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(u).nodeSize;return t}function $b(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?zb(e,n,t,i):Bb(e,n,i):!0:!1}}function zb(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new He(i-1,o,i,o,new D(A.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new _i(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const a=$r(r);if(a==null)return!1;s.lift(r,a);let l=s.doc.resolve(s.mapping.map(i,-1)-1);return On(s.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&s.join(l.pos),e(s.scrollIntoView()),!0}function Bb(t,e,n){let r=t.tr,s=n.parent;for(let f=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)f-=s.child(p).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==s.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(a?0:1),u+1,o.content.append(l?A.empty:A.from(s))))return!1;let d=i.pos,h=d+o.nodeSize;return r.step(new He(d-(a?1:0),h+(l?1:0),d+1,h-1,new D((a?A.empty:A.from(s.copy(A.empty))).append(l?A.empty:A.from(s.copy(A.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function _b(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let a=i.parent,l=a.child(o-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,u=A.from(c?t.create():null),d=new D(A.from(t.create(null,A.from(a.type.create(null,u)))),c?3:1,0),h=i.start,f=i.end;n(e.tr.step(new He(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}const We=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Or=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let cl=null;const Yt=function(t,e,n){let r=cl||(cl=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Hb=function(){cl=null},rr=function(t,e,n,r){return n&&(Lu(t,e,n,r,-1)||Lu(t,e,n,r,1))},Fb=/^(img|br|input|textarea|hr)$/i;function Lu(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:gt(t))){let o=t.parentNode;
vendor: 6,573 bytes, line 7
7if(!o||o.nodeType!=1||zs(t)||Fb.test(t.nodeName)||t.contentEditable=="false")return!1;e=We(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?gt(t):0}else return!1}}function gt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Vb(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=gt(t)}else if(t.parentNode&&!zs(t))e=We(t),t=t.parentNode;else return null}}function jb(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!zs(t))e=We(t)+1,t=t.parentNode;else return null}}function Wb(t,e,n){for(let r=e==0,s=e==gt(t);r||s;){if(t==n)return!0;let i=We(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==gt(t)}}function zs(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const $o=function(t){return t.focusNode&&rr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function $n(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Ub(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function qb(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(gt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(gt(r.startContainer),r.startOffset)}}}const _t=typeof navigator<"u"?navigator:null,Iu=typeof document<"u"?document:null,Ln=_t&&_t.userAgent||"",ul=/Edge\/(\d+)/.exec(Ln),_f=/MSIE \d/.exec(Ln),dl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ln),ot=!!(_f||dl||ul),Mn=_f?document.documentMode:dl?+dl[1]:ul?+ul[1]:0,yt=!ot&&/gecko\/(\d+)/i.test(Ln);yt&&+(/Firefox\/(\d+)/.exec(Ln)||[0,0])[1];const hl=!ot&&/Chrome\/(\d+)/.exec(Ln),Ue=!!hl,Hf=hl?+hl[1]:0,Ye=!ot&&!!_t&&/Apple Computer/.test(_t.vendor),Lr=Ye&&(/Mobile\/\w+/.test(Ln)||!!_t&&_t.maxTouchPoints>2),mt=Lr||(_t?/Mac/.test(_t.platform):!1),Ff=_t?/Win/.test(_t.platform):!1,Xt=/Android \d/.test(Ln),Bs=!!Iu&&"webkitFontSmoothing"in Iu.documentElement.style,Kb=Bs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Jb(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Ut(t,e){return typeof t=="number"?t:t[e]}function Gb(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Du(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Or(o);continue}let a=o,l=a==i.body,c=l?Jb(i):Gb(a),u=0,d=0;if(e.top<c.top+Ut(r,"top")?d=-(c.top-e.top+Ut(s,"top")):e.bottom>c.bottom-Ut(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Ut(s,"top")-c.top:e.bottom-c.bottom+Ut(s,"bottom")),e.left<c.left+Ut(r,"left")?u=-(c.left-e.left+Ut(s,"left")):e.right>c.right-Ut(r,"right")&&(u=e.right-c.right+Ut(s,"right")),u||d)if(l)i.defaultView.scrollBy(u,d);else{let f=a.scrollLeft,p=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let m=a.scrollLeft-f,g=a.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let h=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:Or(o)}}function Yb(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let a=t.root.elementFromPoint(i,o);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,s=l.top;break}}return{refDOM:r,refTop:s,stack:Vf(t.dom)}}function Vf(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Or(r));return e}function Qb({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;jf(n,r==0?0:r-e)}function jf(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let br=null;function Xb(t){if(t.setActive)return t.setActive();if(br)return t.focus(br);let e=Vf(t);t.focus(br==null?{get preventScroll(){return br={preventScroll:!0},!0}}:void 0),br||(br=!1,jf(e,0))}function Wf(t,e){let n,r=2e8,s,i=0,o=e.top,a=e.top,l,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=Yt(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=o&&p.bottom>=a){o=Math.max(p.bottom,o),a=Math.min(p.top,a);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,s=m&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!l&&p.left<=e.left&&p.right>=e.left&&(l=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&l&&(n=l,s=c,r=0),n&&n.nodeType==3?Zb(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:Wf(n,s)}function Zb(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=fn(r,1);if(o.top!=o.bottom&&oc(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function oc(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ek(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function tk(t,e,n){let{node:r,offset:s}=Wf(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function nk(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let a=t.docView.nearestDesc(i,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!o&&l.left>r.left||l.top>
vendor: 67,021 bytes, lines 7-11
7r.top?s=a.posBefore:(!o&&l.right<r.left||l.bottom<r.top)&&(s=a.posAfter),o=!0),!a.contentDOM&&s<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;i=a.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function Uf(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let a=o.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(oc(e,c))return Uf(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function rk(t,e){let n=t.dom.ownerDocument,r,s=0,i=qb(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),a;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=t.dom.getBoundingClientRect();if(!oc(e,c)||(o=Uf(t.dom,e,c),!o))return null}if(Ye)for(let c=o;r&&c;c=Or(c))c.draggable&&(r=void 0);if(o=ek(o,e),r){if(yt&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;Bs&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(a=nk(t,r,s,e))}a==null&&(a=tk(t,o,e));let l=t.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Pu(t){return t.top<t.bottom||t.left<t.right}function fn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Pu(r))return r}return Array.prototype.find.call(n,Pu)||t.getBoundingClientRect()}const sk=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function qf(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=Bs||yt;if(r.nodeType==3)if(o&&(sk.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let l=fn(Yt(r,s,s),n);if(yt&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=fn(Yt(r,s-1,s-1),-1);if(c.top==l.top){let u=fn(Yt(r,s,s+1),-1);if(u.top!=l.top)return Wr(u,u.left<c.left)}}return l}else{let l=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(l--,u=1):n<0?l--:c++,Wr(fn(Yt(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==gt(r))){let l=r.childNodes[s-1];if(l.nodeType==1)return Ma(l.getBoundingClientRect(),!1)}if(i==null&&s<gt(r)){let l=r.childNodes[s];if(l.nodeType==1)return Ma(l.getBoundingClientRect(),!0)}return Ma(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==gt(r))){let l=r.childNodes[s-1],c=l.nodeType==3?Yt(l,gt(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Wr(fn(c,1),!1)}if(i==null&&s<gt(r)){let l=r.childNodes[s];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Yt(l,0,o?0:1):l.nodeType==1?l:null:null;if(c)return Wr(fn(c,-1),!0)}return Wr(fn(r.nodeType==3?Yt(r):r,-n),n>=0)}function Wr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Ma(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Kf(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function ik(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return Kf(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let o=qf(t,s.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Yt(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const ok=/[\u0590-\u08ac]/;function ak(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,a=t.domSelection();return a?!ok.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?i:o:Kf(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!f.contains(p.nodeType==1?p:p.parentNode)||l==p&&c==m;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let $u=null,zu=null,Bu=!1;function lk(t,e,n){return $u==e&&zu==n?Bu:($u=e,zu=n,Bu=n=="up"||n=="down"?ik(t,e,n):ak(t,e,n))}const bt=0,_u=1,_n=2,Ht=3;class _s{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=bt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>We(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let a=s.children[o];if(a.size){s=a;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],a=i+o.size;if(a>e||o instanceof Gf){s=e-i;break}i=a}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Jf&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?We(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?We(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,a=0;;a++){let l=this.children[a],c=o+l.size;if(s==-1&&e<=c){let u=o+l.border;if(e>=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=o;for(let d=a;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=We(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>n||a==this.children.length-1)){n=c;for(let u=a+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=We(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],g=p+m.size;if(i>p&&o<g)return m.setSelection(e-p-m.border,n-p-m.border,r,s);p=g}let a=this.domFromPos(e,e?-1:1),l=n==e?a:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((yt||Ye)&&e==n){let{node:f,offset:p}=a;if(f.nodeType==3){if(d=!!(p&&f.nodeValue[p-1]==` 8`),d&&p==f.nodeValue.length)for(let m=f,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:We(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=f.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(yt&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(s=!0)}if(!(s||d&&Ye)&&rr(a.node,a.offset,u.anchorNode,u.anchorOffset)&&rr(l.node,l.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(d&&yt)){c.collapse(a.node,a.offset);try{e!=n&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>n){let p=a;a=l,l=p}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let a=r+i.border,l=o-i.border;if(e>=a&&n<=l){this.dirty=e==r||n==o?_n:_u,e==a&&n==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ht:i.markDirty(e-a,n-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?_n:Ht}r=o}this.dirty=_n}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?_n:_u;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Jf extends _s{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==bt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class ck extends _s{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class sr extends _s{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=cr.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new sr(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ht||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ht&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=bt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=bt}}slice(e,n,r){let s=sr.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=pl(i,n,o,r)),e>0&&(i=pl(i,0,e,r));for(let a=0;a<i.length;a++)i[a].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Tn extends _s{constructor(e,n,r,s,i,o,a,l,c){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=a}static create(e,n,r,s,i,o){let a=i.nodeViews[n.type.name],l,c=a&&a(n,i,()=>{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=cr.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=Xf(u,r,n),c?l=new uk(e,n,r,s,u,d||null,h,c,i,o+1):n.isText?new zo(e,n,r,s,u,h,i):new Tn(e,n,r,s,u,d||null,h,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>A.empty)}return e}matchesNode(e,n,r){return this.dirty==bt&&e.eq(this.node)&&Fi(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new hk(this,o&&o.node,e);mk(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?ge.none:this.node.child(u).marks,r,e,u),l.placeWidget(c,e,s)},(c,u,d,h)=>{l.syncToMarks(c.marks,r,e,h);let f;l.findNodeMatch(c,u,d,h)||a&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(f=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(c,u,d,f,e)||l.updateNextNode(c,u,d,e,h,s)||l.addNode(c,u,d,e,s),s+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==_n)&&(o&&this.protectLocalComposition(e,o),Yf(this.contentDOM,this.children,e),Lr&&gk(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof U)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,a=yk(this.node.content,o,r-n,s-n);return a<0?null:{node:i,pos:a,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new ck(this,i,n,s);e.input.compositionNodes.push(o),this.children=pl(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Ht||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=bt}updateOuterDeco(e){if(Fi(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Qf(this.dom,this.nodeDOM,fl(this.outerDeco,this.node,n),fl(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Hu(t,e,n,r,s){Xf(r,e,t);let i=new Tn(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class zo extends Tn{constructor(e,n,r,s,i,o,a){super(e,n,r,s,i,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==Ht||this.dirty!=bt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=bt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=bt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new zo(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Ht)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Gf extends _s{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==bt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class uk extends Tn{constructor(e,n,r,s,i,o,a,l,c,u){super(e,n,r,s,i,o,a,c,u),this.spec=l}update(e,n,r,s){if(this.dirty==Ht)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}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 Yf(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],a=o.dom;if(a.parentNode==t){for(;a!=r;)r=Fu(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(a,r);if(o instanceof sr){let l=r?r.previousSibling:t.lastChild;Yf(o.contentDOM,o.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=Fu(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const as=function(t){t&&(this.nodeName=t)};as.prototype=Object.create(null);const Hn=[new as];function fl(t,e,n){if(t.length==0)return Hn;let r=n?Hn[0]:new as,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new as(o.nodeName));for(let a in o){let l=o[a];l!=null&&(n&&s.length==1&&s.push(r=new as(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return s}function Qf(t,e,n,r){if(n==Hn&&r==Hn)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],a=n[i];if(i){let l;a&&a.nodeName==o.nodeName&&s!=t&&(l=s.parentNode)&&l.nodeName.toLowerCase()==o.nodeName||(l=document.createElement(o.nodeName),l.pmIsDeco=!0,l.appendChild(s),a=Hn[0]),s=l}dk(s,a||Hn[0],o)}return s}function dk(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function Xf(t,e,n){return Qf(t,t,Hn,fl(e,n,t.nodeType!=1))}function Fi(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Fu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hk{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=fk(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,a=Math.min(o,e.length);for(;i<a&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=bt,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,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){l=u;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=sr.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=a;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Ht&&o.dom==o.contentDOM&&(o.dirty=_n),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Tn){let c=this.preMatch.matched.get(l);if(c!=null&&c!=i)return!1;let u=l.dom,d,h=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=Ht&&Fi(n,l.outerDeco));if(!h&&l.update(e,n,r,s))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(l,e,n,r,s,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=_n,d.updateChildren(s,o+1),d.dirty=bt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Fi(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let a=Tn.create(this.top,n,r,s,i,o);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,n,r,s,i){let o=Tn.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Jf(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof sr;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof zo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ye||Ue)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Gf(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function fk(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof sr)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(s-1))break;--s,i.set(a,s),o.push(a)}}return{index:s,matched:i,matches:o.reverse()}}function pk(t,e){return t.type.side-e.type.side}function mk(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(i,u),c),i+=u.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){let u,d;for(;o<s.length&&s[o].to==i;){let g=s[o++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(pk);for(let g=0;g<d.length;g++)n(d[g],c,!!l)}else n(u,c,!!l);let h,f;if(l)f=-1,h=l,l=null;else if(c<t.childCount)f=c,h=t.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=i&&a.splice(g--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)a.push(s[o++]);let p=i+h.nodeSize;if(h.isText){let g=p;o<s.length&&s[o].from<g&&(g=s[o].from);for(let y=0;y<a.length;y++)a[y].to<g&&(g=a[y].to);g<p&&(l=h.cut(g-i),h=h.cut(0,g-i),p=g,f=-1)}else for(;o<s.length&&s[o].to<p;)o++;let m=h.isInline&&!h.isLeaf?a.filter(g=>!g.inline):a.slice();r(h,m,e.forChild(i,h),f),i=p}}function gk(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function yk(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),a=i;if(i+=o.nodeSize,!o.isText)continue;let l=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;l+=c.text}if(i>=n){if(i>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function pl(t,e,n,r,s){let i=[];for(let o=0,a=0;o<t.length;o++){let l=t[o],c=a,u=a+=l.size;c>=n||u<=e?i.push(l):(c<e&&i.push(l.slice(0,e-c,r)),s&&(i.push(s),s=void 0),u>n&&i.push(l.slice(n-c,l.size,r)))}return i}function ac(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if($o(n)){for(l=o;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&j.isSelectable(d)&&s.parent&&!(d.isInline&&Wb(n.focusNode,n.focusOffset,s.dom))){let h=s.posBefore;c=new j(o==h?a:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,h=o;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[l,o]=h==t.state.selection.anchor?[h,d]:[d,h],a=r.resolve(o)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let d=e=="pointer"||t.state.selection.head<a.pos&&!i?1:-1;c=lc(t,u,a,d)}return c}function Zf(t){return t.editable?t.hasFocus():tp(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function nn(t,e=!1){let n=t.state.selection;if(ep(t,n),!!Zf(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ue){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&rr(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)kk(t);else{let{anchor:r,head:s}=n,i,o;Vu&&!(n instanceof U)&&(n.$from.parent.inlineContent||(i=ju(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=ju(t,n.to))),t.docView.setSelection(r,s,t,e),Vu&&(i&&Wu(i),o&&Wu(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&bk(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Vu=Ye||Ue&&Hf<63;function ju(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Ye&&s&&s.contentEditable=="false")return Ta(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Ta(s);if(i)return Ta(i)}}function Ta(t){return t.contentEditable="true",Ye&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Wu(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function bk(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Zf(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function kk(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,We(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&ot&&Mn<=11&&(n.disabled=!0,n.disabled=!1)}function ep(t,e){if(e instanceof j){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Uu(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Uu(t)}function Uu(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function lc(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||U.between(e,n,r)}function qu(t){return t.editable&&!t.hasFocus()?!1:tp(t)}function tp(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function xk(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return rr(e.node,e.offset,n.anchorNode,n.anchorOffset)}function ml(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&Q.findFrom(i,e)}function mn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ku(t,e,n){let r=t.state.selection;if(r instanceof U)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return mn(t,new U(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=ml(t.state,e);return s&&s instanceof j?mn(t,s):!1}else if(!(mt&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let a=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(a))&&!o.contentDOM?j.isSelectable(i)?mn(t,new j(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Bs?mn(t,new U(t.state.doc.resolve(e<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof j&&r.node.isInline)return mn(t,new U(e>0?r.$to:r.$from));{let s=ml(t.state,e);return s?mn(t,s):!1}}}function Vi(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ls(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function kr(t,e){return e<0?wk(t):Sk(t)}function wk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(yt&&n.nodeType==1&&r<Vi(n)&&ls(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(ls(a,-1))s=n,i=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(np(n))break;{let a=n.previousSibling;for(;a&&ls(a,-1);)s=n.parentNode,i=We(a),a=a.previousSibling;if(a)n=a,r=Vi(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?gl(t,n,r):s&&gl(t,s,i)}function Sk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Vi(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let a=n.childNodes[r];if(ls(a,1))i=n,o=++r;else break}else{if(np(n))break;{let a=n.nextSibling;for(;a&&ls(a,1);)i=a.parentNode,o=We(a)+1,a=a.nextSibling;if(a)n=a,r=0,s=Vi(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&gl(t,i,o)}function np(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function vk(t,e){for(;t&&e==t.childNodes.length&&!zs(t);)e=We(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Ck(t,e){for(;t&&!e&&!zs(t);)e=We(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function gl(t,e,n){if(e.nodeType!=3){let i,o;(o=vk(e,n))?(e=o,n=0):(i=Ck(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if($o(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&nn(t)},50)}function Ju(t,e){let n=t.state.doc.resolve(e);if(!(Ue||Ff)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Gu(t,e,n){let r=t.state.selection;if(r instanceof U&&!r.empty||n.indexOf("s")>-1||mt&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=ml(t.state,e);if(o&&o instanceof j)return mn(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,a=r instanceof it?Q.near(o,e):Q.findFrom(o,e);return a?mn(t,a):!1}return!1}function Yu(t,e){if(!(t.state.selection instanceof U))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Qu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Mk(t){if(!Ye||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Qu(t,r,"true"),setTimeout(()=>Qu(t,r,"false"),20)}return!1}function Tk(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Ek(t,e){let n=e.keyCode,r=Tk(e);if(n==8||mt&&n==72&&r=="c")return Yu(t,-1)||kr(t,-1);if(n==46&&!e.shiftKey||mt&&n==68&&r=="c")return Yu(t,1)||kr(t,1);if(n==13||n==27)return!0;if(n==37||mt&&n==66&&r=="c"){let s=n==37?Ju(t,t.state.selection.from)=="ltr"?-1:1:-1;return Ku(t,s,r)||kr(t,s)}else if(n==39||mt&&n==70&&r=="c"){let s=n==39?Ju(t,t.state.selection.from)=="ltr"?1:-1:1;return Ku(t,s,r)||kr(t,s)}else{if(n==38||mt&&n==80&&r=="c")return Gu(t,-1,r)||kr(t,-1);if(n==40||mt&&n==78&&r=="c")return Mk(t)||Gu(t,1,r)||kr(t,1);if(r==(mt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function cc(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=t.someProp("clipboardSerializer")||cr.fromSchema(t.state.schema),a=lp(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=ap[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=a.createElement(u[f]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,` 9 10`);return{dom:l,text:h,slice:e}}function rp(t,e,n,r,s){let i=s.parent.type.spec.code,o,a;if(!n&&!e)return null;let l=!!e&&(r||i||!n);if(l){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return a=new D(A.from(t.state.schema.text(e.replace(/\r\n?/g,` 11`))),0,0),t.someProp("transformPasted",h=>{a=h(a,t,!0)}),a;let d=t.someProp("clipboardTextParser",h=>h(e,s,r,t));if(d)a=d;else{let h=s.marks(),{schema:f}=t.state,p=cr.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,h)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=Ok(n),Bs&&Lk(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||en.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Ak.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)a=Ik(Xu(a,+u[1],+u[2]),u[4]);else if(a=D.maxOpen(Nk(a.content,s),!0),a.openStart||a.openEnd){let d=0,h=0;for(let f=a.content.firstChild;d<a.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=a.content.lastChild;h<a.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);a=Xu(a,d,h)}return t.someProp("transformPasted",d=>{a=d(a,t,l)}),a}const Ak=/^(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 Nk(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(a=>{if(!o)return;let l=s.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&i.length&&ip(l,i,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=op(o[o.length-1],i.length));let u=sp(a,l);o.push(u),s=s.matchType(u.type),i=l}}),o)return A.from(o)}return t}function sp(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,A.from(t));return t}function ip(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=ip(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(A.from(sp(n,t,s+1))))}}function op(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,op(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(A.empty,!0);return t.copy(n.append(r))}function yl(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,a=o.content;return t.childCount>1&&(i=0),s<r-1&&(a=yl(a,e,n,r,s+1,i)),s>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(A.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function Xu(t,e,n){return e<t.openStart&&(t=new D(yl(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new D(yl(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const ap={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Zu=null;function lp(){return Zu||(Zu=document.implementation.createHTMLDocument("title"))}let Ea=null;function Rk(t){let e=window.trustedTypes;return e?(Ea||(Ea=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Ea.createHTML(t)):t}function Ok(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=lp().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&ap[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=Rk(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Lk(t){let e=t.querySelectorAll(Ue?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent=="Â "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Ik(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;s=A.from(l.create(r[a+1],s)),i++,o++}return new D(s,i,o)}const nt={},rt={},Dk={touchstart:!0,touchmove:!0};class Pk{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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function $k(t){for(let e in nt){let n=nt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Bk(t,r)&&!uc(t,r)&&(t.editable||!(r.type in rt))&&n(t,r)},Dk[e]?{passive:!0}:void 0)}Ye&&t.dom.addEventListener("input",()=>null),bl(t)}function vn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function zk(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function bl(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>uc(t,r))})}function uc(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Bk(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function _k(t,e){!uc(t,e)&&nt[e.type]&&(t.editable||!(e.type in rt))&&nt[e.type](t,e)}rt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!up(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Xt&&Ue&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Lr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,$n(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Ek(t,n)?n.preventDefault():vn(t,"key")};rt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};rt.keypress=(t,e)=>{let n=e;if(up(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||mt&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof U)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function Bo(t){return{left:t.clientX,top:t.clientY}}function Hk(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function dc(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,a=>o>i.depth?a(t,n,i.nodeAfter,i.before(o),s,!0):a(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function Er(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Fk(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&j.isSelectable(r)?(Er(t,new j(n)),!0):!1}function Vk(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof j&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let a=o>i.depth?i.nodeAfter:i.node(o);if(j.isSelectable(a)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(Er(t,j.create(t.state.doc,s)),!0):!1}function jk(t,e,n,r,s){return dc(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Vk(t,n):Fk(t,n))}function Wk(t,e,n,r){return dc(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Uk(t,e,n,r){return dc(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||qk(t,n,r)}function qk(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Er(t,U.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),a=s.before(i);if(o.inlineContent)Er(t,U.create(r,a+1,a+1+o.content.size));else if(j.isSelectable(o))Er(t,j.create(r,a));else continue;return!0}}function hc(t){return ji(t)}const cp=mt?"metaKey":"ctrlKey";nt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=hc(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&Hk(n,t.input.lastClick)&&!n[cp]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(Bo(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Kk(t,o,n,!!r)):(i=="doubleClick"?Wk:Uk)(t,o.pos,o.inside,n)?n.preventDefault():vn(t,"pointer"))};class Kk{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[cp],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}const a=s?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof j&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&yt&&!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)),vn(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(()=>nn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Bo(e))),this.updateAllowDefault(e),this.allowDefault||!n?vn(this.view,"pointer"):jk(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ye&&this.mightDrag&&!this.mightDrag.node.isAtom||Ue&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Er(this.view,Q.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):vn(this.view,"pointer")}move(e){this.updateAllowDefault(e),vn(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)}}nt.touchstart=t=>{t.input.lastTouch=Date.now(),hc(t),vn(t,"pointer")};nt.touchmove=t=>{t.input.lastTouch=Date.now(),vn(t,"pointer")};nt.contextmenu=t=>hc(t);function up(t,e){return t.composing?!0:Ye&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Jk=Xt?5e3:-1;rt.compositionstart=rt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof U&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ue&&Ff&&Gk(t)))t.markCursor=t.state.storedMarks||n.marks(),ji(t,!0),t.markCursor=null;else if(ji(t,!e.selection.empty),yt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let a=t.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}dp(t,Jk)};function Gk(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}rt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,dp(t,20))};function dp(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ji(t),e))}function hp(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Qk());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Yk(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Vb(e.focusNode,e.focusOffset),r=jb(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Qk(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ji(t,e=!1){if(!(Xt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),hp(t),e||t.docView&&t.docView.dirty){let n=ac(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Xk(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Ms=ot&&Mn<15||Lr&&Kb<604;nt.copy=rt.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Ms?null:n.clipboardData,o=r.content(),{dom:a,text:l}=cc(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):Xk(t,a),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Zk(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function e0(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ts(t,r.value,null,s,e):Ts(t,r.textContent,r.innerHTML,s,e)},50)}function Ts(t,e,n,r,s){let i=rp(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,s,i||D.empty)))return!0;if(!i)return!1;let o=Zk(i),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function fp(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}rt.paste=(t,e)=>{let n=e;if(t.composing&&!Xt)return;let r=Ms?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Ts(t,fp(r),r.getData("text/html"),s,n)?n.preventDefault():e0(t,n)};class pp{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const t0=mt?"altKey":"ctrlKey";function mp(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[t0]}nt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(Bo(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof j?s.to-1:s.to))){if(r&&r.mightDrag)o=j.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=j.create(t.state.doc,d.posBefore))}}let a=(o||t.state.selection).content(),{dom:l,text:c,slice:u}=cc(t,a);(!n.dataTransfer.files.length||!Ue||Hf>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ms?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ms||n.dataTransfer.setData("text/plain",c),t.dragging=new pp(u,mp(t,n),o)};nt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};rt.dragover=rt.dragenter=(t,e)=>e.preventDefault();rt.drop=(t,e)=>{try{n0(t,e,t.dragging)}finally{t.dragging=null}};function n0(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Bo(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",f=>{i=f(i,t,!1)}):i=rp(t,fp(e.dataTransfer),Ms?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&mp(t,e));if(t.someProp("handleDrop",f=>f(t,e,i||D.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let a=i?bf(t.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let l=t.state.tr;if(o){let{node:f}=n;f?f.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,i.content.firstChild):l.replaceRange(c,c,i),l.doc.eq(d))return;let h=l.doc.resolve(c);if(u&&j.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new j(h));else{let f=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((p,m,g,y)=>f=y),l.setSelection(lc(t,h,l.doc.resolve(f)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}nt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&nn(t)},20))};nt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};nt.beforeinput=(t,e)=>{if(Ue&&Xt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,$n(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in rt)nt[t]=rt[t];function Es(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Wi{constructor(e,n){this.toDOM=e,this.spec=n||Kn,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new Ee(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Wi&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Es(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class En{constructor(e,n){this.attrs=e,this.spec=n||Kn}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Ee(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof En&&Es(this.attrs,e.attrs)&&Es(this.spec,e.spec)}static is(e){return e.type instanceof En}destroy(){}}class fc{constructor(e,n){this.attrs=e,this.spec=n||Kn}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Ee(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof fc&&Es(this.attrs,e.attrs)&&Es(this.spec,e.spec)}destroy(){}}class Ee{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ee(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Ee(e,e,new Wi(n,r))}static inline(e,n,r,s){return new Ee(e,n,new En(r,s))}static node(e,n,r,s){return new Ee(e,n,new fc(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof En}get widget(){return this.type instanceof Wi}}const wr=[],Kn={};class ae{constructor(e,n){this.local=e.length?e:wr,this.children=n.length?n:wr}static create(e,n){return n.length?Ui(n,e,0,Kn):Ge}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=n&&a.to>=e&&(!i||i(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,n-a,r,s+a,i)}}map(e,n,r){return this==Ge||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Kn)}mapInner(e,n,r,s,i){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,s);l&&l.type.valid(n,l)?(o||(o=[])).push(l):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?r0(this.children,o||[],e,n,r,s,i):o?new ae(o.sort(Jn),wr):Ge}add(e,n){return n.length?this==Ge?ae.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((a,l)=>{let c=l+r,u;if(u=yp(n,a,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<l;)i+=3;s[i]==l?s[i+2]=s[i+2].addInner(a,u,c+1):s.splice(i,0,l,l+a.nodeSize,Ui(u,a,c+1,Kn)),i+=3}});let o=gp(i?bp(n):n,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new ae(o.length?this.local.concat(o).sort(Jn):this.local,s||this.children)}remove(e){return e.length==0||this==Ge?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,a=r[i]+n,l=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>a&&d.to<l&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,a+1);c!=Ge?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let a=0;a<s.length;a++)s[a].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new ae(s,r):Ge}forChild(e,n){if(this==Ge)return this;if(n.isLeaf)return ae.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let i=e+1,o=i+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>i&&l.type instanceof En){let c=Math.max(i,l.from)-i,u=Math.min(o,l.to)-i;c<u&&(s||(s=[])).push(l.copy(c,u))}}if(s){let a=new ae(s.sort(Jn),wr);return r?new bn([a,r]):a}return r||Ge}eq(e){if(this==e)return!0;if(!(e instanceof ae)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return pc(this.localsInner(e))}localsInner(e){if(this==Ge)return wr;if(e.inlineContent||!this.local.some(En.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof En||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ae.empty=new ae([],[]);ae.removeOverlap=pc;const Ge=ae.empty;class bn{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Kn));return bn.from(r)}forChild(e,n){if(n.isLeaf)return ae.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Ge&&(i instanceof bn?r=r.concat(i.members):r.push(i))}return bn.from(r)}eq(e){if(!(e instanceof bn)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?pc(r?n:n.sort(Jn)):wr}static from(e){switch(e.length){case 0:return Ge;case 1:return e[0];default:return new bn(e.every(n=>n instanceof ae)?e:e.reduce((n,r)=>n.concat(r instanceof ae?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function r0(t,e,n,r,s,i,o){let a=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((h,f,p,m)=>{let g=m-p-(f-h);for(let y=0;y<a.length;y+=3){let v=a[y+1];if(v<0||h>v+u-d)continue;let C=a[y]+u-d;f>=C?a[y+1]=h<=C?-2:-1:h>=u&&g&&(a[y]+=g,a[y+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-s;if(d<0||d>=r.content.size){l=!0;continue}let h=n.map(t[c+1]+i,-1),f=h-s,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==f){let y=a[c+2].mapInner(n,g,u+1,t[c]+i+1,o);y!=Ge?(a[c]=d,a[c+1]=f,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=s0(a,t,e,n,s,i,o),u=Ui(c,r,0,o);e=u.local;for(let d=0;d<a.length;d+=3)a[d+1]<0&&(a.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<a.length&&a[h]<f;)h+=3;a.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ae(e.sort(Jn),a)}function gp(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Ee(s.from+e,s.to+e,s.type))}return n}function s0(t,e,n,r,s,i,o){function a(l,c){for(let u=0;u<l.local.length;u++){let d=l.local[u].map(r,s,c);d?n.push(d):o.onRemove&&o.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+i+1);return n}function yp(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function bp(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Ui(t,e,n,r){let s=[],i=!1;e.forEach((a,l)=>{let c=yp(t,a,l+n);if(c){i=!0;let u=Ui(c,a,n+l+1,r);u!=Ge&&s.push(l,l+a.nodeSize,u)}});let o=gp(i?bp(t):t,-n).sort(Jn);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1));return o.length||s.length?new ae(o,s):Ge}function Jn(t,e){return t.from-e.from||t.to-e.to}function pc(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),ed(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),ed(e,s,r.copy(i.from,r.to)));break}}}return e}function ed(t,e,n){for(;e<t.length&&Jn(n,t[e])>0;)e++;t.splice(e,0,n)}function Aa(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ge&&e.push(r)}
vendor: 14,494 bytes, line 11
11),t.cursorWrapper&&e.push(ae.create(t.state.doc,[t.cursorWrapper.deco])),bn.from(e)}const i0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},o0=ot&&Mn<=11;class a0{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class l0{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new a0,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);ot&&Mn<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Ye&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),o0&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,i0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(qu(this.view)){if(this.suppressingSelectionUpdates)return nn(this.view);if(ot&&Mn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&rr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=Or(i))n.add(i);for(let i=e.anchorNode;i;i=Or(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&qu(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,a=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],l);d&&(i=i<0?d.from:Math.min(d.from,i),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(a=!0))}if(l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(yt&&l.length){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||d0(e,d)!=f)&&h.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&$o(r)&&(c=ac(e))&&c.eq(Q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,nn(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),c0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,h0(e,l)),this.handleDOMChange(i,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||nn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(ot&&Mn<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let o=s&&s.parentNode==e.target?We(s)+1:0,a=r.localPosFromDOM(e.target,o,-1),l=i&&i.parentNode==e.target?We(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let td=new WeakMap,nd=!1;function c0(t){if(!td.has(t)&&(td.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=yt,nd)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."),nd=!0}}function rd(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return rr(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function u0(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return rd(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?rd(t,n):null}function d0(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function h0(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let a=o;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(i,a.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function f0(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:a}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],$o(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Ue&&t.input.lastKeyCode===8)for(let g=i;g>s;g--){let y=r.childNodes[g-1],v=y.pmViewDesc;if(y.nodeName=="BR"&&!v){i=g;break}if(!v||v.size)break}let d=t.state.doc,h=t.someProp("domParser")||en.fromSchema(t.state.schema),f=d.resolve(o),p=null,m=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:p0,context:f});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:a}}function p0(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ye&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Ye&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const m0=/^(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 g0(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let R=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,$=ac(t,R);if($&&!t.state.selection.eq($)){if(Ue&&Xt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",F=>F(t,$n(13,"Enter"))))return;let W=t.state.tr.setSelection($);R=="pointer"?W.setMeta("pointer",!0):R=="key"&&W.scrollIntoView(),i&&W.setMeta("composition",i),t.dispatch(W)}return}let o=t.state.doc.resolve(e),a=o.sharedDepth(n);e=o.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=f0(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=k0(d.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(Lr&&t.input.lastIOSEnter>Date.now()-225||Xt)&&s.some(R=>R.nodeType==1&&!m0.test(R.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",R=>R(t,$n(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof U&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let R=sd(t,t.state.doc,c.sel);if(R&&!R.eq(t.state.selection)){let $=t.state.tr.setSelection(R);i&&$.setMeta("composition",i),t.dispatch($)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof U&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),ot&&Mn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" Â "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),v=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Lr&&t.input.lastIOSEnter>Date.now()-225&&(!v||s.some(R=>R.nodeName=="DIV"||R.nodeName=="P"))||!v&&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,"","")))&&t.someProp("handleKeyDown",R=>R(t,$n(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&b0(u,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",R=>R(t,$n(8,"Backspace")))){Xt&&Ue&&t.domObserver.suppressSelectionUpdates();return}Ue&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Xt&&!v&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(R){return R(t,$n(13,"Enter"))})},20));let C=p.start,N=p.endA,M=R=>{let $=R||t.state.tr.replace(C,N,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let W=sd(t,$.doc,c.sel);W&&!(Ue&&t.composing&&W.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(W.head==C||W.head==$.mapping.map(N)-1)||ot&&W.empty&&W.head==C)&&$.setSelection(W)}return i&&$.setMeta("composition",i),$.scrollIntoView()},I;if(v)if(m.pos==g.pos){ot&&Mn<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>nn(t),20));let R=M(t.state.tr.delete(C,N)),$=u.resolve(p.start).marksAcross(u.resolve(p.endA));$&&R.ensureMarks($),t.dispatch(R)}else if(p.endA==p.endB&&(I=y0(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let R=M(t.state.tr);I.type=="add"?R.addMark(C,N,I.mark):R.removeMark(C,N,I.mark),t.dispatch(R)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let R=m.parent.textBetween(m.parentOffset,g.parentOffset),$=()=>M(t.state.tr.insertText(R,C,N));t.someProp("handleTextInput",W=>W(t,C,N,R,$))||t.dispatch($())}else t.dispatch(M());else t.dispatch(M())}function sd(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:lc(t,e.resolve(n.anchor),e.resolve(n.head))}function y0(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,a,l;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(s.length==1&&i.length==0)a=s[0],o="add",l=u=>u.mark(a.addToSet(u.marks));else if(s.length==0&&i.length==1)a=i[0],o="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(A.from(c).eq(t))return{mark:a,type:o}}function b0(t,e,n,r,s){if(n-e<=s.pos-r.pos||Na(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let a=i.nodeAfter;return a!=null&&n==e+a.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(Na(i,!0,!0));return!o.parent.isTextblock||o.pos>n||Na(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Na(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function k0(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);
vendor: 4,448 bytes, line 11
11if(s=="end"){let l=Math.max(0,i-Math.min(o,a));r-=o+l-i}if(o<i&&t.size<e.size){let l=r<=i&&r>=o?i-r:0;i-=l,i&&i<e.size&&id(e.textBetween(i-1,i+1))&&(i+=l?1:-1),a=i+(a-o),o=i}else if(a<i){let l=r<=i&&r>=a?i-r:0;i-=l,i&&i<t.size&&id(t.textBetween(i-1,i+1))&&(i+=l?1:-1),o=i+(o-a),a=i}return{start:i,endA:o,endB:a}}function id(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class kp{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Pk,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(ud),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=ld(this),ad(this),this.nodeViews=cd(this),this.docView=Hu(this.state.doc,od(this),Aa(this),this.dom,this),this.domObserver=new l0(this,(r,s,i,o)=>g0(this,r,s,i,o)),this.domObserver.start(),$k(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&bl(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ud),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(hp(this),o=!0),this.state=e;let a=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=cd(this);w0(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&bl(this),this.editable=ld(this),ad(this);let l=Aa(this),c=od(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,l);(d||!e.selection.eq(s.selection))&&(o=!0);let h=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Yb(this);if(o){this.domObserver.stop();let f=d&&(ot||Ue)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&x0(s.selection,e.selection);if(d){let p=Ue?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Yk(this)),(i||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Hu(e.doc,c,l,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&xk(this))?nn(this,f):(ep(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&Qb(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof j){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Du(this,n.getBoundingClientRect(),e)}else Du(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;
vendor: 4,556 bytes, line 11
11if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new pp(e.slice,e.move,s<0?void 0:j.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let a=this.directPlugins[o].props[e];if(a!=null&&(s=n?n(a):a))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let a=i[o].props[e];if(a!=null&&(s=n?n(a):a))return s}}hasFocus(){if(ot){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&&Xb(this.dom),nn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return rk(this,e)}coordsAtPos(e,n=1){return qf(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return lk(this,n||this.state,e)}pasteHTML(e,n){return Ts(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Ts(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return cc(this,e)}destroy(){this.docView&&(zk(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Aa(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Hb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return _k(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ye&&this.root.nodeType===11&&Ub(this.dom.ownerDocument)==this.dom&&u0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}kp.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function od(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Ee.node(0,t.state.doc.content.size,e)]}function ad(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ee.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ld(t){return!t.someProp("editable",e=>e(t.state)===!1)}function x0(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function cd(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function w0(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function ud(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const S0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),v0=typeof navigator<"u"&&/Win/.test(navigator.platform);function C0(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))S0?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function M0(t){let e=Object.create(null);for(let n in t)e[C0(n)]=t[n];return e}
vendor: 5,057 bytes, line 11
11function Ra(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function T0(t){return new ue({props:{handleKeyDown:mc(t)}})}function mc(t){let e=M0(t);return function(n,r){let s=qg(r),i,o=e[Ra(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[Ra(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(v0&&r.ctrlKey&&r.altKey)&&(i=Kg[r.keyCode])&&i!=s){let a=e[Ra(i,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var E0=Object.defineProperty,gc=(t,e)=>{for(var n in e)E0(t,n,{get:e[n],enumerable:!0})};function _o(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var Ho=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,a])=>[o,(...c)=>{const u=a(...c)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],a=!!t,l=t||s.tr,c=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,h])=>[d,(...p)=>{const m=this.buildProps(l,e),g=h(...p)(m);return o.push(g),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>l(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:_o({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([a,l])=>[a,(...c)=>l(...c)(o)]))}};return o}},wt={};gc(wt,{blur:()=>A0,clearContent:()=>N0,clearNodes:()=>R0,command:()=>O0,createParagraphNear:()=>L0,cut:()=>I0,deleteCurrentNode:()=>D0,deleteNode:()=>P0,deleteRange:()=>$0,deleteSelection:()=>_0,enter:()=>H0,exitCode:()=>F0,extendMarkRange:()=>V0,first:()=>j0,focus:()=>U0,forEach:()=>q0,insertContent:()=>K0,insertContentAt:()=>Y0,joinBackward:()=>Z0,joinDown:()=>X0,joinForward:()=>ex,joinItemBackward:()=>tx,joinItemForward:()=>nx,joinTextblockBackward:()=>rx,joinTextblockForward:()=>sx,joinUp:()=>Q0,keyboardShortcut:()=>ox,lift:()=>ax,liftEmptyBlock:()=>lx,liftListItem:()=>cx,newlineInCode:()=>ux,resetAttributes:()=>dx,scrollIntoView:()=>hx,selectAll:()=>fx,selectNodeBackward:()=>px,selectNodeForward:()=>mx,selectParentNode:()=>gx,selectTextblockEnd:()=>yx,selectTextblockStart:()=>bx,setContent:()=>kx,setMark:()=>_x,setMeta:()=>Hx,setNode:()=>Fx,setNodeSelection:()=>Vx,setTextDirection:()=>jx,setTextSelection:()=>Wx,sinkListItem:()=>Ux,splitBlock:()=>qx,splitListItem:()=>Kx,toggleList:()=>Gx,toggleMark:()=>Yx,toggleNode:()=>Qx,toggleWrap:()=>Xx,undoInputRule:()=>Zx,unsetAllMarks:()=>ew,unsetMark:()=>tw,unsetTextDirection:()=>nw,updateAttributes:()=>rw,wrapIn:()=>sw,wrapInList:()=>iw});var A0=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),N0=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),R0=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(l)),h=c.resolve(u.map(l+a.nodeSize)),f=d.blockRange(h);if(!f)return;const p=$r(f);if(a.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(f.start,m)}(p||p===0)&&e.lift(f,p)})}),!0},O0=t=>e=>t(e),L0=()=>({state:t,dispatch:e})=>Pf(t,e),I0=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new U(r.doc.resolve(Math.max(o-1,0)))),!0},D0=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const a=s.before(i),l=s.after(i);t.delete(a,l).scrollIntoView()}return!0}return!1};function $e(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);
11return e.nodes[t]}return t}var P0=t=>({tr:e,state:n,dispatch:r})=>{const s=$e(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const l=i.before(o),c=i.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},$0=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},z0=t=>t.content?/^text(\*|\+)/.test(t.content):!1,dd=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return z0(r)?n==="left"?t.start()-1:t.end()+1:t.pos},B0=(t,e,n)=>{const r=dd(t,n,"left"),s=dd(e,n,"right");return{from:r,to:s}},_0=()=>({state:t,dispatch:e})=>{const{$from:n,$to:r}=t.selection;if(t.selection.empty)return!1;const{from:s,to:i}=B0(n,r,t.schema);return e&&(t.tr.deleteRange(s,i).scrollIntoView(),e(t.tr)),!0},H0=()=>({commands:t})=>t.keyboardShortcut("Enter"),F0=()=>({state:t,dispatch:e})=>Mb(t,e);function yc(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function qi(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:yc(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function xp(t,e,n={}){return t.find(r=>r.type===e&&qi(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function hd(t,e,n={}){return!!xp(t,e,n)}function Fo(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!n){const c=r.node.marks.find(u=>u.type===e);c&&(n=c.attrs)}if(!xp([...r.node.marks],e,n))return;let i=r.index,o=t.start()+r.offset,a=i+1,l=o+r.node.nodeSize;for(;i>0&&hd([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&hd([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function on(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var V0=(t,e)=>({tr:n,state:r,dispatch:s})=>{const i=on(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:u}=a;if(s){const d=Fo(l,i,e);if(d&&d.from<=c&&d.to>=u){const h=U.create(o,d.from,d.to);n.setSelection(h)}}return!0},j0=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function wp(t){return t instanceof U}function Fn(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Sp(t,e=null){if(!e)return null;const n=Q.atStart(t),r=Q.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?U.create(t,Fn(0,s,i),Fn(t.content.size,s,i)):U.create(t,Fn(e,s,i),Fn(e,s,i))}function fd(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ki(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function W0(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var U0=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Ki()||fd())&&r.dom.focus(),W0()&&!Ki()&&!fd()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!wp(n.state.selection))return o(),!0;const a=Sp(s.doc,t)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},q0=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),K0=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),vp=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&vp(r)}return t};function Zr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return vp(n)}function As(t,e,n){if(t instanceof Et||t instanceof A)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return A.fromArray(t.map(a=>e.nodeFromJSON(a)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),As("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,a="";const l=new af({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?en.fromSchema(l).parseSlice(Zr(t),n.parseOptions):en.fromSchema(l).parse(Zr(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const i=en.fromSchema(e);return n.slice?i.parseSlice(Zr(t),n.parseOptions).content:i.parse(Zr(t),n.parseOptions)}return As("",e,n)}function J0(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof De||s instanceof He))return;const i=t.mapping.maps[r];let o=0;
vendor: 4,218 bytes, line 11
11i.forEach((a,l,c,u)=>{o===0&&(o=u)}),t.setSelection(Q.near(t.doc.resolve(o),n))}var G0=t=>!("type"in t),Y0=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=g=>{i.emit("contentError",{editor:i,error:g,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{As(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=As(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(g){return l(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((G0(a)?a:[a]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,f=f?g.isBlock:!1}),u===d&&f){const{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(h){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof A){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=a;const g=r.doc.resolve(u),y=g.node(),v=g.parentOffset===0,C=y.isText||y.isTextblock,N=y.content.size>0;v&&C&&N&&f&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&J0(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},Q0=()=>({state:t,dispatch:e})=>Sb(t,e),X0=()=>({state:t,dispatch:e})=>vb(t,e),Z0=()=>({state:t,dispatch:e})=>Af(t,e),ex=()=>({state:t,dispatch:e})=>Lf(t,e),tx=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Io(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},nx=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Io(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},rx=()=>({state:t,dispatch:e})=>xb(t,e),sx=()=>({state:t,dispatch:e})=>wb(t,e);function Cp(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ix(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))Ki()||Cp()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var ox=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=ix(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l?.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function Nn(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?$e(e,t.schema):null,a=[];t.doc.nodesBetween(r,s,(d,h)=>{if(d.isText)return;const f=Math.max(r,h),p=Math.min(s,h+d.nodeSize);a.push({node:d,from:f,to:p})});const l=s-r,c=a.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>qi(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,h)=>d+h.to-h.from,0)>=l}var ax=(t,e={})=>({state:n,dispatch:r})=>{const s=$e(t,n.schema);return Nn(n,s,e)?Cb(n,r):!1},lx=()=>({state:t,dispatch:e})=>$f(t,e),cx=t=>({state:e,dispatch:n})=>{const r=$e(t,e.schema);return $b(r)(e,n)},ux=()=>({state:t,dispatch:e})=>Df(t,e);function Vo(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function pd(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var dx=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=Vo(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(i=$e(t,r.schema)),a==="mark"&&(o=on(t,r.schema));let l=!1;
11return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(l=!0,s&&n.setNodeMarkup(d,void 0,pd(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(h=>{o===h.type&&(l=!0,s&&n.addMark(d,d+u.nodeSize,o.create(pd(h.attrs,e))))})})}),l},hx=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),fx=()=>({tr:t,dispatch:e})=>{if(e){const n=new it(t.doc);t.setSelection(n)}return!0},px=()=>({state:t,dispatch:e})=>Rf(t,e),mx=()=>({state:t,dispatch:e})=>If(t,e),gx=()=>({state:t,dispatch:e})=>Ab(t,e),yx=()=>({state:t,dispatch:e})=>Ob(t,e),bx=()=>({state:t,dispatch:e})=>Rb(t,e);function kl(t,e,n={},r={}){return As(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var kx=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:a})=>{const{doc:l}=i;if(r.preserveWhitespace!=="full"){const c=kl(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Mp(t,e){const n=on(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function Tp(t,e){const n=new ec(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function xx(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function xl(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function wx(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function Ep(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function jo(t){return e=>Ep(e.$from,t)}function H(t,e,n){return t.config[e]===void 0&&t.parent?H(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?H(t.parent,e,n):null}):t.config[e]}function Wo(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=H(e,"addExtensions",n);return r?[e,...Wo(r())]:e}).flat(10)}function bc(t,e){const n=cr.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Ap(t){return typeof t=="function"}function de(t,e=void 0,...n){return Ap(t)?e?t.bind(e)(...n):t(...n):t}function Sx(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Ir(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Np(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ir(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),a=r.map(c=>c.name),l=[...o,...a];return t.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage,extensions:s},d=H(c,"addGlobalAttributes",u);if(!d)return;d().forEach(f=>{let p;Array.isArray(f.types)?p=f.types:f.types==="*"?p=l:f.types==="nodes"?p=o:f.types==="marks"?p=a:p=[],p.forEach(m=>{Object.entries(f.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...i,...y}})})})})}),s.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage},d=H(c,"addAttributes",u);if(!d)return;const h=d();Object.entries(h).forEach(([f,p])=>{const m={...i,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:c.name,name:f,attribute:m})})}),e}function vx(t){const e=[];let n="",r=!1,s=!1,i=0;const o=t.length;for(let a=0;a<o;a+=1){const l=t[a];if(l==="'"&&!s){r=!r,n+=l;continue}if(l==='"'&&!r){s=!s,n+=l;continue}if(!r&&!s){if(l==="("){i+=1,n+=l;continue}if(l===")"&&i>0){i-=1,n+=l;continue}if(l===";"&&i===0){e.push(n),n="";continue}}n+=l}return n&&e.push(n),e}function md(t){const e=[],n=vx(t||""),r=n.length;for(let s=0;s<r;s+=1){const i=n[s],o=i.indexOf(":");if(o===-1)continue;const a=i.slice(0,o).trim(),l=i.slice(o+1).trim();a&&l&&e.push([a,l])}return e}function he(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};
vendor: 26,362 bytes, lines 11-14
11return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const a=i?String(i).split(" "):[],l=r[s]?r[s].split(" "):[],c=a.filter(u=>!l.includes(u));r[s]=[...l,...c].join(" ")}else if(s==="style"){const a=new Map([...md(r[s]),...md(i)]);r[s]=Array.from(a.entries()).map(([l,c])=>`${l}: ${c}`).join("; ")}else r[s]=i}),r},{})}function Ns(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>he(n,r),{})}function Cx(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function gd(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(n):Cx(n.getAttribute(o.name));return a==null?i:{...i,[o.name]:a}},{});return{...r,...s}}}}function yd(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Sx(n)?!1:n!=null))}function bd(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function Rp(t,e){var n;const r=Np(t),{nodeExtensions:s,markExtensions:i}=Ir(t),o=(n=s.find(c=>H(c,"topNode")))==null?void 0:n.name,a=Object.fromEntries(s.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,v)=>{const C=H(v,"extendNodeSchema",d);return{...y,...C?C(c):{}}},{}),f=yd({...h,content:de(H(c,"content",d)),marks:de(H(c,"marks",d)),group:de(H(c,"group",d)),inline:de(H(c,"inline",d)),atom:de(H(c,"atom",d)),selectable:de(H(c,"selectable",d)),draggable:de(H(c,"draggable",d)),code:de(H(c,"code",d)),whitespace:de(H(c,"whitespace",d)),linebreakReplacement:de(H(c,"linebreakReplacement",d)),defining:de(H(c,"defining",d)),isolating:de(H(c,"isolating",d)),attrs:Object.fromEntries(u.map(bd))}),p=de(H(c,"parseHTML",d));p&&(f.parseDOM=p.map(y=>gd(y,u)));const m=H(c,"renderHTML",d);m&&(f.toDOM=y=>m({node:y,HTMLAttributes:Ns(y,u)}));const g=H(c,"renderText",d);return g&&(f.toText=g),[c.name,f]})),l=Object.fromEntries(i.map(c=>{const u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((g,y)=>{const v=H(y,"extendMarkSchema",d);return{...g,...v?v(c):{}}},{}),f=yd({...h,inclusive:de(H(c,"inclusive",d)),excludes:de(H(c,"excludes",d)),group:de(H(c,"group",d)),spanning:de(H(c,"spanning",d)),code:de(H(c,"code",d)),attrs:Object.fromEntries(u.map(bd))}),p=de(H(c,"parseHTML",d));p&&(f.parseDOM=p.map(g=>gd(g,u)));const m=H(c,"renderHTML",d);return m&&(f.toDOM=g=>m({mark:g,HTMLAttributes:Ns(g,u)})),[c.name,f]}));return new af({topNode:o,nodes:a,marks:l})}function Mx(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Ar(t){return t.sort((n,r)=>{const s=H(n,"priority")||100,i=H(r,"priority")||100;return s>i?-1:s<i?1:0})}function kc(t){const e=Ar(Wo(t)),n=Mx(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Tx(t,e){const n=kc(t);return Rp(n,e)}function Ex(t,e){const n=Tx(e),r=Zr(t);return en.fromSchema(n).parse(r).toJSON()}function Op(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=` 12 13`,textSerializers:o={}}=n||{};let a="";return t.nodesBetween(r,s,(l,c,u,d)=>{var h;l.isBlock&&c>r&&(a+=i);const f=o?.[l.type.name];if(f)return u&&(a+=f({node:l,pos:c,parent:u,index:d,range:e})),!1;l.isText&&(a+=(h=l?.text)==null?void 0:h.slice(Math.max(r,c)-c,s-c))}),a}function Ax(t,e){const n={from:0,to:t.content.size};return Op(t,n,e)}function Lp(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Nx(t,e){const n=$e(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,a=>{i.push(a)});const o=i.reverse().find(a=>a.type.name===n.name);return o?{...o.attrs}:{}}function Ip(t,e){const n=Vo(typeof e=="string"?e:e.name,t.schema);return n==="node"?Nx(t,e):n==="mark"?Mp(t,e):{}}function Rx(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function Ox(t){const e=Rx(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Dp(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=n[i];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const c=e.slice(i).map(a,-1),u=e.slice(i).map(l),d=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:d,to:h},newRange:{from:c,to:u}})})}),Ox(r)}function xc(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=Fo(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var Lx=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const a=s.node(i);a?.type.name===e?o=a:i-=1}return[o,i]};function Ur(t,e){return e.nodes[t]||e.marks[t]||null}function Ai(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var Ix=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,a)=>{var l,c;const u=((c=(l=s.type.spec).toText)==null?void 0:c.call(l,{node:s,pos:i,parent:o,index:a}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),n};function wl(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?on(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>qi(d.attrs,n,{strict:!1}));let o=0;const a=[];if(s.forEach(({$from:d,$to:h})=>{const f=d.pos,p=h.pos;t.doc.nodesBetween(f,p,(m,g)=>{if(i&&m.inlineContent&&!m.type.allowsMarkType(i))return!1;if(!m.isText&&!m.marks.length)return;const y=Math.max(f,g),v=Math.min(p,g+m.nodeSize),C=v-y;o+=C,a.push(...m.marks.map(N=>({mark:N,from:y,to:v})))})}),o===0)return!1;const l=a.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>qi(d.mark.attrs,n,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),c=a.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,h)=>d+h.to-h.from,0);return(l>0?l+c:l)>=o}function Dx(t,e,n={}){if(!e)return Nn(t,null,n)||wl(t,null,n);const r=Vo(e,t.schema);return r==="node"?Nn(t,e,n):r==="mark"?wl(t,e,n):!1}var Px=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=jo(a=>a.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},$x=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function kd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Oa(t,e){const{nodeExtensions:n}=Ir(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=de(H(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Rs(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(Rs(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Pp(t){return t instanceof j}var wc=class $p{constructor(e){this.position=e}static fromJSON(e){return new $p(e.position)}toJSON(){return{position:this.position}}};function zp(t,e){const n=e.mapping.mapResult(t.position);return{position:new wc(n.pos),mapResult:n}}function zx(t){return new wc(t)}function Bx(t,e,n){var r;const{selection:s}=e;let i=null;if(wp(s)&&(i=s.$cursor),i){const a=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(c=>c.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(u,d,h)=>{if(c)return!1;if(u.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=f&&p}return!c}),c})}var _x=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:a}=i,l=on(t,r.schema);if(s)if(o){const c=Mp(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(h,f)=>{const p=Math.max(f,u),m=Math.min(f+h.nodeSize,d);h.marks.find(y=>y.type===l)?h.marks.forEach(y=>{l===y.type&&n.addMark(p,m,l.create({...y.attrs,...e}))}):n.addMark(p,m,l.create(e))})});return Bx(r,n,l)},Hx=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Fx=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=$e(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:a})=>Ou(i,{...o,...e})(n)?!0:a.clearNodes()).command(({state:a})=>Ou(i,{...o,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Vx=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Fn(t,0,r.content.size),i=j.create(r,s);e.setSelection(i)}return!0},jx=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let o,a;return typeof e=="number"?(o=e,a=e):e&&"from"in e&&"to"in e?(o=e.from,a=e.to):(o=i.from,a=i.to),s&&n.doc.nodesBetween(o,a,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},Wx=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=U.atStart(r).from,a=U.atEnd(r).to,l=Fn(s,o,a),c=Fn(i,o,a),u=U.create(r,l,c);e.setSelection(u)}return!0},Ux=t=>({state:e,dispatch:n})=>{const r=$e(t,e.schema);return _b(r)(e,n)};function xd(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var qx=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:a,$to:l}=i,c=s.extensionManager.attributes,u=Ai(c,a.node().type.name,a.node().attrs);if(i instanceof j&&i.node.isBlock)return!a.parentOffset||!tn(o,a.pos)?!1:(r&&(t&&xd(n,s.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:xx(a.node(-1).contentMatchAt(a.indexAfter(-1)));let f=d&&h?[{type:h,attrs:u}]:void 0,p=tn(e.doc,e.mapping.map(a.pos),1,f);if(!f&&!p&&tn(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(i instanceof U&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,f),h&&!d&&!a.parentOffset&&a.parent.type!==h)){const m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}t&&xd(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},Kx=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const a=$e(t,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const d=l.node(-1);if(d.type!==a)return!1;const h=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let y=A.empty;const v=l.index(-1)?1:l.index(-2)?2:3;for(let $=l.depth-v;$>=l.depth-3;$-=1)y=A.from(l.node($).copy(y));const C=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,N={...Ai(h,l.node().type.name,l.node().attrs),...e},M=((o=a.contentMatch.defaultType)==null?void 0:o.createAndFill(N))||void 0;y=y.append(A.from(a.createAndFill(null,M)||void 0));const I=l.before(l.depth-(v-1));n.replace(I,l.after(-C),new D(y,4-v,0));let R=-1;n.doc.nodesBetween(I,n.doc.content.size,($,W)=>{if(R>-1)return!1;$.isTextblock&&$.content.size===0&&(R=W+1)}),R>-1&&n.setSelection(U.near(n.doc.resolve(R))),n.scrollIntoView()}return!0}const f=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,p={...Ai(h,d.type.name,d.attrs),...e},m={...Ai(h,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const g=f?[{type:a,attrs:p},{type:f,attrs:m}]:[{type:a,attrs:p}];if(!tn(n.doc,l.pos,2))return!1;if(s){const{selection:y,storedMarks:v}=r,{splittableMarks:C}=i.extensionManager,N=v||y.$to.parentOffset&&y.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!N||!s)return!0;const M=N.filter(I=>C.includes(I.type.name));n.ensureMarks(M)}return!0},La=(t,e)=>{const n=jo(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&On(t.doc,n.pos)&&t.join(n.pos),!0},Ia=(t,e)=>{const n=jo(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&On(t.doc,r)&&t.join(r),!0};function Jx(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),s=e.resolve(n.nodeSize-1);return U.between(r,s)}var Gx=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:d,splittableMarks:h}=s.extensionManager,f=$e(t,o.schema),p=$e(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:v}=m,C=y.blockRange(v),N=g||m.$to.parentOffset&&m.$from.marks();if(!C)return!1;const M=jo(G=>Oa(G.type.name,d))(m),I=m.from===0&&m.to===o.doc.content.size,R=o.doc.content.content,$=R.length===1?R[0]:null,W=I&&$&&Oa($.type.name,d)?{node:$,pos:0}:null,F=M??W,Z=!!M&&C.depth>=1&&C.depth-M.depth<=1,ne=!!W;if((Z||ne)&&F){if(F.node.type===f)return I&&ne?l().command(({tr:G,dispatch:_})=>{const ee=Jx(G);return ee?(G.setSelection(ee),_&&_(G),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Oa(F.node.type.name,d)&&f.validContent(F.node.content))return l().command(()=>(i.setNodeMarkup(F.pos,f),!0)).command(()=>La(i,f)).command(()=>Ia(i,f)).run()}return!n||!N||!a?l().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>La(i,f)).command(()=>Ia(i,f)).run():l().command(()=>{const G=u().wrapInList(f,r),_=N.filter(ee=>h.includes(ee.type.name));return i.ensureMarks(_),G?!0:c.clearNodes()}).wrapInList(f,r).command(()=>La(i,f)).command(()=>Ia(i,f)).run()},Yx=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=on(t,r.schema);return wl(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},Qx=(t,e,n={})=>({state:r,commands:s})=>{const i=$e(t,r.schema),o=$e(e,r.schema),a=Nn(r,i,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?s.setNode(o,l):s.setNode(i,{...l,...n})},Xx=(t,e={})=>({state:n,commands:r})=>{const s=$e(t,n.schema);return Nn(n,s,e)?r.lift(s):r.wrapIn(s,e)},Zx=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,a=i.transform;for(let l=a.steps.length-1;l>=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(i.text){const l=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,l))}else o.delete(i.from,i.to)}return!0}}return!1},ew=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},tw=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=on(t,r.schema),{$from:c,empty:u,ranges:d}=a;if(!s)return!0;if(u&&o){let{from:h,to:f}=a;const p=(i=c.marks().find(g=>g.type===l))==null?void 0:i.attrs,m=Fo(c,l,p);m&&(h=m.from,f=m.to),n.removeMark(h,f,l)}else d.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,l)});return n.removeStoredMark(l),!0},nw=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(a,l)=>{if(a.isText)return;const c={...a.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},rw=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=Vo(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(i=$e(t,r.schema)),a==="mark"&&(o=on(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let h,f,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{i&&i===g.type&&(l=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),h=y,f=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y<u&&i&&i===g.type&&(l=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),h=y,f=g),y>=u&&y<=d&&(i&&i===g.type&&(l=!0,s&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(v=>{if(o===v.type&&(l=!0,s)){const C=Math.max(y,u),N=Math.min(y+g.nodeSize,d);n.addMark(C,N,o.create({...v.attrs,...e}))}}))}),f&&(h!==void 0&&s&&n.setNodeMarkup(h,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&s&&n.addMark(p,m,o.create({...g.attrs,...e}))}))}),l},sw=(t,e={})=>({state:n,dispatch:r})=>{const s=$e(t,n.schema);return Lb(s,e)(n,r)},iw=(t,e={})=>({state:n,dispatch:r})=>{const s=$e(t,n.schema);return Ib(s,e)(n,r)},ow=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},ur=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},aw=(t,e)=>{if(yc(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function oi(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let u=!1;const d=Ix(c)+i;return o.forEach(h=>{if(u)return;const f=aw(d,h.find);if(!f)return;const p=l.state.tr,m=_o({state:l.state,transaction:p}),g={from:r-(f[0].length-i.length),to:s},{commands:y,chain:v,can:C}=new Ho({editor:n,state:m});h.handler({state:m,range:g,match:f,commands:y,chain:v,can:C})===null||!p.steps.length||(h.undoable&&p.setMeta(a,{transform:p,from:r,to:s,text:i}),l.dispatch(p),u=!0)}),u}function lw(t){const{editor:e,rules:n}=t,r=new ue({state:{init(){return null},apply(s,i,o){const a=s.getMeta(r);if(a)return a;const l=s.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=bc(A.from(u),o.schema);const{from:d}=l,h=d+u.length;oi({editor:e,from:d,to:h,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,a){return oi({editor:e,from:i,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&oi({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?oi({editor:e,from:o.pos,to:o.pos,text:` 14`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function cw(t){return Object.prototype.toString.call(t).slice(8,-1)}function ai(t){return cw(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Bp(t,e){const n={...t};return ai(t)&&ai(e)&&Object.keys(e).forEach(r=>{ai(e[r])&&ai(t[r])?n[r]=Bp(t[r],e[r]):n[r]=e[r]}),n}var Sc=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...de(H(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...de(H(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Bp(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},an=class _p extends Sc{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new _p(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>c?.type.name===n.name))return!1;const l=o.find(c=>c?.type.name===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function uw(t){return typeof t=="number"}var Hp=class{constructor(t){this.find=t.find,this.handler=t.handler}},dw=(t,e,n)=>{if(yc(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function hw(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:a}=t,{commands:l,chain:c,can:u}=new Ho({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(f,p)=>{var m,g,y,v,C;if((g=(m=f.type)==null?void 0:m.spec)!=null&&g.code||!(f.isText||f.isTextblock||f.isInline))return;const N=(C=(v=(y=f.content)==null?void 0:y.size)!=null?v:f.nodeSize)!=null?C:0,M=Math.max(r,p),I=Math.min(s,p+N);if(M>=I)return;const R=f.isText?f.text||"":f.textBetween(M-p,I-p,void 0,"");dw(R,i.find,o).forEach(W=>{if(W.index===void 0)return;const F=M+W.index+1,Z=F+W[0].length,ne={from:n.tr.mapping.map(F),to:n.tr.mapping.map(Z)},G=i.handler({state:n,range:ne,match:W,commands:l,chain:c,can:u,pasteEvent:o,dropEvent:a});d.push(G)})}),d.every(f=>f!==null)}var li=null,fw=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function pw(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:u,from:d,to:h,rule:f,pasteEvt:p})=>{const m=u.tr,g=_o({state:u,transaction:m});if(!(!hw({editor:e,state:g,from:Math.max(d-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:a})||!m.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(u=>new ue({view(d){const h=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(li=e)},f=()=>{li&&(li=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,h)=>{if(i=r===d.dom.parentElement,a=h,!i){const f=li;f?.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return o=h,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,h,f)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!s,g=p.getMeta("uiEvent")==="drop"&&!i,y=p.getMeta("applyPasteRules"),v=!!y;if(!m&&!g&&!v)return;if(v){let{text:M}=y;typeof M=="string"?M=M:M=bc(A.from(M),f.schema);const{from:I}=y,R=I+M.length,$=fw(M);return l({rule:u,state:f,from:I,to:{b:R},pasteEvt:$})}const C=h.doc.content.findDiffStart(f.doc.content),N=h.doc.content.findDiffEnd(f.doc.content);if(!(!uw(C)||!N||C===N.b))return l({rule:u,state:f,from:C,to:N,pasteEvt:o})}}))}var Uo=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=kc(t),this.schema=Rp(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ur(e.name,this.schema)},r=H(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Ar([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Ur(r.name,this.schema)},i=[],o=H(r,"addKeyboardShortcuts",s);let a={};if(r.type==="mark"&&H(r,"exitable",s)&&(a.ArrowRight=()=>an.handleExit({editor:t,mark:r})),o){const h=Object.fromEntries(Object.entries(o()).map(([f,p])=>[f,()=>p({editor:t})]));a={...a,...h}}const l=T0(a);i.push(l);const c=H(r,"addInputRules",s);if(kd(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=lw({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}const u=H(r,"addPasteRules",s);if(kd(r,t.options.enablePasteRules)&&u){const h=u();if(h&&h.length){const f=pw({editor:t,rules:h});i.push(...f)}}const d=H(r,"addProseMirrorPlugins",s);if(d){const h=d();i.push(...h)}return i})}get attributes(){return Np(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Ir(this.extensions);return Object.fromEntries(e.filter(n=>!!H(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:$e(n.name,this.schema)},i=H(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const a=(l,c,u,d,h)=>{const f=Ns(l,r);return o({node:l,view:c,getPos:u,decorations:d,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,a]}
14))}dispatchTransaction(t){const{editor:e}=this;return Ar([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Ur(s.name,this.schema)},o=H(s,"dispatchTransaction",i);return o?a=>{o.call(i,{transaction:a,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Ar([...this.extensions]).reduce((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Ur(s.name,this.schema)},o=H(s,"transformPastedHTML",i);return o?(a,l)=>{const c=r(a,l);return o.call(i,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=Ir(this.extensions);return Object.fromEntries(e.filter(n=>!!H(n,"addMarkView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:on(n.name,this.schema)},i=H(n,"addMarkView",s);if(!i)return[];const o=(a,l,c)=>{const u=Ns(a,r);return i()({mark:a,view:l,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{Rw(a,t,d)}})};return[n.name,o]}))}destroy(){this.extensions.forEach(t=>{let e=t;for(;e.parent;){const n=e.parent;n.child===e&&(n.child=null),e=n}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ur(e.name,this.schema)};e.type==="mark"&&((n=de(H(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=H(e,"onBeforeCreate",r),i=H(e,"onCreate",r),o=H(e,"onUpdate",r),a=H(e,"onSelectionUpdate",r),l=H(e,"onTransaction",r),c=H(e,"onFocus",r),u=H(e,"onBlur",r),d=H(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};Uo.resolve=kc;Uo.sort=Ar;Uo.flatten=Wo;var mw={};gc(mw,{ClipboardTextSerializer:()=>Vp,Commands:()=>jp,Delete:()=>Wp,Drop:()=>Up,Editable:()=>qp,FocusEvents:()=>Jp,Keymap:()=>Gp,Paste:()=>Yp,Tabindex:()=>Qp,TextDirection:()=>Xp,focusEventsPluginKey:()=>Kp});var ie=class Fp extends Sc{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Fp(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Vp=ie.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ue({key:new fe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(u=>u.$from.pos)),a=Math.max(...i.map(u=>u.$to.pos)),l=Lp(n);return Op(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),jp=ie.create({name:"commands",addCommands(){return{...wt}}}),Wp=ie.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,a,l,c;if((c=(l=(a=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,t))!=null?c:t.getMeta("y-sync$"))return;const u=Tp(t.before,[t,...e]);Dp(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,m)=>{const g=m+p.nodeSize-2,y=f.oldRange.from<=m&&g<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:u.mapping.map(m),newTo:u.mapping.map(g),deletedRange:f.oldRange,newRange:f.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((f,p)=>{var m,g;if(f instanceof Mt){const y=h.slice(p).map(f.from,-1),v=h.slice(p).map(f.to),C=h.invert().map(y,-1),N=h.invert().map(v),M=y>0?(m=u.doc.nodeAt(y-1))==null?void 0:m.marks.some(R=>R.eq(f.mark)):!1,I=(g=u.doc.nodeAt(v))==null?void 0:g.marks.some(R=>R.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:C,to:N},newRange:{from:y,to:v},partial:!!(I||M),editor:this.editor,transaction:t,combinedTransform:u})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),Up=ie.create({name:"drop",addProseMirrorPlugins(){return[new ue({key:new fe("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>
vendor: 15,582 bytes, lines 14-84
14{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),qp=ie.create({name:"editable",addProseMirrorPlugins(){return[new ue({key:new fe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Kp=new fe("focusEvents"),Jp=ie.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ue({key:Kp,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Gp=ie.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:h,parent:f}=d,p=d.parent.isTextblock&&h>0?a.doc.resolve(h-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:Q.atStart(c).from===h;return!u||!f.type.isTextblock||f.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ki()||Cp()?i:s},addProseMirrorPlugins(){return[new ue({key:new fe("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;const r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),s=t.some(m=>m.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:a}=e.selection,l=Q.atStart(e.doc).from,c=Q.atEnd(e.doc).to;if(i||!(o===l&&a===c)||!Rs(n.doc))return;const h=n.tr,f=_o({state:n,transaction:h}),{commands:p}=new Ho({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),Yp=ie.create({name:"paste",addProseMirrorPlugins(){return[new ue({key:new fe("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Qp=ie.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new ue({key:new fe("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),Xp=ie.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Ir(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ue({key:new fe("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),gw=class es{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You canât set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new es(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new es(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new es(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,a=this.pos+r+(i?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(a);if(!s&&!o&&l.depth<=this.depth)return;const c=new es(l,this.editor,s,s||o?n:null);s&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let a=0;a<o.length;a+=1){const l=o[a];if(i[l]!==n[l])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(l=>n[l]===o.node.attrs[l])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},yw=`.ProseMirror { 15 position: relative; 16} 17 18.ProseMirror { 19 word-wrap: break-word; 20 white-space: pre-wrap; 21 white-space: break-spaces; 22 -webkit-font-variant-ligatures: none; 23 font-variant-ligatures: none; 24 font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ 25} 26 27.ProseMirror [contenteditable="false"] { 28 white-space: normal; 29} 30 31.ProseMirror [contenteditable="false"] [contenteditable="true"] { 32 white-space: pre-wrap; 33} 34 35.ProseMirror pre { 36 white-space: pre-wrap; 37} 38 39img.ProseMirror-separator { 40 display: inline !important; 41 border: none !important; 42 margin: 0 !important; 43 width: 0 !important; 44 height: 0 !important; 45} 46 47.ProseMirror-gapcursor { 48 display: none; 49 pointer-events: none; 50 position: absolute; 51 margin: 0; 52} 53 54.ProseMirror-gapcursor:after { 55 content: ""; 56 display: block; 57 position: absolute; 58 top: -2px; 59 width: 20px; 60 border-top: 1px solid black; 61 animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; 62} 63 64@keyframes ProseMirror-cursor-blink { 65 to { 66 visibility: hidden; 67 } 68} 69 70.ProseMirror-hideselection *::selection { 71 background: transparent; 72} 73 74.ProseMirror-hideselection *::-moz-selection { 75 background: transparent; 76} 77 78.ProseMirror-hideselection * { 79 caret-color: transparent; 80} 81 82.ProseMirror-focused .ProseMirror-gapcursor { 83 display: block; 84}`;function bw(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var kw=class extends ow{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:zp,createMappablePosition:zx},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:i})=>this.options.onDrop(r,s,i)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Sp(e,this.options.autofocus);this.editorState=Cr.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=bw(yw,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Ap(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e,n,r;const i=[...this.options.enableCoreExtensions?[qp,Vp.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),jp,Jp,Gp,Qp.configure({value:(r=(n=this.options.coreExtensionOptions)==null?void 0:n.tabindex)==null?void 0:r.value}),Up,Yp,Wp,Xp.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new Uo(i,this)}createCommandManager(){this.commandManager=new Ho({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=kl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=kl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new kp(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:s,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const l=this.view.dom;l.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;
84if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=o?.getMeta("focus"),l=o?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:o}),l&&this.emit("blur",{editor:this,event:l.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Ip(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return Dx(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return bc(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` 85 86`,textSerializers:n={}}=t||{};return Ax(this.state.doc,{blockSeparator:e,textSerializers:{...Lp(this.schema),...n}})}get isEmpty(){return Rs(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null;return new gw(e,this,!1,n)}get $doc(){return this.$pos(0)}};function ir(t){return new ur({find:t.find,handler:({state:e,range:n,match:r})=>{const s=de(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),c=n.from+a.indexOf(o),u=c+o.length;if(xc(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(m=>m===t.type&&m!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+l,c);const h=n.from+l+o.length;i.addMark(n.from+l,h,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function Zp(t){return new ur({find:t.find,handler:({state:e,range:n,match:r})=>{const s=de(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let a=n.to;const l=t.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>a?u=a:a=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,o+r[0].length-1),i.replaceWith(u,a,l)}else if(r[0]){const c=t.type.isInline?o:o-1;i.insert(c,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(a))}i.scrollIntoView()},undoable:t.undoable})}function Sl(t){return new ur({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=de(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Ie(t){return new ur({find:t.find,handler:({state:e,range:n,match:r})=>{let s=t.replace,i=n.from;const o=n.to;if(r[1]){const a=r[0].lastIndexOf(r[1]);s+=r[0].slice(a+r[1].length),i+=a;const l=i-o;l>0&&(s=r[0].slice(a-l,a)+s,i=o)}e.tr.insertText(s,i,o)},undoable:t.undoable})}function Dr(t){return new ur({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=de(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),c=l&&Zl(l,t.type,i);if(!c)return null;if(o.wrap(l,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>f.includes(g.type.name));o.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,i).run()}const u=o.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&On(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&o.join(n.from-1)},undoable:t.undoable})}var xw=t=>"touches"in t,ww=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=a=>{if(!this.isResizing||!this.activeHandle)return;const l=a.clientX-this.startX,c=a.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=a=>{if(!this.isResizing||!this.activeHandle)return;const l=a.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>
86{if(!this.isResizing)return;const a=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(a,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}
86removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,xw(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,s,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const i=t.includes("right"),o=t.includes("left"),a=t.includes("bottom"),l=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),a?s=this.startHeight+n:l&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(a?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,o;if(!n){let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(s=this.maxSize)!=null&&s.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let a=t,l=e;return a<this.minSize.width&&(a=this.minSize.width,l=a/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,a=l*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&a>this.maxSize.width&&(a=this.maxSize.width,l=a/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&l>this.maxSize.height&&(l=this.maxSize.height,a=l*this.aspectRatio),{width:a,height:l}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function Sw(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof j){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function vw(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function zr(t,e){const n=t.getAttribute("style");if(!n)return null;const r=n.split(";").map(i=>i.trim()).filter(Boolean),s=e.toLowerCase();for(let i=r.length-1;i>=0;i-=1){const o=r[i],a=o.indexOf(":");if(a===-1)continue;if(o.slice(0,a).trim().toLowerCase()===s)return o.slice(a+1).trim()}return null}function wd(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")}function Cw(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Mw={};gc(Mw,{createAtomBlockMarkdownSpec:()=>Mc,createBlockMarkdownSpec:()=>Tw,createInlineMarkdownSpec:()=>Nw,parseAttributes:()=>vc,parseIndentedBlocks:()=>vl,renderNestedMarkdownContent:()=>Tc,serializeAttributes:()=>Cc});function vc(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}
86__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.trim().slice(1));e.class=c.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var d;const h=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),f=n[h];f&&(e[c]=f.slice(1,-1))});const l=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Cc(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function Mc(t){const{nodeName:e,name:n,parseAttributes:r=vc,serializeAttributes:s=Cc,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:a}=t,l=n||e,c=u=>{if(!a)return u;const d={};return a.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{const h={...i,...u.attributes};return d.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${l}(?:\\s|$)`,"m"),f=(d=u.match(h))==null?void 0:d.index;return f!==void 0?f:-1},tokenize(u,d,h){const f=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(f);if(!p)return;const m=p[1]||"",g=r(m);if(!o.find(v=>!(v in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:u=>{const d=c(u.attrs||{}),h=s(d),f=h?` {${h}}`:"";return`:::${l}${f} :::`}}}function Tw(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=vc,serializeAttributes:i=Cc,defaultAttributes:o={},content:a="block",allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const h={};return l.forEach(f=>{f in d&&(h[f]=d[f])}),h};return{parseMarkdown:(d,h)=>{let f;if(r){const m=r(d);f=typeof m=="string"?[{type:"text",text:m}]:m}else a==="block"?f=h.parseChildren(d.tokens||[]):f=h.parseInline(d.tokens||[]);const p={...o,...d.attributes};return h.createNode(e,p,f)},markdownTokenizer:{name:e,level:"block",start(d){var h;const f=new RegExp(`^:::${c}`,"m"),p=(h=d.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(d,h,f){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=d.match(m);if(!g)return;const[y,v=""]=g,C=s(v);let N=1;const M=y.length;let I="";const R=/^:::([\w-]*)(\s.*)?/gm,$=d.slice(M);for(R.lastIndex=0;;){const W=R.exec($);if(W===null)break;const F=W.index,Z=W[1];if(!((p=W[2])!=null&&p.endsWith(":::"))){if(Z)N+=1;else if(N-=1,N===0){const ne=$.slice(0,F);I=ne.trim();const G=d.slice(0,M+F+W[0].length);let _=[];if(I)if(a==="block")for(_=f.blockTokens(ne),_.forEach(ee=>{ee.text&&(!ee.tokens||ee.tokens.length===0)&&(ee.tokens=f.inlineTokens(ee.text))});_.length>0;){const ee=_[_.length-1];if(ee.type==="paragraph"&&(!ee.text||ee.text.trim()===""))_.pop();else break}else _=f.inlineTokens(I);return{type:e,raw:G,attributes:C,content:I,tokens:_}}}}}},renderMarkdown:(d,h)=>{const f=u(d.attrs||{}),p=i(f),m=p?` {${p}}`:"",g=h.renderChildren(d.content||[],` 87 88`);return`:::${c}${m} 89 90${g} 91 92:::`}}}function Ew(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function Aw(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function Nw(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Ew,serializeAttributes:i=Aw,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=t,c=n||e,u=h=>{if(!l)return h;const f={};return l.forEach(p=>{const m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in h){const y=h[m];if(g!==void 0&&y===g)return;f[m]=y}}),f},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,f)=>{const p={...o,...h.attributes};if(a)return f.createNode(e,p);const m=r?r(h):h.content||"";return m?f.createNode(e,p,[f.createTextNode(m)]):f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(h){const f=a?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=h.match(f),m=p?.index;return m!==void 0?m:-1},tokenize(h,f,p){const m=a?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),g=h.match(m);if(!g)return;let y="",v="";if(a){const[,N]=g;v=N}else{const[,N,M]=g;v=N,y=M||""}const C=s(v.trim());return{type:e,raw:g[0],content:y.trim(),attributes:C}}},renderMarkdown:h=>{let f="";r?f=r(h):h.content&&h.content.length>0&&(f=h.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const p=u(h.attrs||{}),m=i(p),g=m?` ${m}`:"";return a?`[${c}${g}]`:`[${c}${g}]${f}[/${c}]`}}}function vl(t,e,n){var r,s,i,o;const a=t.split(` 93`),l=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<a.length;){const h=a[u],f=h.match(e.itemPattern);if(!f){if(l.length>0)break;if(h.trim()===""){u+=1,c=`${c}${h} 94`;continue}else return}const p=e.extractItemData(f),{indentLevel:m,mainContent:g}=p;c=`${c}${h} 95`;const y=[g];for(u+=1;u<a.length;){const M=a[u];if(M.trim()===""){const R=a.slice(u+1).findIndex(F=>F.trim()!=="");if(R===-1)break;if((((s=(r=a[u+1+R].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>m){y.push(M),c=`${c}${M} 96`,u+=1;continue}else break}if((((o=(i=M.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>m)y.push(M),c=`${c}${M} 97`,u+=1;else break}let v;const C=y.slice(1);if(C.length>0){const M=C.map(I=>I.slice(m+d)).join(` 98`);M.trim()&&(e.customNestedParser?v=e.customNestedParser(M):v=n.blockTokens(M))}const N=e.createToken(p,v);l.push(N)}if(l.length!==0)return{items:l,raw:c}}function Tc(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,a=e.renderChildren([i]);let l=`${s}${a}`;return o&&o.length>0&&o.forEach((c,u)=>{var d,h;const f=(h=(d=e.renderChild)==null?void 0:d.call(e,c,u+1))!=null?h:e.renderChildren([c]);if(f!=null){const p=f.split(` 99`).map(m=>m?e.indent(m):e.indent("")).join(` 100`);l+=c.type==="paragraph"?` 101 102${p}`:` 103${p}`}}),l}function Rw(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((a,l)=>{const c=i.mapping.map(l),u=i.mapping.map(l)+a.nodeSize;let d=null;if(a.marks.forEach(f=>{if(f!==o)return!1;d=f}),!d)return;let h=!1;
103if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,f)}}),i.docChanged&&e.view.dispatch(i)}var Ae=class em extends Sc{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new em(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Rn(t){return new Hp({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=de(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const u=l.search(/\S/),d=n.from+l.indexOf(a),h=d+a.length;if(xc(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;h<n.to&&o.delete(h,n.to),d>n.from&&o.delete(n.from+u,d),c=n.from+u+a.length,o.addMark(n.from+u,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}function tm(t){return new Hp({find:t.find,handler({match:e,chain:n,range:r,pasteEvent:s}){const i=de(t.getAttributes,void 0,e,s),o=de(t.getContent,void 0,i);if(i===!1||i===null)return null;const a={type:t.type.name,attrs:i};o&&(a.content=o),e.input&&n().deleteRange(r).insertContentAt(r.from,a)}})}var Ji=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},Ow=/^\s*>\s$/,Lw=Ae.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Ji("blockquote",{...he(this.options.HTMLAttributes,t),children:Ji("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach((s,i)=>{var o,a;const u=((a=(o=e.renderChild)==null?void 0:o.call(e,s,i))!=null?a:e.renderChildren([s])).split(` 104`).map(d=>d.trim()===""?n:`${n} ${d}`);r.push(u.join(` 105`))}),r.join(` 106${n} 107`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}}
vendor: 1,201 bytes, line 107
107,addInputRules(){return[Dr({find:Ow,type:this.type})]}}),Iw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Dw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Pw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,$w=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,zw=an.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Ji("strong",{...he(this.options.HTMLAttributes,t),children:Ji("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}}
vendor: 7,833 bytes, lines 107-128
107,addInputRules(){return[ir({find:Iw,type:this.type}),ir({find:Pw,type:this.type})]},addPasteRules(){return[Rn({find:Dw,type:this.type}),Rn({find:$w,type:this.type})]}}),Bw=/(^|[^`])`([^`]+)`(?!`)$/,_w=/(^|[^`])`([^`]+)`(?!`)/g,Hw=an.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",he(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ir({find:Bw,type:this.type})]},addPasteRules(){return[Rn({find:_w,type:this.type})]}}),Da=4,Fw=/^```([a-z]+)?[\s\n]$/,Vw=/^~~~([a-z]+)?[\s\n]$/,nm=Ae.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Da,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",he(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(` 108`):r=`\`\`\`${s} 109 110\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Da,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const a=" ".repeat(n);return o?t.commands.insertContent(a):t.commands.command(({tr:l})=>{const{from:c,to:u}=s,f=r.doc.textBetween(c,u,` 111`,` 112`).split(` 113`).map(p=>a+p).join(` 114`);return l.replaceWith(c,u,r.schema.text(f)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Da,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:a})=>{var l;const{pos:c}=i,u=i.start(),d=i.end(),f=r.doc.textBetween(u,d,` 115`,` 116`).split(` 117`);let p=0,m=0;const g=c-u;for(let I=0;I<f.length;I+=1){if(m+f[I].length>=g){p=I;break}m+=f[I].length+1}const v=((l=f[p].match(/^ */))==null?void 0:l[0])||"",C=Math.min(v.length,n);if(C===0)return!0;let N=u;for(let I=0;I<p;I+=1)N+=f[I].length+1;return a.delete(N,N+C),c-N<=C&&a.setSelection(U.create(a.doc,N)),!0}):t.commands.command(({tr:a})=>{const{from:l,to:c}=s,h=r.doc.textBetween(l,c,` 118`,` 119`).split(` 120`).map(f=>{var p;const m=((p=f.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,n);return f.slice(g)}).join(` 121`);return a.replaceWith(l,c,r.schema.text(h)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` 122 123`);return!i||!o?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const a=s.after();return a===void 0?!1:r.nodeAt(a)?t.commands.command(({tr:c})=>(c.setSelection(Q.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[Sl({find:Fw,type:this.type,getAttributes:t=>({language:t[1]})}),Sl({find:Vw,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ue({key:new fe("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:o,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,` 124`));return o.replaceSelectionWith(this.type.create({language:i},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(U.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),jw=Ae.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` 125 126`):""}),Ww=Ae.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",he(this.options.HTMLAttributes,t)]},renderText(){return` 127`},renderMarkdown:()=>` 128`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&o){const d=l.filter(h=>a.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Uw=Ae.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,he(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Sl({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}}
128)\\s$`),type:this.type,getAttributes:{level:t}}))}}),qw=Ae.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",he(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Sw(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Pp(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:a})=>{if(a){const{$to:l}=o.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?o.setSelection(U.create(o.doc,l.pos+1)):l.nodeAfter.isBlock?o.setSelection(j.create(o.doc,l.pos)):o.setSelection(U.create(o.doc,l.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,d=u?.create();d&&(o.insert(c,d),o.setSelection(U.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Zp({find:/^(?:---|â-|___\s|\*\*\*\s)$/,type:this.t
vendor: 1,046 bytes, line 128
128ype})]}}),Kw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Jw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Gw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Yw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Qw=an.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",he(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}}
128,addInputRules(){return[ir({find:Kw,type:this.type}),ir({find:Gw,type:this.type})]},addPasteRules(){return[Rn({find:Jw,type:this.type}),Rn({find:Yw,type:this.type})]}});const Xw="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yac
128hts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Zw="ελ1Ï 2бг1ел3деÑи4еÑ2каÑолик6ом3мкд2он1Ñква6онлайн5Ñг3ÑÑÑ2Ñ2ÑайÑ3Ñб3ÑкÑ3Òаз3Õ°Õ¡Õµ3×שר××5×§××3Ø§Ø¨ÙØ¸Ø¨Ù5را٠ÙÙ5ÙØ§Ø±Ø¯Ù4Ø¨ØØ±ÙÙ5جزائر5Ø³Ø¹ÙØ¯ÙØ©6عÙÙØ§Ù5٠غرب5٠ارات5ÛØ±Ø§Ù5بارت2زار4ÙØªÙ3ھارت5تÙÙØ³4Ø³ÙØ¯Ø§Ù3Ø±ÙØ©5Ø´Ø¨ÙØ©4عراÙ2ب2٠اÙ4ÙÙØ³Ø·ÙÙ6ÙØ·Ø±3ÙØ§Ø«ÙÙÙÙ6ÙÙ 3٠صر2ÙÙØ³Ùا5ÙØ±ÙتاÙÙØ§7ÙØ¹4Ù٠راÙ5پاکستاÙ7ÚØ§Ø±Øª4à¤à¥à¤®3नà¥à¤3à¤à¤¾à¤°à¤¤0मà¥3à¥à¤¤5सà¤à¤à¤ न5বাà¦à¦²à¦¾5à¦à¦¾à¦°à¦¤2ৰত4à¨à¨¾à¨°à¨¤4àªàª¾àª°àª¤4à¬à¬¾à¬°à¬¤4à®à®¨à¯à®¤à®¿à®¯à®¾6லà®à¯à®à¯6à®à®¿à®à¯à®à®ªà¯à®ªà¯à®°à¯11à°à°¾à°°à°¤à±5à²à²¾à²°à²¤4à´à´¾à´°à´¤à´5à¶½à¶à¶à·4à¸à¸à¸¡3à¹à¸à¸¢3ລາວ3áá2ã¿ããª3ã¢ãã¾ã³4ã¯ã©ã¦ã4ã°ã¼ã°ã«4ã³ã 2ã¹ãã¢3ã»ã¼ã«3ãã¡ãã·ã§ã³6ãã¤ã³ã4ä¸ç2ä¸ä¿¡1å½1å1æç½3äºé©¬é3ä¼ä¸2ä½å±±2ä¿¡æ¯2å¥åº·2å «å¦2å ¬å¸1ç2å°æ¹¾1ç£2åå1åº1æ 2åé0大é åº5å¨çº¿2大æ¿2天主æ3娱ä¹2å®¶é»2广ä¸2å¾®å2æ å2æç±ä½ 3ææº2æè2æ¿å¡1åº2æ°å å¡2é»2æ¶å°2æ¸ç±2æºæ2淡马é¡3游æ2æ¾³é2ç¹ç2ç§»å¨2ç»ç»æºæ4ç½å1åº1ç«1ç»2èé2è°·æ2è´ç©2é販2éå¢2é»è¨çç§4é£å©æµ¦3é£å2é¤å 2馿 ¼éæ3港2ë·ë·1ì»´2ì¼ì±2íêµ2",Cl="numeric",Ml="ascii",Tl="alpha",cs="asciinumeric",ts="alphanumeric",El="domain",rm="emoji",eS="scheme",tS="slashscheme",Pa="whitespace";function nS(t,e){return t in e||(e[t]=[]),e[t]}function Vn(t,e,n){e[Cl]&&(e[cs]=!0,e[ts]=!0),e[Ml]&&(e[cs]=!0,e[Tl]=!0),e[cs]&&(e[ts]=!0),e[Tl]&&(e[ts]=!0),e[ts]&&(e[El]=!0),e[rm]&&(e[El]=!0);for(const r in e){const s=nS(r,n);s.indexOf(t)<0&&s.push(t)}}function rS(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function st(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}st.groups={};st.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||st.groups;let s;return e&&e.j?s=e:(s=new st(e),n&&r&&Vn(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||st.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,a=s.go(t);if(a?(o=new st,Object.assign(o.j,a.j),o.jr.push.apply(o.jr,a.jr),o.jd=a.jd,o.t=a.t):o=new st,i){if(r)if(o.t&&typeof o.t=="string"){const l=Object.assign(rS(o.t,r),n);Vn(i,l,r)}else n&&Vn(i,n,r);o.t=i}return s.j[t]=o,o}};const se=(t,e,n,r,s)=>t.ta(e,n,r,s),Re=(t,e,n,r,s)=>t.tr(e,n,r,s),Sd=(t,e,n,r,s)=>t.ts(e,n,r,s),O=(t,e,n,r,s)=>t.tt(e,n,r,s),Jt="WORD",Al="UWORD",sm="ASCIINUMERICAL",im="ALPHANUMERICAL",Os="LOCALHOST",Nl="TLD",Rl="UTLD",Ni="SCHEME",Sr="SLASH_SCHEME",Ec="NUM",Ol="WS",Ac="NL",us="OPENBRACE",ds="CLOSEBRACE",Gi="OPENBRACKET",Yi="CLOSEBRACKET",Qi="OPENPAREN",Xi="CLOSEPAREN",Zi="OPENANGLEBRACKET",eo="CLOSEANGLEBRACKET",to="FULLWIDTHLEFTPAREN",no="FULLWIDTHRIGHTPAREN",ro="LEFTCORNERBRACKET",so="RIGHTCORNERBRACKET",io="LEFTWHITECORNERBRACKET",oo="RIGHTWHITECORNERBRACKET",ao="FULLWIDTHLESSTHAN",lo="FULLWIDTHGREATERTHAN",co="AMPERSAND",uo="APOSTROPHE",ho="ASTERISK",gn="AT",fo="BACKSLASH",po="BACKTICK",mo="CARET",jn="COLON",Nc="COMMA",go="DOLLAR",Pt="DOT",yo="EQUALS",Rc="EXCLAMATION",pt="HYPHEN",hs="PERCENT",bo="PIPE",ko="PLUS",xo="POUND",fs="QUERY",Oc="QUOTE",om="FULLWIDTHMIDDLEDOT",Lc="SEMI",$t="SLASH",ps="TILDE",wo="UNDERSCORE",am="EMOJI",So="SYM";var lm=Object.freeze({__proto__:null,ALPHANUMERICAL:im,AMPERSAND:co,APOSTROPHE:uo,ASCIINUMERICAL:sm,ASTERISK:ho,AT:gn,BACKSLASH:fo,BACKTICK:po,CARET:mo,CLOSEANGLEBRACKET:eo,CLOSEBRACE:ds,CLOSEBRACKET:Yi,CLOSEPAREN:Xi,COLON:jn,COMMA:Nc,DOLLAR:go,DOT:Pt,EMOJI:am,EQUALS:yo,EXCLAMATION:Rc,FULLWIDTHGREATERTHAN:lo,FULLWIDTHLEFTPAREN:to,FULLWIDTHLESSTHAN:ao,FULLWIDTHMIDDLEDOT:om,FULLWIDTHRIGHTPAREN:no,HYPHEN:pt,LEFTCORNERBRACKET:ro,LEFTWHITECORNERBRACKET:io,LOCALHOST:Os,NL:Ac,NUM:Ec,OPENANGLEBRACKET:Zi,OPENBRACE:us,OPENBRACKET:Gi,OPENPAREN:Qi,PERCENT:hs,PIPE:bo,PLUS:ko,POUND:xo,QUERY:fs,QUOTE:Oc,RIGHTCORNERBRACKET:so,RIGHTWHITECORNERBRACKET:oo,SCHEME:Ni,SEMI:Lc,SLASH:$t,SLASH_SCHEME:Sr,SYM:So,TILDE:ps,TLD:Nl,UNDERSCORE:wo,UTLD:Rl,UWORD:Al,WORD:Jt,WS:Ol});const qt=/[a-z]/,qr=new RegExp("\\p{L}","u"),$a=new RegExp("\\p{Emoji}","u"),Kt=/\d/,za=/\s/,vd="\r",Ba=` 129`,sS="ï¸",iS="â",_a="";let ci=null,ui=null;function oS(t=[]){const e={};st.groups=e;const n=new st;ci==null&&(ci=Cd(Xw)),ui==null&&(ui=Cd(Zw)),O(n,"'",uo),O(n,"{",us),O(n,"}",ds),O(n,"[",Gi),O(n,"]",Yi),O(n,"(",Qi),O(n,")",Xi),O(n,"<",Zi),O(n,">",eo),O(n,"ï¼",to),O(n,"ï¼",no),O(n,"ã",ro),O(n,"ã",so),O(n,"ã",io),O(n,"ã",oo),O(n,"ï¼",ao),O(n,"ï¼",lo),O(n,"&",co),O(n,"*",ho),O(n,"@",gn),O(n,"`",po),O(n,"^",mo),O(n,":",jn),O(n,",",Nc),O(n,"$",go),O(n,".",Pt),O(n,"=",yo),O(n,"!",Rc),O(n,"-",pt),O(n,"%",hs),O(n,"|",bo),O(n,"+",ko),O(n,"#",xo),O(n,"?",fs),O(n,'"',Oc),O(n,"/",$t),O(n,";",Lc),O(n,"~",ps),O(n,"_",wo),O(n,"\\",fo),O(n,"ã»",om);const r=Re(n,Kt,Ec,{[Cl]:!0});Re(r,Kt,r);const s=Re(r,qt,sm,{[cs]:!0}),i=Re(r,qr,im,{[ts]:!0}),o=Re(n,qt,Jt,{[Ml]:!0});Re(o,Kt,s),Re(o,qt,o),Re(s,Kt,s),Re(s,qt,s);const a=Re(n,qr,Al,{[Tl]:!0});Re(a,qt),Re(a,Kt,i),Re(a,qr,a),Re(i,Kt,i),Re(i,qt),Re(i,qr,i);const l=O(n,Ba,Ac,{[Pa]:!0}),c=O(n,vd,Ol,{[Pa]:!0}),u=Re(n,za,Ol,{[Pa]:!0});O(n,_a,u),O(c,Ba,l),O(c,_a,u),Re(c,za,u),O(u,vd),O(u,Ba),Re(u,za,u),O(u,_a,u);const d=Re(n,$a,am,{[rm]:!0});O(d,"#"),Re(d,$a,d),O(d,sS,d);
vendor: 9,470 bytes, lines 129-132
129const h=O(d,iS);O(h,"#"),Re(h,$a,d);const f=[[qt,o],[Kt,s]],p=[[qt,null],[qr,a],[Kt,i]];for(let m=0;m<ci.length;m++)hn(n,ci[m],Nl,Jt,f);for(let m=0;m<ui.length;m++)hn(n,ui[m],Rl,Al,p);Vn(Nl,{tld:!0,ascii:!0},e),Vn(Rl,{utld:!0,alpha:!0},e),hn(n,"file",Ni,Jt,f),hn(n,"mailto",Ni,Jt,f),hn(n,"http",Sr,Jt,f),hn(n,"https",Sr,Jt,f),hn(n,"ftp",Sr,Jt,f),hn(n,"ftps",Sr,Jt,f),Vn(Ni,{scheme:!0,ascii:!0},e),Vn(Sr,{slashscheme:!0,ascii:!0},e),t=t.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<t.length;m++){const g=t[m][0],v=t[m][1]?{[eS]:!0}:{[tS]:!0};g.indexOf("-")>=0?v[El]=!0:qt.test(g)?Kt.test(g)?v[cs]=!0:v[Ml]=!0:v[Cl]=!0,Sd(n,g,g,v)}return Sd(n,"localhost",Os,{ascii:!0}),n.jd=new st(So),{start:n,tokens:Object.assign({groups:e},lm)}}function cm(t,e){const n=aS(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let a=t,l=null,c=0,u=null,d=-1,h=-1;for(;o<r&&(l=a.go(n[o]));)a=l,a.accepts()?(d=0,h=0,u=a):d>=0&&(d+=n[o].length,h++),c+=n[o].length,i+=n[o].length,o++;i-=d,o-=h,c-=d,s.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function aS(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function hn(t,e,n,r,s){let i;const o=e.length;for(let a=0;a<o-1;a++){const l=e[a];t.j[l]?i=t.j[l]:(i=new st(r),i.jr=s.slice(),t.j[l]=i),t=i}return i=new st(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function Cd(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Ls={defaultProtocol:"http",events:null,format:Md,formatHref:Md,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ic(t,e=null){let n=Object.assign({},Ls);t&&(n=Object.assign(n,t instanceof Ic?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}Ic.prototype={o:Ls,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Ls[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Md(t){return t}function um(t,e){this.t="token",this.v=t,this.tk=e}um.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"â¦":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Ls.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:s,attributes:o,content:i,eventListeners:d}}};function qo(t,e){class n extends um{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const lS=qo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Td=qo("text"),cS=qo("nl"),di=qo("url",{isLink:!0,toHref(t=Ls.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Os&&t[1].t===jn}}),ft=t=>new st(t);function uS({groups:t}){const e=t.domain.concat([co,ho,gn,fo,po,mo,go,yo,pt,Ec,hs,bo,ko,xo,$t,So,ps,wo]),n=[uo,jn,Nc,Pt,Rc,hs,fs,Oc,Lc,Zi,eo,us,ds,Yi,Gi,Qi,Xi,to,no,ro,so,io,oo,ao,lo],r=[co,uo,ho,fo,po,mo,go,yo,pt,us,ds,hs,bo,ko,xo,fs,$t,So,ps,wo],s=ft(),i=O(s,ps);se(i,r,i),se(i,t.domain,i);const o=ft(),a=ft(),l=ft();se(s,t.domain,o),se(s,t.scheme,a),se(s,t.slashscheme,l),se(o,r,i),se(o,t.domain,o);const c=O(o,gn);O(i,gn,c),O(a,gn,c),O(l,gn,c);const u=O(i,Pt);se(u,r,i),se(u,t.domain,i);const d=ft();se(c,t.domain,d),se(d,t.domain,d);const h=O(d,Pt);se(h,t.domain,d);const f=ft(lS);se(h,t.tld,f),se(h,t.utld,f),O(c,Os,f);const p=O(d,pt);O(p,pt,p),se(p,t.domain,d),se(f,t.domain,d),O(f,Pt,h),O(f,pt,p);const m=O(o,pt),g=O(o,Pt);O(m,pt,m),se(m,t.domain,o),se(g,r,i),se(g,t.domain,o);const y=ft(di);se(g,t.tld,y),se(g,t.utld,y),se(y,t.domain,o),se(y,r,i),O(y,Pt,g),O(y,pt,m),O(y,gn,c);const v=O(y,jn),C=ft(di);se(v,t.numeric,C);const N=ft(di),M=ft();se(N,e,N),se(N,n,M),se(M,e,N),se(M,n,M),O(y,$t,N),O(C,$t,N);const I=O(a,jn),R=O(l,jn),$=O(R,$t),W=O($,$t);se(a,t.domain,o),O(a,Pt,g),O(a,pt,m),se(l,t.domain,o),O(l,Pt,g),O(l,pt,m),se(I,t.domain,N),O(I,$t,N),O(I,fs,N),se(W,t.domain,N),se(W,e,N),O(W,$t,N);const F=[[us,ds],[Gi,Yi],[Qi,Xi],[Zi,eo],[to,no],[ro,so],[io,oo],[ao,lo]];for(let Z=0;Z<F.length;Z++){const[ne,G]=F[Z],_=O(N,ne);O(M,ne,_);const ee=ft(di);se(_,e,ee);const Ce=ft();se(_,n,Ce),O(_,G,N),se(ee,e,ee),se(ee,n,Ce),se(Ce,e,ee),se(Ce,n,Ce),O(ee,G,N),O(Ce,G,N)}return O(s,Os,y),O(s,Ac,cS),{start:s,tokens:lm}}function dS(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let a=t,l=null,c=null,u=0,d=null,h=-1;for(;s<r&&!(l=a.go(n[s].t));)o.push(n[s++]);for(;s<r&&(c=l||a.go(n[s].t));)l=null,a=c,a.accepts()?(h=0,d=a):h>=0&&h++,s++,u++;if(h<0)s-=u,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(Ha(Td,e,o)),o=[]),s-=h,u-=h;const f=d.t,p=n.slice(s-u,s);i.push(Ha(f,e,p))}}return o.length>0&&i.push(Ha(Td,e,o)),i}function Ha(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const hS=typeof console<"u"&&console&&console.warn||(()=>{}),fS="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ve={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function pS(){return st.groups={},ve.scanner=null,ve.parser=null,ve.tokenQueue=[],ve.pluginQueue=[],ve.customSchemes=[],ve.initialized=!1,ve}function Ed(t,e=!1){if(ve.initialized&&hS(`linkifyjs: already initialized - will not register custom scheme "${t}" ${fS}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1301. Must only contain digits, lowercase ASCII letters or "-" 1312. Cannot start or end with "-" 1323. "-" cannot repeat`);ve.customSchemes.push([t,e])}function mS(){ve.scanner=oS(ve.customSchemes);for(let t=0;t<ve.tokenQueue.length;t++)ve.tokenQueue[t][1]({scanner:ve.scanner});ve.parser=uS(ve.scanner.tokens);for(let t=0;t<ve.pluginQueue.length;t++)ve.pluginQueue[t][1]({scanner:ve.scanner,parser:ve.parser});return ve.initialized=!0,ve}function Dc(t){return ve.initialized||mS(),dS(ve.parser.start,t,cm(ve.scanner.start,t))}Dc.scan=cm;function dm(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Ic(n),s=Dc(t),i=[];for(let o=0;o<s.length;o++){const a=s[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}var Pc="[\0-  áá â-\u2029âã]",gS=new RegExp(Pc),yS=new RegExp(`${Pc}$`),bS=new RegExp(Pc,"g");function kS(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function xS(t){return new ue({key:new fe("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=Tp(n.doc,[...e]);if(Dp(a).forEach(({newRange:c})=>{const u=wx(r.doc,c,f=>f.isTextblock);let d,h;if(u.length>1)d=u[0],h=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!yS.test(f))return;d=u[0],h=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&h){const f=h.split(gS).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],m=d.pos+h.lastIndexOf(p);if(!p)return!1;const g=Dc(p).map(y=>y.toObject(t.defaultProtocol));if(!kS(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{xc(y.from,y.to,r.doc).some(v=>v.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function wS(t){return new ue({key:new fe("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const l=r.target;if(!l)return!1;const c=t.editor.view.dom;o=l.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let a=!1;if(t.enableClickSelection&&(a=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const l=Ip(e.state,t.type.n
132ame),c=(s=o.href)!=null?s:l.href,u=(i=o.target)!=null?i:l.target;c&&(window.open(c,u),a=!0)}return a}}})}function SS(t){return new ue({key:new fe("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});const c=dm(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||s!==void 0&&!s(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Pn(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(bS,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var hm=an.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Ed(t);return}Ed(t.scheme,t.optionalSlashes)})},onDestroy(){pS()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Pn(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Pn(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Pn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",he(this.options.HTMLAttributes,t),0]:["a",he(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",a=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",l=e.renderChildren(t);return a?`[${l}](${o} "${a}")`:`[${l}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Pn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Pn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Rn({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=dm(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Pn(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e}
vendor: 1,848 bytes, lines 132-133
132,type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(xS({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Pn(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(wS({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(SS({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),vS=Object.defineProperty,CS=(t,e)=>{for(var n in e)vS(t,n,{get:e[n],enumerable:!0})},MS="listItem",Ad="textStyle",Nd=/^\s*([-+*])\s$/,fm=Ae.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",he(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` 133`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(MS,this.editor.getAttributes(Ad)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}}
133,addInputRules(){let t=Dr({find:Nd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Dr({find:Nd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ad),editor:this.editor})),[t]}});function TS(t){var e,n;const r=(e=t.tokens)==null?void 0:e[0];return!!(t.text&&((n=t.tokens)==null?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function ES(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var pm=Ae.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",he(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;let s=[];if(t.tokens&&t.tokens.length>0){if(TS(t))return{type:"listItem",content:[{type:"paragraph",content:ES(t.text||"",e)}]};if(t.tokens.some(o=>o.type==="paragraph"))s=r(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const l=t.tokens.slice(1),c=r(l);s.push(...c)}}else s=r(t.tokens)}}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(t,e,n)=>Tc(t,e,r=>{var s,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),AS={};CS(AS,{findListItemPos:()=>Hs,getNextListDepth:()=>$c,handleBackspace:()=>Ll,handleDelete:()=>Il,hasListBefore:()=>mm,hasListItemAfter:()=>NS,hasListItemBefore:()=>gm,listItemHasSubList:()=>ym,nextListIsDeeper:()=>bm,nextListIsHigher:()=>km});var Hs=(t,e)=>{const{$from:n}=e.selection,r=$e(t,e.schema);let s=null,i=n.depth,o=n.pos,a=null;for(;i>0&&a===null;)s=n.node(i),s.type===r?a=i:(i-=1,o-=1);return a===null?null:{$pos:e.doc.resolve(o),depth:a}},$c=(t,e)=>{const n=Hs(t,e);if(!n)return!1;const[,r]=Lx(e,t,n.$pos.pos+4);return r},mm=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},gm=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},ym=(t,e,n)=>{if(!n)return!1;const r=$e(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},Ll=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Nn(t.state,e)&&mm(t.state,e,n)){const{$anchor:a}=t.state.selection,l=t.state.doc.resolve(a.before()-1),c=[];l.node().descendants((h,f)=>{h.type.name===e&&c.push({node:h,pos:f})});const u=c.at(-1);if(!u)return!1;const d=t.state.doc.resolve(l.start()+u.pos+1);return t.chain().cut({from:a.start()-1,to:a.end()+1},d.end()).joinForward().run()}if(!Nn(t.state,e)||!$x(t.state))return!1;const r=Hs(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=ym(e,t.state,i);return gm(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},bm=(t,e)=>{const n=$c(t,e),r=Hs(t,e);return!r||!n?!1:n>r.depth},km=(t,e)=>{const n=$c(t,e),r=Hs(t,e);return!r||!n?!1:n<r.depth},Il=(t,e)=>{if(!Nn(t.state,e)||!Px(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:bm(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():km(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},NS=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},xm=ie.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;
133return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Il(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Il(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ll(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ll(t,n,r)&&(e=!0)}),e}}}}),Rd=/^(\s*)(\d+)\.\s+(.*)$/,RS=/^\s/;function OS(t){const e=t.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function LS(t){const e=[],n=[];let r=!1;return t.forEach(s=>{if(r){n.push(s);return}if(s.trim()===""){r=!0,n.push(s);return}if(e.length>0&&OS(s)){r=!0,n.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:n}}function IS(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Rd);if(!i)break;const[,o,a,l]=i,c=o.length,u=[l];let d=n+1;const h=[s];let f=!1;for(;d<t.length;){const p=t[d];if(p.match(Rd))break;if(p.trim()==="")h.push(p),u.push(""),f=!0,d+=1;else if(p.match(RS))h.push(p),u.push(p.slice(c+2)),d+=1;else{if(f)break;h.push(p),u.push(p),d+=1}}e.push({indent:c,number:parseInt(a,10),content:u.join(` 134`).trim(),contentLines:u,raw:h.join(` 135`)}),r=d,n=d}return[e,r]}function wm(t,e,n){const r=[];let s=0;for(;s<t.length;){const i=t[s];if(i.indent===e){const{paragraphLines:o,blockLines:a}=LS(i.contentLines),l=o.join(` 136`).trim(),c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const u=a.join(` 137`).trim();if(u){const f=n.blockTokens(u);c.push(...f)}let d=s+1;const h=[];for(;d<t.length&&t[d].indent>e;)h.push(t[d]),d+=1;if(h.length>0){const f=Math.min(...h.map(m=>m.indent)),p=wm(h,f,n);c.push({type:"list",ordered:!0,start:h[0].number,items:p,raw:h.map(m=>m.raw).join(` 138`)})}r.push({type:"list_item",raw:i.raw,tokens:c}),s=d}else s+=1}return r}function DS(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var PS="listItem",Od="textStyle",Ld=/^(\d+)\.\s$/,Sm=Ae.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",he(this.options.HTMLAttributes,n),0]:["ol",he(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?DS(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` 139`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(` 140`),[i,o]=IS(s);if(i.length===0)return;const a=wm(i,0,n);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:a,raw:s.slice(0,o).join(` 141`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(PS,this.editor.getAttributes(Od)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}
141,addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Dr({find:Ld,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Dr({find:Ld,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Od)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),$S=/^\s*(\[([( |x])?\])\s$/,vm=Ae.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",he(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Tc(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=d=>{var h,f;a.ariaLabel=((f=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:f.call(h,d,a.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(t),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",d=>d.preventDefault()),a.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:h}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const p=n();if(typeof p!="number")return!1;const m=f.doc.nodeAt(p);return f.setNodeMarkup(p,void 0,{...m?.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,h])=>{s.setAttribute(d,h)}),s.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,i.append(a,o),s.append(i,l),Object.entries(e).forEach(([d,h])=>{s.setAttribute(d,h)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:l,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,a.checked=d.attrs.checked,c(d);const h=r.extensionManager.attributes,f=Ns(d,h),p=new Set(Object.keys(f)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?s.setAttribute(g,m[g]):s.removeAttribute(g))}),Object.entries(f).forEach(([g,y])=>{y==null?g in m?s.setAttribute(g,m[g]):s.removeAttribute(g):s.setAttribute(g,y)}),u=p,!0}}}}
141,addInputRules(){return[Dr({find:$S,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Cm=Ae.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",he(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` 142`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=vl(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=vl(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ie.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(fm.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(pm.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(xm.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Sm.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(vm.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Cm.configure(this.options.taskList)),t}});var hi=" ",Fa="Â ",zS=Ae.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",he(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===hi||n[0].text===hi||n[0].raw===Fa||n[0].text===Fa)&&r.length===1&&r[0].type==="text"&&(r[0].text===hi||r[0].text===Fa)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,s;if(!t)return"";const i=Array.isArray(t.content)?t.content:[];if(i.length===0){const o=Array.isArray((r=n?.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((s=n?.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?hi:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),BS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,_S=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,HS=an.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",he(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}}
vendor: 5,101 bytes, line 142
142,addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ir({find:BS,type:this.type})]},addPasteRules(){return[Rn({find:_S,type:this.type})]}}),FS=Ae.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Mm=an.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",he(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function VS(t={}){return new ue({view(e){return new jS(e,t)}})}class jS{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,a=i.height/s.offsetHeight;if(n){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let p=f.getBoundingClientRect(),m=d?p.bottom:p.top;d&&h&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=l.getBoundingClientRect(),h=d.width/l.offsetWidth,f=d.height/l.offsetHeight;c=d.left-l.scrollLeft*h,u=d.top-l.scrollTop*f}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=bf(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Oe extends Q{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Oe.valid(r)?new Oe(r):Q.near(r)}content(){return D.empty}eq(e){return e instanceof Oe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Oe(e.resolve(n.pos))}getBookmark(){return new zc(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!WS(e)||!US(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Oe.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let a=e.node(o);if(n>
vendor: 10,612 bytes, line 142
1420?e.indexAfter(o)<a.childCount:e.index(o)>0){i=a.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let l=e.doc.resolve(s);if(Oe.valid(l))return l}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!j.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let a=e.doc.resolve(s);if(Oe.valid(a))return a}return null}}}Oe.prototype.visible=!1;Oe.findFrom=Oe.findGapCursorFrom;Q.jsonID("gapcursor",Oe);class zc{constructor(e){this.pos=e}map(e){return new zc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Oe.valid(n)?new Oe(n):Q.near(n)}}function Tm(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function WS(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Tm(s.type))return!0;if(s.inlineContent)return!1}}return!0}function US(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Tm(s.type))return!0;if(s.inlineContent)return!1}}return!0}function qS(){return new ue({props:{decorations:YS,createSelectionBetween(t,e,n){return e.pos==n.pos&&Oe.valid(n)?new Oe(n):null},handleClick:JS,handleKeyDown:KS,handleDOMEvents:{beforeinput:GS}}})}const KS=mc({ArrowLeft:fi("horiz",-1),ArrowRight:fi("horiz",1),ArrowUp:fi("vert",-1),ArrowDown:fi("vert",1)});function fi(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof U){if(!i.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=Oe.findGapCursorFrom(a,e,l);return c?(s&&s(r.tr.setSelection(new Oe(c))),!0):!1}}function JS(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Oe.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&j.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Oe(r))),!0)}function GS(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Oe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=A.empty;for(let o=r.length-1;o>=0;o--)s=A.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new D(s,0,0));return i.setSelection(U.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function YS(t){if(!(t.selection instanceof Oe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ae.create(t.doc,[Ee.widget(t.selection.head,e,{key:"gapcursor"})])}var vo=200,Fe=function(){};Fe.prototype.append=function(e){return e.length?(e=Fe.from(e),!this.length&&e||e.length<vo&&this.leafAppend(e)||this.length<vo&&e.leafPrepend(this)||this.appendInner(e)):this};Fe.prototype.prepend=function(e){return e.length?Fe.from(e).append(this):this};Fe.prototype.appendInner=function(e){return new QS(this,e)};Fe.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Fe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Fe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Fe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Fe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};Fe.from=function(e){return e instanceof Fe?e:e&&e.length?new Em(e):Fe.empty};var Em=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,a){for(var l=i;l<o;l++)if(s(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,a){for(var l=i-1;l>=o;l--)if(s(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=vo)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=vo)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Fe);Fe.empty=new Em([]);var QS=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(i,a),o)===!1||i>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,i)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(i,a)-a,o+a)===!1||i<a&&this.left.forEachInvertedInner(r,Math.min(s,a),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Fe);const XS=500;class Ct{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,a,l,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new zt(d.map));let f=d.step.map(s.slice(i)),p;f&&o.maybeStep(f).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new zt(p,void 0,void 0,c.length+u.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(d.step);if(d.selection)return a=s?d.selection.map(s.slice(i)):d.selection,l=new Ct(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,n,r,s){let i=[],o=this.eventCount,a=this.items,l=!s&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new zt(e.mapping.maps[u],d,n),f;(f=l&&l.merge(h))&&(h=f,u?i.pop():a=a.slice(0,a.length-1)),i.push(h),n&&(o++,n=void 0),s||(l=h)}let c=o-r.depth;return c>e1&&(a=ZS(a,c),o-=c),new Ct(a.append(i),o)}remapping(e,n){let r=new vs;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ct(this.items.append(e.map(n=>new zt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},s);let l=n;this.items.forEach(h=>{let f=i.getMirror(--l);if(f==null)return;o=Math.min(o,f);let p=i.maps[f];if(h.step){let m=e.steps[f].invert(e.docs[f]),g=h.selection&&h.selection.map(i.slice(l+1,f));g&&a++,r.push(new zt(p,m,g))}else r.push(new zt(p))},s);let c=[];for(let h=n;h<o;h++)c.push(new zt(i.maps[h]));let u=this.items.slice(0,s).append(c).append(r),d=new Ct(u,a);return d.emptyItemCount()>XS&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,a)=>{if(a>=e)s.push(o),o.selection&&i++;else if(o.step){let l=o.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let d=new zt(c.invert(),l,u),h,f=s.length-1;(h=s.length&&s[f].merge(d))?s[f]=h:s.push(d)}}else o.map&&r--},this.items.length,0),new Ct(Fe.from(s.reverse()),i)}}Ct.empty=new Ct(Fe.empty,0);function ZS(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class zt{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new zt(n.getMap().invert(),n,this.selection)}}}class yn{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const e1=20;function t1(t,e,n,r){let s=n.getMeta(Gn),i;if(s)return s.historyState;n.getMeta(s1)&&(t=new yn(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Gn))return o.getMeta(Gn).redo?new yn(t.done.addTransform(n,void 0,r,Ri(e)),t.undone,Id(n.mapping.maps),t.prevTime,t.prevComposition):new yn(t.done,t.undone.addTransform(n,void 0,r,Ri(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!o&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!n1(n,t.prevRanges)),c=o?Va(t.prevRanges,n.mapping):Id(n.mapping.maps);return new yn(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,Ri(e)),Ct.empty,c,n.time,a??t.prevComposition)}else return(i=n.getMeta("rebased"))?new yn(t.done.rebased(n,i),t.undone.rebased(n,i),Va(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new yn(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Va(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function n1(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function Id(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;
142n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Va(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function r1(t,e,n){let r=Ri(e),s=Gn.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),a=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),l=new yn(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(Gn,{redo:n,historyState:l})}let ja=!1,Dd=null;function Ri(t){let e=t.plugins;if(Dd!=e){ja=!1,Dd=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){ja=!0;break}}return ja}const Gn=new fe("history"),s1=new fe("closeHistory");function i1(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ue({key:Gn,state:{init(){return new yn(Ct.empty,Ct.empty,null,0,-1)},apply(e,n,r){return t1(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?Nm:r=="historyRedo"?Rm:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Am(t,e){return(n,r)=>{let s=Gn.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=r1(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const Nm=Am(!1,!0),Rm=Am(!0,!0);ie.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ue({key:new fe("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit,i=this.options.autoTrim;if(s==null||s===0||i===!1){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const a=o-s,l=0,c=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=i-r,c=a-l,u=a;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var Om=ie.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[VS(this.options)]}});ie.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ue({key:new fe("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return ae.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(s>=c&&s<=c+l.nodeSize-1))return!1;o+=1});let a=0;return t.descendants((l,c)=>{if(l.isText||!(s>=c&&s<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&o-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";i.push(Ee.node(c,c+l.nodeSize,{class:this.options.className}))}),ae.create(t,i)}}})]}});var o1=ie.create({name:"gapCursor",addProseMirrorPlugins(){return[qS()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=de(H(t,"allowGapCursor",n)))!=null?e:null}}});function Pd(t){const{editor:e,placeholder:n,dataAttribute:r,pos:s,node:i,isEmptyDoc:o,hasAnchor:a,classes:{emptyNode:l,emptyEditor:c}}=t,u=[l];return o&&u.push(c),Ee.node(s,s+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:s,hasAnchor:a}):n})}function a1(t){const e=getComputedStyle(t),n=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(n)}function l1(t){let e=t;for(;e;){if(a1(e))return e;const n=e.parentElement;if(!n){const r=e.getRootNode();if(r instanceof ShadowRoot){e=r.host;continue}return window}
142e=n}return window}function c1(t){return t===window?{top:0,bottom:window.innerHeight}:t.getBoundingClientRect()}function u1({doc:t,view:e,scrollContainer:n}){const r=e.dom.getBoundingClientRect(),s=n?c1(n):{top:0,bottom:window.innerHeight},i=Math.max(r.top,s.top),o=Math.min(r.bottom,s.bottom);if(i>=o)return{top:0,bottom:t.content.size};const l=getComputedStyle(e.dom).direction==="rtl"?Math.max(r.right-2,r.left+2):r.left+2,c=e.posAtCoords({left:l,top:i+2}),u=e.posAtCoords({left:l,top:o-2});return{top:c?c.pos:0,bottom:u?u.pos:t.content.size}}function d1(t,e){let n=null;return{call:((...i)=>{n||(t(...i),n=setTimeout(()=>{n=null},e))}),cancel:()=>{n&&(clearTimeout(n),n=null)}}}var $d="placeholder";function h1(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Kr=new fe("tiptap__placeholder"),f1=ie.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:$d,placeholder:"Write something â¦",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${h1(this.options.dataAttribute)}`:`data-${$d}`;return[new ue({state:{init(){return{topPos:null,bottomPos:null}},apply(e,n){const r=e.getMeta(Kr);return r?.positions?{topPos:r.positions.top,bottomPos:r.positions.bottom}:e.docChanged?{topPos:n.topPos!==null?e.mapping.map(n.topPos):null,bottomPos:n.bottomPos!==null?e.mapping.map(n.bottomPos):null}:n}},key:Kr,view(e){const n=l1(e.dom),r=()=>{const a=u1({view:e,doc:e.state.doc,scrollContainer:n}),l=Kr.getState(e.state);if(l.topPos===a.top&&l.bottomPos===a.bottom)return;const c=e.state.tr.setMeta(Kr,{positions:a}).setMeta("tiptap__viewportUpdate",!0);e.dispatch(c)},{call:s,cancel:i}=d1(r,250),o=n;return o.addEventListener("scroll",s,{passive:!0}),r(),{update(a,l){e.state.doc.content.size!==l.doc.content.size&&r()},destroy:()=>{i(),o.removeEventListener("scroll",s)}}},props:{decorations:({doc:e,selection:n})=>{var r,s;if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:o}=n,a=[],l=this.editor.isEmpty;if(this.options.showOnlyCurrent&&!this.options.includeChildren){const u=e.resolve(o);if(u.depth>0){const d=u.node(1),h=u.before(1);if(d.type.isTextblock&&Rs(d)){const f=o>=h&&o<=h+d.nodeSize,p=Pd({node:d,dataAttribute:t,hasAnchor:f,placeholder:this.options.placeholder,classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:l,pos:u.before(1)});a.push(p)}}}else{const u=Kr.getState(this.editor.state),d=(r=u.topPos)!=null?r:0,h=(s=u.bottomPos)!=null?s:e.content.size;e.nodesBetween(d,h,(f,p)=>{const m=o>=p&&o<=p+f.nodeSize,g=!f.isLeaf&&Rs(f);if(!f.type.isTextblock)return this.options.includeChildren;if((m||!this.options.showOnlyCurrent)&&g){const y=Pd({classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:l,dataAttribute:t,hasAnchor:m,placeholder:this.options.placeholder,node:f,pos:p});a.push(y)}return this.options.includeChildren})}return ae.create(e,a)}}})]}});ie.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ue({key:new fe("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Pp(n.selection)||t.view.dragging?null:ae.create(n.doc,[Ee.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});var p1="skipTrailingNode";function zd({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var Lm=ie.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new fe(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new ue({key:e,appendTransaction:(s,i,o)=>{const{doc:a,tr:l,schema:c}=o,u=e.getState(o),d=a.content.size,h=c.nodes[n];if(!s.some(f=>f.getMeta(p1))&&u)return l.insert(d,h.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!zd({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!zd({node:o,types:r})}}})]}}),m1=ie.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Nm(t,e),redo:()=>({state:t,dispatch:e})=>Rm(t,e)}},addProseMirrorPlugins(){return[i1(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-Ñ":()=>this.editor.commands.undo(),"Shift-Mod-Ñ":()=>this.editor.commands.redo()}}}),g1=ie.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(zw.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Lw.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(fm.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Hw.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(nm.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(jw.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(Om.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(o1.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Ww.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Uw.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(m1.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(qw.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Qw.configure(this.options.italic)),this.options.listItem!==!1&&s.push(pm.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(xm.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(hm.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Sm.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(zS.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(HS.configure(this.options.strike)),this.options.text!==!1&&s.push(FS.configure(this.options.text)),this.options.underline!==!1&&s.push(Mm.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(Lm.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),y1=g1;function Bc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var dr=Bc();function Im(t){dr=t}var zn={exec:()=>null};function ce(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(tt.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var b1=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),tt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine
vendor: 6,510 bytes, lines 142-143
142:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},k1=/^(?:[ \t]*(?:\n|$))+/,x1=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,w1=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Fs=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,S1=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_c=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Dm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Pm=ce(Dm).replace(/bull/g,_c).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),v1=ce(Dm).replace(/bull/g,_c).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Hc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,C1=/^[^\n]+/,Fc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,M1=ce(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Fc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),T1=ce(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_c).getRegex(),Ko="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Vc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,E1=ce("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Vc).replace("tag",Ko).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),$m=ce(Hc).replace("hr",Fs).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex(),A1=ce(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",$m).getRegex(),jc={blockquote:A1,code:x1,def:M1,fences:w1,heading:S1,hr:Fs,html:E1,lheading:Pm,list:T1,newline:k1,paragraph:$m,table:zn,text:C1},Bd=ce("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Fs).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex(),N1={...jc,lheading:v1,table:Bd,paragraph:ce(Hc).replace("hr",Fs).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Bd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex()},R1={...jc,html:ce(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vc).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:zn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ce(Hc).replace("hr",Fs).replace("heading",` *#{1,6} *[^ 143]`).replace("lheading",Pm).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},O1=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,L1=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,zm=/^( {2,}|\\)\n(?!\s*$)/,I1=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Br=/[\p{P}\p{S}]/u,Jo=/[\s\p{P}\p{S}]/u,Wc=/[^\s\p{P}\p{S}]/u,D1=ce(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Jo).getRegex(),Bm=
vendor: 4,251 bytes, line 143
143/(?!~)[\p{P}\p{S}]/u,P1=/(?!~)[\s\p{P}\p{S}]/u,$1=/(?:[^\s\p{P}\p{S}]|~)/u,z1=ce(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",b1?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),_m=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,B1=ce(_m,"u").replace(/punct/g,Br).getRegex(),_1=ce(_m,"u").replace(/punct/g,Bm).getRegex(),Hm="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",H1=ce(Hm,"gu").replace(/notPunctSpace/g,Wc).replace(/punctSpace/g,Jo).replace(/punct/g,Br).getRegex(),F1=ce(Hm,"gu").replace(/notPunctSpace/g,$1).replace(/punctSpace/g,P1).replace(/punct/g,Bm).getRegex(),V1=ce("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Wc).replace(/punctSpace/g,Jo).replace(/punct/g,Br).getRegex(),j1=ce(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Br).getRegex(),W1="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",U1=ce(W1,"gu").replace(/notPunctSpace/g,Wc).replace(/punctSpace/g,Jo).replace(/punct/g,Br).getRegex(),q1=ce(/\\(punct)/,"gu").replace(/punct/g,Br).getRegex(),K1=ce(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),J1=ce(Vc).replace("(?:-->|$)","-->").getRegex(),G1=ce("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",J1).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Co=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Y1=ce(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Co).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Fm=ce(/^!?\[(label)\]\[(ref)\]/).replace("label",Co).replace("ref",Fc).getRegex(),Vm=ce(/^!?\[(ref)\](?:\[\])?/).replace("ref",Fc).getRegex(),Q1=ce("reflink|nolink(?!\\()","g").replace("reflink",Fm).replace("nolink",Vm).getRegex(),_d=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Uc={_backpedal:zn,anyPunctuation:q1,autolink:K1,blockSkip:z1,br:zm,code:L1,del:zn,delLDelim:zn,delRDelim:zn,emStrongLDelim:B1,emStrongRDelimAst:H1,emStrongRDelimUnd:V1,escape:O1,link:Y1,nolink:Vm,punctuation:D1,reflink:Fm,reflinkSearch:Q1,tag:G1,text:I1,url:zn},X1={...Uc,link:ce(/^!?\[(label)\]\((.*?)\)/).replace("label",Co).getRegex(),reflink:ce(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Co).getRegex()},Dl={...Uc,emStrongRDelimAst:F1,emStrongLDelim:_1,delLDelim:j1,delRDelim:U1,url:ce(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",_d).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:ce(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",_d).getRegex()},Z1={...Dl,br:ce(zm).replace("{2,}","*").getRegex(),text:ce(Dl.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},pi={normal:jc,gfm:N1,pedantic:R1}
vendor: 24,626 bytes, lines 143-199
143,Jr={normal:Uc,gfm:Dl,breaks:Z1,pedantic:X1},ev={"&":"&","<":"<",">":">",'"':""","'":"'"},Hd=t=>ev[t];function Dt(t,e){if(e){if(tt.escapeTest.test(t))return t.replace(tt.escapeReplace,Hd)}else if(tt.escapeTestNoEncode.test(t))return t.replace(tt.escapeReplaceNoEncode,Hd);return t}function Fd(t){try{t=encodeURI(t).replace(tt.percentDecode,"%")}catch{return null}return t}function Vd(t,e){let n=t.replace(tt.findPipe,(i,o,a)=>{let l=!1,c=o;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(tt.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(tt.slashPipe,"|");return r}function Gr(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function tv(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function nv(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function jd(t,e,n,r,s){let i=e.href,o=e.title||null,a=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function rv(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(` 144`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[a]=o;return a.length>=s.length?i.slice(s.length):i}).join(` 145`)}var Mo=class{options;rules;lexer;constructor(t){this.options=t||dr}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Gr(n,` 146`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=rv(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=Gr(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Gr(e[0],` 147`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Gr(e[0],` 148`).split(` 149`),r="",s="",i=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(` 150`),u=c.replace(this.rules.other.blockquoteSetextReplace,` 151 $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r} 152${c}`:c,s=s?`${s} 153${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=d,n.length===0)break;let h=i.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let f=h,p=f.raw+` 154`+n.join(` 155`),m=this.blockquote(p);i[i.length-1]=m,r=r.substring(0,r.length-f.raw.length)+m.raw,s=s.substring(0,s.length-f.text.length)+m.text;break}else if(h?.type==="list"){let f=h,p=f.raw+` 156`+n.join(` 157`),m=this.list(p);i[i.length-1]=m,r=r.substring(0,r.length-h.raw.length)+m.raw,s=s.substring(0,s.length-f.raw.length)+m.raw,n=p.substring(i.at(-1).raw.length).split(` 158`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),o=!1;for(;t;){let l=!1,c="",u="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let d=nv(e[2].split(` 159`,1)[0],e[1].length),h=t.split(` 160`,1)[0],f=!d.trim(),p=0;if(this.options.pedantic?(p=2,u=d.trimStart()):f?p=e[1].length+1:(p=d.search(this.rules.other.nonSpaceChar),p=p>4?1:p,u=d.slice(p),p+=e[1].length),f&&this.rules.other.blankLine.test(h)&&(c+=h+` 161`,t=t.substring(h.length+1),l=!0),!l){let m=this.rules.other.nextBulletRegex(p),g=this.rules.other.hrRegex(p),y=this.rules.other.fencesBeginRegex(p),v=this.rules.other.headingBeginRegex(p),C=this.rules.other.htmlBeginRegex(p),N=this.rules.other.blockquoteBeginRegex(p);for(;t;){let M=t.split(` 162`,1)[0],I;if(h=M,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),I=h):I=h.replace(this.rules.other.tabCharGlobal," "),y.test(h)||v.test(h)||C.test(h)||N.test(h)||m.test(h)||g.test(h))break;if(I.search(this.rules.other.nonSpaceChar)>=p||!h.trim())u+=` 163`+I.slice(p);else{if(f||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(d)||v.test(d)||g.test(d))break;u+=` 164`+h}f=!h.trim(),c+=M+` 165`,t=t.substring(M.length+1),d=I.slice(p)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),s.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),s.raw+=c}let a=s.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let l of s.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(l.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};l.checked=u.checked,s.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=u.raw+l.tokens[0].raw,l.tokens[0].text=u.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(u)):l.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):l.tokens.unshift(u)}}if(!s.loose){let c=l.tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));s.loose=u}}if(s.loose)for(let l of s.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return s}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Vd(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(` 166`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<n.length;o++)i.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:i.align[o]});for(let o of s)i.rows.push(Vd(o,i.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:i.align[l]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===` 167`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=Gr(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=tv(e[2],"()");if(i===-2)return;if(i>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),jd(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return jd(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(r=c.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&s%3&&!((s+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let u=[...r[0]][0].length,d=t.slice(0,s+r.index+u+o);if(Math.min(s,o)%2){let f=d.slice(1,-1);return{type:"em",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}let h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,o,a=s,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+s);(r=l.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(o=[...i].length,o!==s))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let c=[...r[0]][0].length,u=t.slice(0,s+r.index+c+o),d=u.slice(s,-s);return{type:"del",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},St=class Pl{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||dr,this.options.tokenizer=this.options.tokenizer||new Mo,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:tt,block:pi.normal,inline:Jr.normal};this.options.pedantic?(n.block=pi.pedantic,n.inline=Jr.pedantic):this.options.gfm&&(n.block=pi.gfm,this.options.breaks?n.inline=Jr.breaks:n.inline=Jr.gfm),this.tokenizer.rules=n}static get rules(){return{block:pi,inline:Jr}}static lex(e,n){return new Pl(n).lex(e)}static lexInline(e,n){return new Pl(n).inlineTokens(e)}lex(e){e=e.replace(tt.carriageReturn,` 168`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(tt.tabCharGlobal," ").replace(tt.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(o=>(s=o.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let o=n.at(-1);s.raw.length===1&&o!==void 0?o.raw+=` 169`:n.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(` 170`)?"":` 171`)+s.raw,o.text+=` 172`+s.text,this.inlineQueue.at(-1).src=o.text):n.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(` 173`)?"":` 174`)+s.raw,o.text+=` 175`+s.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},n.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),n.push(s);continue}let i=e;if(this.options.extensions?.startBlock){let o=1/0,a=e.slice(1),l;this.options.extensions.startBlock.forEach(c=>{l=c.call({lexer:this},a),typeof l=="number"&&l>=0&&(o=Math.min(o,l))}),o<1/0&&o>=0&&(i=e.substring(0,o+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){let o=n.at(-1);r&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(` 176`)?"":` 177`)+s.raw,o.text+=` 178`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s),r=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(` 179`)?"":` 180`)+s.raw,o.text+=` 181`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s);continue}if(e){let o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e,s=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)l.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,a="";for(;e;){o||(a=""),o=!1;let l;if(this.options.extensions?.inline?.some(u=>(l=u.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let u=n.at(-1);l.type==="text"&&u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(e,r,a)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(e,r,a)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),n.push(l);continue}let c=e;if(this.options.extensions?.startInline){let u=1/0,d=e.slice(1),h;this.options.extensions.startInline.forEach(f=>{h=f.call({lexer:this},d),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(l=this.tokenizer.inlineText(c)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(a=l.raw.slice(-1)),o=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return n}},To=class{options;parser;constructor(t){this.options=t||dr}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(tt.notSpaceStart)?.[0],s=t.replace(tt.endingNewline,"")+` 182`;return r?'<pre><code class="language-'+Dt(r)+'">'+(n?s:Dt(s,!0))+`</code></pre> 183`:"<pre><code>"+(n?s:Dt(s,!0))+`</code></pre> 184`}blockquote({tokens:t}){return`<blockquote> 185${this.parser.parse(t)}</blockquote> 186`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}> 187`}hr(t){return`<hr> 188`}list(t){let e=t.ordered,n=t.start,r="";for(let o=0;o<t.items.length;o++){let a=t.items[o];r+=this.listitem(a)}let s=e?"ol":"ul",i=e&&n!==1?' start="'+n+'"':"";return"<"+s+i+`> 189`+r+"</"+s+`> 190`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li> 191`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p> 192`}table(t){let e="",n="";for(let s=0;s<t.header.length;s++)n+=this.tablecell(t.header[s]);e+=this.tablerow({text:n});let r="";for(let s=0;s<t.rows.length;s++){let i=t.rows[s];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table> 193<thead> 194`+e+`</thead> 195`+r+`</table> 196`}tablerow({text:t}){return`<tr> 197${t}</tr> 198`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}> 199`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Dt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=Fd(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+Dt(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=Fd(t);if(s===null)return Dt(n);t=s;let i=`<img src="${t}" alt="${Dt(n)}"`;return e&&(i+=` title="${Dt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Dt(t.text)}},qc=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},vt=class $l{options;renderer;textRenderer;constructor(e){this.options=e||dr,this.options.renderer=this.options.renderer||new To,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new qc}static parse(e,n){return new $l(n).parse(e)}static parseInline(e,n){return new $l(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let o=s,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let i=s;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=a||"";continue}}let o=i;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"checkbox":{r+=n.checkbox(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},ns=class{options;block;constructor(t){this.options=t||dr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?St.lex:St.lexInline}provideParser(t=this.block){return t?vt.parse:vt.parseInline}},sv=class{defaults=Bc();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=vt;Renderer=To;TextRenderer=qc;Lexer=St;Tokenizer=Mo;Hooks=ns;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let s=r;for(let i of s.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of s.rows)for(let o of i)n=n.concat(this.walkTokens(o.tokens,e));break}case"list":{let s=r;n=n.concat(this.walkTokens(s.items,e));break}default:{let s=r;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>
199{let o=s[i].flat(1/0);n=n.concat(this.walkTokens(o,e))}):s.tokens&&(n=n.concat(this.walkTokens(s.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=i.apply(this,o)),a}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new To(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,a=n.renderer[o],l=s[o];s[o]=(...c)=>{let u=a.apply(s,c);return u===!1&&(u=l.apply(s,c)),u||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Mo(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,a=n.tokenizer[o],l=s[o];s[o]=(...c)=>{let u=a.apply(s,c);return u===!1&&(u=l.apply(s,c)),u}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new ns;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,a=n.hooks[o],l=s[o];ns.passThroughHooks.has(i)?s[o]=c=>{if(this.defaults.async&&ns.passThroughHooksRespectAsync.has(i))return(async()=>{let d=await a.call(s,c);return l.call(s,d)})();let u=a.call(s,c);return l.call(s,u)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await a.apply(s,c);return d===!1&&(d=await l.apply(s,c)),d})();let u=a.apply(s,c);return u===!1&&(u=l.apply(s,c)),u}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(i.call(this,o)),s&&(a=a.concat(s.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return St.lex(t,e??this.defaults)}parser(t,e){return vt.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(e):e,a=await(s.hooks?await s.hooks.provideLexer(t):t?St.lex:St.lexInline)(o,s),l=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser(t):t?vt.parse:vt.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let o=(s.hooks?s.hooks.provideLexer(t):t?St.lex:St.lexInline)(e,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let a=(s.hooks?s.hooks.provideParser(t):t?vt.parse:vt.parseInline)(o,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(o){return i(o)}}}onError(t,e){return n=>{if(n.message+=` 200Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+Dt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},or=new sv;function me(t,e){return or.parse(t,e)}me.options=me.setOptions=function(t){return or.setOptions(t),me.defaults=or.defaults,Im(me.defaults),me};me.getDefaults=Bc;me.defaults=dr;me.use=function(...t){return or.use(...t),me.defaults=or.defaults,Im(me.defaults),me};me.walkTokens=function(t,e){return or.walkTokens(t,e)};me.parseInline=or.parseInline;me.Parser=vt;me.parser=vt.parse;me.Renderer=To;me.TextRenderer=qc;me.Lexer=St;me.lexer=St.lex;me.Tokenizer=Mo;me.Hooks=ns;me.parse=me;me.options;me.setOptions;me.use;me.walkTokens;me.parseInline;vt.parse;St.lex;function iv(t,e){const r=e.split(` 201`).flatMap(s=>[s,""]).map(s=>`${t}${s}`).join(` 202`);return r.slice(0,r.length-1)}function Is(t,e){if(t===e)return!0;
202if(!t||!e)return!1;const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(s=>Object.prototype.hasOwnProperty.call(e,s)&&Object.is(t[s],e[s]))}function ov(t,e){const n=[];return Array.from(t.entries()).forEach(([r,s])=>{if(!e){n.push(r);return}(e.marks||[]).find(o=>o.type===r&&Is(o.attrs,s.attrs))||n.push(r)}),n}function av(t,e){const n=[];return Array.from(e.entries()).forEach(([r,s])=>{const i=t.get(r);(!i||!Is(i.attrs,s.attrs))&&n.push({type:r,mark:s})}),n}function lv(t,e,n,r){const s=!n,i=n&&(!n.marks||n.marks.length===0),o=n&&n.marks&&!r(e,new Map(n.marks.map(l=>[l.type,l]))),a=[];return(s||i||o)&&(n&&n.marks?Array.from(t.entries()).reverse().forEach(([l,c])=>{n.marks.find(d=>d.type===l&&Is(d.attrs,c.attrs))||a.push(l)}):(s||i)&&a.push(...Array.from(t.keys()).reverse())),a}function cv(t,e){let n="";return Array.from(t.keys()).reverse().forEach(r=>{const s=t.get(r),i=e(r,s);i&&(n=i+n)}),t.clear(),n}function uv(t,e,n){let r="";return Array.from(t.entries()).forEach(([s,i])=>{const o=n(s,i);o&&(r+=o),e.set(s,i)}),r}function Wa(t){const n=(t.raw||t.text||"").match(/^(\s*)[-+*]\s+\[([ xX])\]\s+/);return n?{isTask:!0,checked:n[2].toLowerCase()==="x",indentLevel:n[1].length}:{isTask:!1,indentLevel:0}}function mi(t,e){return typeof t!="string"?"json":e}var dv=class{constructor(t){this.activeParseLexer=null,this.extensionRanks=new Map,this.baseExtensions=[],this.extensions=[],this.codeTypes=new Set,this.lastParseResult=null;var e,n,r,s,i;this.markedInstance=(e=t?.marked)!=null?e:me,this.indentStyle=(r=(n=t?.indentation)==null?void 0:n.style)!=null?r:"space",this.indentSize=(i=(s=t?.indentation)==null?void 0:s.size)!=null?i:2,this.baseExtensions=t?.extensions||[],t?.markedOptions&&typeof this.markedInstance.setOptions=="function"&&this.markedInstance.setOptions(t.markedOptions),this.registry=new Map,this.nodeTypeRegistry=new Map,t?.extensions&&(this.baseExtensions=t.extensions,Ar(Wo(t.extensions)).forEach(a=>this.registerExtension(a)))}get instance(){return this.markedInstance}get indentCharacter(){return this.indentStyle==="space"?" ":" "}get indentString(){return this.indentCharacter.repeat(this.indentSize)}hasMarked(){return!!this.markedInstance}registerExtension(t){var e,n;this.extensions.push(t);const r=de(H(t,"code")),s=t.name;r&&this.codeTypes.add(s),this.extensionRanks.has(s)||this.extensionRanks.set(s,this.extensionRanks.size);const i=H(t,"markdownTokenName")||s,o=H(t,"parseMarkdown"),a=H(t,"renderMarkdown"),l=H(t,"markdownTokenizer"),c=(e=H(t,"markdownOptions"))!=null?e:null,u=(n=c?.indentsContent)!=null?n:!1,d=c?.htmlReopen,h={tokenName:i,nodeName:s,parseMarkdown:o,renderMarkdown:a,isIndenting:u,htmlReopen:d,tokenizer:l};if(i&&o){const f=this.registry.get(i)||[];f.push(h),this.registry.set(i,f)}if(a){const f=this.nodeTypeRegistry.get(s)||[];f.push(h),this.nodeTypeRegistry.set(s,f)}l&&this.hasMarked()&&this.registerTokenizer(l)}createLexer(){return new this.markedInstance.Lexer}createTokenizerHelpers(t){return{inlineTokens:e=>t.inlineTokens(e),blockTokens:e=>t.blockTokens(e)}}tokenizeInline(t){var e;return((e=this.activeParseLexer)!=null?e:this.createLexer()).inlineTokens(t)}registerTokenizer(t){if(!this.hasMarked())return;const{name:e,start:n,level:r="inline",tokenize:s}=t,i=this.createTokenizerHelpers.bind(this),o=this.createLexer.bind(this);let a;n?a=typeof n=="function"?n:c=>c.indexOf(n):a=c=>{const u=s(c,[],this.createTokenizerHelpers(this.createLexer()));return u&&u.raw?c.indexOf(u.raw):-1};const l={name:e,level:r,start:a,tokenizer(c,u){const d=this.lexer?i(this.lexer):i(o()),h=s(c,u,d);if(h&&h.type)return{...h,type:h.type||e,raw:h.raw||"",tokens:h.tokens||[]}},childTokens:[]};this.markedInstance.use({extensions:[l]})}getHandlersForToken(t){try{return this.registry.get(t)||[]}catch{return[]}}getHandlerForToken(t){const e=this.getHandlersForToken(t);if(e.length>0)return e[0];const n=this.getHandlersForNodeType(t);return n.length>0?n[0]:void 0}getHandlersForNodeType(t){try{return this.nodeTypeRegistry.get(t)||[]}catch{return[]}}serialize(t){if(!t)return"";const e=this.renderNodes(t,t);
202return this.isEmptyOutput(e)?"":e}isEmptyOutput(t){return!t||t.trim()===""?!0:t.replace(/ /g,"").replace(/\u00A0/g,"").trim()===""}parse(t){if(!this.hasMarked())throw new Error("No marked instance available for parsing");const e=this.activeParseLexer,n=this.createLexer();this.activeParseLexer=n;try{const r=n.lex(t);return{type:"doc",content:this.parseTokens(r,!0)}}finally{this.activeParseLexer=e}}parseTokens(t,e=!1){const n=t.reduce((i,o,a)=>(o.type!=="space"&&i.push(a),i),[]);let r=-1,s=0;return t.flatMap((i,o)=>{for(var a;s<n.length&&n[s]<o;)r=n[s],s+=1;if(e&&i.type==="space"){const c=(a=n[s])!=null?a:-1;return this.createImplicitEmptyParagraphsFromSpace(i,r,c)}const l=this.parseToken(i,e);return l===null?[]:Array.isArray(l)?l:[l]})}createImplicitEmptyParagraphsFromSpace(t,e,n){const r=this.countParagraphSeparators(t.raw||"");if(r===0)return[];const i=Math.max(r-(e===-1||n===-1?0:1),0);return Array.from({length:i},()=>({type:"paragraph",content:[]}))}countParagraphSeparators(t){return(t.replace(/\r\n/g,` 203`).match(/\n\n/g)||[]).length}parseToken(t,e=!1){if(!t.type)return null;if(t.type==="list")return this.parseListToken(t);const n=this.getHandlersForToken(t.type),r=this.createParseHelpers();if(n.find(i=>{if(!i.parseMarkdown)return!1;const o=i.parseMarkdown(t,r),a=this.normalizeParseResult(o);return a&&(!Array.isArray(a)||a.length>0)?(this.lastParseResult=a,!0):!1})&&this.lastParseResult){const i=this.lastParseResult;return this.lastParseResult=null,i}return this.parseFallbackToken(t,e)}parseListToken(t){if(!t.items||t.items.length===0)return this.parseTokenWithHandlers(t);const e=t.items.some(a=>Wa(a).isTask),n=t.items.some(a=>!Wa(a).isTask);if(!e||!n||this.getHandlersForToken("taskList").length===0)return this.parseTokenWithHandlers(t);const r=[];let s=[],i=null;for(let a=0;a<t.items.length;a+=1){const l=t.items[a],{isTask:c,checked:u,indentLevel:d}=Wa(l);let h=l;if(c){const m=(l.raw||l.text||"").split(` 204`),g=m[0].match(/^\s*[-+*]\s+\[([ xX])\]\s+(.*)$/),y=g?g[2]:"";let v=[];if(m.length>1&&m.slice(1).join(` 205`).trim()){const N=m.slice(1),M=N.filter(I=>I.trim());if(M.length>0){const I=Math.min(...M.map(W=>W.length-W.trimStart().length)),$=N.map(W=>W.trim()?W.slice(I):"").join(` 206`).trim();$&&(v=this.markedInstance.lexer(`${$} 207`))}}h={type:"taskItem",raw:"",mainContent:y,indentLevel:d,checked:u??!1,text:y,tokens:this.tokenizeInline(y),nestedTokens:v}}const f=c?"taskList":"list";i!==f?(s.length>0&&r.push({type:i,items:s}),s=[h],i=f):s.push(h)}s.length>0&&r.push({type:i,items:s});const o=[];for(let a=0;a<r.length;a+=1){const l=r[a],c={...t,type:l.type,items:l.items},u=this.parseToken(c);u&&(Array.isArray(u)?o.push(...u):o.push(u))}return o.length>0?o:null}parseTokenWithHandlers(t){if(!t.type)return null;const e=this.getHandlersForToken(t.type),n=this.createParseHelpers();if(e.find(s=>{if(!s.parseMarkdown)return!1;const i=s.parseMarkdown(t,n),o=this.normalizeParseResult(i);return o&&(!Array.isArray(o)||o.length>0)?(this.lastParseResult=o,!0):!1})&&this.lastParseResult){const s=this.lastParseResult;return this.lastParseResult=null,s}return this.parseFallbackToken(t)}createParseHelpers(){return{parseInline:t=>this.parseInlineTokens(t),tokenizeInline:t=>this.tokenizeInline(t),parseChildren:t=>this.parseTokens(t),parseBlockChildren:t=>this.parseTokens(t,!0),createTextNode:(t,e)=>({type:"text",text:t,marks:e||void 0}),createNode:(t,e,n)=>{const r={type:t,attrs:e||void 0,content:n||void 0};return(!e||Object.keys(e).length===0)&&delete r.attrs,r},applyMark:(t,e,n)=>({mark:t,content:e,attrs:n&&Object.keys(n).length>0?n:void 0})}}escapeRegex(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}parseInlineTokens(t){var e,n,r,s;const i=[];for(let o=0;o<t.length;o+=1){const a=t[o];if(a.type==="text")i.push({type:"text",text:wd(a.text||"")});else if(a.type==="html"){const l=((n=(e=a.raw)!=null?e:a.text)!=null?n:"").toString(),c=/^<\/[\s]*[\w-]+/i.test(l),u=l.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!c&&u&&!/\/>$/.test(l)){const h=u[1],f=this.escapeRegex(h),p=new RegExp(`^<\\/\\s*${f}\\b`,"i");let m=-1;const g=[l];for(let y=o+1;y<t.length;y+=1){const v=t[y],C=((s=(r=v.raw)!=null?r:v.text)!=null?s:"").toString();if(g.push(C),v.type==="html"&&p.test(C)){m=y;break}}if(m!==-1){const y=g.join(""),v={type:"html",raw:y,text:y,block:!1},C=this.parseHTMLToken(v);if(C){const N=this.normalizeParseResult(C);Array.isArray(N)?i.push(...N):N&&i.push(N)}o=m;continue}}const d=this.parseHTMLToken(a);if(d){const h=this.normalizeParseResult(d);Array.isArray(h)?i.push(...h):h&&i.push(h)}}else if(a.type){const l=this.getHandlerForToken(a.type);if(l&&l.parseMarkdown){const c=this.createParseHelpers(),u=l.parseMarkdown(a,c);if(this.isMarkResult(u)){const d=this.applyMarkToContent(u.mark,u.content,u.attrs);i.push(...d)}else{const d=this.normalizeParseResult(u);Array.isArray(d)?i.push(...d):d&&i.push(d)}}else a.tokens&&i.push(...this.parseInlineTokens(a.tokens))}}return i}applyMarkToContent(t,e,n){return e.map(r=>{if(r.type==="text"){const s=r.marks||[],i=n?{type:t,attrs:n}:{type:t};return{...r,marks:[...s,i]}}return{...r,content:r.content?this.applyMarkToContent(t,r.content,n):void 0}})}isMarkResult(t){return t&&typeof t=="object"&&"mark"in t}normalizeParseResult(t){return t?this.isMarkResult(t)?t.content:t:null}parseFallbackToken(t,e=!1){switch(t.type){case"paragraph":return{type:"paragraph",content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"heading":return{type:"heading",attrs:{level:t.depth||1},content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"text":return{type:"text",text:wd(t.text||"")};case"html":return this.parseHTMLToken(t);case"space":return null;default:return t.tokens?this.parseTokens(t.tokens,e):null}}parseHTMLToken(t){const e=t.text||t.raw||"";if(!e.trim())return null;if(typeof window>"u")return t.block?{type:"paragraph",content:[{type:"text",text:e}]}:{type:"text",text:e};try{const n=Ex(e,this.baseExtensions);return n.type==="doc"&&n.content?t.block?n.content:n.content.length===1&&n.content[0].type==="paragraph"&&n.content[0].content?n.content[0].content:n.content:n}catch(n){throw new Error(`Failed to parse HTML in markdown: ${n}`)}}encodeTextForMarkdown(t,e,n){return n?.type!=null&&this.codeTypes.has(n.type)||(e.marks||[]).some(s=>this.codeTypes.has(typeof s=="string"?s:s.type))?t:Cw(t)}renderNodeToMarkdown(t,e,n=0,r=0,s={}){var i;if(t.type==="text")return this.encodeTextForMarkdown(t.text||"",t,e);if(!t.type)return"";const o=this.getHandlerForToken(t.type);if(!o)return"";const a=Array.isArray(e?.content)&&n>0?e.content[n-1]:void 0,l={renderChildren:(d,h)=>{const f=o.isIndenting?r+1:r;return!Array.isArray(d)&&d.content?this.renderNodes(d.content,t,h||"",n,f):this.renderNodes(d,t,h||"",n,f)},renderChild:(d,h)=>{const f=o.isIndenting?r+1:r;return this.renderNodeToMarkdown(d,t,h,f)},indent:d=>
207this.indentString+d,wrapInBlock:iv},c={index:n,level:r,parentType:e?.type,previousNode:a,meta:{parentAttrs:e?.attrs,...s}};return((i=o.renderMarkdown)==null?void 0:i.call(o,t,l,c))||""}renderNodes(t,e,n="",r=0,s=0){return Array.isArray(t)?this.renderNodesWithMarkBoundaries(t,e,n,s):t.type?this.renderNodeToMarkdown(t,e,r,s):""}renderNodesWithMarkBoundaries(t,e,n="",r=0){const s=[],i=new Map,o=new Set,a=new Map;return t.forEach((l,c)=>{const u=c<t.length-1?t[c+1]:null;if(l.type)if(l.type==="text"){let d=this.encodeTextForMarkdown(l.text||"",l,e);const h=new Map((l.marks||[]).map(M=>[M.type,M])),f=this.getMarksToOpenForSerialization(i,h,u),p=ov(h,u),m=p.filter(M=>i.has(M)),g=m.length>0&&f.length>0;let y="";if(p.length>0&&!g){const M=d.match(/(\s+)$/);M&&(y=M[1],d=d.slice(0,-y.length))}g||p.slice().reverse().forEach(M=>{if(!i.has(M))return;const I=h.get(M),R=this.getMarkClosing(M,I,a.get(M));R&&(d+=R),i.has(M)&&(i.delete(M),a.delete(M))});let v="";if(f.length>0){const M=d.match(/^(\s+)/);M&&(v=M[1],d=d.slice(v.length))}f.forEach(({type:M,mark:I})=>{const R=o.has(M)?"html":"markdown",$=this.getMarkOpening(M,I,R);$&&(d=$+d),a.set(M,R),o.delete(M)}),g||f.slice().reverse().forEach(({type:M,mark:I})=>{i.set(M,I)}),d=v+d;let C;if(g){const M=new Set((u?.marks||[]).map($=>$.type));f.forEach(({type:$})=>{M.has($)&&this.getHtmlReopenTags($)&&o.add($)});const I=Array.from(i.keys()),R=m.slice().sort(($,W)=>I.indexOf(W)-I.indexOf($));C=[...f.map($=>$.type),...R]}else C=lv(i,h,u,this.markSetsEqual.bind(this));let N="";if(C.length>0){const M=d.match(/(\s+)$/);M&&(N=M[1],d=d.slice(0,-N.length))}C.forEach(M=>{var I;const R=(I=i.get(M))!=null?I:h.get(M),$=this.getMarkClosing(M,R,a.get(M));$&&(d+=$),i.delete(M),a.delete(M)}),d+=N,d+=y,s.push(d)}else{const d=new Set((l.marks||[]).map(y=>y.type)),h=new Map,f=new Map;i.forEach((y,v)=>{var C;d.has(v)&&(h.set(v,y),f.set(v,(C=a.get(v))!=null?C:"markdown"))});const p=cv(i,(y,v)=>this.getMarkClosing(y,v,a.get(y)));a.clear();const m=this.renderNodeToMarkdown(l,e,c,r),g=l.type==="hardBreak"?"":uv(h,i,(y,v)=>{var C;const N=(C=f.get(y))!=null?C:"markdown";return a.set(y,N),this.getMarkOpening(y,v,N)});s.push(p+m+g)}}),s.join(n)}getMarkOpening(t,e,n="markdown"){var r;if(n==="html")return((r=this.getHtmlReopenTags(t))==null?void 0:r.open)||"";const s=this.getHandlersForNodeType(t),i=s.length>0?s[0]:void 0;if(!i||!i.renderMarkdown)return"";const o="î__TIPTAP_MARKDOWN_PLACEHOLDER__î",a={type:t,attrs:e.attrs||{},content:[{type:"text",text:o}]};try{const l=i.renderMarkdown(a,{renderChildren:()=>o,renderChild:()=>o,indent:u=>u,wrapInBlock:(u,d)=>u+d},{index:0,level:0,parentType:"text",meta:{}}),c=l.indexOf(o);return c>=0?l.substring(0,c):""}catch(l){throw new Error(`Failed to get mark opening for ${t}: ${l}`)}}getMarkClosing(t,e,n="markdown"){var r;if(n==="html")return((r=this.getHtmlReopenTags(t))==null?void 0:r.close)||"";const s=this.getHandlersForNodeType(t),i=s.length>0?s[0]:void 0;if(!i||!i.renderMarkdown)return"";const o="î__TIPTAP_MARKDOWN_PLACEHOLDER__î",a={type:t,attrs:e.attrs||{},content:[{type:"text",text:o}]};try{const l=i.renderMarkdown(a,{renderChildren:()=>o,renderChild:()=>o,indent:d=>d,wrapInBlock:(d,h)=>d+h},{index:0,level:0,parentType:"text",meta:{}}),c=l.indexOf(o),u=c+o.length;return c>=0?l.substring(u):""}catch(l){throw new Error(`Failed to get mark closing for ${t}: ${l}`)}}getHtmlReopenTags(t){const e=this.getHandlersForNodeType(t),n=e.length>0?e[0]:void 0;return n?.htmlReopen}markSetsEqual(t,e){return t.size!==e.size?!1:Array.from(t.entries()).every(([n,r])=>{const s=e.get(n);return s&&Is(r.attrs,s.attrs)})}getMarksToOpenForSerialization(t,e,n){const r=av(t,e);if(r.length<=1)return r;const s=n?.marks||[],i=(c,u)=>s.some(d=>d.type===c&&Is(d.attrs,u)),o=(c,u)=>{var d,h;const f=(d=this.extensionRanks.get(c.type))!=null?d:Number.MAX_SAFE_INTEGER,p=(h=this.extensionRanks.get(u.type))!=null?h:Number.MAX_SAFE_INTEGER;return f!==p?p-f:c.type.localeCompare(u.type)},a=r.filter(c=>!i(c.type,c.mark.attrs)).sort(o),l=r.filter(c=>i(c.type,c.mark.attrs)).sort(o);return[...a,...l]}},Wd=dv,hv=ie.create({name:"markdown",addOptions(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(t,e)=>{if(!e?.contentType||mi(t,e?.contentType)!=="markdown"||!this.editor.markdown)return wt.setContent(t,e);const r=this.editor.markdown.parse(t);return wt.setContent(r,e)},insertContent:(t,e)=>{if(!e?.contentType||mi(t,e?.contentType)!=="markdown"||!this.editor.markdown)return wt.insertContent(t,e);const r=this.editor.markdown.parse(t);return wt.insertContent(r,e)},insertContentAt:(t,e,n)=>{if(!n?.contentType||mi(e,n?.contentType)!=="markdown"||!this.editor.markdown)return wt.insertContentAt(t,e,n);const s=this.editor.markdown.parse(e);return wt.insertContentAt(t,s,n)}}},addStorage(){return{manager:new Wd({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){var t;if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}if(this.storage.manager=new Wd({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON()),!this.editor.options.contentType||mi(this.editor.options.content,this.editor.options.contentType)!=="markdown")return;if(!this.editor.markdown)throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(this.editor.options.content===void 0||typeof this.editor.options.content!="string")throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');const n=this.editor.markdown.parse(this.editor.options.content);(t=n.content)!=null&&t.length&&(this.editor.options.content=n)}});const fv=t=>class{constructor(n){this._=n}destroy(){t(this._)}},pv=fv(clearTimeout),Go=(t,e)=>new pv(setTimeout(e,t)),mv=/[\uD800-\uDBFF]/,gv=/[\uDC00-\uDFFF]/,yv=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&mv.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&gv.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},bv=yv,Bt=(t,e)=>t>>>e|t<<32-e,kv=t=>Bt(t,2)^Bt(t,13)^Bt(t,22),xv=t=>Bt(t,6)^Bt(t,11)^Bt(t,25),wv=t=>Bt(t,7)^Bt(t,18)^t>>>3,Sv=t=>Bt(t,17)^Bt(t,19)^t>>>10,vv=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756
207734187,3204031479,3329325298]),Cv=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class Mv{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Cv),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let d=16;d<64;d++)n[d]=Sv(n[d-2])+n[d-7]+wv(n[d-15])+n[d-16];let r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],l=e[5],c=e[6],u=e[7];for(let d=0,h,f;d<64;d++)h=u+xv(a)+(a&l^~a&c)+vv[d]+n[d]>>>0,f=kv(r)+(r&s^r&i^s&i)>>>0,u=c,c=l,l=a,a=o+h>>>0,o=i,i=s,s=r,r=h+f>>>0;e[0]+=r,e[1]+=s,e[2]+=i,e[3]+=o,e[4]+=a,e[5]+=l,e[6]+=c,e[7]+=u}digest(e){let n=0;for(;n+56<=e.length;){let o=0;for(;o<16&&n+3<e.length;o++)this._W[o]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<e.length;)this._W[o]|=e[n]<<(3-n%4)*8,n++;this._W[o]|=au<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let o=3;o>=0&&n<e.length;o--)this._W[s]|=e[n++]<<o*8;r||(this._W[s-(n%4===0?0:1)]|=au<<(3-n%4)*8),this._W[14]=e.byteLength/Jg,this._W[15]=e.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let a=0;a<4;a++)i[o*4+a]=this._H[o]>>>(3-a)*8;return i}}const Tv=t=>new Mv().digest(t),xe=new fe("y-sync"),rn=new fe("y-undo"),gi=new fe("yjs-cursor"),Ev=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},Av=t=>hy(Ev(Tv(fy(t)))),Eo=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!ey(e.ds,t.id),Nv=[{light:"#ecd44433",dark:"#ecd444"}],Rv=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=dy();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,ly(e))}return t.get(n)},Ov=(t,{colors:e=Nv,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const a=new Dv(t,i),l=new ue({props:{editable:c=>{const u=xe.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:xe,state:{init:(c,u)=>({type:t,doc:t.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,u)=>{const d=c.getMeta(xe);if(d!==void 0){u=Object.assign({},u);for(const h in d)u[h]=d[h]}return u.addToHistory=c.getMeta("addToHistory")!==!1,u.isChangeOrigin=d!==void 0&&!!d.isChangeOrigin,u.isUndoRedoOperation=d!==void 0&&!!d.isChangeOrigin&&!!d.isUndoRedoOperation,a.prosemirrorView!==null&&d!==void 0&&(d.snapshot!=null||d.prevSnapshot!=null)&&Go(0,()=>{a.prosemirrorView!=null&&(d.restore==null?a._renderSnapshot(d.snapshot,d.prevSnapshot,u):(a._renderSnapshot(d.snapshot,d.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),u}},view:c=>(a.initView(c),i==null&&a._forceRerender(),s(),{update:()=>{const u=l.getState(c.state);if(u.snapshot==null&&u.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,u.addToHistory===!1&&!u.isChangeOrigin){const d=rn.getState(c.state),h=d&&d.undoManager;h&&h.stopCapturing()}a.mux(()=>{u.doc.transact(d=>{d.meta.set("addToHistory",u.addToHistory),a._prosemirrorChanged(c.state.doc)},xe)})}},destroy:()=>{a.destroy()}})});return l},Lv=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new it(t.doc));else if(e.type==="node"){const r=Yn(n.doc,n.type,e.anchor,n.mapping);t.setSelection(Iv(t,r))}else{const r=Yn(n.doc,n.type,e.anchor,n.mapping),s=Yn(n.doc,n.type,e.head,n.mapping);r!==null&&s!==null&&t.setSelection(U.between(t.doc.resolve(r),t.doc.resolve(s)))}},Iv=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?j.create(t.doc,e):U.near(n)},zl=(t,e)=>({type:e.selection.jsonID,anchor:Ps(e.selection.anchor,t.type,t.mapping),head:Ps(e.selection.head,t.type,t.mapping)});class Dv{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=gy(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=zl(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Yg&&this._domSelectionInView===null&&(Go(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),i=Qg.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=Zg(py(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(xe,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Oi(r,this.prosemirrorView.state.schema,this)).filter(r=>
207r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new D(A.from(e),0,0));n.setMeta(xe,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>Oi(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new D(A.from(n),0,0));if(e){const s=Wn(Pi(e.anchor,0),r.doc.content.size),i=Wn(Pi(e.head,0),r.doc.content.size);r.setSelection(U.create(r.doc,s,i))}this.prosemirrorView.dispatch(r.setMeta(xe,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc,i=this.type;if(e||(e=ga(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&zh(),s=new Bh({gc:!1}),lu(s,n),n=ga(s),lu(s,e),e=ga(s),i._item===null){const o=Array.from(this.doc.share.keys()).find(a=>this.doc.share.get(a)===this.type);i=s.getXmlFragment(o)}else{const o=s.store.clients.get(i._item.id.client)??[],a=Xg(o,i._item.id.clock);i=o[a].content.type}this.mapping.clear(),this.mux(()=>{s.transact(o=>{const a=r.permanentUserData;a&&a.dss.forEach(d=>{cu(o,d,h=>{})});const l=(d,h)=>{const f=d==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:f,type:d,color:Rv(r.colorMapping,r.colors,f)}},c=_h(i,new Hh(n.ds,e.sv)).map(d=>!d._item.deleted||Eo(d._item,e)||Eo(d._item,n)?Oi(d,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,l):null).filter(d=>d!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new D(A.from(c),0,0));this.prosemirrorView.dispatch(u.setMeta(xe,{isChangeOrigin:!0}))},xe)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=xe.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(a,l)=>this.mapping.delete(l);cu(n,n.deleteSet,a=>{if(a.constructor===Ph){const l=a.content.type;l&&this.mapping.delete(l)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const i=this.type.toArray().map(a=>jm(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new D(A.from(i),0,0));Lv(o,this.beforeTransactionSelection,this),o=o.setMeta(xe,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof Dh}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{_l(this.doc,this.type,e,this),this.beforeTransactionSelection=zl(this,this.prosemirrorView.state)},xe)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const jm=(t,e,n,r,s,i)=>{const o=n.mapping.get(t);if(o===void 0){if(t instanceof Qt)return Oi(t,e,n,r,s,i);throw ty()}return o},Oi=(t,e,n,r,s,i)=>{const o=[],a=l=>{if(l instanceof Qt){const c=jm(l,e,n,r,s,i);c!==null&&o.push(c)}else{const c=l._item.right?.content?.type;c instanceof $h&&!c._item.deleted&&c._item.id.client===c.doc.clientID&&(l.applyDelta([{retain:l.length},...c.toDelta()]),c.doc.transact(d=>{c._item.delete(d)}));const u=Pv(l,e,n,r,s,i);u!==null&&u.forEach(d=>{d!==null&&o.push(d)})}};r===void 0||s===void 0?t.toArray().forEach(a):_h(t,new Hh(s.ds,r.sv)).forEac
207h(a);try{const l=t.getAttributes(r);r!==void 0&&(Eo(t._item,r)?Eo(t._item,s)||(l.ychange=i?i("added",t._item.id):{type:"added"}):l.ychange=i?i("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,l,o);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},xe),n.mapping.delete(t),null}},Pv=(t,e,n,r,s,i)=>{const o=[],a=t.toDelta(r,s,i);try{for(let l=0;l<a.length;l++){const c=a[l];o.push(e.text(c.insert,Fv(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},xe),null}return o},$v=(t,e)=>{const n=new Zt,r=t.map(s=>({insert:s.text,attributes:qm(s.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},zv=(t,e)=>{const n=new Qt(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,Yo(t).map(r=>Bl(r,e))),e.mapping.set(n,t),n},Bl=(t,e)=>t instanceof Array?$v(t,e):zv(t,e),Ud=t=>typeof t=="object"&&t!==null,Kc=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=t[i],a=e[i];r=i==="ychange"||o===a||Ud(o)&&Ud(a)&&Kc(o,a)}return r},Yo=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,n.push(i)}else n.push(s)}return n},Wm=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&oy(r.attributes||{}).length===e[s].marks.length&&ay(r.attributes,(i,o)=>{const a=Um(o),l=e[s].marks;return l.find(u=>u.type.name===a)?Kc(i,l.find(u=>u.type.name===a)?.attrs):!1}))},Ds=(t,e)=>{if(t instanceof Qt&&!(e instanceof Array)&&Hl(t,e)){const n=Yo(e);return t._length===n.length&&Kc(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>Ds(r,n[s]))}
207return t instanceof Zt&&e instanceof Array&&Wm(t,e)},Ao=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),qd=(t,e,n)=>{const r=t.toArray(),s=Yo(e),i=s.length,o=r.length,a=Wn(o,i);let l=0,c=0,u=!1;for(;l<a;l++){const d=r[l],h=s[l];if(Ao(n.mapping.get(d),h))u=!0;else if(!Ds(d,h))break}for(;l+c<a;c++){const d=r[o-c-1],h=s[i-c-1];if(Ao(n.mapping.get(d),h))u=!0;else if(!Ds(d,h))break}return{equalityFactor:l+c,foundMappedChild:u}},Bv=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof cy?e+=n.content.str:n.content instanceof uy&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},_v=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:s}=Bv(t),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,qm(c.marks,n))})),{insert:o,remove:a,index:l}=bv(s,i.map(c=>c.insert).join(""));t.delete(l,a),t.insert(l,o),t.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Hv=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Um=t=>Hv.exec(t)?.[1]??t,Fv=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(Um(r),t[r]));return n},qm=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const s=Fh(e.isOMark,r.type,()=>!r.type.excludes(r.type));
207n[s?`${r.type.name}--${Av(r.toJSON())}`:r.type.name]=r.attrs}}),n},_l=(t,e,n,r)=>{if(e instanceof Qt&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof Qt){const d=e.getAttributes(),h=n.attrs;for(const f in h)h[f]!==null?d[f]!==h[f]&&f!=="ychange"&&e.setAttribute(f,h[f]):e.removeAttribute(f);for(const f in d)h[f]===void 0&&e.removeAttribute(f)}const s=Yo(n),i=s.length,o=e.toArray(),a=o.length,l=Wn(i,a);let c=0,u=0;for(;c<l;c++){const d=o[c],h=s[c];if(!Ao(r.mapping.get(d),h))if(Ds(d,h))r.mapping.set(d,h);else break}for(;u+c+1<l;u++){const d=o[a-u-1],h=s[i-u-1];if(!Ao(r.mapping.get(d),h))if(Ds(d,h))r.mapping.set(d,h);else break}t.transact(()=>{for(;a-c-u>0&&i-c-u>0;){const h=o[c],f=s[c],p=o[a-u-1],m=s[i-u-1];if(h instanceof Zt&&f instanceof Array)Wm(h,f)||_v(h,f,r),c+=1;else{let g=h instanceof Qt&&Hl(h,f),y=p instanceof Qt&&Hl(p,m);if(g&&y){const v=qd(h,f,r),C=qd(p,m,r);v.foundMappedChild&&!C.foundMappedChild?y=!1:!v.foundMappedChild&&C.foundMappedChild||v.equalityFactor<C.equalityFactor?g=!1:y=!1}g?(_l(t,h,f,r),c+=1):y?(_l(t,p,m,r),u+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[Bl(f,r)]),c+=1)}}const d=a-c-u;if(a===1&&i===0&&o[0]instanceof Zt?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):d>0&&(e.slice(c,c+d).forEach(h=>r.mapping.delete(h)),e.delete(c,d)),c+u<i){const h=[];for(let f=c;f<i-u;f++)h.push(Bl(s[f],r));e.insert(c,h)}},xe)},Hl=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let ms=null;class Vv{constructor(e,n,r){this.view=e,this.key=n,this.value=r}apply(){const e=xe.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){const n=this.view.state.tr;n.setMeta(this.key,this.value),this.view.dispatch(n)}}}class Jc{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){const e=ms;ms=null;const n=[];return e.forEach((r,s)=>{r.forEach((i,o)=>{n.push(new Vv(s,o,i))})}),new Jc(n)}}const Km=(t=Jc.fromViewsToUpdate(),e=!1)=>{let n=!0;for(;!t.isEmpty();){const r=t.getFirst();try{r.apply()}catch(s){if(s instanceof RangeError){e&&n&&t.dequeueFirst(),t.isEmpty()||Go(0,()=>Km(t,!0));return}throw s}n=!1,t.dequeueFirst()}},jv=(t,e,n)=>{ms||(ms=new Map,Go(0,Km)),Fh(ms,t,sy).set(e,n)},Ps=(t,e,n)=>{if(t===0)return ya(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Zt){if(r._length>=t)return ya(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new tl(r._item===null?null:r._item.id,r._item===null?nl(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new tl(r._item===null?null:r._item.id,r._item===null?nl(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw zh();if(t===0&&r.constructor!==Zt&&r!==e)return Wv(r._item.parent,r._item)}return ya(e,e._length,-1)},Wv=(t,e)=>{let n=null,r=null;return t._item===null?r=nl(t):n=iy(t._item.id.client,t._item.id.clock),new tl(n,r,e.id)},Yn=(t,e,n,r)=>{const s=ny(n,t);if(s===null||s.type!==e&&!ry(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===Zt)o=s.index;else if(i._item===null||!i._item.deleted){let a=i._first,l=0;for(;l<i._length&&l<s.index&&a!==null;){if(!a.deleted){const c=a.content.type;l++,c instanceof Zt?o+=c._length:o+=r.get(c).nodeSize}a=a.right}o+=1}for(;i!==e&&i._item!==null;){const a=i._item.parent;if(a._item===null||!a._item.deleted){o+=1;let l=a._first;for(;l!==null;){const c=l.content.type;if(c===i)break;l.deleted||(c instanceof Zt?o+=c._length:o+=r.get(c).nodeSize),l=l.right}}i=a}return o-1},Uv=(t,e,n)=>t!==e,qv=t=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null);const r=document.createTextNode("â "),s=document.createTextNode("â ");return e.insertBefore(r,null),e.insertBefore(n,null),e.insertBefore(s,null),e},Jm=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),Kv=/^#[0-9a-fA-F]{6}$/,Kd=(t,e,n,r,s)=>{const i=xe.getState(t);if(i==null||i.doc==null||i.binding==null)return ae.create(t.doc,[]);const o=i.doc,a=[];return i.snapshot!=null||i.prevSnapshot!=null||i.binding.mapping.size===0?ae.create(t.doc,[]):(e.getStates().forEac
207h((l,c)=>{if(n(o.clientID,c,l)&&l.cursor!=null){const u=l.user||{};u.color==null?u.color="#ffa500":Kv.test(u.color)||console.warn("A user uses an unsupported color format",u),u.name==null&&(u.name=`User: ${c}`);let d=Yn(o,i.type,rs(l.cursor.anchor),i.binding.mapping),h=Yn(o,i.type,rs(l.cursor.head),i.binding.mapping);if(d!==null&&h!==null){const f=Pi(t.doc.content.size-1,0);d=Wn(d,f),h=Wn(h,f),a.push(Ee.widget(h,()=>r(u,c),{key:c+"",side:10}));const p=Wn(d,h),m=Pi(d,h);a.push(Ee.inline(p,m,s(u,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),ae.create(t.doc,a))},Jv=(t,{awarenessStateFilter:e=Uv,cursorBuilder:n=qv,selectionBuilder:r=Jm,getSelection:s=o=>o.selection}={},i="cursor")=>new ue({key:gi,state:{init(o,a){return Kd(a,t,e,n,r)},apply(o,a,l,c){const u=xe.getState(c),d=o.getMeta(gi);return u&&u.isChangeOrigin||d&&d.awarenessUpdated?Kd(c,t,e,n,r):a.map(o.mapping,o.doc)}},props:{decorations:o=>gi.getState(o)},view:o=>{const a=()=>{o.docView&&jv(o,gi,{awarenessUpdated:!0})},l=()=>{const c=xe.getState(o.state),u=t.getLocalState()||{};if(o.hasFocus()){const d=s(o.state),h=Ps(d.anchor,c.type,c.binding.mapping),f=Ps(d.head,c.type,c.binding.mapping);(u.cursor==null||!uu(rs(u.cursor.anchor),h)||!uu(rs(u.cursor.head),f))&&t.setLocalStateField(i,{anchor:h,head:f})}else u.cursor!=null&&Yn(c.doc,c.type,rs(u.cursor.anchor),c.binding.mapping)!==null&&t.setLocalStateField(i,null)};return t.on("change",a),o.dom.addEventListener("focusin",l),o.dom.addEventListener("focusout",l),{update:l,destroy:()=>{o.dom.removeEventListener("focusin",l),o.dom.removeEventListener("focusout",l),t.off("change",a),t.setLocalStateField(i,null)}}}}),Gv=t=>{const e=rn.getState(t).undoManager;if(e!=null)return e.undo(),!0},Yv=t=>{const e=rn.getState(t).undoManager;if(e!=null)return e.redo(),!0},Qv=new Set(["paragraph"]),Xv=(t,e)=>!(t instanceof Ph)||!(t.content instanceof Gg)||!(t.content.type instanceof $h||t.content.type instanceof Qt&&e.has(t.content.type.nodeName))||t.content.type._length===0,Zv=({protectedNodes:t=Qv,trackedOrigins:e=[],undoManager:n=null}={})=>new ue({key:rn,state:{init:(r,s)=>{const i=xe.getState(s),o=n||new Dh(i.type,{trackedOrigins:new Set([xe].concat(e)),deleteFilter:a=>Xv(a,t),captureTransaction:a=>a.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const a=xe.getState(o).binding,l=s.undoManager,c=l.undoStack.length>0,u=l.redoStack.length>0;return a?{undoManager:l,prevSel:zl(a,i),hasUndoOps:c,hasRedoOps:u}:c!==s.hasUndoOps||u!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):s}},view:r=>{const s=xe.getState(r.state),i=rn.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const a=s.binding;a&&o.meta.set(a,rn.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const a=s.binding;a&&(a.beforeTransactionSelection=o.meta.get(a)||a.beforeTransactionSelection)}),{destroy:()=>{i.destroy()}}}});function Gc(t){return!!t.getMeta(xe)}function eC(t,e){const n=xe.getState(t);return Yn(n.doc,n.type,e,n.binding.mapping)||0}function Gm(t,e){const n=xe.getState(t);return Ps(e,n.type,n.binding.mapping)}var Li=class Ym extends wc{constructor(e,n){super(e),this.yRelativePosition=n}static fromJSON(e){return new Ym(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function tC(t,e){const n=Gm(e,t);return new Li(t,n)}function nC(t,e,n){const r=t instanceof Li?t.yRelativePosition:null;if(Gc(e)&&r){const o=eC(n,r);return{position:new Li(o,r),mapResult:null}}const s=zp(t,e),i=s.position.position;return{position:new Li(i,r??Gm(n,i)),mapResult:s.mapResult}}var rC=ie.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')}
207,onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>nC(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>tC(t,this.editor.state)},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),rn.getState(e).undoManager.undoStack.length===0?!1:n?Gv(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),rn.getState(e).undoManager.redoStack.length===0?!1:n?Yv(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=Zv(this.options.yUndoOptions),n=e.spec.view;e.spec.view=i=>{const{undoManager:o}=rn.getState(i.state);o.restore&&(o.restore(),o.restore=()=>{});const a=n?n(i):void 0;return{destroy:()=>{const l=o.trackedOrigins.has(o),c=o._observers;o.restore=()=>{l&&o.trackedOrigins.add(o),o.doc.on("afterTransaction",o.afterTransactionHandler),o._observers=c},a?.destroy&&a.destroy()}}};const r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender};return[Ov(t,r),e,this.editor.options.enableContentCheck&&new ue({key:new fe("filterInvalidContent"),filterTransaction:i=>{if(!Gc(i))return!0;if(this.storage.isDisabled)return!1;if(!i.docChanged)return!0;try{return i.doc.check(),!0}catch(o){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var a;(a=t.doc)==null||a.destroy()}}),!1}}})].filter(Boolean)}}),Jd=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n.user})),Gd=()=>null,sC=ie.create({name:"collaborationCaret",priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:t=>{const e=document.createElement("span");e.classList.add("collaboration-carets__caret"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");return n.classList.add("collaboration-carets__label"),n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null),e.insertBefore(n,null),e},selectionRender:Jm,onUpdate:Gd}},onCreate(){if(this.options.onUpdate!==Gd&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret'),!this.options.provider)throw new Error('The "provider" option is required for the CollaborationCaret extension')},addStorage(){return{users:[]}},addCommands(){return{updateUser:t=>()=>(this.options.provider.awareness.setLocalStateField("user",t),!0),user:t=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret'),e.commands.updateUser(t))}},addProseMirrorPlugins(){return[Jv((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=Jd(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=Jd(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),iC=({key:t,editor:e,onPaste:n,onDrop:r,allowedMimeTypes:s})=>new ue({key:t||new fe("fileHandler"),props:{handleDrop(i,o){var a;if(!r||!((a=o.dataTransfer)!=null&&a.files.length))return!1;const l=i.posAtCoords({left:o.clientX,top:o.clientY});let c=Array.from(o.dataTransfer.files);return s&&(c=c.filter(u=>s.includes(u.type))),c.length===0?!1:(o.preventDefault(),o.stopPropagation(),r(e,c,l?.pos||0),!0)},handlePaste(i,o){var a;if(!n||!((a=o.clipboardData)!=null&&a.files.length))return!1;let l=Array.from(o.clipboardData.files);const c=o.clipboardData.getData("text/html");return s&&(l=l.filter(u=>s.includes(u.type))),!(l.length===0||(o.preventDefault(),o.stopPropagation(),n(e,l,c),c.length>0))}}}),oC=ie.create({name:"fileHandler",addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[iC({key:new fe(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),aC=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,lC=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,cC=an.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||zr(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",he(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>
207e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ir({find:aC,type:this.type})]},addPasteRules(){return[Rn({find:lC,type:this.type})]}}),uC=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,dC=Ae.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",he(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const a=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",l=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",c=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:o,editor:a})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,h])=>{if(h!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,h);break}}),l.src=o.src;const c=new ww({element:l,editor:a,node:s,getPos:i,onResize:(d,h)=>{l.style.width=`${d}px`,l.style.height=`${h}px`},onCommit:(d,h)=>{const f=i();f!==void 0&&this.editor.chain().setNodeSelection(f).updateAttributes(this.name,{width:d,height:h}).run()},onUpdate:(d,h,f)=>d.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",l.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}
207,addInputRules(){return[Zp({find:uC,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),hC=Ae.create({name:"blockMath",group:"block",atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:"",parseHTML:t=>t.getAttribute("data-latex"),renderHTML:t=>({"data-latex":t.latex})}}},addCommands(){return{insertBlockMath:t=>({commands:e,editor:n})=>{const{latex:r,pos:s}=t;return r?e.insertContentAt(s??n.state.selection.from,{type:this.name,attrs:{latex:r}}):!1},deleteBlockMath:t=>({editor:e,tr:n})=>{var r;const s=(r=t?.pos)!=null?r:e.state.selection.$from.pos,i=e.state.doc.nodeAt(s);return!i||i.type.name!==this.name?!1:(n.delete(s,s+i.nodeSize),!0)},updateBlockMath:t=>({editor:e,tr:n})=>{const r=t?.latex;let s=t?.pos;s===void 0&&(s=e.state.selection.$from.pos);const i=e.state.doc.nodeAt(s);return!i||i.type.name!==this.name?!1:(n.setNodeMarkup(s,this.type,{...i.attrs,latex:r??i.attrs.latex}),!0)}}},parseHTML(){return[{tag:'div[data-type="block-math"]'}]},renderHTML({HTMLAttributes:t}){return["div",he(t,{"data-type":"block-math"})]},parseMarkdown:t=>({type:"blockMath",attrs:{latex:t.latex}}),renderMarkdown:t=>{var e;return["$$",((e=t.attrs)==null?void 0:e.latex)||"","$$"].join(` 208`)},markdownTokenizer:{name:"blockMath",level:"block",start:t=>t.indexOf("$$"),tokenize:t=>{const e=t.match(/^\$\$([^$]+)\$\$/);if(!e)return;const[n,r]=e;return{type:"blockMath",raw:n,latex:r.trim()}}},addInputRules(){return[new ur({find:/^\$\$\$([^$]+)\$\$\$$/,handler:({state:t,range:e,match:n})=>{const[,r]=n,{tr:s}=t,i=t.doc.resolve(e.from),o=this.type.create({latex:r}),c=i.depth>0&&i.parent.isTextblock&&e.from===i.start()&&e.to===i.end()&&i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),this.type)?{from:i.before(),to:i.after()}:e;s.replaceWith(c.from,c.to,o)}})]},addNodeView(){const{katexOptions:t}=this.options;return({node:e,getPos:n})=>{const r=document.createElement("div"),s=document.createElement("div");r.className="tiptap-mathematics-render",this.editor.isEditable&&r.classList.add("tiptap-mathematics-render--editable"),s.className="block-math-inner",r.dataset.type="block-math",r.setAttribute("data-latex",e.attrs.latex),r.appendChild(s);function i(){try{Vh.render(e.attrs.latex,s,t),r.classList.remove("block-math-error")}catch{r.textContent=e.attrs.latex,r.classList.add("block-math-error")}}const o=a=>{a.preventDefault(),a.stopPropagation();const l=n();l!=null&&this.options.onClick&&this.options.onClick(e,l)};return this.options.onClick&&r.addEventListener("click",o),i(),{dom:r,destroy(){r.removeEventListener("click",o)}}}}}),fC=Ae.create({name:"inlineMath",group:"inline",inline:!0,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:"",parseHTML:t=>t.getAttribute("data-latex"),renderHTML:t=>({"data-latex":t.latex})}}},addCommands(){return{insertInlineMath:t=>({editor:e,tr:n})=>{var r;const s=t.latex,i=(r=t?.pos)!=null?r:e.state.selection.from;return s?(n.replaceWith(i,i,this.type.create({latex:s})),!0):!1},deleteInlineMath:t=>({editor:e,tr:n})=>{var r;const s=(r=t?.pos)!=null?r:e.state.selection.$from.pos,i=e.state.doc.nodeAt(s);return!i||i.type.name!==this.name?!1:(n.delete(s,s+i.nodeSize),!0)},updateInlineMath:t=>({editor:e,tr:n})=>{const r=t?.latex;let s=t?.pos;s===void 0&&(s=e.state.selection.$from.pos);const i=e.state.doc.nodeAt(s);return!i||i.type.name!==this.name?!1:(n.setNodeMarkup(s,this.type,{...i.attrs,latex:r}),!0)}}},parseHTML(){return[{tag:'span[data-type="inline-math"]'}]},renderHTML({HTMLAttributes:t}){return["span",he(t,{"data-type":"inline-math"})]},parseMarkdown:t=>({type:"inlineMath",attrs:{latex:t.latex}}),renderMarkdown:t=>{var e;return`$${((e=t.attrs)==null?void 0:e.latex)||""}$`},markdownTokenizer:{name:"inlineMath",level:"inline",start:t=>t.indexOf("$"),tokenize:t=>{const e=t.match(/^\$([^$]+)\$(?!\$)/);if(!e)return;const[n,r]=e;return{type:"inlineMath",raw:n,latex:r.trim()}}},addInputRules(){return[new ur({find:new RegExp("(?<!\\$)(\\$\\$([^$\\n]+?)\\$\\$)(?!\\$)"),handler:({state:t,range:e,match:n}
208)=>{const r=n[2],{tr:s}=t,i=e.from,o=e.to;s.replaceWith(i,o,this.type.create({latex:r}))}})]},addNodeView(){const{katexOptions:t}=this.options;return({node:e,getPos:n})=>{const r=document.createElement("span");r.className="tiptap-mathematics-render",this.editor.isEditable&&r.classList.add("tiptap-mathematics-render--editable"),r.dataset.type="inline-math",r.setAttribute("data-latex",e.attrs.latex);function s(){try{Vh.render(e.attrs.latex,r,t),r.classList.remove("inline-math-error")}catch{r.textContent=e.attrs.latex,r.classList.add("inline-math-error")}}const i=o=>{o.preventDefault(),o.stopPropagation();const a=n();a!=null&&this.options.onClick&&this.options.onClick(e,a)};return this.options.onClick&&r.addEventListener("click",i),s(),{dom:r,destroy(){r.removeEventListener("click",i)}}}}}),pC=ie.create({name:"Mathematics",addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[hC.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),fC.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});let Fl,Vl;if(typeof WeakMap<"u"){let t=new WeakMap;Fl=e=>t.get(e),Vl=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Fl=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},Vl=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Le=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let a=1;i<this.width&&this.map[e+a]==n;a++)i++;for(let a=1;o<this.height&&this.map[e+this.width*a]==n;a++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,l),right:Math.max(r,a),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const a=(t+1)*this.width;for(;o<a&&this.map[o]<s;)o++;return o==a?i-1:this.map[o]}s=i}}static get(t){return Fl(t)||Vl(t,mC(t))}};function mC(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=gC(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const d=t.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==d.childCount)break;const m=d.child(p),{colspan:g,rowspan:y,colwidth:v}=m.attrs;for(let C=0;C<y;C++){if(C+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-C});break}const N=s+C*e;for(let M=0;M<g;M++){r[N+M]==0?r[N+M]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:g-M});const I=v&&v[M];if(I){const R=(N+M)%e*2,$=o[R];$==null||$!=I&&o[R+1]==1?(o[R]=I,o[R+1]=1):$==I&&o[R+1]++}}}s+=g,u+=m.nodeSize}const h=(c+1)*e;let f=0;for(;s<h;)r[s++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const a=new Le(e,n,r,i);let l=!1;for(let c=0;!l&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(l=!0);return l&&yC(a,o,t),a}function gC(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const a=t.child(o);for(let l=0;l<a.childCount;l++){const c=a.child(l);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const a=s.child(o);i+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function yC(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;
208r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let a=null;const l=o.attrs;for(let c=0;c<l.colspan;c++){const u=e[(s+c)%t.width*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((a||(a=bC(l)))[c]=u)}a&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function bC(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Qe(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const kn=new fe("selectingCells");function ar(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function kC(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function At(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Qo(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=ar(e.$head)||xC(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function xC(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function jl(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function wC(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Yc(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Qm(t,e,n){const r=t.node(-1),s=Le.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function lr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function Xm(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function SC(t,e,n){const r=Qe(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var we=class Gt extends Q{constructor(e,n=e){const r=e.node(-1),s=Le.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),a=e.node(0),l=s.cellsInRect(o).filter(u=>u!=n.pos-i);l.unshift(n.pos-i);const c=l.map(u=>{const d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const h=i+u+1;return new vf(a.resolve(h),a.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(jl(r)&&jl(s)&&Yc(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Gt.rowSelection(r,s):i&&this.isColSelection()?Gt.colSelection(r,s):new Gt(r,s)}return U.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Le.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let l=s.top;l<s.bottom;l++){const c=[];for(let u=l*n.width+s.left,d=s.left;d<s.right;d++,u++){const h=n.map[u];if(i[h])continue;i[h]=!0;const f=n.findCell(h);let p=e.nodeAt(h);if(!p)throw new RangeError(`No cell with offset ${h} found`);const m=s.left-f.left,g=f.right-s.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=lr(y,0,m)),g>0&&(y=lr(y,y.colspan-g,g)),f.left<s.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(f.top<s.top||f.bottom>s.bottom){const y={...p.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}o.push(e.child(l).copy(A.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:o;return new D(A.from(a),1,1)}replace(e,n=D.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:a,$to:l}=s[o],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),o?D.empty:n)}const i=Q.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new D(A.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Le.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Le.get(r),i=e.start(-1),o=s.findCell(e.pos-i),a=s.findCell(n.pos-i),l=e.node(0);return o.top<=a.top?(o.top>0&&(e=l.resolve(i+s.map[o.left])),a.bottom<s.height&&(n=l.resolve(i+s.map[s.width*(s.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(i+s.map[a.left])),o.bottom<s.height&&(e=l.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Gt(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Le.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,a=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,a)==n.width}eq(e){return e instanceof Gt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Le.get(r),i=e.start(-1),o=s.findCell(e.pos-i),a=s.findCell(n.pos-i),l=e.node(0);return o.left<=a.left?(o.left>0&&(e=l.resolve(i+s.map[o.top*s.width])),a.right<s.width&&(n=l.resolve(i+s.map[s.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(i+s.map[a.top*s.width])),o.right<s.width&&(e=l.resolve(i+s.map[s.width*(o.top+1)-1]))),new Gt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Gt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Gt(e.resolve(n),e.resolve(r))}getBookmark(){return new vC(this.$anchorCell.pos,this.$headCell.pos)}};we.prototype.visible=!1;Q.jsonID("cell",we);var vC=class Zm{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Zm(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Yc(n,r)?new we(n,r):Q.near(r,1)}};function CC(t){if(!(t.selection instanceof we))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Ee.node(r,r+n.nodeSize,{class:"selectedCell"}))}),ae.create(t.doc,e)}function MC({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);
208return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function TC({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function EC(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof j&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=we.create(s,r.from);else if(o=="row"){const a=s.resolve(r.from+1);i=we.rowSelection(a,a)}else if(!n){const a=Le.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];i=we.create(s,l+1,c)}}else r instanceof U&&MC(r)?i=U.create(s,r.from):r instanceof U&&TC(r)&&(i=U.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const AC=new fe("fix-tables");function eg(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,a=0;o<i;o++){const l=e.child(o);for(let c=a,u=Math.min(s,o+3);c<u;c++)if(t.child(c)==l){a=c+1,n+=l.nodeSize;continue e}r(l,n),a<s&&t.child(a).sameMarkup(l)?eg(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function tg(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=NC(t,s,i,n))};return e?e.doc!=t.doc&&eg(e.doc,t.doc,0,r):t.doc.descendants(r),n}function NC(t,e,n,r){const s=Le.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let l=0;l<s.height;l++)i.push(0);for(let l=0;l<s.problems.length;l++){const c=s.problems[l];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)i[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,lr(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let o,a;for(let l=0;l<i.length;l++)i[l]&&(o==null&&(o=l),a=l);for(let l=0,c=n+1;l<s.height;l++){const u=e.child(l),d=c+u.nodeSize,h=i[l];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<h;g++){const y=Qe(t.schema)[f].createAndFill();y&&p.push(y)}const m=(l==0||o==l-1)&&a==l?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(AC,{fixTables:!0})}function Ft(t){const e=t.selection,n=Qo(t),r=n.node(-1),s=n.start(-1),i=Le.get(r);return{...e instanceof we?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function ng(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;SC(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const a=o*e.width+s;if(s>0&&s<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],c=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,Xm(c.attrs,s-e.colCount(l))),o+=c.attrs.rowspan-1}else{const l=i==null?Qe(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),l.createAndFill())}}return t}function RC(t,e){if(!At(t))return!1;if(e){const n=Ft(t);e(ng(t.tr,n,n.left))}return!0}function OC(t,e){if(!At(t))return!1;if(e){const n=Ft(t);e(ng(t.tr,n,n.right))}return!0}function LC(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const a=o*e.width+s,l=e.map[a],c=n.nodeAt(l),u=c.attrs;if(s>0&&e.map[a-1]==l||s<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(i).map(r+l),null,lr(u,s-e.colCount(l)));else{const d=t.mapping.slice(i).map(r+l);t.delete(d,d+c.nodeSize)}o+=u.rowspan}}function IC(t,e){if(!At(t))return!1;if(e){const n=Ft(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;LC(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Le.get(i)}e(r)}return!0}function DC(t,e,n){var r;const s=Qe(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function rg(t,{map:e,tableStart:n,table:r},s){let i=n;for(let c=0;c<s;c++)i+=r.child(c).nodeSize;const o=[];let a=s>0?-1:0;DC(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],h=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var l;const d=a==null?Qe(r.type.schema).cell:(l=r.nodeAt(e.map[u+a*e.width]))===null||l===void 0?void 0:l.type,h=d?.createAndFill();h&&o.push(h)}return t.insert(i,Qe(r.type.schema).row.create(null,o)),t}function PC(t,e){if(!At(t))return!1;if(e){const n=Ft(t);e(rg(t.tr,n,n.top))}return!0}function $C(t,e){if(!At(t))return!1;if(e){const n=Ft(t);e(rg(t.tr,n,n.bottom))}return!0}function zC(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const o=i+n.child(s).nodeSize,a=t.mapping.maps.length;t.delete(i+r,o+r);const l=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){const d=e.map[u];if(!l.has(d)){if(l.add(d),s>0&&d==e.map[u-e.width]){const h=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(a).map(d+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){const h=n.nodeAt(d),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),m=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(a).map(r+m),p),c+=f.colspan-1}}}}function BC(t,e){if(!At(t))return!1;if(e){const n=Ft(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;zC(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Le.get(n.table)}e(r)}return!0}function Yd(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function _C({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,a=s+(r.right-r.left-1);for(let l=r.top;
208l<r.bottom;l++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[a]==n[a+1])return!0;i+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Qd(t,e){const n=t.selection;if(!(n instanceof we)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Ft(t),{map:s}=r;if(_C(s,r))return!1;if(e){const i=t.tr,o={};let a=A.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const h=s.map[u*s.width+d],f=r.table.nodeAt(h);if(!(o[h]||!f))if(o[h]=!0,l==null)l=h,c=f;else{Yd(f)||(a=a.append(f.content));const p=i.mapping.map(h+r.tableStart);i.delete(p,p+f.nodeSize)}}if(l==null||c==null)return!0;if(i.setNodeMarkup(l+r.tableStart,null,{...Xm(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const u=l+1+c.content.size,d=Yd(c)?l+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,a)}i.setSelection(new we(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function Xd(t,e){const n=Qe(t.schema);return HC(({node:r})=>n[r.type.spec.tableRole])(t,e)}function HC(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof we){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=kC(r.$from),!s)return!1;i=(o=ar(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let a=s.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const u=Ft(e),d=e.tr;for(let f=0;f<u.right-u.left;f++)l.push(c?{...a,colwidth:c&&c[f]?[c[f]]:null}:a);let h;for(let f=u.top;f<u.bottom;f++){let p=u.map.positionAt(f,u.left,u.table);f==u.top&&(p+=s.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&f==u.top||d.insert(h=d.mapping.map(p+u.tableStart,1),t({node:s,row:f,col:m}).createAndFill(l[g]))}d.setNodeMarkup(i,t({node:s,row:u.top,col:u.left}),l[0]),r instanceof we&&d.setSelection(new we(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function FC(t,e){return function(n,r){if(!At(n))return!1;const s=Qo(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof we?n.selection.forEachCell((o,a)=>{o.attrs[t]!==e&&i.setNodeMarkup(a,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function VC(t){return function(e,n){if(!At(e))return!1;if(n){const r=Qe(e.schema),s=Ft(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),a=o.map(l=>s.table.nodeAt(l));for(let l=0;l<o.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[l],r.cell,a[l].attrs);if(i.steps.length===0)for(let l=0;l<o.length;l++)i.setNodeMarkup(s.tableStart+o[l],r.header_cell,a[l].attrs);n(i)}return!0}}function Zd(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function $s(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?VC(t):function(n,r){if(!At(n))return!1;if(r){const s=Qe(n.schema),i=Ft(n),o=n.tr,a=Zd("row",i,s),l=Zd("column",i,s),c=(t==="column"?a:t==="row"&&l)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t=="column"?l?s.cell:s.header_cell:t=="row"?a?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(h=>{const f=h+i.tableStart,p=o.doc.nodeAt(f);p&&o.setNodeMarkup(f,d,p.attrs)}),r(o)}return!0}}$s("row",{useDeprecatedLogic:!0});$s("column",{useDeprecatedLogic:!0});const jC=$s("cell",{useDeprecatedLogic:!0});function WC(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function eh(t){return function(e,n){if(!At(e))return!1;const r=WC(Qo(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(U.between(s,wC(s))).scrollIntoView())}return!0}}function UC(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function yi(t,e){const n=t.selection;if(!(n instanceof we))return!1;if(e){const r=t.tr,s=Qe(t.schema).cell.createAndFill().content;
208n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new D(s,0,0))}),r.docChanged&&e(r)}return!0}function qC(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const u=l?0:Math.max(0,n-1),d=l<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Wl(Qe(o).row,new D(c,u,d)).content),a.push(c)}else if(i=="cell"||i=="header_cell")a.push(n||r?Wl(Qe(o).row,new D(e,n,r)).content:e);else return null;return KC(o,a)}function KC(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:a,colspan:l}=i.child(o).attrs;for(let c=s;c<s+a;c++)n[c]=(n[c]||0)+l}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(A.empty),n[s]<r){const i=Qe(t).cell.createAndFill(),o=[];for(let a=n[s];a<r;a++)o.push(i);e[s]=e[s].append(A.from(o))}return{height:e.length,width:r,rows:e}}function Wl(t,e){const n=t.createAndFill();return new ec(n).replace(0,n.content.size,e).doc}function JC({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let a=0;a<n.length;a++){const l=n[a],c=[];for(let u=i[a]||0,d=0;u<r;d++){let h=l.child(d%l.childCount);u+h.attrs.colspan>r&&(h=h.type.createChecked(lr(h.attrs,h.attrs.colspan,u+h.attrs.colspan-r),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[a+f]=(i[a+f]||0)+h.attrs.colspan}o.push(A.from(c))}n=o,t=r}if(e!=s){const i=[];for(let o=0,a=0;o<s;o++,a++){const l=[],c=n[a%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),l.push(d)}i.push(A.from(l))}n=i,e=s}return{width:t,height:e,rows:n}}function GC(t,e,n,r,s,i,o){const a=t.doc.type.schema,l=Qe(a);let c,u;if(s>e.width)for(let d=0,h=0;d<e.height;d++){const f=n.child(d);h+=f.nodeSize;const p=[];let m;f.lastChild==null||f.lastChild.type==l.cell?m=c||(c=l.cell.createAndFill()):m=u||(u=l.header_cell.createAndFill());for(let g=e.width;g<s;g++)p.push(m);t.insert(t.mapping.slice(o).map(h-1+r),p)}if(i>e.height){const d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==l.header_cell;d.push(g?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,A.from(d)),f=[];for(let p=e.height;p<i;p++)f.push(h);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||u)}function th(t,e,n,r,s,i,o,a){if(o==0||o==e.height)return!1;let l=!1;for(let c=s;c<i;c++){const u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){l=!0;const h=n.nodeAt(d),{top:f,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(a).map(d+r),null,{...h.attrs,rowspan:o-f}),t.insert(t.mapping.slice(a).map(e.positionAt(o,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-o})),c+=h.attrs.colspan-1}}return l}function nh(t,e,n,r,s,i,o,a){if(o==0||o==e.width)return!1;let l=!1;for(let c=s;c<i;c++){const u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){l=!0;const h=n.nodeAt(d),f=e.colCount(d),p=t.mapping.slice(a).map(d+r);t.setNodeMarkup(p,null,lr(h.attrs,o-f,h.attrs.colspan-(o-f))),t.insert(p+h.nodeSize,h.type.createAndFill(lr(h.attrs,0,o-f))),c+=h.attrs.rowspan-1}}return l}function rh(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=Le.get(i);const{top:a,left:l}=r,c=l+s.width,u=a+s.height,d=t.tr;let h=0;function f(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");o=Le.get(i),h=d.mapping.maps.length}GC(d,o,i,n,c,u,h)&&f(),th(d,o,i,n,l,c,a,h)&&f(),th(d,o,i,n,l,c,u,h)&&f(),nh(d,o,i,n,a,u,l,h)&&f(),nh(d,o,i,n,a,u,c,h)&&f();for(let p=a;p<u;p++){const m=o.positionAt(p,l,i),g=o.positionAt(p,c,i);d.replace(d.mapping.slice(h).map(m+n),d.mapping.slice(h).map(g+n),new D(s.rows[p-a],0,0))}f(),d.setSelection(new we(d.doc.resolve(n+o.positionAt(a,l,i)),d.doc.resolve(n+o.positionAt(u-1,c-1,i)))),e(d)}const YC=mc({ArrowLeft:bi("horiz",-1),ArrowRight:bi("horiz",1),ArrowUp:bi("vert",-1),ArrowDown:bi("vert",1),"Shift-ArrowLeft":ki("horiz",-1),"Shift-ArrowRight":ki("horiz",1),"Shift-ArrowUp":ki("vert",-1),"Shift-ArrowDown":ki("vert",1),Backspace:yi,"Mod-Backspace":yi,Delete:yi,"Mod-Delete":yi});function Ii(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function bi(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof we)return Ii(n,r,Q.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=sg(s,t,e);if(o==null)return!1;if(t=="horiz")return Ii(n,r,Q.near(n.doc.resolve(i.head+e),e));{const a=n.doc.resolve(o),l=Qm(a,t,e);let c;return l?c=Q.near(l,1):e<0?c=Q.near(n.doc.resolve(a.before(-1)),-1):c=Q.near(n.doc.resolve(a.after(-1)),1),Ii(n,r,c)}}}function ki(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof we)o=i;else{const l=sg(s,t,e);if(l==null)return!1;o=new we(n.doc.resolve(l))}const a=Qm(o.$headCell,t,e);return a?Ii(n,r,new we(o.$anchorCell,a)):!1}}function QC(t,e){const n=t.state.doc,r=ar(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new we(r))),!0):!1}function XC(t,e,n){if(!At(t.state))return!1;let r=qC(n);const s=t.state.selection;if(s instanceof we){r||(r={width:1,height:1,rows:[A.from(Wl(Qe(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),a=Le.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=JC(r,a.right-a.left,a.bottom-a.top),rh(t.state,t.dispatch,o,a,r),!0}else if(r){const i=Qo(t.state),o=i.start(-1);return rh(t.state,t.dispatch,o,Le.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function ZC(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=sh(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof we)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=ar(t.state.selection.$anchor))!=null&&((n=Ua(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(l,c){let u=Ua(t,c);const d=kn.getState(t.state)==null;if(!u||!Yc(l,u))if(d)u=l;else return;const h=new we(l,u);if(d||!t.state.selection.eq(h)){const f=t.state.tr.setSelection(h);d&&f.setMeta(kn,l.pos),t.dispatch(f)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",a),kn.getState(t.state)!=null&&t.dis
208patch(t.state.tr.setMeta(kn,-1))}function a(l){const c=l,u=kn.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(sh(t,c.target)!=r&&(d=Ua(t,e),!d))return o();d&&i(d,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",a)}function sg(t,e,n){if(!(t.state.selection instanceof U))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?o:null}}return null}function sh(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ua(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&ar(t.state.doc.resolve(r))||ar(t.state.doc.resolve(s))}var eM=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ul(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Ul(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ul(t,e,n,r,s,i){let o=0,a=!0,l=e.firstChild;const c=t.firstChild;if(c){for(let d=0,h=0;d<c.childCount;d++){const{colspan:f,colwidth:p}=c.child(d).attrs;for(let m=0;m<f;m++,h++){const g=s==h?i:p&&p[m],y=g?g+"px":"";if(o+=g||r,g||(a=!1),l)l.style.width!=y&&(l.style.width=y),l=l.nextSibling;else{const v=document.createElement("col");v.style.width=y,e.appendChild(v)}}}for(;l;){var u;const d=l.nextSibling;(u=l.parentNode)===null||u===void 0||u.removeChild(l),l=d}a?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const ut=new fe("tableColumnResizing");function tM({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=eM,lastColumnResizable:s=!0}={}){const i=new ue({key:ut,state:{init(o,a){var l;const c=(l=i.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,u=Qe(a.schema).table.name;return r&&c&&(c[u]=(d,h)=>new r(d,n,h)),new nM(-1,!1)},apply(o,a){return a.apply(o)}},props:{attributes:o=>{const a=ut.getState(o);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,a)=>{rM(o,a,t,s)},mouseleave:o=>{sM(o)},mousedown:(o,a)=>{iM(o,a,e,n)}},decorations:o=>{const a=ut.getState(o);if(a&&a.activeHandle>-1)return uM(o,a.activeHandle)},nodeViews:{}}});return i}var nM=class Di{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(ut);if(r&&r.setHandle!=null)return new Di(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Di(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return jl(e.doc.resolve(s))||(s=-1),new Di(s,n.dragging)}return n}};function rM(t,e,n,r){if(!t.editable)return;const s=ut.getState(t.state);if(s&&!s.dragging){const i=aM(e.target);let o=-1;if(i){const{left:a,right:l}=i.getBoundingClientRect();e.clientX-a<=n?o=ih(t,e,"left",n):l-e.clientX<=n&&(o=ih(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const a=t.state.doc.resolve(o),l=a.node(-1),c=Le.get(l),u=a.start(-1);if(c.colCount(a.pos-u)+a.nodeAfter.attrs.colspan-1==c.width-1)return}ig(t,o)}}}function sM(t){if(!t.editable)return;const e=ut.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&ig(t,-1)}function iM(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=ut.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const a=t.state.doc.nodeAt(o.activeHandle),l=oM(t,o.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(ut,{setDragging:{startX:e.clientX,startWidth:l}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);const h=ut.getState(t.state);
208h?.dragging&&(lM(t,h.activeHandle,oh(h.dragging,d,n)),t.dispatch(t.state.tr.setMeta(ut,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=ut.getState(t.state);if(h&&h.dragging){const f=oh(h.dragging,d,n);ah(t,h.activeHandle,f,r)}}return ah(t,o.activeHandle,l,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function oM(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(o-=r[l],a--);return o/a}function aM(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function ih(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,a=ar(t.state.doc.resolve(o));if(!a)return-1;if(n=="right")return a.pos;const l=Le.get(a.node(-1)),c=a.start(-1),u=l.map.indexOf(a.pos-c);return u%l.width==0?-1:c+l.map[u-1]}function oh(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function ig(t,e){t.dispatch(t.state.tr.setMeta(ut,{setHandle:e}))}function lM(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Le.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let c=0;c<i.height;c++){const u=c*i.width+a;if(c&&i.map[u]==i.map[u-i.width])continue;const d=i.map[u],h=s.nodeAt(d).attrs,f=h.colspan==1?0:a-i.colCount(d);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():cM(h.colspan);p[f]=n,l.setNodeMarkup(o+d,null,{...h,colwidth:p})}l.docChanged&&t.dispatch(l)}function ah(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),a=Le.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let l=t.domAtPos(s.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Ul(i,l.firstChild,l,r,a,n)}function cM(t){return Array(t).fill(0)}function uM(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return ae.empty;const i=Le.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const u=a+c*i.width;if((a==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var l;const d=i.map[u],h=o+d+s.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((l=ut.getState(t))===null||l===void 0)&&l.dragging&&n.push(Ee.node(o+d,o+d+s.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(Ee.widget(h,f))}}return ae.create(t.doc,n)}function dM({allowTableNodeSelection:t=!1}={}){return new ue({key:kn,state:{init(){return null},apply(e,n){const r=e.getMeta(kn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:CC,handleDOMEvents:{mousedown:ZC},createSelectionBetween(e){return kn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:QC,handleKeyDown:YC,handlePaste:XC},appendTransaction(e,n,r){return EC(r,tg(r,n),t)}})}function No(t){return t==="left"||t==="right"||t==="center"?t:null}function hM(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return No(e||n)}function fM(t){return No(t?.align)}function og(){return{default:null,parseHTML:t=>hM(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var pM=Ae.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const a=i[o].getAttribute("width");return a?[parseInt(a,10)]:null}}return s}},align:og()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",he(this.options.HTMLAttributes,t),0]}}),mM=Ae.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}},align:og()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",he(this.options.HTMLAttributes,t),0]}}),gM=Ae.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",he(this.options.HTMLAttributes,t),0]}});function ql(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function lh(t,e,n,r,s,i){var o;let a=0,l=!0,c=e.firstChild;const u=t.firstChild;if(u!==null)for(let h=0,f=0;h<u.childCount;h+=1){const{colspan:p,colwidth:m}=u.child(h).attrs;for(let g=0;g<p;g+=1,f+=1){const y=s===f?i:m&&m[g],v=y?`${y}px`:"";if(a+=y||r,y||(l=!1),c){if(c.style.width!==v){const[C,N]=ql(r,y);c.style.setProperty(C,N)}c=c.nextSibling}else{const C=document.createElement("col"),[N,M]=ql(r,y);C.style.setProperty(N,M),e.appendChild(C)}}}for(;c;){const h=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=h}const d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!d?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}var yM=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),lh(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,lh(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function bM(t,e,n,r){let s=0,i=!0;const o=[],a=t.firstChild;if(!a)return{};for(let d=0,h=0;d<a.childCount;d+=1){const{colspan:f,colwidth:p}=a.child(d).attrs;for(let m=0;m<f;m+=1,h+=1){const g=n===h?r:p&&p[m];s+=g||e,g||(i=!1);const[y,v]=ql(e,g);o.push(["col",{style:`${y}: ${v}`}])}}const l=i?`${s}
208px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:l,tableMinWidth:c}}function ch(t,e){return t.createAndFill()}function kM(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function xM(t,e,n,r,s){const i=kM(t),o=[],a=[];for(let c=0;c<n;c+=1){const u=ch(i.cell);if(u&&a.push(u),r){const d=ch(i.header_cell);d&&o.push(d)}}const l=[];for(let c=0;c<e;c+=1)l.push(i.row.createChecked(null,r&&c===0?o:a));return i.table.createChecked(null,l)}function wM(t){return t instanceof we}var xi=({editor:t})=>{const{selection:e}=t.state;if(!wM(e))return!1;let n=0;const r=Ep(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},SM="�";function vM(t){return(t||"").replace(/\s+/g," ").trim()}function CM(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:SM;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(m=>{const g=[];m.content&&m.content.forEach(y=>{let v="";y.content&&Array.isArray(y.content)&&y.content.length>1?v=y.content.map(R=>e.renderChildren(R)).join(s):v=y.content?e.renderChildren(y.content):"";const C=vM(v),N=y.type==="tableHeader",M=fM(y.attrs);g.push({text:C,isHeader:N,align:M})}),i.push(g)});const o=i.reduce((m,g)=>Math.max(m,g.length),0);if(o===0)return"";const a=new Array(o).fill(0);i.forEach(m=>{var g;for(let y=0;y<o;y+=1){const C=(((g=m[y])==null?void 0:g.text)||"").length;C>a[y]&&(a[y]=C),a[y]<3&&(a[y]=3)}});const l=(m,g)=>m+" ".repeat(Math.max(0,g-m.length)),c=i[0],u=c.some(m=>m.isHeader),d=new Array(o).fill(null);i.forEach(m=>{var g;for(let y=0;y<o;y+=1)!d[y]&&((g=m[y])!=null&&g.align)&&(d[y]=m[y].align)});let h=` 209`;const f=new Array(o).fill(0).map((m,g)=>u&&c[g]&&c[g].text||"");return h+=`| ${f.map((m,g)=>l(m,a[g])).join(" | ")} | 210`,h+=`| ${a.map((m,g)=>{const y=Math.max(3,m),v=d[g];return v==="left"?`:${"-".repeat(y)}`:v==="right"?`${"-".repeat(y)}:`:v==="center"?`:${"-".repeat(y)}:`:"-".repeat(y)}).join(" | ")} | 211`,(u?i.slice(1):i).forEach(m=>{h+=`| ${new Array(o).fill(0).map((g,y)=>l(m[y]&&m[y].text||"",a[y])).join(" | ")} | 212`}),h}var MM=CM,TM=Ae.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:yM,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=bM(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const a=["table",he(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},a]:a},parseMarkdown:(t,e)=>{const n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){const s=[];t.header.forEach((i,o)=>{var a;const l=No((a=r[o])!=null?a:i.align),c=l?{align:l}:{};s.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const i=[];s.forEach((o,a)=>{var l;const c=No((l=r[a])!=null?l:o.align),u=c?{align:c}:{};i.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>MM(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=xM(i.schema,t,e,n);if(s){const a=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(U.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>RC(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>OC(t,e),deleteColumn:()=>({state:t,dispatch:e})=>IC(t,e),addRowBefore:()=>({state:t,dispatch:e})=>PC(t,e),addRowAfter:()=>({state:t,dispatch:e})=>$C(t,e),deleteRow:()=>({state:t,dispatch:e})=>BC(t,e),deleteTable:()=>({state:t,dispatch:e})=>UC(t,e),mergeCells:()=>({state:t,dispatch:e})=>Qd(t,e),splitCell:()=>({state:t,dispatch:e})=>Xd(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>$s("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>$s("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>jC(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Qd(t,e)?!0:Xd(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>FC(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>eh(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>eh(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&tg(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=we.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:xi,"Mod-Backspace":xi,Delete:xi,"Mod-Delete":xi}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[tM({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],dM({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r})=>new e(n,this.options.cellMinWidth,r)},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:de(H(t,"tableRole",e))}}}),EM=ie.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(TM.configure(this.options.table)),this.options.tableCell!==!1&&t.push(pM.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(mM.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(gM.configure(this.options.tableRow)),t}}),AM=ie.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}}
212,addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),NM=AM,RM=20,ag=(t,e=0)=>{const n=[];return!t.children.length||e>RM||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...ag(r,e+1))}),n},OM=t=>{if(!t.children.length)return;const e=ag(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},LM=an.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&OM(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",he(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),IM=ie.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=(e=zr(t,"background-color"))!=null?e:t.style.backgroundColor;return n?.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),DM=ie.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=(e=zr(t,"color"))!=null?e:t.style.color;return n?.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),PM=ie.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=zr(t,"font-family"))!=null?e:t.style.fontFamily},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),$M=ie.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=zr(t,"font-size"))!=null?e:t.style.fontSize},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),zM=ie.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>{var e;return(e=zr(t,"line-height"))!=null?e:t.style.lineHeight},renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),BM=ie.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(IM.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(DM.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(PM.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push($M.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(zM.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(LM.configure(this.options.textStyle)),t}}),_M=t=>Ie({find:/--$/,replace:t??"â"}),HM=t=>Ie({find:/\.\.\.$/,replace:t??"â¦"}),qa=t=>Ie({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"â"}),Ka=t=>Ie({find:/"$/,replace:t??"â"}),Ja=t=>Ie({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"â"}),Ga=t=>Ie({find:/'$/,replace:t??"â"}),FM=t=>Ie({find:/<-$/,replace:t??"â"}),VM=t=>Ie({find:/->$/,replace:t??"â"}),jM=t=>Ie({find:/\(c\)$/,replace:t??"©"}),WM=t=>Ie({find:/\(tm\)$/,replace:t??"â¢"}),UM=t=>Ie({find:/\(sm\)$/,replace:t??"â "}),qM=t=>Ie({find:/\(r\)$/,replace:t??"®"}),KM=t=>Ie({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),JM=t=>Ie({find:/\+\/-$/,replace:t??"±"}),GM=t=>Ie({find:/!=$/,replace:t??"â "}),YM=t=>Ie({find:/<<$/,replace:t??"«"}),QM=t=>Ie({find:/>>$/,replace:t??"»"}),XM=t=>Ie({find:/\d+\s?([*x])\s?\d+$/,replace:t??"Ã"}),ZM=t=>Ie({find:/\^2$/,replace:t??"²"}),eT=t=>Ie({find:/\^3$/,replace:t??"³"}),tT=t=>Ie({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),nT=t=>Ie({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),rT=ie.create({name:"typography",addOptions(){return{closeDoubleQuote:"â",closeSingleQuote:"â",copyright:"©",ellipsis:"â¦",emDash:"â",laquo:"«",leftArrow:"â",multiplication:"Ã",notEqual:"â ",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"â",openSingleQuote:"â",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"â",servicemark:"â ",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"â¢"}},addInputRules(){var t,e;const n=[];this.options.emDash!==!1&&n.push(_M(this.options.emDash)),this.options.ellipsis!==!1&&n.push(HM(this.options.ellipsis));const r=this.editor.options.textDirection==="rtl";if((t=this.options.doubleQuotes)!=null&&t.rtl){const{open:s,close:i}=this.options.doubleQuotes.rtl;n.push(qa(s)),n.push(Ka(i))}else r?(n.push(qa("â")),n.push(Ka("â"))):(this.options.openDoubleQuote!==!1&&n.push(qa(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&n.push(Ka(this.options.closeDoubleQuote)));if((e=this.options.singleQuotes)!=null&&e.rtl){const{open:s,close:i}=this.options.singleQuotes.rtl;n.push(Ja(s)),n.push(Ga(i))}else r?(n.push(Ja("â")),n.push(Ga("â"))):(this.options.openSingleQuote!==!1&&n.push(Ja(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&n.push(Ga(this.options.closeSingleQuote)));return this.options.leftArrow!==!1&&n.push(FM(this.options.leftArrow)),this.options.rightArrow!==!1&&n.push(VM(this.options.rightArrow)),this.options.copyright!==!1&&n.push(jM(this.options.copyright)),this.options.trademark!==!1&&n.push(WM(this.options.trademark)),this.options.servicemark!==!1&&n.push(UM(this.options.servicemark)),this.options.registeredTrademark!==!1&&n.push(qM(this.options.registeredTrademark)),this.options.oneHalf!==!1&&n.push(KM(this.options.oneHalf)),this.options.plusMinus!==!1&&n.push(JM(this.options.plusMinus)),this.options.notEqual!==!1&&n.push(GM(this.options.notEqual)),this.options.laquo!==!1&&n.push(YM(this.options.laquo)),this.options.raquo!==!1&&n.push(QM(this.options.raquo)),this.options.multiplication!==!1&&n.push(XM(this.options.multiplication)),this.options.superscriptTwo!==!1&&n.push(ZM(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&n.push(eT(this.options.superscriptThree)),this.options.oneQuarter!==!1&&n.push(tT(this.options.oneQuarter)),this.options.threeQuarters!==!1&&n.push(nT(this.options.threeQuarters)),n}}),sT=/^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/,iT=/^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/g,Qc=t=>t.match(sT),uh=(t,e)=>e?"https://www.youtube-nocookie.com/embed/videoseries?list=":t?"https://www.youtube-nocookie.com/embed/":"https://www.youtube.com/embed/",oT=t=>{const{url:e,allowFullscreen:n,autoplay:r,ccLanguage:s,ccLoadPolicy:i,controls:o,disableKBcontrol
212s:a,enableIFrameApi:l,endTime:c,interfaceLanguage:u,ivLoadPolicy:d,loop:h,modestBranding:f,nocookie:p,origin:m,playlist:g,progressBarColor:y,startAt:v,rel:C}=t;if(!Qc(e))return null;if(e.includes("/embed/"))return e;if(e.includes("youtu.be")){const $=e.split("/").pop();return $?`${uh(p)}${$}`:null}const M=/(?:(v|list)=|shorts\/)([-\w]+)/gm.exec(e);if(!M||!M[2])return null;let I=`${uh(p,M[1]==="list")}${M[2]}`;const R=[];return n===!1&&R.push("fs=0"),r&&R.push("autoplay=1"),s&&R.push(`cc_lang_pref=${s}`),i&&R.push("cc_load_policy=1"),o||R.push("controls=0"),a&&R.push("disablekb=1"),l&&R.push("enablejsapi=1"),c&&R.push(`end=${c}`),u&&R.push(`hl=${u}`),d&&R.push(`iv_load_policy=${d}`),h&&R.push("loop=1"),f&&R.push("modestbranding=1"),m&&R.push(`origin=${m}`),g&&R.push(`playlist=${g}`),v&&R.push(`start=${v}`),y&&R.push(`color=${y}`),C!==void 0&&R.push(`rel=${C}`),R.length&&(I+=`${M[1]==="list"?"&":"?"}${R.join("&")}`),I},aT=t=>{let e;try{e=new URL(t)}catch{return null}const n=e.hostname.replace(/^www\./,"");if(n!=="youtube.com"&&n!=="youtube-nocookie.com")return null;let r=null;if(e.pathname==="/embed/videoseries"){const o=e.searchParams.get("list");if(!o)return null;r=`https://www.youtube.com/playlist?list=${o}`}else{const o=e.pathname.match(/^\/embed\/([\w-]+)$/);if(!o?.[1])return null;r=`https://www.youtube.com/watch?v=${o[1]}`}if(!Qc(r))return null;const s={src:r},i=e.searchParams.get("start");if(i){const o=Number.parseInt(i,10);Number.isNaN(o)||(s.start=o)}return s},dh=t=>{if(!t)return null;const e=Number.parseInt(t,10);return Number.isNaN(e)?null:e},hh=t=>{const e=t.getAttribute("src");if(!e)return null;const n=aT(e);return n||{src:e}},lT=Ae.create({name:"youtube",addOptions(){return{addPasteHandler:!0,allowFullscreen:!0,autoplay:!1,ccLanguage:void 0,ccLoadPolicy:void 0,controls:!0,disableKBcontrols:!1,enableIFrameApi:!1,endTime:0,height:480,interfaceLanguage:void 0,ivLoadPolicy:0,loop:!1,modestBranding:!1,HTMLAttributes:{},inline:!1,nocookie:!1,origin:"",playlist:"",progressBarColor:void 0,width:640,rel:1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null,parseHTML:t=>{var e;return(e=hh(t))==null?void 0:e.src}},start:{default:0,parseHTML:t=>{var e;return(e=hh(t))==null?void 0:e.start}},width:{default:this.options.width,parseHTML:t=>dh(t.getAttribute("width"))},height:{default:this.options.height,parseHTML:t=>dh(t.getAttribute("height"))}}},parseHTML(){return[{tag:"div[data-youtube-video] iframe"}]},addCommands(){return{setYoutubeVideo:t=>({commands:e})=>Qc(t.src)?e.insertContent({type:this.name,attrs:t}):!1}},addPasteRules(){return this.options.addPasteHandler?[tm({find:iT,type:this.type,getAttributes:t=>({src:t.input})})]:[]},renderHTML({HTMLAttributes:t}){const e=oT({url:t.src,allowFullscreen:this.options.allowFullscreen,autoplay:this.options.autoplay,ccLanguage:this.options.ccLanguage,ccLoadPolicy:this.options.ccLoadPolicy,controls:this.options.controls,disableKBcontrols:this.options.disableKBcontrols,enableIFrameApi:this.options.enableIFrameApi,endTime:this.options.endTime,interfaceLanguage:this.options.interfaceLanguage,ivLoadPolicy:this.options.ivLoadPolicy,loop:this.options.loop,modestBranding:this.options.modestBranding,nocookie:this.options.nocookie,origin:this.options.origin,playlist:this.options.playlist,progressBarColor:this.options.progressBarColor,startAt:t.start||0,rel:this.options.rel});return t.src=e,["div",{"data-youtube-video":""},["iframe",he(this.options.HTMLAttributes,{width:this.options.width,height:this.options.height,allowfullscreen:this.options.allowFullscreen,autoplay:this.options.autoplay,ccLanguage:this.options.ccLanguage,ccLoadPolicy:this.options.ccLoadPolicy,disableKBcontrols:this.options.disableKBcontrols,enableIFrameApi:this.options.enableIFrameApi,endTime:this.options.endTime,interfaceLanguage:this.options.interfaceLanguage,ivLoadPolicy:this.options.ivLoadPolicy,loop:this.options.loop,modestBranding:this.options.modestBranding,origin:this.options.origin,playlist:this.options.playlist,progressBarColor:this.options.progressBarColor,rel:this.options.rel},t)]]},...Mc({nodeName:"youtube",allowedAttributes:["src","width","height","start"]})}),cT=/^(https?:\/\/)?(www\.)?(twitch\.tv|clips\.twitch\.tv)\/(?:videos\/(\d+)|(\w+)\/clip\/([\w-]+)|([\w-]+)(?:\/)?)?(\?.*)?$/,uT=/^(https?:\/\/)?(www\.)?(twitch\.tv|clips\.twitch\.tv)\/(?:videos\/(\d+)|(\w+)\/clip\/([\w-]+)|([\w-]+)(?:\/)?)?(\?.*)?$/g,Xo=t=>t.match(cT),dT=t=>{if(!Xo(t))return null;const e=t.split("?")[0];if(e.includes("clips.twitch.tv/")){const n=/clips\.twitch\.tv\/([\w-]+)/,r=e.match(n);return r?{type:"clip",id:r[1]}:null}if(e.includes("twitch.tv/")){const n=/twitch\.tv\/videos\/(\d+)/,r=e.match(n);if(r)return{type:"video",id:r[1]};const s=/twitch\.tv\/([\w-]+)\/clip\/([\w-]+)/,i=e.match(s);if(i)return{type:"clip",id:i[2]};const o=/twitch\.tv\/([\w-]+)(?:\/)?$/,a=e.match(o);if(a)return{type:"channel",id:a[1]}}return null},hT=t=>{const{url:e,allowFullscreen:n=!0,autoplay:r=!1,muted:s=!1,time:i,parent:o}=t,a=dT(e);if(!a)return null;const l=o||"localhost";if(a.type==="clip"){const c=new URL("https://clips.twitch.tv/embed");
212return c.searchParams.set("clip",a.id),c.searchParams.set("parent",l),r&&c.searchParams.set("autoplay","true"),s&&c.searchParams.set("muted","true"),c.toString()}if(a.type==="video"){const c=new URL("https://player.twitch.tv/");return c.searchParams.set("video",a.id),c.searchParams.set("parent",l),n&&c.searchParams.set("allowfullscreen","true"),r&&c.searchParams.set("autoplay","true"),s&&c.searchParams.set("muted","true"),i&&c.searchParams.set("time",i),c.toString()}if(a.type==="channel"){const c=new URL("https://player.twitch.tv/");return c.searchParams.set("channel",a.id),c.searchParams.set("parent",l),n&&c.searchParams.set("allowfullscreen","true"),r&&c.searchParams.set("autoplay","true"),s&&c.searchParams.set("muted","true"),c.toString()}return null},fT=t=>{let e;try{e=new URL(t)}catch{return null}const n=e.hostname.replace(/^www\./,""),r={src:""};if(n==="player.twitch.tv"){const i=e.searchParams.get("video"),o=e.searchParams.get("channel");if(i)r.src=`https://www.twitch.tv/videos/${i}`;else if(o)r.src=`https://www.twitch.tv/${o}`;else return null}else if(n==="clips.twitch.tv"&&e.pathname==="/embed"){const i=e.searchParams.get("clip");if(!i)return null;r.src=`https://clips.twitch.tv/${i}`}else return null;e.searchParams.get("autoplay")==="true"&&(r.autoplay=!0),e.searchParams.get("muted")==="true"&&(r.muted=!0);const s=e.searchParams.get("time");return s&&(r.time=s),Xo(r.src)?r:null},fh=t=>{if(!t)return null;const e=Number.parseInt(t,10);return Number.isNaN(e)?null:e},wi=t=>{const e=t.getAttribute("src");if(!e)return null;const n=fT(e);return n||(Xo(e)?{src:e}:{src:e})},pT=Ae.create({name:"twitch",addOptions(){return{addPasteHandler:!0,allowFullscreen:!0,autoplay:!1,muted:!1,time:void 0,parent:"localhost",height:480,width:640,HTMLAttributes:{},inline:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null,parseHTML:t=>{var e;return(e=wi(t))==null?void 0:e.src}},width:{default:this.options.width,parseHTML:t=>fh(t.getAttribute("width"))},height:{default:this.options.height,parseHTML:t=>fh(t.getAttribute("height"))},autoplay:{default:this.options.autoplay,parseHTML:t=>{var e;return(e=wi(t))==null?void 0:e.autoplay}},muted:{default:this.options.muted,parseHTML:t=>{var e;return(e=wi(t))==null?void 0:e.muted}},time:{default:this.options.time,parseHTML:t=>{var e;return(e=wi(t))==null?void 0:e.time}}}},parseHTML(){return[{tag:"div[data-twitch-video] iframe"}]},addCommands(){return{setTwitchVideo:t=>({commands:e})=>Xo(t.src)?e.insertContent({type:this.name,attrs:t}):!1}},addPasteRules(){return this.options.addPasteHandler?[tm({find:uT,type:this.type,getAttributes:t=>({src:t.input})})]:[]},renderHTML({HTMLAttributes:t}){var e,n,r;const s=hT({url:t.src,allowFullscreen:this.options.allowFullscreen,autoplay:(e=t.auto
212play)!=null?e:this.options.autoplay,muted:(n=t.muted)!=null?n:this.options.muted,time:(r=t.time)!=null?r:this.options.time,parent:this.options.parent});return s?(t.src=s,["div",{"data-twitch-video":""},["iframe",he(this.options.HTMLAttributes,{width:this.options.width,height:this.options.height,allowfullscreen:this.options.allowFullscreen,scrolling:"no",frameborder:"0"},t)]]):["div","Invalid Twitch URL"]},...Mc({nodeName:"twitch",allowedAttributes:["src","width","height","autoplay","muted","time"]})});function mT(t,e,n){return Bg(t,e,n)}async function ph({setId:t,file:e}){const n=new FormData;n.append("action","docs:uploadImage"),n.append("setId",String(Number(t||0))),n.append("file",e);const r=await fetch("/api",{method:"POST",body:n});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);const s=await r.json(),i=Array.isArray(s)?s[0]:s;if(!i?.success)throw new Error(i?.reason||"Image upload failed.");return{id:Number(i.id||0),value:i.value||{},url:mT(t,i.id,i.value)}}function gT(t={}){const e=xs(t);return`graph[${e.expression}][${e.xmin}][${e.xmax}]`}const yT=Ae.create({name:"docGraph",group:"inline",inline:!0,atom:!0,draggable:!0,addOptions(){return{onClick:void 0}},addAttributes(){return{expression:{default:"x^2",parseHTML:t=>t.getAttribute("data-expression")||"x^2",renderHTML:t=>({"data-expression":t.expression||"x^2"})},xmin:{default:yr.xmin,parseHTML:t=>t.getAttribute("data-xmin")||yr.xmin,renderHTML:t=>({"data-xmin":String(t.xmin??yr.xmin)})},xmax:{default:yr.xmax,parseHTML:t=>t.getAttribute("data-xmax")||yr.xmax,renderHTML:t=>({"data-xmax":String(t.xmax??yr.xmax)})}}},parseHTML(){return[{tag:'span[data-type="doc-graph"]'}]},renderHTML({HTMLAttributes:t}){return["span",he(t,{"data-type":"doc-graph"})]},parseMarkdown:t=>({type:"docGraph",attrs:xs(t)}),renderMarkdown:t=>gT(t.attrs),markdownTokenizer:{name:"docGraph",level:"inline",start:t=>t.indexOf("graph["),tokenize:t=>{const e=jh(t).find(n=>n.start===0);if(e)return{type:"docGraph",raw:e.raw,expression:e.expression,xmin:e.xmin,xmax:e.xmax}}},addCommands(){return{insertDocGraph:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:xs(t)})}},addNodeView(){const t=this.options.onClick;return({node:e,getPos:n})=>{const r=document.createElement("span");r.className="docs-graph-node",r.dataset.type="doc-graph",r.contentEditable="false";const s=document.createElement("span");s.className="docs-graph-node-header",s.textContent="Edit Graph",s.setAttribute("role","button"),s.setAttribute("tabindex","0"),s.setAttribute("aria-label","Edit Graph"),s.contentEditable="false";const i=document.createElement("div");i.className="docs-graph-stage",i.contentEditable="false",r.append(s),r.append(i);let o=e,a=0,l=null;function c(){const f=a+1;a=f,l?.(),l=null,wy(i,o.attrs).then(p=>{f===a?l=p:p?.()}).catch(()=>{f===a&&(i.textContent="Graph unavailable")})}function u(f){f.preventDefault(),f.stopPropagation();const p=typeof n=="function"?n():-1;p>=0&&t?.(o,p)}function d(f){f.key!=="Enter"&&f.key!==" "||u(f)}function h(f){f.target?.closest?.(".docs-graph-node-header, .js-plotly-plot")||u(f)}return s.addEventListener("click",u),s.addEventListener("keydown",d),r.addEventListener("click",h),c(),{dom:r,update(f){return f.type.name!==o.type.name?!1:(o=f,c(),!0)},destroy(){a+=1,l?.(),l=null,s.removeEventListener("click",u),s.removeEventListener("keydown",d),r.removeEventListener("click",h)}}}}}),xn=`flowchart TD 213 A[Start] --> B[End]`,bT=Ae.create({name:"docMermaid",group:"block",atom:!0,draggable:!0,addOptions(){return{onClick:void 0}},addAttributes(){return{code:{default:xn,parseHTML:t=>t.textContent?.trim()||xn,renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="doc-mermaid"]'}]},renderHTML({node:t,HTMLAttributes:e}){return["div",he(e,{"data-type":"doc-mermaid"}),String(t.attrs.code||"")]},parseMarkdown:t=>({type:"docMermaid",attrs:{code:String(t.text||"").trim()||xn}}),renderMarkdown:t=>`\`\`\`mermaid 214${String(t.attrs.code||"").trim()} 215\`\`\``,addCommands(){return{insertDocMermaid:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{code:String(t.code||xn).trim()||xn}})}},addNodeView(){const t=this.options.onClick;return({node:e,getPos:n})=>{const r=document.createElement("div");r.className="docs-mermaid-node",r.dataset.type="doc-mermaid",r.contentEditable="false";const s=document.createElement("div");s.className="docs-mermaid-node-header",s.textContent="Edit Flowchart",s.setAttribute("role","button"),s.setAttribute("tabindex","0"),s.setAttribute("aria-label","Edit Flowchart"),s.contentEditable="false";const i=document.createElement("div");i.className="docs-mermaid-stage",i.contentEditable="false",r.append(s,i);let o=e,a=0,l=null;function c(){const f=a+1;a=f,l?.(),l=null,Fg(i,o.attrs.code).then(p=>{f===a?l=p:p?.()})}function u(f){f.preventDefault(),f.stopPropagation();const p=typeof n=="function"?n():-1;p>=0&&t?.(o,p)}function d(f){f.key!=="Enter"&&f.key!==" "||u(f)}function h(f){f.target?.closest?.(".docs-mermaid-node-header")||u(f)}return s.addEventListener("click",u),s.addEventListener("keydown",d),r.addEventListener("click",h),c(),{dom:r,update(f){return f.type.n
215ame!==o.type.name?!1:(o=f,c(),!0)},destroy(){a+=1,l?.(),l=null,s.removeEventListener("click",u),s.removeEventListener("keydown",d),r.removeEventListener("click",h)}}}}});var Ya,mh;function kT(){if(mh)return Ya;mh=1;function t(x){return x instanceof Map?x.clear=x.delete=x.set=function(){throw new Error("map is read-only")}:x instanceof Set&&(x.add=x.clear=x.delete=function(){throw new Error("set is read-only")}),Object.freeze(x),Object.getOwnPropertyNames(x).forEach(E=>{const P=x[E],X=typeof P;(X==="object"||X==="function")&&!Object.isFrozen(P)&&t(P)}),x}class e{constructor(E){E.data===void 0&&(E.data={}),this.data=E.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(x){return x.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(x,...E){const P=Object.create(null);for(const X in x)P[X]=x[X];return E.forEach(function(X){for(const Ne in X)P[Ne]=X[Ne]}),P}const s="</span>",i=x=>!!x.scope,o=(x,{prefix:E})=>{if(x.startsWith("language:"))return x.replace("language:","language-");if(x.includes(".")){const P=x.split(".");return[`${E}${P.shift()}`,...P.map((X,Ne)=>`${X}${"_".repeat(Ne+1)}`)].join(" ")}return`${E}${x}`};class a{constructor(E,P){this.buffer="",this.classPrefix=P.classPrefix,E.walk(this)}addText(E){this.buffer+=n(E)}openNode(E){if(!i(E))return;const P=o(E.scope,{prefix:this.classPrefix});this.span(P)}closeNode(E){i(E)&&(this.buffer+=s)}value(){return this.buffer}span(E){this.buffer+=`<span class="${E}">`}}const l=(x={})=>{const E={children:[]};return Object.assign(E,x),E};class c{constructor(){this.rootNode=l(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(E){this.top.children.push(E)}openNode(E){const P=l({scope:E});this.add(P),this.stack.push(P)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(E){return this.constructor._walk(E,this.rootNode)}static _walk(E,P){return typeof P=="string"?E.addText(P):P.children&&(E.openNode(P),P.children.forEach(X=>this._walk(E,X)),E.closeNode(P)),E}static _collapse(E){typeof E!="string"&&E.children&&(E.children.every(P=>typeof P=="string")?E.children=[E.children.join("")]:E.children.forEach(P=>{c._collapse(P)}))}}class u extends c{constructor(E){super(),this.options=E}addText(E){E!==""&&this.add(E)}startScope(E){this.openNode(E)}endScope(){this.closeNode()}__addSublanguage(E,P){const X=E.root;P&&(X.scope=`language:${P}`),this.add(X)}toHTML(){return new a(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(x){return x?typeof x=="string"?x:x.source:null}function h(x){return m("(?=",x,")")}function f(x){return m("(?:",x,")*")}function p(x){return m("(?:",x,")?")}function m(...x){return x.map(P=>d(P)).join("")}function g(x){const E=x[x.length-1];return typeof E=="object"&&E.constructor===Object?(x.splice(x.length-1,1),E):{}}function y(...x){return"("+(g(x).capture?"":"?:")+x.map(X=>d(X)).join("|")+")"}function v(x){return new RegExp(x.toString()+"|").exec("").length-1}function C(x,E){const P=x&&x.exec(E);return P&&P.index===0}const N=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function M(x,{joinWith:E}){let P=0;return x.map(X=>{P+=1;const Ne=P;let Me=d(X),b="";for(;Me.length>0;){const k=N.exec(Me);if(!k){b+=Me;break}b+=Me.substring(0,k.index),Me=Me.substring(k.index+k[0].length),k[0][0]==="\\"&&k[1]?b+="\\"+String(Number(k[1])+Ne):(b+=k[0],k[0]==="("&&P++)}return b}).map(X=>`(${X})`).join(E)}const I=/\b\B/,R="[a-zA-Z]\\w*",$="[a-zA-Z_]\\w*",W="\\b\\d+(\\.\\d+)?",F="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Z="\\b(0b[01]+)",ne="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",G=(x={})=>{const E=/^#![ ]*\//;return x.binary&&(x.begin=m(E,/.*\b/,x.binary,/\b.*/)),r({scope:"meta",begin:E,end:/$/,relevance:0,"on:begin":(P,X)=>{P.index!==0&&X.ignoreMatch()}},x)},_={begin:"\\\\[\\s\\S]",relevance:0},ee={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[_]},Ce={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[_]},at={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},qe=function(x,E,P={}){const X=r({scope:"comment",begin:x,end:E,contains:[]},P);X.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});
vendor: 4,071 bytes, line 215
215const Ne=y("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return X.contains.push({begin:m(/[ ]+/,"(",Ne,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),X},Y=qe("//","$"),Ze=qe("/\\*","\\*/"),ye=qe("#","$"),Be={scope:"number",begin:W,relevance:0},et={scope:"number",begin:F,relevance:0},In={scope:"number",begin:Z,relevance:0},Nt={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[_,{begin:/\[/,end:/\]/,relevance:0,contains:[_]}]},dt={scope:"title",begin:R,relevance:0},Rt={scope:"title",begin:$,relevance:0},Ot={begin:"\\.\\s*"+$,relevance:0};var kt=Object.freeze({__proto__:null,APOS_STRING_MODE:ee,BACKSLASH_ESCAPE:_,BINARY_NUMBER_MODE:In,BINARY_NUMBER_RE:Z,COMMENT:qe,C_BLOCK_COMMENT_MODE:Ze,C_LINE_COMMENT_MODE:Y,C_NUMBER_MODE:et,C_NUMBER_RE:F,END_SAME_AS_BEGIN:function(x){return Object.assign(x,{"on:begin":(E,P)=>{P.data._beginMatch=E[1]},"on:end":(E,P)=>{P.data._beginMatch!==E[1]&&P.ignoreMatch()}})},HASH_COMMENT_MODE:ye,IDENT_RE:R,MATCH_NOTHING_RE:I,METHOD_GUARD:Ot,NUMBER_MODE:Be,NUMBER_RE:W,PHRASAL_WORDS_MODE:at,QUOTE_STRING_MODE:Ce,REGEXP_MODE:Nt,RE_STARTERS_RE:ne,SHEBANG:G,TITLE_MODE:dt,UNDERSCORE_IDENT_RE:$,UNDERSCORE_TITLE_MODE:Rt});function ea(x,E){x.input[x.index-1]==="."&&E.ignoreMatch()}function ta(x,E){x.className!==void 0&&(x.scope=x.className,delete x.className)}function na(x,E){E&&x.beginKeywords&&(x.begin="\\b("+x.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",x.__beforeBegin=ea,x.keywords=x.keywords||x.beginKeywords,delete x.beginKeywords,x.relevance===void 0&&(x.relevance=0))}function Vs(x,E){Array.isArray(x.illegal)&&(x.illegal=y(...x.illegal))}function js(x,E){if(x.match){if(x.begin||x.end)throw new Error("begin & end are not supported with match");x.begin=x.match,delete x.match}}function Ws(x,E){x.relevance===void 0&&(x.relevance=1)}const _r=(x,E)=>{if(!x.beforeMatch)return;if(x.starts)throw new Error("beforeMatch cannot be used with starts");const P=Object.assign({},x);Object.keys(x).forEach(X=>{delete x[X]}),x.keywords=P.keywords,x.begin=m(P.beforeMatch,h(P.begin)),x.starts={relevance:0,contains:[Object.assign(P,{endsParent:!0})]},x.relevance=0,delete P.beforeMatch},Us=["of","and","for","in","not","or","if","then","parent","list","value"],ra="keyword";function qs(x,E,P=ra){const X=Object.create(null);return typeof x=="string"?Ne(P,x.split(" ")):Array.isArray(x)?Ne(P,x):Object.keys(x).forEach(function(Me){Object.assign(X,qs(x[Me],E,Me))}),X;function Ne(Me,b){E&&(b=b.map(k=>k.toLowerCase())),b.forEach(function(k){const w=k.split("|");X[w[0]]=[Me,Ks(w[0],w[1])]})}}function Ks(x,E){return E?Number(E):sa(x)?0:1}function sa(x){return Us.includes(x.toLowerCase())}const Hr={},Vt=x=>{console.error(x)},Js=(x,...E)=>{console.log(`WARN: ${x}`,...E)},jt=(x,E)=>{Hr[`${x}/${E}`]||(console.log(`Deprecated as of ${x}. ${E}`),Hr[`${x}/${E}`]=!0)},hr=new Error;function Gs(x,E,{key:P}){let X=0;const Ne=x[P],Me={},b={};for(let k=1;k<=E.length;k++)b[k+X]=Ne[k],Me[k+X]=!0,X+=v(E[k-1]);x[P]=b,x[P]._emit=Me,x[P]._multi=!0}function ia(x){if(Array.isArray(x.begin)){if(x.skip||x.excludeBegin||x.returnBegin)throw Vt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),hr;if(typeof x.beginScope!="object"||x.beginScope===null)throw Vt("beginScope must be object"),hr;Gs(x,x.begin,{key:"beginScope"}),x.begin=M(x.begin,{joinWith:""})}}function oa(x){if(Array.isArray(x.end)){if(x.skip||x.excludeEnd||x.returnEnd)throw Vt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),hr;if(typeof x.endScope!="object"||x.endScope===null)throw Vt("endScope must be object"),hr;Gs(x,x.end,{key:"endScope"}),x.end=M(x.end,{joinWith:""})}}function aa(x){x.scope&&typeof x.scope=="object"&&x.scope!==null&&(x.beginScope=x.scope,delete x.scope)}function la(x){aa(x),typeof x.beginScope=="string"&&(x.beginScope={_wrap:x.beginScope}),typeof x.endScope=="string"&&(x.endScope={_wrap:x.endScope}),ia(x),oa(x)}function ca(x){function E(b,k){return new RegExp(d(b),"m"+(x.case_insensitive?"i":"")+(x.unicodeRegex?"u":"")+(k?"g"
215:""))}class P{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(k,w){w.position=this.position++,this.matchIndexes[this.matchAt]=w,this.regexes.push([w,k]),this.matchAt+=v(k)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const k=this.regexes.map(w=>w[1]);this.matcherRe=E(M(k,{joinWith:"|"}),!0),this.lastIndex=0}exec(k){this.matcherRe.lastIndex=this.lastIndex;const w=this.matcherRe.exec(k);if(!w)return null;const S=w.findIndex((z,V)=>V>0&&z!==void 0),T=this.matchIndexes[S];return w.splice(0,S),Object.assign(w,T)}}class X{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(k){if(this.multiRegexes[k])return this.multiRegexes[k];const w=new P;return this.rules.slice(k).forEach(([S,T])=>w.addRule(S,T)),w.compile(),this.multiRegexes[k]=w,w}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(k,w){this.rules.push([k,w]),w.type==="begin"&&this.count++}exec(k){const w=this.getMatcher(this.regexIndex);w.lastIndex=this.lastIndex;let S=w.exec(k);if(this.resumingScanAtSamePosition()&&!(S&&S.index===this.lastIndex)){const T=this.getMatcher(0);T.lastIndex=this.lastIndex+1,S=T.exec(k)}return S&&(this.regexIndex+=S.position+1,this.regexIndex===this.count&&this.considerAll()),S}}function Ne(b){const k=new X;return b.contains.forEach(w=>k.addRule(w.begin,{rule:w,type:"begin"})),b.terminatorEnd&&k.addRule(b.terminatorEnd,{type:"end"}),b.illegal&&k.addRule(b.illegal,{type:"illegal"}),k}function Me(b,k){const w=b;if(b.isCompiled)return w;[ta,js,la,_r].forEach(T=>T(b,k)),x.compilerExtensions.forEach(T=>T(b,k)),b.__beforeBegin=null,[na,Vs,Ws].forEach(T=>T(b,k)),b.isCompiled=!0;let S=null;return typeof b.keywords=="object"&&b.keywords.$pattern&&(b.keywords=Object.assign({},b.keywords),S=b.keywords.$pattern,delete b.keywords.$pattern),S=S||/\w+/,b.keywords&&(b.keywords=qs(b.keywords,x.case_insensitive)),w.keywordPatternRe=E(S,!0),k&&(b.begin||(b.begin=/\B|\b/),w.beginRe=E(w.begin),!b.end&&!b.endsWithParent&&(b.end=/\B|\b/),b.end&&(w.endRe=E(w.end)),w.terminatorEnd=d(w.end)||"",b.endsWithParent&&k.terminatorEnd&&(w.terminatorEnd+=(b.end?"|":"")+k.terminatorEnd)),b.illegal&&(w.illegalRe=E(b.illegal)),b.contains||(b.contains=[]),b.contains=[].concat(...b.contains.map(function(T){return ua(T==="self"?b:T)})),b.contains.forEach(function(T){Me(T,w)}),b.starts&&Me(b.starts,k),w.matcher=Ne(w),w}if(x.compilerExtensions||(x.compilerExtensions=[]),x.contains&&x.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return x.classNameAliases=r(x.classNameAliases||{}),Me(x)}function Ys(x){return x?x.endsWithParent||Ys(x.starts):!1}function ua(x){return x.variants&&!x.cachedVariants&&(x.cachedVariants=x.variants.map(function(E){return r(x,{variants:null},E)})),x.cachedVariants?x.cachedVariants:Ys(x)?r(x,{starts:x.starts?r(x.starts):null}):Object.isFrozen(x)?r(x):x}var Fr="11.11.1";class Vr extends Error{constructor(E,P){super(E),this.name="HTMLInjectionError",this.html=P}}const ln=n,fr=r,pr=Symbol("nomatch"),mr=7,jr=function(x){const E=Object.create(null),P=Object.create(null),X=[];let Ne=!0;const Me="Could not find the language '{}', did you forget to load/include a language module?",b={disableAutodetect:!0,name:"Plain text",contains:[]};let k={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function w(L){return k.noHighlightRe.test(L)}function S(L){let K=L.className+" ";K+=L.parentNode?L.parentNode.className:"";const le=k.languageDetectRe.exec(K);if(le){const be=un(le[1]);return be||(Js(Me.replace("{}",le[1])),Js("Falling back to no-highlight mode for this block.",L)),be?le[1]:"no-highlight"}return K.split(/\s+/).find(be=>w(be)||un(be))}function T(L,K,le){let be="",ze="";typeof K=="object"?(be=L,le=K.ignoreIllegals,ze=K.language):(jt("10.7.0","highlight(lang, code, ...args) has been deprecated."),jt("10.7.0",`Please use highlight(code, options) instead. 216https://github.com/highlightjs/highlight.js/issues/2277`),ze=L,be=K),le===void 0&&(le=!0);const xt={code:be,language:ze};Xs("before:highlight",xt);const dn=xt.result?xt.result:z(xt.language,xt.code,le);return dn.code=xt.code,Xs("after:highlight",dn),dn}function z(L,K,le,be){const ze=Object.create(null);function xt(B,q){return B.keywords[q]}function dn(){if(!te.keywords){Ve.addText(ke);return}let B=0;te.keywordPatternRe.lastIndex=0;let q=te.keywordPatternRe.exec(ke),re="";for(;q;){re+=ke.substring(B,q.index);const pe=It.case_insensitive?q[0].toLowerCase():q[0],Je=xt(te,pe);if(Je){const[Wt,Og]=Je;if(Ve.addText(re),re="",ze[pe]=(ze[pe]||0)+1,ze[pe]<=mr&&(ti+=Og),Wt.startsWith("_"))re+=q[0];else{const Lg=It.classNameAliases[Wt]||Wt;Lt(q[0],Lg)}}else re+=q[0];B=te.keywordPatternRe.lastIndex,q=te.keywordPatternRe.exec(ke)}re+=ke.substring(B),Ve.addText(re)}function Zs(){if(ke==="")return;let B=null;if(typeof te.subLanguage=="string"){if(!E[te.subLanguage]){Ve.addText(ke);return}B=z(te.subLanguage,ke,!0,ou[te.subLanguage]),ou[te.subLanguage]=B._top}else B=J(ke,te.subLanguage.length?te.subLanguage:null);te.relevance>0&&(ti+=B.relevance),Ve.__addSublanguage(B._emitter,B.language)}function lt(){te.subLanguage!=null?Zs():dn(),ke=""}function Lt(B,q){B!==""&&(Ve.startScope(q),Ve.addText(B),Ve.endScope())}function nu(B,q){let re=1;const pe=q.length-1;for(;re<=pe;){if(!B._emit[re]){re++;continue}const Je=It.classNameAliases[B[re]]||B[re],Wt=q[re];Je?Lt(Wt,Je):(ke=Wt,dn(),ke=""),re++}}function ru(B,q){return B.scope&&typeof B.scope=="string"&&Ve.openNode(It.classNameAliases[B.scope]||B.scope),B.beginScope&&(B.beginScope._wrap?(Lt(ke,It.classNameAliases[B.beginScope._wrap]||B.beginScope._wrap),ke=""):B.beginScope._multi&&(nu(B.beginScope,q),ke="")),te=Object.create(B,{parent:{value:te}}),te}function su(B,q,re){let pe=C(B.endRe,re);if(pe){if(B["on:end"]){const Je=new e(B);B["on:end"](q,Je),Je.isMatchIgnored&&(pe=!1)}if(pe){for(;B.endsParent&&B.parent;)B=B.parent;return B}}if(B.endsWithParent)return su(B.parent,q,re)}function Tg(B){return te.matcher.regexIndex===0?(ke+=B[0],1):(pa=!0,0)}
216function Eg(B){const q=B[0],re=B.rule,pe=new e(re),Je=[re.__beforeBegin,re["on:begin"]];for(const Wt of Je)if(Wt&&(Wt(B,pe),pe.isMatchIgnored))return Tg(q);return re.skip?ke+=q:(re.excludeBegin&&(ke+=q),lt(),!re.returnBegin&&!re.excludeBegin&&(ke=q)),ru(re,B),re.returnBegin?0:q.length}function Ag(B){const q=B[0],re=K.substring(B.index),pe=su(te,B,re);if(!pe)return pr;const Je=te;te.endScope&&te.endScope._wrap?(lt(),Lt(q,te.endScope._wrap)):te.endScope&&te.endScope._multi?(lt(),nu(te.endScope,B)):Je.skip?ke+=q:(Je.returnEnd||Je.excludeEnd||(ke+=q),lt(),Je.excludeEnd&&(ke=q));do te.scope&&Ve.closeNode(),!te.skip&&!te.subLanguage&&(ti+=te.relevance),te=te.parent;while(te!==pe.parent);return pe.starts&&ru(pe.starts,B),Je.returnEnd?0:q.length}function Ng(){const B=[];for(let q=te;q!==It;q=q.parent)q.scope&&B.unshift(q.scope);B.forEach(q=>Ve.openNode(q))}let ei={};function iu(B,q){const re=q&&q[0];if(ke+=B,re==null)return lt(),0;if(ei.type==="begin"&&q.type==="end"&&ei.index===q.index&&re===""){if(ke+=K.slice(q.index,q.index+1),!Ne){const pe=new Error(`0 width match regex (${L})`);throw pe.languageName=L,pe.badRule=ei.rule,pe}return 1}if(ei=q,q.type==="begin")return Eg(q);if(q.type==="illegal"&&!le){const pe=new Error('Illegal lexeme "'+re+'" for mode "'+(te.scope||"<unnamed>")+'"');throw pe.mode=te,pe}else if(q.type==="end"){const pe=Ag(q);if(pe!==pr)return pe}if(q.type==="illegal"&&re==="")return ke+=` 217`,1;if(fa>1e5&&fa>q.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ke+=re,re.length}const It=un(L);if(!It)throw Vt(Me.replace("{}",L)),new Error('Unknown language: "'+L+'"');const Rg=ca(It);let ha="",te=be||Rg;const ou={},Ve=new k.__emitter(k);Ng();let ke="",ti=0,Dn=0,fa=0,pa=!1;try{if(It.__emitTokens)It.__emitTokens(K,Ve);else{for(te.matcher.considerAll();;){fa++,pa?pa=!1:te.matcher.considerAll(),te.matcher.lastIndex=Dn;const B=te.matcher.exec(K);if(!B)break;const q=K.substring(Dn,B.index),re=iu(q,B);Dn=B.index+re}iu(K.substring(Dn))}return Ve.finalize(),ha=Ve.toHTML(),{language:L,value:ha,relevance:ti,illegal:!1,_emitter:Ve,_top:te}}catch(B){if(B.message&&B.message.includes("Illegal"))return{language:L,value:ln(K),illegal:!0,relevance:0,_illegalBy:{message:B.message,index:Dn,context:K.slice(Dn-100,Dn+100),mode:B.mode,resultSoFar:ha},_emitter:Ve};if(Ne)return{language:L,value:ln(K),illegal:!1,relevance:0,errorRaised:B,_emitter:Ve,_top:te};throw B}}function V(L){const K={value:ln(L),illegal:!1,relevance:0,_top:b,_emitter:new k.__emitter(k)};return K._emitter.addText(L),K}function J(L,K){K=K||k.languages||Object.keys(E);const le=V(L),be=K.filter(un).filter(tu).map(lt=>z(lt,L,!1));be.unshift(le);const ze=be.sort((lt,Lt)=>{if(lt.relevance!==Lt.relevance)return Lt.relevance-lt.relevance;if(lt.language&&Lt.language){if(un(lt.language).supersetOf===Lt.language)return 1;if(un(Lt.language).supersetOf===lt.language)return-1}return 0}),[xt,dn]=ze,Zs=xt;return Zs.secondBest=dn,Zs}function Se(L,K,le){const be=K&&P[K]||le;L.classList.add("hljs"),L.classList.add(`language-${be}`)}function Te(L){let K=null;const le=S(L);if(w(le))return;if(Xs("before:highlightElement",{el:L,language:le}),L.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",L);return}if(L.children.length>
2170&&(k.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(L)),k.throwUnescapedHTML))throw new Vr("One of your code blocks includes unescaped HTML.",L.innerHTML);K=L;const be=K.textContent,ze=le?T(be,{language:le,ignoreIllegals:!0}):J(be);L.innerHTML=ze.value,L.dataset.highlighted="yes",Se(L,le,ze.language),L.result={language:ze.language,re:ze.relevance,relevance:ze.relevance},ze.secondBest&&(L.secondBest={language:ze.secondBest.language,relevance:ze.secondBest.relevance}),Xs("after:highlightElement",{el:L,result:ze,text:be})}function Ke(L){k=fr(k,L)}const gr=()=>{Qs(),jt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function da(){Qs(),jt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Zc=!1;function Qs(){function L(){Qs()}if(document.readyState==="loading"){Zc||window.addEventListener("DOMContentLoaded",L,!1),Zc=!0;return}document.querySelectorAll(k.cssSelector).forEach(Te)}function kg(L,K){let le=null;try{le=K(x)}catch(be){if(Vt("Language definition for '{}' could not be registered.".replace("{}",L)),Ne)Vt(be);else throw be;le=b}le.name||(le.name=L),E[L]=le,le.rawDefinition=K.bind(null,x),le.aliases&&eu(le.aliases,{languageName:L})}function xg(L){delete E[L];for(const K of Object.keys(P))P[K]===L&&delete P[K]}function wg(){return Object.keys(E)}function un(L){return L=(L||"").toLowerCase(),E[L]||E[P[L]]}function eu(L,{languageName:K}){typeof L=="string"&&(L=[L]),L.forEach(le=>{P[le.toLowerCase()]=K})}function tu(L){const K=un(L);return K&&!K.disableAutodetect}function Sg(L){L["before:highlightBlock"]&&!L["before:highlightElement"]&&(L["before:highlightElement"]=K=>{L["before:highlightBlock"](Object.assign({block:K.el},K))}),L["after:highlightBlock"]&&!L["after:highlightElement"]&&(L["after:highlightElement"]=K=>{L["after:highlightBlock"](Object.assign({block:K.el},K))})}function vg(L){Sg(L),X.push(L)}function Cg(L){const K=X.indexOf(L);K!==-1&&X.splice(K,1)}function Xs(L,K){const le=L;X.forEach(function(be){be[le]&&be[le](K)})}function Mg(L){return jt("10.7.0","highlightBlock will be removed entirely in v12.0"),jt("10.7.0","Please use highlightElement now."),Te(L)}Object.assign(x,{highlight:T,highlightAuto:J,highlightAll:Qs,highlightElement:Te,highlightBlock:Mg,configure:Ke,initHighlighting:gr,initHighlightingOnLoad:da,registerLanguage:kg,unregisterLanguage:xg,listLanguages:wg,getLanguage:un,registerAliases:eu,autoDetection:tu,inherit:fr,addPlugin:vg,removePlugin:Cg}),x.debugMode=function(){Ne=!1},x.safeMode=function(){Ne=!0},x.versionString=Fr,x.regex={concat:m,lookahead:h,either:y,optional:p,anyNumberOfTimes:f};for(const L in kt)typeof kt[L]=="object"&&t(kt[L]);return Object.assign(x,kt),x},cn=jr({});return cn.newInstance=()=>jr({}),Ya=cn,cn.HighlightJS=cn,cn.default=cn,Ya}var xT=kT();const wT=Cy(xT);function lg(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?lg(n.children,r):{text:n.value,classes:r}})}function gh(t){return t.value||t.children||[]}function ST(t){return!!wT.getLanguage(t)}function yh({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return xl(t,i=>i.type.name===e).forEach(i=>{var o;let a=i.pos+1;const l=i.node.attrs.language||r,c=n.listLanguages(),u=l&&(c.includes(l)||ST(l)||(o=n.registered)!=null&&o.call(n,l))?gh(n.highlight(l,i.node.textContent)):gh(n.highlightAuto(i.node.textContent));lg(u).forEach(d=>{const h=a+d.text.length;if(d.classes.length){const f=Ee.inline(a,h,{class:d.classes.join(" ")});s.push(f)}a=h})}),ae.create(t,s)}function vT(t){return typeof t=="function"}function CT({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>vT(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new ue({key:new fe("lowlight"),state:{init:(s,{doc:i})=>yh({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,o,a)=>{const l=o.selection.$head.parent.type.name,c=a.selection.$head.parent.type.name,u=xl(o.doc,h=>h.type.name===t),d=xl(a.doc,h=>h.type.name===t);return s.docChanged&&([l,c].includes(t)||d.length!==u.length||s.steps.some(h=>h.from!==void 0&&h.to!==void 0&&u.some(f=>f.pos>
217=h.from&&f.pos+f.node.nodeSize<=h.to)))?yh({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var MT=nm.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],CT({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});const Si=new fe("docsPrismCodeBlock"),cg=jg();function Kl(t){return typeof t=="string"?t.length:Array.isArray(t)?t.reduce((e,n)=>e+Kl(n),0):t&&typeof t=="object"?Kl(t.content):String(t||"").length}function ug(t,e,n){let r=e;(Array.isArray(t)?t:[t]).forEach(s=>{if(typeof s=="string"){r+=s.length;return}const i=Kl(s.content),o=r+i,a=Array.isArray(s.alias)?s.alias:s.alias?[s.alias]:[];o>r&&n.push(Ee.inline(r,o,{class:["token",s.type,...a].join(" ")}
217)),(Array.isArray(s.content)||s.content&&typeof s.content=="object")&&ug(s.content,r,n),r=o})}function bh(t,e="codeBlock"){const n=[];return t.descendants((r,s)=>{if(r.type?.name!==e)return;const{language:i,grammar:o}=Lh(r.attrs?.language);!o||i==="mermaid"||ug(Sy.tokenize(r.textContent,o),s+1,n)}),ae.create(t,n)}function TT(t){const e=t.root.activeElement;if(!e||!t.dom.contains(e))return!1;let n=e;for(;n&&n!==t.dom;){if(n.contentEditable==="true")return!0;if(n.contentEditable==="false")return!1;n=n.parentElement}return n===t.dom}function ET(t="codeBlock"){return new ue({key:Si,state:{init:(e,{doc:n})=>bh(n,t),apply(e,n,r,s){return e.getMeta(Si)?.reload?bh(s.doc,t):n.map(e.mapping,e.doc)}},props:{decorations(e){return Si.getState(e)}},view(e){const n=new Set;let r=0;const s=()=>{if(e.isDestroyed)return;r&&(window.cancelAnimationFrame(r),r=0);const a=TT(e),l=e.state.selection;e.dispatch(e.state.tr.setSelection(l).setMeta(Si,{reload:!0}).setMeta("addToHistory",!1)),a&&e.focus()},i=()=>{r||e.isDestroyed||(r=window.requestAnimationFrame(()=>{r=0,s()}))},o=()=>{const a=new Set;e.state.doc.descendants(l=>{if(l.type?.name!==t)return;const c=Mr(l.attrs?.language);c!=="txt"&&c!=="mermaid"&&a.add(c)}),a.forEach(l=>{n.has(l)||Lh(l).grammar||(n.add(l),Wg(l).then(()=>{e.isDestroyed||s()}).catch(()=>{}).finally(()=>n.delete(l)))})};return o(),i(),{update(a,l){o(),a.state.doc.eq(l.doc)||i()},destroy(){r&&window.cancelAnimationFrame(r),n.clear()}}}})}let pn=null,Qn=null;function AT(){if(pn&&pn.el&&document.body.contains(pn.el))return pn;try{const t=document.body;if(!t)throw new Error("No document root available for code language select.");const e=document.createElement("div");return e.hidden=!0,e.setAttribute("aria-hidden","true"),t.append(e),pn=vy(e,{placeholder:"Code language",search:"on",searchPlaceholder:"Search languages...",choices:cg,callback(n){const r=Qn,s=Mr(n.get());Qn=null,!(!r||!s||s===r.language)&&r.onLanguageChange?.(r.position,s)},closeCallback(){Qn=null}}),pn}catch(t){throw pn=null,t}}function NT(t,e,n,r){const s=AT();Qn=null,s.set(cg,"replace"),s.update(t),Qn={language:t,position:e,onLanguageChange:n,owner:r},s.open()}function RT(t){Qn?.owner===t&&(Qn=null,pn?.close())}const OT=MT.extend({name:"codeBlock",addOptions(){return{...this.parent?.(),onLanguageChange:void 0}},addAttributes(){const t=this.parent?.()||{};return{...t,language:{...t.language,default:"txt",parseHTML:e=>Mr(t.language?.parseHTML?.(e))}}},addProseMirrorPlugins(){return[ET(this.name)]},addNodeView(){const t=this.options.onLanguageChange;return({node:e,getPos:n})=>{const r={},s=document.createElement("pre");s.className="docs-code-block",s.contentEditable="false";const i=document.createElement("div");i.className="docs-node-header docs-code-block-header",i.contentEditable="false";const o=document.createElement("button");o.type="button",o.className="docs-code-language-control",o.setAttribute("aria-haspopup","dialog"),o.contentEditable="false";const a=document.createElement("span");a.className="docs-code-language-label";const l=document.createElement("i");l.className="fa-solid fa-chevron-down docs-code-language-chevron",l.setAttribute("aria-hidden","true"),o.append(a,l);const c=document.createElement("span");c.className="docs-node-header-actions",c.contentEditable="false";const u=document.createElement("button");u.type="button",u.className="docs-node-header-action docs-code-copy tooltip-init",u.dataset.tooltip="Copy code",u.setAttribute("aria-label","Copy code"),u.innerHTML='<i class="fa-regular fa-copy"></i>',c.append(u),i.append(o,c);const d=document.createElement("code");d.contentEditable="true",s.append(i,d);const h=rl();h?.tooltip?.create&&(u.f7Tooltip=h.tooltip.create({targetEl:u,text:"Copy code"}));let f=e,p=Mr(e.attrs?.language);o._docsOpenCodeLanguage=()=>{NT(p,typeof n=="function"?n():-1,t,r)};const m=y=>{y.preventDefault(),y.stopPropagation(),Vg(d.textContent||"")};u.addEventListener("click",m);function g(y){p=Mr(y.attrs?.language),d.className=p==="txt"?"":`language-${p}`,s.dataset.language=p,o.dataset.codeLanguage=p,a.textContent=p,o.setAttribute("aria-label",`Change code language, currently ${p}`)}return g(e),{dom:s,contentDOM:d,update(y){return y.type.name!==f.type.name?!1:(f=y,g(y),!0)},destroy(){u.removeEventListener("click",m),delete o._docsOpenCodeLanguage,RT(r)},stopEvent(y){return!!y.target?.closest?.(".docs-code-copy")}}}}});function kh(t,e={}){Object.entries(e).forEach(([n,r])=>
217{r!=null&&t.setAttribute(n,String(r))})}const LT=vm.extend({name:"taskItem",addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("input"),a=document.createElement("span"),l=document.createElement("div"),c=this.type;i.className="docs-task-checkbox-wrap",i.contentEditable="false",o.className="docs-task-checkbox",o.type="checkbox",o.contentEditable="false",a.className="docs-task-checkbox-icon",a.setAttribute("aria-hidden","true"),l.className="docs-task-item-content",kh(s,this.options.HTMLAttributes),kh(s,e),s.classList.add("docs-task-item");const u=p=>{const m=!!p.attrs?.checked,g=String(p.textContent||"").trim()||"empty task item";s.dataset.type=this.name,s.dataset.checked=String(m),o.checked=m,o.setAttribute("aria-label",this.options.a11y?.checkboxLabel?.(p,m)||(m?"Mark task incomplete: ":"Mark task complete: ")+g)},d=p=>{if(!r.isEditable){o.checked=!p;return}r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const g=n();if(typeof g!="number")return!1;const y=m.doc.nodeAt(g);return!y||y.type!==c?!1:(m.setNodeMarkup(g,void 0,{...y.attrs,checked:p}),!0)}).run()},h=p=>{p.stopPropagation()},f=p=>{p.stopPropagation(),d(!!p.currentTarget.checked)};return i.addEventListener("pointerdown",h),i.addEventListener("mousedown",h),i.addEventListener("click",h),o.addEventListener("change",f),i.append(o,a),s.append(i,l),u(t),{dom:s,contentDOM:l,update(p){return p.type!==c?!1:(u(p),!0)},stopEvent(p){return!!p.target?.closest?.(".docs-task-checkbox-wrap")},ignoreMutation(p){return i.contains(p.target)},destroy(){i.removeEventListener("pointerdown",h),i.removeEventListener("mousedown",h),i.removeEventListener("click",h),o.removeEventListener("change",f)}}}}}),Xn="î",Zn="î";function IT(t){return String(t||"").trim().toLowerCase().replace(/^language-/,"").replace(/^lang-/,"")==="mermaid"}function Ro(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function dg(t,e){return t?.type?.name==="codeBlock"||e.marks?.some(n=>n.type?.name==="code")}function DT(t=""){const e=String(t||""),n=[...hg(e),...fg(e)];let r="";for(let s=0;s<e.length;s+=1){if(e[s]!=="\\"){r+=e[s];continue}let i=s;for(;e[i]==="\\";)i+=1;const o=i-s;if(e[i]==="$"&&o%2===1){r+="\\".repeat(o-1);const a=n.some(({start:l,end:c})=>i>l&&i<c);r+=a?Zn:Xn,s=i;continue}r+="\\".repeat(o),s=i-1}return r}function hg(t=""){const e=String(t||"");if(!e.includes("$$"))return[];const n=[];let r=0;for(;r<e.length;){const s=e.indexOf("$$",r);if(s<0)break;if(Ro(e,s)){r=s+2;continue}let i=e.indexOf("$$",s+2);for(;i>=0&&Ro(e,i);)i=e.indexOf("$$",i+2);if(i<0)break;const o=e.slice(s+2,i);o.trim()&&n.push({start:s,end:i+2,latex:o.trim()}),r=i+2}return n}function fg(t=""){const e=String(t||"");if(!e.includes("$"))return[];const n=[];let r=0;for(;r<e.length;){const s=e.indexOf("$",r);if(s<0)break;if(Ro(e,s)||e[s-1]==="$"||e[s+1]==="$"){r=s+1;continue}let i=s+1;for(;i<e.length&&!(e[i]==="$"&&!Ro(e,i)&&e[i-1]!=="$"&&e[i+1]!=="$");)i+=1;if(i>=e.length)break;const o=e.slice(s+1,i),a=/^\s*\d+(?:[.,]\d+)?\s*$/.test(o),l=/\d/.test(e[i+1]||"");if(!o.trim()||a||l){r=i+1;continue}n.push({start:s,end:i+1,latex:o}),r=i+1}return n}function pg(t,e,n){const r=[];if(t.state.doc.descendants((i,o,a)=>{if(!i.isText||!i.text||dg(a,i))return;const l=e(i.text);l.length&&r.push({node:i,pos:o,tokens:l})}),!r.length)return!1;const s=t.state.tr;return[...r].reverse().forEach(({node:i,pos:o,tokens:a})=>{[...a].reverse().forEach(l=>{const c=s.mapping.map(o+l.start),u=s.mapping.map(o+l.end);s.replaceWith(c,u,n(l))})}),s.docChanged?(s.setMeta("addToHistory",!1),t.view.dispatch(s),!0):!1}function PT(t){const e=t.schema.nodes.blockMath;if(!e)return!1;const n=[];if(t.state.doc.descendants((s,i)=>{if(s.type?.name!=="paragraph")return;const o=[];s.content.forEach((a,l)=>{!a.isText||!a.text||dg(s,a)||hg(a.text).forEach(c=>{o.push({...c,start:l+c.start,end:l+c.end})})}),o.length&&n.push({pos:i,node:s,tokens:o})}),!n.length)return!1;const r=t.state.tr;return[...n].reverse().forEach(({pos:s,node:i,tokens:o})=>{const a=[];let l=0;
217if(o.forEach(c=>{if(c.start>l){const u=i.content.cut(l,c.start);u.content.some(d=>!d.isText||d.text?.trim())&&a.push(i.type.create(i.attrs,u))}a.push(e.create({latex:c.latex})),l=c.end}),l<i.content.size){const c=i.content.cut(l,i.content.size);c.content.some(u=>!u.isText||u.text?.trim())&&a.push(i.type.create(i.attrs,c))}r.replaceWith(r.mapping.map(s),r.mapping.map(s+i.nodeSize),A.fromArray(a))}),r.docChanged?(r.setMeta("addToHistory",!1),t.view.dispatch(r),!0):!1}function $T(t){const e=t.schema.nodes.inlineMath;return e?pg(t,fg,n=>e.create({latex:n.latex})):!1}function zT(t){const e=t.schema.nodes.docGraph;return e?pg(t,jh,n=>e.create({expression:n.expression,xmin:n.xmin,xmax:n.xmax})):!1}function BT(t){const e=t.schema.nodes.docMermaid;if(!e)return!1;const n=[];if(t.state.doc.descendants((s,i)=>{s.type?.name!=="codeBlock"||!IT(s.attrs?.language)||n.push({node:s,pos:i})}),!n.length)return!1;const r=t.state.tr;return[...n].reverse().forEach(({node:s,pos:i})=>{r.replaceWith(r.mapping.map(i),r.mapping.map(i+s.nodeSize),e.create({code:s.textContent.trim()||`flowchart TD 218 A[Start] --> B[End]`}))}),r.docChanged?(r.setMeta("addToHistory",!1),t.view.dispatch(r),!0):!1}function _T(t=""){const e=String(t||"").replaceAll(Xn,"$");let n="";for(let r=0;r<e.length;r+=1){if(e[r]===Zn){n+="\\$";continue}if(e[r]!=="\\"){n+=e[r];continue}let s=r;for(;e[s]==="\\";)s+=1;const i=s-r;if(e[s]==="$"&&i%2===1){n+="\\".repeat(i-1),n+="$",r=s;continue}n+="\\".repeat(i),r=s-1}return n}function Jl(t){if(Array.isArray(t))return t.map(n=>Jl(n));if(!t||typeof t!="object")return t;const e={...t};return e.type==="text"&&typeof e.text=="string"&&(e.text=e.text.replaceAll(Zn,"\\$").replaceAll(Xn,"$")),(e.type==="inlineMath"||e.type==="blockMath")&&e.attrs?.latex!=null&&(e.attrs={...e.attrs,latex:String(e.attrs.latex).replaceAll(Zn,"\\$").replaceAll(Xn,"\\$")}),Array.isArray(e.content)&&(e.content=Jl(e.content)),e}function HT(t){return t.some(e=>e?.type!=="text"||!!String(e.text||"").trim())}function mg(t){if(!t||typeof t!="object")return[];const e={...t};if(Array.isArray(t.content)&&(e.content=t.content.flatMap(mg)),e.type!=="paragraph"||!Array.isArray(e.content)||!e.content.some(i=>i?.type==="image"))return[e];const n=[];let r=[];const s=()=>{HT(r)&&n.push({...e,content:r}),r=[]};return e.content.forEach(i=>{if(i?.type==="image"){s(),n.push(i);return}r.push(i)}),s(),n}function FT(t){return!t||typeof t!="object"||!Array.isArray(t.content)?t:{...t,content:t.content.flatMap(mg)}}function xh(t,e=""){const n=t.markdown.parse(DT(e));return FT(Jl(n))}function VT(t){const e=[];if(t.state.doc.descendants((r,s)=>{if(r.isText&&(r.text?.includes(Xn)||r.text?.includes(Zn)||r.text?.includes("\\$"))){e.push({type:"text",pos:s,node:r});return}(r.type?.name==="inlineMath"||r.type?.name==="blockMath")&&(String(r.attrs?.latex||"").includes(Xn)||String(r.attrs?.latex||"").includes(Zn))&&e.push({type:"math",pos:s,node:r})}),!e.length)return!1;const n=t.state.tr;return[...e].reverse().forEach(r=>{const s=n.mapping.map(r.pos);if(r.type==="math"){n.setNodeMarkup(s,void 0,{...r.node.attrs,latex:String(r.node.attrs.latex).replaceAll(Zn,"\\$").replaceAll(Xn,"\\$")});return}const i=_T(r.node.text);i!==r.node.text&&n.replaceWith(s,n.mapping.map(r.pos+r.node.nodeSize),t.schema.text(i,r.node.marks))}),n.docChanged?(n.setMeta("addToHistory",!1),t.view.dispatch(n),!0):!1}function wh(t){if(!t)return!1;let e=!1;return e=PT(t)||e,e=$T(t)||e,e=zT(t)||e,e=BT(t)||e,e=VT(t)||e,e}const gs=new fe("docs-preserved-selection"),jT=ie.create({name:"docsSelectionPreserver",addProseMirrorPlugins(){return[new ue({key:gs,state:{init:()=>ae.empty,apply(t,e){const n=t.getMeta(gs);if(n?.clear)return ae.empty;if(n?.range){const r=Number(n.range.from||0),s=Number(n.range.to||0);return s<=r?ae.empty:ae.create(t.doc,[Ee.inline(r,s,{class:"docs-preserved-selection"})])}return t.docChanged?e.map(t.mapping,t.doc):e}},props:{decorations(t){return gs.getState(t)}}})]}});function WT(t,e){if(!t||!e||Number(e.to||0)<=Number(e.from||0))return;const n=t.state.doc.content.size,r=Math.min(Math.max(1,Number(e.from||1)),n),s=Math.min(Math.max(r,Number(e.to||r)),n);s<=r||t.view.dispatch(t.state.tr.setMeta(gs,{range:{from:r,to:s}}).setMeta("addToHistory",!1))}function UT(t){t&&t.view.dispatch(t.state.tr.setMeta(gs,{clear:!0}).setMeta("addToHistory",!1))}function qT(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:a}=t,l=r&&!s,c=vw(n),u=new RegExp(`\\s${c}$`),d=o?"^":"",h=s?"":c,f=l?new RegExp(`${d}${c}.*?(?=\\s${h}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${h}]*`,"gm"),p=((e=a.nodeBefore)==null?void 0:e.isText)&&a.nodeBefore.text;if(!p)return null;const m=a.pos-p.length,g=Array.from(p.matchAll(f)).pop();if(!g||g.input===void 0||g.index===void 0)return null;const y=g.input.slice(Math.max(0,g.index-1),g.index),v=new RegExp(`^[${i?.join("")}\0]?$`).test(y);if(i!==null&&!v)return null;const C=m+g.index;let N=C+g[0].length;return l&&u.test(p.slice(N-1,N+1))&&(g[0]+=" ",N+=1),C<a.pos&&N>=a.pos?{range:{from:C,to:N},query:g[0].slice(n.length),text:g[0]}:null}function KT(t){return t.docChanged?t.steps.some(e=>{const n=e.slice;if(!n?.content)return!1;const r=n.content.textBetween(0,n.content.size,` 219`);return/\s/.test(r)}):!1}var JT=new fe("suggestion");function GT({pluginKey:t=JT,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:h=()=>[],render:f=()=>({}),allow:p=()=>!0,findSuggestionMatch:m=qT,shouldShow:g,shouldResetDismissed:y}){let v;const C=f?.(),N=r&&!s,M=()=>{const F=e.state.selection.$anchor.pos,Z=e.view.coordsAtPos(F),{top:ne,right:G,bottom:_,left:ee}=Z;try{return new DOMRect(ee,ne,G-ee,_-ne)}catch{return null}},I=(F,Z)=>Z?()=>{const ne=t.getState(e.state),G=ne?.decorationId,_=F.dom.querySelector(`[data-decoration-id="${G}"]`);return _?.getBoundingClientRect()||null}:M,R=({match:F,dismissedRange:Z,state:ne,transaction:G})=>y?.({editor:e,state:ne,range:Z,match:F,transaction:G,allowSpaces:N})?!1:N?F.range.from===Z.from:F.range.from===Z.from&&!KT(G);function $(F,Z){var ne;try{const _=t.getState(F.state),ee=_?.decorationId?F.dom.querySelector(`[data-decoration-id="${_.decorationId}"]`):null,Ce={editor:e,range:_?.range||{from:0,to:0},query:_?.query||null,text:_?.text||null,items:[],command:at=>d({editor:e,range:_?.range||{from:0,to:0},props:at}),decorationNode:ee,clientRect:I(F,ee)};(ne=C?.onExit)==null||ne.call(C,Ce)}catch{}const G=F.state.tr.setMeta(Z,{exit:!0});F.dispatch(G)}const W=new ue({key:t,view(){return{update:async(F,Z)=>{var ne,G,_,ee,Ce,at,qe;const Y=(ne=this.key)==null?void 0:ne.getState(Z),Ze=(G=this.key)==null?void 0:G.getState(F.state),ye=Y.active&&Ze.active&&Y.range.from!==Ze.range.from,Be=!Y.active&&Ze.active,et=Y.active&&!Ze.active,In=!Be&&!et&&Y.query!==Ze.query,Nt=Be||ye&&In,dt=In||ye,Rt=et||ye&&In;if(!Nt&&!dt&&!Rt)return;const Ot=Rt&&!Nt?Y:Ze,ht=F.dom.querySelector(`[data-decoration-id="${Ot.decorationId}"]`);v={editor:e,range:Ot.range,query:Ot.query,text:Ot.text,items:[],command:kt=>d({editor:e,range:Ot.range,props:kt}),decorationNode:ht,clientRect:I(F,ht)},Nt&&((_=C?.onBeforeStart)==null||_.call(C,v)),dt&&((ee=C?.onBeforeUpdate)==null||ee.call(C,v)),(dt||Nt)&&(v.items=await h({editor:e,query:Ot.query})),Rt&&((Ce=C?.onExit)==null||Ce.call(C,v)),dt&&((at=C?.onUpdate)==null||at.call(C,v)),Nt&&((qe=C?.onStart)==null||qe.call(C,v))},destroy:()=>{var F;v&&((F=C?.onExit)==null||F.call(C,v))}}}
219,state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(F,Z,ne,G){const{isEditable:_}=e,{composing:ee}=e.view,{selection:Ce}=F,{empty:at,from:qe}=Ce,Y={...Z},Ze=F.getMeta(t);if(Ze&&Ze.exit)return Y.active=!1,Y.decorationId=null,Y.range={from:0,to:0},Y.query=null,Y.text=null,Y.dismissedRange=Z.active?{...Z.range}:Z.dismissedRange,Y;if(Y.composing=ee,F.docChanged&&Y.dismissedRange!==null&&(Y.dismissedRange={from:F.mapping.map(Y.dismissedRange.from),to:F.mapping.map(Y.dismissedRange.to)}),_&&(at||e.view.composing)){(qe<Z.range.from||qe>Z.range.to)&&!ee&&!Z.composing&&(Y.active=!1);const ye=m({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:Ce.$from}),Be=`id_${Math.floor(Math.random()*4294967295)}`;ye&&p({editor:e,state:G,range:ye.range,isActive:Z.active})&&(!g||g({editor:e,range:ye.range,query:ye.query,text:ye.text,transaction:F}))?(Y.dismissedRange!==null&&!R({match:ye,dismissedRange:Y.dismissedRange,state:G,transaction:F})&&(Y.dismissedRange=null),Y.dismissedRange===null?(Y.active=!0,Y.decorationId=Z.decorationId?Z.decorationId:Be,Y.range=ye.range,Y.query=ye.query,Y.text=ye.text):Y.active=!1):(ye||(Y.dismissedRange=null),Y.active=!1)}else Y.active=!1;return Y.active||(Y.decorationId=null,Y.range={from:0,to:0},Y.query=null,Y.text=null),Y}},props:{handleKeyDown(F,Z){var ne,G;const{active:_,range:ee}=W.getState(F.state);if(!_)return!1;if(Z.key==="Escape"||Z.key==="Esc"){const at=W.getState(F.state);return(ne=C?.onKeyDown)==null||ne.call(C,{view:F,event:Z,range:at.range}),$(F,t),!0}return((G=C?.onKeyDown)==null?void 0:G.call(C,{view:F,event:Z,range:ee}))||!1},decorations(F){const{active:Z,range:ne,decorationId:G,query:_}=W.getState(F);if(!Z)return null;const ee=!_?.length,Ce=[l];return ee&&Ce.push(u),ae.create(F.doc,[Ee.inline(ne.from,ne.to,{nodeName:a,class:Ce.join(" "),"data-decoration-id":G,"data-decoration-content":c})])}}});return W}var YT=GT;const QT=[{title:"Heading 1",icon:"fa-solid fa-heading",command:({editor:t,range:e})=>t.chain().focus().deleteRange(e).setNode("heading",{level:1}).run()},{title:"Heading 2",icon:"fa-solid fa-heading",command:({editor:t,range:e})=>t.chain().focus().deleteRange(e).setNode("heading",{level:2}).run()},{title:"Bullet List",icon:"fa-solid fa-list-ul",command:({editor:t,range:e})=>t.chain().focus().deleteRange(e).toggleBulletList().run()},{title:"Checklist",icon:"fa-solid fa-list-check",command:({editor:t,range:e})=>t.chain().focus().deleteRange(e).toggleTaskList().run()},{title:"Table",icon:"fa-solid fa-table-cells",command:({editor:t,range:e})=>t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Inline Math",icon:"fa-solid fa-square-root-variable",command:({editor:t,range:e})=>t.chain().focus().deleteRange(e).insertInlineMath({latex:"E = mc^2"}).run()},{title:"Display Math",icon:"fa-solid fa-equals",command:({editor:t,range:e})=>t.chain().focus().deleteRange(e).insertBlockMath({latex:"E = mc^2"}).run()},{title:"Code Block",icon:"fa-solid fa-code",command:({editor:t,range:e})=>t.chain().focus().deleteRange(e).setCodeBlock().run()}];function XT(){const t=document.createElement("div");return t.className="docs-slash-menu",t}function vi(t,e,n){t.innerHTML=e.map((r,s)=>` 220 <button class="docs-slash-item${s===n?" active":""}" type="button" data-index="${String(s).attr()}"> 221 <i class="${String(r.icon).attr()}"></i> 222 <span>${String(r.title).html()}</span> 223 </button> 224 `).join("")}function ZT(t,e){if(!e||!t)return;const n=8,r=10,s=Math.max(t.offsetWidth||220,220),i=t.offsetHeight||0,o=window.innerHeight-e.bottom-r,a=e.top-r,l=o<i&&a>o,c=Math.max(120,(l?a:o)-n),u=Math.min(Math.max(e.left,r),Math.max(r,window.innerWidth-s-r)),d=l?Math.max(r,e.top-Math.min(i,c)-n):Math.min(e.bottom+n,window.innerHeight-r-Math.min(i,c));t.dataset.placement=l?"top":"bottom",t.style.maxHeight=`${c}px`,t.style.left=`${u}px`,t.style.top=`${d}px`}const eE=ie.create({name:"docsSlashCommands",addOptions(){return{suggestion:{char:"/",startOfLine:!1}}},addProseMirrorPlugins(){return[YT({editor:this.editor,...this.options.suggestion,items:({query:t})=>{const e=String(t||"").toLowerCase();return QT.filter(n=>n.title.toLowerCase().includes(e)).slice(0,8)},command:({editor:t,range:e,props:n})=>n?.command?.({editor:t,range:e}),render:()=>{let t=null,e=0,n=[],r=null;function s(i){const o=n[i];!o||!r||r(o)}return{onStart(i){t=XT(),r=i.command,n=i.items,e=0,vi(t,n,e),document.body.appendChild(t),this.onUpdate(i),t.addEventListener("mousedown",o=>{const a=o.target?.closest?.("[data-index]");a&&(o.preventDefault(),s(Number(a.dataset.index||0)))})},onUpdate(i){r=i.command,n=i.items,e=Math.min(e,Math.max(n.length-1,0)),vi(t,
224n,e);const o=i.clientRect?.();ZT(t,o)},onKeyDown(i){return i.event.key==="ArrowDown"?(e=(e+1)%Math.max(n.length,1),vi(t,n,e),!0):i.event.key==="ArrowUp"?(e=(e-1+Math.max(n.length,1))%Math.max(n.length,1),vi(t,n,e),!0):i.event.key==="Enter"?(s(e),!0):(i.event.key==="Escape",!1)},onExit(){t?.remove(),t=null,n=[],r=null}}}})]}}),tE=["wss://signaling.bizybear.app"],Qa=8e3,Sh=[{command:"tableHeader",iconClass:"fa-solid fa-heading",label:"Make Header"},{command:"tableRowBefore",iconClass:"fa-solid fa-arrow-up",label:"Insert Row Above"},{command:"tableRowAfter",iconClass:"fa-solid fa-arrow-down",label:"Insert Row Below"},{command:"tableDeleteRow",iconClass:"fa-solid fa-minus",label:"Delete Row"},{command:"tableColumnBefore",iconClass:"fa-solid fa-arrow-left",label:"Add Column Left"},{command:"tableColumnAfter",iconClass:"fa-solid fa-arrow-right",label:"Add Column Right"}];function nE(t=""){const e=String(t||"").trim();if(!e)return null;const n=atob(e),r=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1)r[s]=n.charCodeAt(s);return r}function vh(t){let e="";for(let r=0;r<t.length;r+=32768)e+=String.fromCharCode(...t.subarray(r,r+32768));return btoa(e)}function rE(t=0){const e=["#2563eb","#16a34a","#dc2626","#9333ea","#ea580c","#0891b2","#be123c"];return e[Math.abs(Number(t||0))%e.length]}function sE(t={}){const e=String(t.name||t.display_name||t.username||t.email||"").trim();return e||"You"}function iE(t={}){return{name:sE(t),color:rE(t.id)}}function Ch(t){const e=t.target?.closest?.("a, button");!e||!t.currentTarget.contains(e)||t.preventDefault()}function Ci(t){const e=t?.el;e&&(e.addEventListener("mousedown",Ch),t.on("closed",()=>{e.removeEventListener("mousedown",Ch)}))}function oE(t={}){const e=Array.isArray(t.signaling)?t.signaling:[];return(e.length?e:tE).map(r=>String(r||"").trim()).filter(r=>r.startsWith("wss://")||r.startsWith("ws://"))}function aE(t,e){return`bizybear:docs:leader:${Number(t||0)}:${Number(e||0)}`}function lE(t=""){try{const n=new URL(String(t||""),window.location.origin).pathname.split("/").filter(Boolean),r=n.indexOf("sets");return r<0?0:Number(n[r+2]||0)}catch{return 0}}function Xa(t){const e=new Set;return t?.descendants?.(n=>{if(n.type?.name!=="image")return;const r=lE(n.attrs?.src);r&&e.add(r)}),e}function Mh(){return Date.now()}function Mi(t=""){let e=String(t||"").trim();return e.startsWith("$$")&&e.endsWith("$$")&&e.length>=4?e=e.slice(2,-2).trim():e.startsWith("$")&&e.endsWith("$")&&e.length>=2&&(e=e.slice(1,-1).trim()),e}function cE(t,e=t.state.selection){const{from:n,to:r,empty:s}=e;return s?"":t.state.doc.textBetween(n,r,` 225`).trim()}function uE(t=""){const e=String(t||"").trim();return e?/(^|\n)\s{0,3}(#{1,6}\s|[-*+]\s|\d+[.)]\s|>\s|```|~~~|---\s*$)/m.test(e)||/^\s*\|.+\|\s*$/m.test(e)||/(?:!\[[^\]]*\]\([^\)]+\)|\*\*|__|~~|`[^`]+`|\[[^\]]+\]\([^\)]+\))/.test(e):!1}function Gl(t,e=[]){return Array.isArray(t)?(t.forEach(n=>Gl(n,e)),e):(!t||typeof t!="object"||(t.type==="image"&&e.push(t),Array.isArray(t.content)&&Gl(t.content,e)),e)}function dE(t){const e=Array.from(t?.items||[]).filter(n=>n.kind==="file"&&String(n.type||"").toLowerCase().startsWith("image/")).map(n=>n.getAsFile()).filter(Boolean);return e.length?e:Array.from(t?.files||[]).filter(n=>String(n.type||"").toLowerCase().startsWith("image/"))}function hE(t){const e=String(t||"").trim();return!e||/^(?:blob:|data:image\/|file:|attachment:|cid:)/i.test(e)}async function fE(t,e){const n=String(t||"").trim();if(!/^(?:blob:|data:image\/)/i.test(n))return null;try{const r=await fetch(n);if(!r.ok)return null;const s=await r.blob(),i=String(s.type||n.match(/^data:(image\/[^;,]+)/i)?.[1]||"image/png");if(!i.toLowerCase().startsWith("image/"))return null;const o=String(i.split("/")[1]||"png").split(/[;+]/)[0].replace(/[^a-z0-9]/gi,"")||"png";return new File([s],`pasted-image-${e+1}.${o}`,{type:i})}catch{return null}}function pE({set:t,content:e,collab:n,editorEl:r,onStatus:s,onSaved:i,onStateChange:o}){const a=new Bh,l=String(n?.room||""),c=oE(n),u=new yy(l,a,{password:String(n?.password||""),...c.length?{signaling:c}:{}}),d=new by(l,a),h=Oo.raw||{},f=aE(t?.id,e?.id),p=`${Date.now()}-${Math.random().toString(36).slice(2)}`;let m=null,g=null,y=0,v=0,C=0,N=!1,M=0,I=null,R=!1,$=!1,W=new Set,F=!1,Z=!1;const ne=Ih();let G=null,_=null,ee=!1,Ce=null;const at=nE(e?.base64);at&&my(a,at);function qe(b){s?.(b)}function Y(b=m){if(!b)return;const{from:k,to:w}=b.state.selection;_={from:k,to:w}}function Ze(b=m){if(!b||!_)return;
225const k=b.state.doc.content.size,w=Math.min(Math.max(1,Number(_.from||1)),k),S=Math.min(Math.max(w,Number(_.to||w)),k);b.commands.setTextSelection({from:w,to:S})}function ye(b=m){Y(b),!(!_||_.to<=_.from)&&(WT(b,_),ee=!0)}function Be(b=m){ee&&(ee=!1,UT(b))}function et(){return Ze(),m.chain().focus()}function In(b){if(!m)return"";const{$from:k}=m.state.selection;for(let w=k.depth;w>0;w-=1){const S=k.node(w).attrs?.[b];if(S)return S}return""}function Nt(b=m){if(!b)return null;const k=[1,2,3,4,5,6].find(z=>b.isActive("heading",{level:z})),w=b.isActive("taskList")?"task":b.isActive("orderedList")?"ordered":b.isActive("bulletList")?"bullet":"",S=b.getAttributes("textStyle")||{},T=b.getAttributes("highlight")||{};return{canUndo:b.can().undo(),canRedo:b.can().redo(),heading:k?`h${k}`:"paragraph",list:w,align:In("textAlign")||"left",bold:b.isActive("bold"),italic:b.isActive("italic"),underline:b.isActive("underline"),strike:b.isActive("strike"),codeInline:b.isActive("code"),link:b.isActive("link"),mathInline:b.isActive("inlineMath"),mathBlock:b.isActive("blockMath"),graph:b.isActive("docGraph"),mermaid:b.isActive("docMermaid"),quote:b.isActive("blockquote"),codeBlock:b.isActive("codeBlock"),highlight:b.isActive("highlight"),fontSize:String(S.fontSize||""),color:String(S.color||""),highlightColor:String(T.color||"")}}function dt(b=m){Ce=Nt(b),o?.(Ce)}function Rt(b=m){if(!G)return;const k=b?.state?.selection;if(!(k instanceof j)||k.node?.type?.name!=="image"){G.hidden=!0;return}const w=b.view.nodeDOM(k.from),S=r.parentElement;if(!(w instanceof HTMLElement)||!S){G.hidden=!0;return}G.hidden=!1;const T=S.getBoundingClientRect(),z=w.getBoundingClientRect(),V=G.offsetWidth||36,J=G.offsetHeight||36,Se=Math.max(8,S.clientWidth-V-8),Te=Math.max(8,S.scrollHeight-J-8),Ke=Math.min(Math.max(8,z.right-T.left+S.scrollLeft-V/2),Se),gr=Math.min(Math.max(8,z.top-T.top+S.scrollTop+8),Te);G.style.left=`${Ke}px`,G.style.top=`${gr}px`}function Ot(){const b=m?.state?.selection;return!(b instanceof j)||b.node?.type?.name!=="image"?!1:m.chain().focus().deleteSelection().run()}function ht(){Be(),ne.close()}async function kt(b,k={}){if(!b)return;ye();const w=typeof k.open=="function",S=typeof k.plainText=="function",T=typeof k.delete=="function",z=await ne.open(b,{content:` 226 <div class="docs-modern-popover-panel docs-inline-edit-popover"> 227 <div class="docs-inline-edit-bar"> 228 <input class="docs-inline-edit-input" type="text" value="${String(k.value||"").attr()}" placeholder="${String(k.placeholder||"").attr()}"> 229 <a class="link icon-only tooltip-init docs-inline-edit-submit" aria-label="Apply" data-tooltip="Apply"> 230 <i class="fa-solid fa-arrow-turn-down"></i> 231 </a> 232 ${w||S||T?'<span class="docs-inline-edit-separator"></span>':""} 233 ${w?` 234 <a class="link icon-only tooltip-init docs-inline-edit-open" aria-label="Open in new tab" data-tooltip="Open in new tab"> 235 <i class="fa-solid fa-arrow-up-right-from-square"></i> 236 </a> 237 `:""} 238 ${S?` 239 <a class="link icon-only tooltip-init docs-inline-edit-plain" aria-label="Remove formatting" data-tooltip="Remove formatting"> 240 <i class="fa-solid fa-text-slash"></i> 241 </a> 242 `:""} 243 ${T?` 244 <a class="link icon-only tooltip-init docs-inline-edit-delete" aria-label="Delete" data-tooltip="Delete"> 245 <i class="fa-regular fa-trash-can"></i> 246 </a> 247 `:""} 248 </div> 249 </div>`});if(!z){Be();return}ye(),Ci(z),z.on("closed",()=>{Be()});const V=z.el,J=V.querySelector(".docs-inline-edit-input"),Se=()=>{k.submit?.(String(J?.value||"").trim()),ht()};V.querySelector(".docs-inline-edit-submit")?.addEventListener("click",Se),V.querySelector(".docs-inline-edit-open")?.addEventListener("click",()=>{k.open?.(String(J?.value||"").trim())}),V.querySelector(".docs-inline-edit-plain")?.addEventListener("click",()=>{k.plainText?.(String(J?.value||"").trim()),ht()}),V.querySelector(".docs-inline-edit-delete")?.addEventListener("click",()=>{k.delete?.(),ht()}),J?.addEventListener("keydown",Te=>{Te.key==="Enter"&&(Te.preventDefault(),Se()),Te.key==="Escape"&&(Te.preventDefault(),ht())}),J?.focus(),J?.select()}function ea(b,k,w=!1){if(!k||!m)return;const S=w?"updateBlockMath":"updateInlineMath";m.chain().setNodeSelection(b)[S]({latex:k,pos:b}).focus().run()}function ta(b,k=!1){if(!m)return;const w=k?"deleteBlockMath":"deleteInlineMath";m.chain().focus()[w]({pos:b}).run()}function na(b,k,w=!1){if(!m)return;const S=m.state.doc.nodeAt(b);if(!S)return;const T=Mi(k||S.attrs?.latex||""),z=w?{type:"paragraph",content:T?[{type:"text",text:T}]:[]}:{type:"text",text:T};m.chain().focus().insertContentAt({from:b,to:b+S.nodeSize},z).run()}function Vs(b,k,w=!1){const S=m?.view?.nodeDOM(k);kt(S instanceof HTMLElement?S:r,{value:b?.attrs?.latex||"",placeholder:"Raw math...",submit:T=>ea(k,Mi(T),w),plainText:T=>na(k,T||b?.attrs?.latex||"",w),delete:()=>ta(k,w)})}function js(b,k="",w=null){w?_={...w}:Y(),kt(b,{value:k,placeholder:"Paste a link...",submit:S=>{if(!S||!m)return;const T=w||_,z=T&&T.to>T.from,V=et();if(z){V.setTextSelection(T).extendMarkRange("link").setLink({href:S}).run();return}V.insertContent({type:"text",text:S,marks:[{type:"link",attrs:{href:S}}]}).run()},open:S=>{S&&window.open(S,"_blank","noopener,noreferrer")},delete:()=>{if(!m)return;const S=et();(w||_)&&S.setTextSelection(w||_),S.unsetLink().run()}})}function Ws(b,k={}){kt(b,{value:"",placeholder:k.placeholder||"Paste a link...",submit:w=>
249{!w||!m||k.submit?.(w)},open:w=>{w&&window.open(w,"_blank","noopener,noreferrer")}})}function _r(b){if(!m)return;const k=et();b==="tableHeader"&&k.toggleHeaderRow().run(),b==="tableRowBefore"&&k.addRowBefore().run(),b==="tableRowAfter"&&k.addRowAfter().run(),b==="tableDeleteRow"&&k.deleteRow().run(),b==="tableColumnBefore"&&k.addColumnBefore().run(),b==="tableColumnAfter"&&k.addColumnAfter().run()}function Us(b){if(!m)return!1;const{selection:k,schema:w}=m.state;if(k.empty||!k.$from.sameParent(k.$to)||!k.$from.parent.isTextblock||m.isActive(b))return!1;const S=k.$from.parent,T=k.$from.start(),z=k.from-T,V=k.to-T,J=S.content.cut(0,z),Se=S.content.cut(z,V),Te=S.content.cut(V),Ke=[];if(J.size&&Ke.push(S.type.create(S.attrs,J)),b==="blockquote")Ke.push(w.nodes.blockquote.create(null,w.nodes.paragraph.create(null,Se)));else{const gr=S.textBetween(z,V,` 250`),da=gr?w.text(gr):null;Ke.push(w.nodes.codeBlock.create({language:"txt"},da))}return Te.size&&Ke.push(S.type.create(S.attrs,Te)),m.view.dispatch(m.state.tr.replaceWith(k.$from.before(k.$from.depth),k.$from.after(k.$from.depth),A.fromArray(Ke))),m.commands.focus(),!0}function ra(){return` 251 <div class="docs-modern-popover-panel docs-toolbar-popover docs-table-context-popover"> 252 <div class="list links-list no-margin"> 253 <ul class="list-unstyled"> 254 ${Sh.map(b=>` 255 <li> 256 <a class="list-button docs-popover-close" data-table-command="${String(b.command).attr()}"> 257 <span class="docs-toolbar-popover-icon"><i class="${String(b.iconClass).attr()}"></i></span> 258 <span>${String(b.label).html()}</span> 259 </a> 260 </li> 261 `).join("")} 262 </ul> 263 </div> 264 </div>`}async function qs(b){ye();const k=await ne.open(b,{content:ra()});if(!k){Be();return}ye(),Ci(k),k.on("closed",()=>{Be()}),k.el.querySelectorAll("[data-table-command]").forEach(w=>{w.addEventListener("click",()=>{_r(w.dataset.tableCommand),ne.close()})})}function Ks(b=!1,k=r){if(!m)return;Y();const w=_||m.state.selection,{from:S,to:T}=w,z=S===T,V=Mi(cE(m,w));if(!z&&V){const J=b?{type:"blockMath",attrs:{latex:V}}:{type:"inlineMath",attrs:{latex:V}};et().setTextSelection({from:S,to:T}).insertContentAt({from:S,to:T},J).run();return}kt(k,{value:V,placeholder:b?"Display math...":"Inline math...",submit:J=>{const Se=Mi(J);if(!Se)return;const Te=b?{type:"blockMath",attrs:{latex:Se}}:{type:"inlineMath",attrs:{latex:Se}},Ke=_||m.state.selection;et().insertContentAt(Ke.from,Te).run()}})}function sa(b={},k="Edit graph"){const w=xs(b);return` 265 <div class="docs-modern-popover-panel docs-graph-edit-popover"> 266 <div class="docs-graph-edit-header">${String(k).html()}</div> 267 <label class="docs-graph-edit-field"> 268 <span>Expression</span> 269 <input type="text" data-graph-expression value="${String(w.expression).attr()}" placeholder="x^2"> 270 </label> 271 <div class="docs-graph-edit-range"> 272 <label class="docs-graph-edit-field"> 273 <span>Minimum x</span> 274 <input type="number" data-graph-xmin value="${String(w.xmin).attr()}" step="any"> 275 </label> 276 <label class="docs-graph-edit-field"> 277 <span>Maximum x</span> 278 <input type="number" data-graph-xmax value="${String(w.xmax).attr()}" step="any"> 279 </label> 280 </div> 281 <a class="button button-outline button-round docs-graph-edit-submit" data-graph-submit>Apply graph</a> 282 </div>`}async function Hr(b,k=null,w=-1){if(!m)return;k||ye();const S=await ne.open(b||r,{content:sa(k?.attrs||{},k?"Edit graph":"Insert graph")});if(!S){Be();return}k||ye(),Ci(S),S.on("closed",()=>{Be()});const T=S.el,z=T.querySelector("[data-graph-expression]"),V=T.querySelector("[data-graph-xmin]"),J=T.querySelector("[data-graph-xmax]"),Se=()=>{const Te=xs({expression:z?.value,xmin:V?.value,xmax:J?.value});if(Te.expression){if(w>=0)m.view.dispatch(m.state.tr.setNodeMarkup(w,void 0,Te).scrollIntoView());else{const Ke=_||m.state.selection;et().setTextSelection(Ke).insertContent({type:"docGraph",attrs:Te}).run()}ht()}};T.querySelector("[data-graph-submit]")?.addEventListener("click",Se),T.querySelectorAll("input").forEach(Te=>{Te.addEventListener("keydown",Ke=>{Ke.key==="Enter"&&(Ke.preventDefault(),Se())})}),z?.focus(),z?.select()}function Vt(b,k){const w=m?.view?.nodeDOM(k),S=w?.querySelector?.(".docs-graph-node-header")||w;Hr(S instanceof HTMLElement?S:r,b,k)}function Js(b=xn,k="Insert Flowchart"){return` 283 <div class="docs-modern-popover-panel docs-mermaid-edit-popover"> 284 <div class="docs-graph-edit-header">
284${String(k).html()}</div> 285 <label class="docs-graph-edit-field"> 286 <span>Mermaid code</span> 287 <textarea data-mermaid-code-input rows="9" spellcheck="false">${String(b).html()}</textarea> 288 </label> 289 <a class="button button-outline button-round docs-graph-edit-submit" data-mermaid-submit>Apply flowchart</a> 290 </div>`}async function jt(b,k=null,w=-1){if(!m)return;k||ye();const S=await ne.open(b||r,{content:Js(k?.attrs?.code||xn,k?"Edit Flowchart":"Insert Flowchart")});if(!S){Be();return}k||ye(),Ci(S),S.on("closed",()=>{Be()});const T=S.el,z=T.querySelector("[data-mermaid-code-input]"),V=()=>{const J=String(z?.value||"").trim();if(J){if(w>=0)m.state.doc.nodeAt(w)?.type?.name==="docMermaid"&&m.view.dispatch(m.state.tr.setNodeMarkup(w,void 0,{code:J}).scrollIntoView());else{const Se=_||m.state.selection;et().setTextSelection(Se).insertContent({type:"docMermaid",attrs:{code:J}}).run()}ht()}};T.querySelector("[data-mermaid-submit]")?.addEventListener("click",V),z?.addEventListener("keydown",J=>{J.key==="Escape"&&(J.preventDefault(),ht())}),z?.focus(),z?.select()}function hr(b,k){const w=m?.view?.nodeDOM(k),S=w?.querySelector?.(".docs-mermaid-node-header")||w;jt(S instanceof HTMLElement?S:r,b,k)}function Gs(b,k){if(!m||b<0)return;const w=m.state.doc.nodeAt(b);if(w?.type?.name!=="codeBlock")return;const S=Mr(k);if(S==="mermaid"){const T=m.schema.nodes.docMermaid;if(!T)return;m.view.dispatch(m.state.tr.replaceWith(b,b+w.nodeSize,T.create({code:w.textContent.trim()||xn})).scrollIntoView());return}m.view.dispatch(m.state.tr.setNodeMarkup(b,void 0,{...w.attrs,language:S}).scrollIntoView())}function ia(b,k,w){const S=w.target?.closest?.(".docs-code-language-control");if(S&&r.contains(S))return w.preventDefault(),S._docsOpenCodeLanguage?.(),!0;const T=w.target?.closest?.("a[href]");if(!T||!r.contains(T))return!1;w.preventDefault(),w.stopPropagation();const z=Fo(b.state.doc.resolve(k),b.state.schema.marks.link);return _={from:z.from,to:z.to},js(T,T.getAttribute("href")||"",z),!0}function oa(b,k){if(k.button!==0)return!1;const w=k.target instanceof Element?k.target:null;if(!w||!r.contains(w))return!1;const S=w.closest("img");if(S&&r.contains(S)){const J=b.posAtDOM(S,0);if(b.state.doc.nodeAt(J)?.type?.name==="image")return k.preventDefault(),b.dispatch(b.state.tr.setSelection(j.create(b.state.doc,J)).setMeta("pointer",!0)),b.focus(),!0}let T=w;for(;T&&T!==r&&T.getAttribute("contenteditable")!=="true";){if(T.getAttribute("contenteditable")==="false")return!1;T=T.parentElement}const z=b.posAtCoords({left:k.clientX,top:k.clientY});if(!z)return!1;const V=Q.near(b.state.doc.resolve(z.pos));return b.focus(),b.state.selection.eq(V)||b.dispatch(b.state.tr.setSelection(V).setMeta("pointer",!0)),!1}function aa(b,k){const w=k.target?.closest?.("td, th, table, .tableWrapper");return!w||!r.contains(w)?!1:(k.preventDefault(),k.stopPropagation(),qs(w),!0)}function la(b,k=m.state.selection){const w=b?.content||b,S=m.state.doc.content.size,T=Math.min(Math.max(0,Number(k.from||0)),S),z=Math.min(Math.max(T,Number(k.to??T)),S);m.commands.insertContentAt({from:T,to:z},w),wh(m)}function ca(b,k){const w=Gl(b).filter(T=>hE(T.attrs?.src));if(!w.length)return[];const S=dE(k);return w.map((T,z)=>{const V=String(T.attrs?.src||"").trim(),J=S[z]||null;if(!J&&!V)return null;const Se=J&&typeof URL<"u"&&typeof URL.createObjectURL=="function"?URL.createObjectURL(J):"",Te=Se||V;return T.attrs={...T.attrs,src:Te},{file:J,index:z,objectUrl:Se,originalSource:V,source:Te}}).filter(Boolean)}async function Ys(b){const k=await Promise.all(b.map(async S=>{const T=S.file||await fE(S.originalSource,S.index);if(!T)return null;try{const z=await ph({setId:t.id,file:T});return{source:S.source,nextSource:z?.url||S.originalSource}}catch(z){return xy.push("error",z instanceof Error?z.message:"Pasted image upload failed."),{source:S.source,nextSource:S.originalSource}}})),w=new Map(k.filter(Boolean).map(S=>[S.source,S.nextSource]));if(!$&&!m?.isDestroyed&&w.size){const S=m.state.tr;m.state.doc.descendants((T,z)=>{if(T.type?.name!=="image")return;const V=String(T.attrs?.src||"");w.has(V)&&S.setNodeMarkup(z,void 0,{...T.attrs,src:w.get(V)})}),S.docChanged&&(S.setMeta("addToHistory",!1),m.view.dispatch(S))}b.forEach(({objectUrl:S})=>{S&&URL.revokeObjectURL(S)})}function ua(b,k){const w=k.clipboardData;if(!w)return!1;const S=w.getData("text/markdown"),T=w.getData("text/plain"),z=S||T;if(!z||!S&&!uE(T))return!1;k.preventDefault();const V={from:b.state.selection.from,to:b.state.selection.to},J=xh(m,z),Se=ca(J,w);return la(J,V),Se.length&&Ys(Se),!0}function Fr(){const b=rl();r.querySelectorAll(".tiptap-mathematics-render").forEach(k=>{k.classList.add("tooltip-init"),k.dataset.tooltip="Edit math",k.setAttribute("aria-label","Edit math"),k.removeAttribute("role"),k.removeAttribute("tabindex"),!k.f7Tooltip&&b?.tooltip?.create&&b.tooltip.create({targetEl:k,text:"Edit math"})})}function Vr(b=r){b.querySelectorAll(".tableWrapper").forEach(k=>{k.classList.add("docs-table-wrapper"),k.classList.remove("card","data-table");const w=k.querySelector(":scope > table");w?.classList.add("docs-table"),w?.classList.remove("card","data-table");let S=k.querySelector(":scope > .docs-table-node-header");if(!S){S=document.createElement("div"),S.className="docs-node-header docs-table-node-header",S.contentEditable="false",S.innerHTML=`
291 <span class="docs-node-header-label">Table</span> 292 <span class="docs-node-header-actions" data-table-actions></span> 293 `;const z=S.querySelector("[data-table-actions]");Sh.forEach(V=>{const J=document.createElement("button");J.type="button",J.className="docs-node-header-action tooltip-init",J.dataset.tableCommand=V.command,J.dataset.tooltip=V.label,J.setAttribute("aria-label",V.label),J.innerHTML=`<i class="${V.iconClass}"></i>`,z?.append(J)}),k.insertBefore(S,k.firstChild),S.addEventListener("pointerdown",V=>{V.target.closest("[data-table-command]")&&(V.preventDefault(),V.stopPropagation())}),S.addEventListener("click",V=>{const J=V.target.closest("[data-table-command]");!J||!S.contains(J)||(V.preventDefault(),V.stopPropagation(),_r(J.dataset.tableCommand))})}const T=rl();S.querySelectorAll(".tooltip-init").forEach(z=>{z.f7Tooltip||!T?.tooltip?.create||(z.f7Tooltip=T.tooltip.create({targetEl:z,text:z.dataset.tooltip||z.getAttribute("aria-label")||""}))})})}function ln(){try{return JSON.parse(localStorage.getItem(f)||"{}")}catch{return{}}}function fr(b=!1){const k=ln();if(!b&&k.id&&k.id!==p&&Number(k.expires||0)>Mh())return!1;try{return localStorage.setItem(f,JSON.stringify({id:p,expires:Mh()+14e3})),ln().id===p}catch{return!0}}function pr(){return ln().id===p||fr(!1)}async function mr(b="manual"){if($||!N||!pr()&&b!=="close")return;if(I)return R=!0,I;const k=M;R=!1;const w=du(a),S=X();return qe("Saving..."),I=An.fetch({action:"docs:save",setId:t.id,contentId:e.id,base64:vh(w),html:S},{error:b!=="auto"}).then(T=>{M===k&&(N=!1),i?.(T?.meta||null),qe(`Saved ${T?.meta?.updatedAt||""}`.trim())}).catch(()=>{qe("Save failed")}).finally(()=>{I=null,N&&R&&!$&&(R=!1,jr(Qa))}),I}function jr(b=Qa){window.clearTimeout(y),y=window.setTimeout(()=>{mr("auto")},b)}function cn(b=Qa){N=!0,M+=1,qe("Unsaved changes"),jr(b)}function x(b=[]){return Promise.all(Array.from(b||[]).map(async k=>{const w=await ph({setId:t.id,file:k});w.url&&m?.chain().focus().setImage({src:w.url,alt:w.value?.name||"Document image",title:w.value?.name||""}).run()}))}function E(b){if(!W.size){W=b;return}const k=[...W].filter(w=>!b.has(w));W=b,!(!k.length||!pr())&&k.forEach(w=>{An.fetch({action:"docs:deleteMedia",setId:t.id,contentId:w},{error:!1})})}function P(b){F||(F=!0,wh(b),Fr(),Vr())}function X(){return m?.getHTML?.()||""}function Ne(){const b=r.parentElement;if(!b)return;const k=document.createElement("button");k.type="button",k.className="docs-image-selection-delete tooltip-init",k.dataset.click="docsDeleteSelectedImage",k.setAttribute("aria-label","Delete image"),k.dataset.tooltip="Delete image",k.innerHTML='<i class="fa-regular fa-trash-can" aria-hidden="true"></i>',k.hidden=!0,b.append(k),G=k}Ne(),m=new kw({element:r,content:"",editorProps:{attributes:{spellcheck:"true"},handleClick:ia,handlePaste:ua,handleDOMEvents:{pointerdown:oa,contextmenu:aa}},extensions:[y1.configure({undoRedo:!1,codeBlock:!1,dropcursor:!1,link:!1,underline:!1,bulletList:{keepMarks:!0,keepAttributes:!0},orderedList:{keepMarks:!0,keepAttributes:!0},trailingNode:!1}),OT.configure({onLanguageChange:(b,k)=>Gs(b,k)}),hv,jT,rC.configure({document:a}),sC.configure({provider:u,user:iE(h)}),f1.configure({placeholder:"Start writing..."}),hm.configure({openOnClick:!1,autolink:!0}),dC.configure({allowBase64:!1,inline:!1}),oC.configure({allowedMimeTypes:["image/jpeg","image/png","image/webp","image/gif"],onPaste:(b,k)=>{x(k)},onDrop:(b,k)=>{x(k)}}),pC.configure({inlineOptions:{onClick:(b,k)=>Vs(b,k,!1)},blockOptions:{onClick:(b,k)=>Vs(b,k,!0)},katexOptions:{throwOnError:!1,output:"html"}}),yT.configure({onClick:(b,k)=>Vt(b,k)}),bT.configure({onClick:(b,k)=>hr(b,k)}),EM.configure({table:{HTMLAttributes:{class:"docs-table"},resizable:!0}}),BM,NM.configure({types:["heading","paragraph"]}),cC.configure({multicolor:!0}),rT,Mm,Cm.configure({itemTypeName:"taskItem"}),LT.configure({nested:!0}),lT.configure({controls:!0,nocookie:!0,width:1280,height:720}),pT.configure({parent:window.location.hostname||"localhost",width:1280,height:720}),eE,Om.configure({color:"var(--f7-theme-color)",width:2}),Lm.configure({node:"paragraph"}
293)].filter(Boolean),onCreate({editor:b}){e?.legacyMarkdown&&(b.commands.setContent(xh(b,e.legacyMarkdown),{emitUpdate:!1}),P(b)),u.on("synced",()=>{P(b)}),Fr(),Vr(),W=Xa(b.state.doc),Y(b),dt(b),Rt(b)},onBlur({editor:b}){Y(b),dt(b)},onSelectionUpdate({editor:b}){Y(b),dt(b),Rt(b)},onTransaction({editor:b}){dt(b),Rt(b)},onUpdate({editor:b,transaction:k}){Fr(),Vr(),dt(b),Rt(b),!(!Z||Gc(k)||!k.docChanged)&&(E(Xa(b.state.doc)),cn())}}),window.setTimeout(()=>{Z=!0,W=Xa(m.state.doc)},0),d.on("synced",()=>{qe("Offline copy ready")}),g=ky.addListener({buttonTrigger:{selector:"[data-docs-media-trigger]"},filetypes:["image/*"],mediaTypes:["image"],multiple:!0,actions:["upload","gif","existing"],owner:()=>Pg(t),async onFile(b){await x(b)},onGif(b){b?.url&&m.chain().focus().setImage({src:b.url,alt:b.title||"GIF"}).run()},onExisting(b){(Array.isArray(b)?b:[]).forEach(k=>{k?.previewUrl&&m.chain().focus().setImage({src:k.previewUrl,alt:k.name||"Image"}).run()})}}),fr(!0),v=window.setInterval(()=>{pr()&&fr(!0)},5e3),C=window.setInterval(()=>{mr("auto")},6e4);const Me=()=>{if(!N)return;const b=du(a),k=JSON.stringify({action:"docs:save",setId:t.id,contentId:e.id,base64:vh(b),html:X()});navigator.sendBeacon?.("/api",new Blob([k],{type:"application/json"}))};return window.addEventListener("beforeunload",Me),{editor:m,saveNow:mr,runCommand(b,k=null,w=r){if(!m)return;const S=String(b||"");if(S==="undo"){Ze(),m.commands.undo();return}if(S==="redo"){Ze(),m.commands.redo();return}const T=et();if(S==="bold"&&T.toggleBold().run(),S==="italic"&&T.toggleItalic().run(),S==="underline"&&T.toggleUnderline().run(),S==="strike"&&T.toggleStrike().run(),S==="highlight"&&T.toggleHighlight().run(),S==="codeInline"&&T.toggleCode().run(),S==="bullet"&&T.toggleBulletList().run(),S==="ordered"&&T.toggleOrderedList().run(),S==="task"&&T.toggleTaskList().run(),S==="quote"){Us("blockquote")||T.toggleBlockquote().run();return}if(S==="code"||S==="codeBlock"){Us("codeBlock")||T.toggleCodeBlock().run();return}if(S==="paragraph"&&T.setParagraph().run(),S==="heading"&&T.setNode("heading",{level:Number(k||2)}).run(),S==="align"&&T.setTextAlign(String(k||"left")).run(),S==="fontSize"&&(String(k||"")==="reset"?T.unsetFontSize().run():T.setFontSize(String(k||"")).run()),S==="color"&&(String(k||"")==="reset"?T.unsetColor().run():T.setColor(String(k||"")).run()),S==="highlightColor"&&(String(k||"")==="reset"?T.unsetHighlight().run():T.setHighlight({color:String(k||"")}).run()),S==="table"){const[z,V]=String(k||"3:3").split(":").map(Number);T.insertTable({rows:Number.isInteger(z)&&z>0?z:3,cols:Number.isInteger(V)&&V>0?V:3,withHeaderRow:!0}).run()}if(S.startsWith("table")&&S!=="table"&&_r(S),(S==="math"||S==="mathInline")&&Ks(!1,w),S==="mathBlock"&&Ks(!0,w),S==="graph"&&Hr(w),S==="mermaid"&&jt(w),S==="youtube"&&Ws(w,{placeholder:"Paste a YouTube link...",submit:z=>et().setYoutubeVideo({src:z}).run()}),S==="twitch"&&Ws(w,{placeholder:"Paste a Twitch link...",submit:z=>et().setTwitchVideo({src:z}).run()}),S==="link"){const{from:z,to:V,empty:J}=m.state.selection;Y(),js(w,m.getAttributes("link")?.href||"",J?null:{from:z,to:V})}},getToolbarState(){return Ce||Nt()},captureSelection(){Y()},preserveSelection(){ye()},releaseSelection(){Be()},deleteSelectedImage(){return Ot()},async destroy(){window.clearTimeout(y),window.clearInterval(v),window.clearInterval(C),window.removeEventListener("beforeunload",Me),N&&await mr("close"),$=!0,ht(),Be(),g?.destroy(),G?.remove(),G=null,u.destroy(),d.destroy?.(),a.destroy(),m?.destroy();try{ln().id===p&&localStorage.removeItem(f)}catch{}}}}function mE(){return` 294 <div class="docs-editor-document-skeleton skeleton-text skeleton-effect-wave" aria-hidden="true"> 295 <div class="skeleton-block docs-editor-skeleton-title"></div> 296 <div class="skeleton-block docs-editor-skeleton-line"></div> 297 <div class="skeleton-block docs-editor-skeleton-line docs-editor-skeleton-line-short"></div> 298 <div class="skeleton-block docs-editor-skeleton-line"></div> 299 <div class="skeleton-block docs-editor-skeleton-gap"></div> 300 <div class="skeleton-block docs-editor-skeleton-line docs-editor-skeleton-line-mid"></div> 301 <div class="skeleton-block docs-editor-skeleton-line"></div> 302 <div class="skeleton-block docs-editor-skeleton-line docs-editor-skeleton-line-short"></div> 303 </div> 304 `}function Th(t={}){const e=t.loading===!0,n=Array.isArray(t.linkedSets)?t.linkedSets:[];return` 305 <div class="docs-editor-shell"> 306 <div class="docs-editor-toolbar" data-docs-toolbar>
307 <span class="docs-toolbar-group" data-doc-group="structure"> 308 <a class="docs-toolbar-btn is-disabled tooltip-init" data-doc-command="undo" data-doc-disabled-state="canUndo" aria-disabled="true" aria-label="Undo" data-tooltip="Undo"><i class="fa-solid fa-rotate-left"></i></a> 309 <a class="docs-toolbar-btn is-disabled tooltip-init" data-doc-command="redo" data-doc-disabled-state="canRedo" aria-disabled="true" aria-label="Redo" data-tooltip="Redo"><i class="fa-solid fa-rotate-right"></i></a> 310 </span> 311 <span class="docs-toolbar-separator"></span> 312 <span class="docs-toolbar-group" data-doc-group="structure"> 313 <a class="docs-toolbar-btn docs-toolbar-menu-btn docs-toolbar-heading-btn tooltip-init" data-click="docsOpenHeadingMenu" data-doc-state="heading" aria-label="Text style" data-tooltip="Text style"> 314 <span class="docs-toolbar-heading-glyph" data-doc-heading-glyph>T</span> 315 <i class="fa-solid fa-chevron-down"></i> 316 </a> 317 <a class="docs-toolbar-btn docs-toolbar-menu-btn tooltip-init" data-click="docsOpenListMenu" data-doc-state="list" aria-label="List" data-tooltip="List"> 318 <i data-doc-list-icon class="fa-solid fa-list-ul"></i> 319 <i class="fa-solid fa-chevron-down"></i> 320 </a> 321 <a class="docs-toolbar-btn docs-toolbar-menu-btn tooltip-init" data-click="docsOpenAlignMenu" data-doc-state="align" aria-label="Text alignment" data-tooltip="Text alignment"> 322 <i data-doc-align-icon class="fa-solid fa-align-left"></i> 323 <i class="fa-solid fa-chevron-down"></i> 324 </a> 325 </span> 326 <span class="docs-toolbar-separator"></span> 327 <span class="docs-toolbar-group" data-doc-group="styles"> 328 <span class="docs-font-size-control" data-doc-font-size> 329 <a class="docs-font-size-step tooltip-init" data-click="docsFontSizeStep" data-font-size-step="-1" aria-label="Decrease font size" data-tooltip="Decrease font size">â</a> 330 <input class="docs-font-size-toolbar-input tooltip-init" data-click="docsOpenFontSizeMenu" data-doc-font-size-input type="text" value="17" inputmode="numeric" aria-label="Font size" aria-haspopup="listbox" data-tooltip="Font size"> 331 <a class="docs-font-size-step tooltip-init" data-click="docsFontSizeStep" data-font-size-step="1" aria-label="Increase font size" data-tooltip="Increase font size">+</a> 332 </span> 333 <span class="docs-toolbar-separator" aria-hidden="true"></span> 334 <a class="docs-toolbar-btn docs-toolbar-color-btn tooltip-init" data-click="docsOpenTextColorMenu" data-doc-state="color" aria-label="Text color" data-tooltip="Text color"><i class="fa-solid fa-font"></i><span class="docs-toolbar-color-strip" data-doc-color-strip="color" aria-hidden="true"></span></a> 335 <a class="docs-toolbar-btn tooltip-init" data-doc-command="bold" data-doc-state="bold" aria-label="Bold" data-tooltip="Bold"><i class="fa-solid fa-bold"></i></a> 336 <a class="docs-toolbar-btn tooltip-init" data-doc-command="italic" data-doc-state="italic" aria-label="Italic" data-tooltip="Italic"><i class="fa-solid fa-italic"></i></a> 337 <a class="docs-toolbar-btn tooltip-init" data-doc-command="underline" data-doc-state="underline" aria-label="Underline" data-tooltip="Underline"><i class="fa-solid fa-underline"></i></a> 338 <a class="docs-toolbar-btn docs-toolbar-color-btn tooltip-init" data-click="docsOpenHighlightMenu" data-doc-state="highlight" aria-label="Highlight" data-tooltip="Highlight"><i class="fa-solid fa-highlighter"></i><span class="docs-toolbar-color-strip" data-doc-color-strip="highlight" aria-hidden="true"></span></a> 339 <a class="docs-toolbar-btn tooltip-init" data-doc-command="strike" data-doc-state="strike" aria-label="Str
339ikethrough" data-tooltip="Strikethrough"><i class="fa-solid fa-strikethrough"></i></a> 340 </span> 341 <span class="docs-toolbar-separator"></span> 342 <span class="docs-toolbar-group" data-doc-group="markdown"> 343 <a class="docs-toolbar-btn tooltip-init" data-doc-command="link" data-doc-state="link" aria-label="Link" data-tooltip="Link"><i class="fa-solid fa-link"></i></a> 344 <a class="docs-toolbar-btn tooltip-init" data-doc-command="mathInline" data-doc-state="mathInline" aria-label="Inline math" data-tooltip="Inline math"><i class="fa-solid fa-square-root-variable"></i></a> 345 <a class="docs-toolbar-btn tooltip-init" data-doc-command="mathBlock" data-doc-state="mathBlock" aria-label="Display math" data-tooltip="Display math"><i class="fa-solid fa-equals"></i></a> 346 <a class="docs-toolbar-btn tooltip-init" data-doc-command="quote" data-doc-state="quote" aria-label="Quote" data-tooltip="Quote"><i class="fa-solid fa-quote-left"></i></a> 347 <a class="docs-toolbar-btn tooltip-init" data-doc-command="codeInline" data-doc-state="codeInline" aria-label="Inline code" data-tooltip="Inline code"><i class="fa-solid fa-terminal"></i></a> 348 <a class="docs-toolbar-btn tooltip-init" data-doc-command="codeBlock" data-doc-state="codeBlock" aria-label="Display code" data-tooltip="Display code"><i class="fa-regular fa-square-caret-left"></i></a> 349 </span> 350 <span class="docs-toolbar-separator"></span> 351 <span class="docs-toolbar-group" data-doc-group="elements"> 352 <a class="docs-toolbar-btn tooltip-init" data-docs-media-trigger aria-label="Image" data-tooltip="Image"><i class="fa-regular fa-image"></i></a> 353 <a class="docs-toolbar-btn tooltip-init" data-click="docsOpenTableInsert" aria-label="Insert table" data-tooltip="Insert table"><i class="fa-solid fa-table-cells"></i></a> 354 <a class="docs-toolbar-btn tooltip-init" data-doc-command="graph" data-doc-state="graph" aria-label="Graph" data-tooltip="Graph"><i class="fa-solid fa-chart-line"></i></a> 355 <a class="docs-toolbar-btn tooltip-init" data-doc-command="mermaid" data-doc-state="mermaid" aria-label="Flowchart" data-tooltip="Flowchart"><i class="fa-solid fa-diagram-project"></i></a> 356 <a class="docs-toolbar-btn tooltip-init" data-doc-command="youtube" aria-label="YouTube" data-tooltip="YouTube"><i class="fa-brands fa-youtube"></i></a> 357 <a class="docs-toolbar-btn tooltip-init" data-doc-command="twitch" aria-label="Twitch" data-tooltip="Twitch"><i class="fa-brands fa-twitch"></i></a> 358 </span> 359 </div> 360 <div class="docs-editor-scroll"> 361 <div class="docs-editor-surface" data-docs-editor>${e?mE():""}</div> 362 ${e?"":gg(n)} 363 </div> 364 </div> 365 `}function gg(t=[]){const e=Array.isArray(t)?t:[];return` 366 <section class="docs-linked-flashcards" id="docsLinkedFlashcards" data-docs-linked-flashcards> 367 <div class="block-title">Flashcard sets</div> 368 <div class="block-footer">Linked sets will highlight matching terms in learn.</div> 369 <div class="list list-strong list-dividers inset"> 370 <ul> 371 <li> 372 <div class="item-content item-input"> 373 <div class="item-media"><i class="fa-solid fa-note-sticky"></i></div> 374 <div class="item-inner"> 375 <div class="item-title item-label">Linked flashcards</div> 376 <div class="item-input-wrap"> 377 <div class="docs-linked-flashcards-select" data-docs-linked-flashcards-select></div> 378 </div> 379 </div> 380 </div> 381 </li> 382 </ul> 383 </div> 384 <div class="docs-linked-flashcards-list" data-docs-linked-flashcards-list> 385 ${e.length?e.map(n=>_g(n,{showCourseHeader:!1})).join(""):'<p class="docs-linked-flashcards-empty muted-text">No flashcard sets linked.</p>'} 386 </div> 387 </section> 388 `}const _e=Hg(),sn=Ih(),gE=["#111827","#6b7280","#dc2626","#ea580c","#ca8a04","#16a34a","#2563eb","#9333ea"],yE=["#fef08a","#fed7aa","#fecaca","#bbf7d0","#bfdbfe","#ddd6fe","#fbcfe8"],vr=[8,9,10,11,12,14,18,24,30,36,48,60,72,96],bE=17,kE={h1:36,h2:30,h3:24,h4:20,h5:18,h6:16},xE=8,wE=10;let oe=null,Pr=0,Tt=0,ys=null,er=[],bs=null,ks=null;function Zo(t={}){const e=Number.parseInt(t.fontSize||"",10);return Number.isFinite(e)?e:kE[t.heading]||bE}function yg(t,e=!1){const n=Number.parseInt(String(t?.value||"").trim(),10);if(!Number.isInteger(n)||n<=0){t.value=String(Zo(oe?.getToolbarState?.()));return}t.value=String(n),oe?.runCommand("fontSize",`${n}px`,t),e&&sn.close()}function Eh(t){const e=t.target?.closest?.("[data-doc-command], [data-click], [data-docs-media-trigger]");if(!(!e||!t.currentTarget.contains(e))&&!e.classList.contains("is-disabled")){if(e.matches("[data-doc-font-size-input]")){oe?.captureSelection?.();return}t.preventDefault(),oe?.captureSelection?.()}}function Ah(t){const e=t.target?.closest?.("a, button");!e||!t.currentTarget.contains(e)||t.preventDefault()}function Xc(t){const e=t?.el;e&&(e.addEventListener("mousedown",Ah),t.on("closed",()=>{e.removeEventListener("mousedown",Ah)}))}function SE(t){const e=String(t||"Saved").trim()||"Saved",n=_e.get()?.querySelector(`[data-action-id="save:${Cn.type}"]`);n&&(n.setAttribute("aria-label",e),n.setAttribute("data-tooltip",e))}function vE(t=[]){return` 389 <div class="docs-modern-popover-panel docs-toolbar-popover"> 390 <div class="list links-list no-margin"> 391 <ul class="list-unstyled"> 392 ${t.map(e=>` 393 <li> 394 <a class="list-button docs-popover-close${e.active?" is-active":""}" data-click="docsToolbarMenuCommand" data-menu-command="${String(e.command).attr()}" data-value="${String(e.value||"").attr()}"${e.active?' aria-current="true"':""}> 395 ${e.iconClass||e.icon?`<span class="docs-toolbar-popover-icon">${e.iconClass?`<i class="${String(e.iconClass).attr()}"></i>`:String(e.icon).html()}</span>`:""}
396 <span>${String(e.label||"").html()}</span> 397 </a> 398 </li> 399 `).join("")} 400 </ul> 401 </div> 402 </div>`}function CE(t,e){return!t?.stateKey||!e?!1:t.stateKey==="heading"?e.heading===t.stateValue:t.stateKey==="list"?e.list===t.stateValue:t.stateKey==="align"?e.align===t.stateValue:!1}async function Za(t,e){oe?.preserveSelection?.();const n=await sn.toggle(t,{content:vE(e.map(r=>({...r,active:CE(r,oe?.getToolbarState?.())})))});if(!n){oe?.releaseSelection?.();return}oe?.preserveSelection?.(),Xc(n),n.on("closed",()=>{oe?.releaseSelection?.()})}function Nh(t,e,n=!1){return` 403 <div class="docs-modern-popover-panel docs-style-popover"> 404 <div class="docs-style-menu-grid"> 405 ${e.map(r=>r.value==="reset"?`<button class="docs-style-reset" type="button" data-style-command="${String(t).attr()}" data-style-value="reset">Reset</button>`:`<button class="docs-color-swatch tooltip-init" type="button" data-style-command="${String(t).attr()}" data-style-value="${String(r.value).attr()}" style="--docs-swatch-color:${String(r.value).attr()}" aria-label="${String(r.label||r.value).attr()}" data-tooltip="${String(r.label||r.value).attr()}"><span></span></button>`).join("")} 406 </div> 407 ${n?` 408 <label class="docs-custom-color"> 409 <input type="color" data-style-picker="${String(t).attr()}" value="#ffffff"> 410 <span><i class="fa-solid fa-eyedropper"></i> Custom color</span> 411 </label> 412 `:""} 413 </div>`}function ME(){const t=Zo(oe?.getToolbarState?.());return` 414 <div class="docs-modern-popover-panel docs-font-size-popover" role="listbox" aria-label="Font size"> 415 <button class="docs-font-size-option tooltip-init" type="button" data-style-command="fontSize" data-style-value="reset" aria-label="Reset font size" data-tooltip="Reset font size"> 416 <i class="fa-solid fa-rotate-left"></i> 417 </button> 418 ${vr.map(e=>` 419 <button class="docs-font-size-option${e===t?" is-active":""}" type="button" role="option" aria-selected="${String(e===t)}" data-style-command="fontSize" data-style-value="${String(e)}px">${String(e)}</button> 420 `).join("")} 421 </div>`}async function el(t,e,n){oe?.preserveSelection?.();const r=await sn.open(t,{content:n});if(!r){oe?.releaseSelection?.();return}oe?.preserveSelection?.(),Xc(r),r.on("closed",()=>{oe?.releaseSelection?.()}),r.el.querySelectorAll("[data-style-command]").forEach(s=>{s.addEventListener("click",()=>{oe?.runCommand(s.dataset.styleCommand,s.dataset.styleValue,t),sn.close()})}),r.el.querySelectorAll("[data-style-picker]").forEach(s=>{s.addEventListener("input",()=>{oe?.runCommand(s.dataset.stylePicker,s.value,t)}),s.addEventListener("change",()=>{sn.close()})})}function TE(){const t=[];for(let e=1;e<=xE;e+=1)for(let n=1;n<=wE;n+=1)t.push(` 422 <button class="docs-table-picker-cell" type="button" role="gridcell" data-table-size="${e}:${n}" aria-label="${e} by ${n} table"></button> 423 `);return` 424 <div class="docs-modern-popover-panel docs-table-picker-popover"> 425 <div class="docs-table-picker-label" data-table-picker-label>Insert table</div> 426 <div class="docs-table-picker-grid" role="grid" aria-label="Table size"> 427 ${t.join("")} 428 </div> 429 </div>`}async function EE(t){oe?.preserveSelection?.();const e=await sn.toggle(t,{content:TE()});if(!e){oe?.releaseSelection?.();return}oe?.preserveSelection?.(),Xc(e),e.on("closed",()=>{oe?.releaseSelection?.()});const n=e.el,r=n.querySelector(".docs-table-picker-grid"),s=n.querySelector("[data-table-picker-label]"),i=()=>{n.querySelectorAll("[data-table-size].is-highlighted").forEach(a=>{a.classList.remove("is-highlighted")}),s&&(s.textContent="Insert table")},o=a=>{const[l,c]=String(a?.dataset.tableSize||"").split(":").map(Number);!l||!c||(n.querySelectorAll("[data-table-size]").forEach(u=>{const[d,h]=String(u.dataset.tableSize||"").split(":").map(Number);u.classList.toggle("is-highlighted",d<=l&&h<=c)}),s&&(s.textContent=`${l} Ã ${c}`))};r?.addEventListener("pointerover",a=>{o(a.target.closest("[data-table-size]"))}),r?.addEventListener("focusin",a=>{o(a.target.closest("[data-table-size]"))}),r?.addEventListener("pointerleave",i),r?.addEventListener("click",a=>{const l=a.target.closest("[data-table-size]");if(!l||!r.contains(l))return;const[c,u]=String(l.dataset.tableSize||"").split(":").map(Number);oe?.runCommand("table",`${c}:${u}`,t),sn.close()})}function Rh(t){if(!t)return;const e=_e.getViewElement()?.querySelector("[data-docs-toolbar]");if(!e)return;const n={heading:!0,list:!!t.list,align:t.align!=="left",fontSize:!!t.fontSize,color:!!t.color,bold:t.bold,italic:t.italic,underline:t.underline,highlight:t.highlight,strike:t.strike,link:t.link,mathInline:t.mathInline,mathBlock:t.mathBlock,graph:t.graph,mermaid:t.mermaid,quote:t.quote,codeInline:t.codeInline,codeBlock:t.codeBlock};e.querySelectorAll("[data-doc-state]").forEach(c=>{const u=!!n[c.dataset.docState];c.classList.toggle("is-active",u),c.setAttribute("aria-pressed",String(u))}),e.querySelectorAll("[data-doc-disabled-state]").forEach(c=>{const u=!!t[c.dataset.docDisabledState];c.classList.toggle("is-disabled",!u),c.setAttribute("aria-disabled",String(!u))});const r=e.querySelector("[data-doc-heading-glyph]");r&&(r.textContent=t.heading==="paragraph"?"T":t.heading.toUpperCase());const s=e.querySelector("[data-doc-font-size-input]");
429s&&(s.value=String(Zo(t)));const i=e.querySelector("[data-doc-list-icon]");i&&(i.className=t.list==="task"?"fa-solid fa-list-check":t.list==="ordered"?"fa-solid fa-list-ol":"fa-solid fa-list-ul");const o=e.querySelector("[data-doc-align-icon]");o&&(o.className=`fa-solid fa-align-${t.align==="justify"?"justify":t.align||"left"}`);const a=e.querySelector('[data-doc-color-strip="color"]');a&&(a.style.backgroundColor=t.color||"currentColor",a.classList.toggle("is-default",!t.color));const l=e.querySelector('[data-doc-color-strip="highlight"]');l&&(l.style.backgroundColor=t.highlightColor||(t.highlight?"#fff59d":"transparent"),l.classList.toggle("is-default",!t.highlightColor&&!t.highlight))}function AE(){return er.map(t=>String(t?.id||"")).filter(Boolean)}async function NE(t={},e=Tt){if(bs)return bs;const n=t?.set||Bn.get(Pr)||{},s=(Array.isArray(t?.setCourses)?t.setCourses:[]).map(l=>Number(l?.id||0)).filter(Boolean),i=$g(n),o=i>0?[i]:[],a=await An.fetch({action:"set:listSelectionOptions",types:["flashcards"],orgIds:o,courseIds:s,limit:24},{error:!1}).catch(()=>
429({ownedSets:[],favoriteExternalSets:[],publicSets:[]}));return e!==Tt?null:(Yl([...Array.isArray(a?.ownedSets)?a.ownedSets:[],...Array.isArray(a?.favoriteExternalSets)?a.favoriteExternalSets:[],...Array.isArray(a?.publicSets)?a.publicSets:[]],"docs-set-selection"),Dg.merge(a?.courses||[],"set-selection-courses"),(Array.isArray(a?.entities)?a.entities:[]).forEach(l=>{Oo.push(l)}),bs=a,a)}function RE(){const t=_e.getViewElement()?.querySelector("[data-docs-linked-flashcards]");if(!t)return;const e=document.createElement("div");e.innerHTML=gg(er);const n=e.firstElementChild;n&&t.replaceWith(n)}async function bg(t={},e=Tt){ys?.destroy?.(),ys=null;const n=_e.getViewElement()?.querySelector("[data-docs-linked-flashcards-select]");if(!n)return;const r=await NE(t,e);if(e!==Tt||!r)return;const s=t?.set||Bn.get(Pr)||{},i=(Array.isArray(t?.setCourses)?t.setCourses:[]).map(c=>Number(c?.id||0)).filter(Boolean),o=AE(),a=[s?.name,...Array.isArray(t?.setCourses)?t.setCourses.map(c=>c?.name):[]].filter(Boolean).join(" "),l={owned:ma(r?.ownedSets||[],{types:["flashcards"],category:"owned",selectedIds:o,courseIds:i,contextText:a}
429),favorites:ma(r?.favoriteExternalSets||[],{types:["flashcards"],category:"favorites",selectedIds:o,courseIds:i,contextText:a}),public:ma(r?.publicSets||[],{types:["flashcards"],category:"public",selectedIds:o,courseIds:i,contextText:a})};ys=Ug(n,{label:null,placeholder:"Select flashcard sets",searchPlaceholder:"Search public flashcard sets",multiple:!0,types:["flashcards"],selectedIds:o,courseIds:i,contextText:a,choices:l.owned,callback(c){OE(c)}},{getChoices(c){return l[c]||l.owned},getCategoryChoices(c){return l[c]||[]}})}async function OE(t){const e=Tt,n=Pr,s=(Array.isArray(t?.choice?.())?t.choice():[]).map(o=>Number(o?.setId||o?.value||0)).filter(Boolean),i=await An.fetch({action:"docs:updateLinks",setId:n,setIds:s},{error:!0});e!==Tt||n!==Pr||((Array.isArray(i?.entities)?i.entities:[]).forEach(o=>{Oo.push(o)}),er=Yl(i?.linkedSets,"docs-linked-flashcards"),RE(),bg({set:Bn.get(n)||{},setCourses:[]},e))}async function LE(){const{default:t}=await Ig(async()=>{const{default:e}=await import("./state-C7hNOihD.js").then(n=>n.l);return{default:e}},__vite__mapDeps([0,1,2]));await t.loadUser({error:!1}).catch(()=>null)}async function IE(){if(!oe)return;const t=oe;oe=null,await t.destroy()}Oh({id:`save:${Cn.type}`,type:Cn.type,name:"Save document",label:"Save",icon:"fa-solid fa-cloud",tooltip:"Save",order:1,contexts:["popup-main"],execute(){return oe?.saveNow("manual")}});Oh({id:`links:${Cn.type}`,type:Cn.type,name:"Flashcard sets",label:"Flashcard sets",icon:"fa-solid fa-note-sticky",order:1,contexts:["popup-more"],execute(){_e.getViewElement()?.querySelector("[data-docs-linked-flashcards]")?.scrollIntoView?.({behavior:"smooth",block:"start"})}});An.click.register({docsDeleteSelectedImage(t,e){e.preventDefault(),oe?.deleteSelectedImage?.()},docsOpenHeadingMenu(t,e){e.preventDefault(),oe?.captureSelection?.(),Za(t,[{command:"heading",value:"1",label:"Heading 1",stateKey:"heading",stateValue:"h1"},{command:"heading",value:"2",label:"Heading 2",stateKey:"heading",stateValue:"h2"},{command:"heading",value:"3",label:"Heading 3",stateKey:"heading",stateValue:"h3"},{command:"heading",value:"4",label:"Heading 4",stateKey:"heading",stateValue:"h4"},{command:"paragraph",label:"Text",stateKey:"heading",stateValue:"paragraph"}])},docsOpenListMenu(t,e){e.preventDefault(),oe?.captureSelection?.(),Za(t,[{command:"bullet",icon:"â¢",label:"Bullet List",stateKey:"list",stateValue:"bullet"},{command:"ordered",icon:"1.",label:"Numbered List",stateKey:"list",stateValue:"ordered"},{command:"task",icon:"â",label:"Task List",stateKey:"list",stateValue:"task"}])},docsOpenAlignMenu(t,e){e.preventDefault(),oe?.captureSelection?.(),Za(t,[{command:"align",value:"left",iconClass:"fa-solid fa-align-left",label:"Align Left",stateKey:"align",stateValue:"left"},{command:"align",value:"center",iconClass:"fa-solid fa-align-center",label:"Align Center",stateKey:"align",stateValue:"center"},{command:"align",value:"right",iconClass:"fa-solid fa-align-right",label:"Align Right",stateKey:"align",stateValue:"right"},{command:"align",value:"justify",iconClass:"fa-solid fa-align-justify",label:"Align Justify",stateKey:"align",stateValue:"justify"}])},docsFontSizeStep(t,e){e.preventDefault();const r=t.closest("[data-docs-toolbar]")?.querySelector("[data-doc-font-size-input]"),s=Number.parseInt(r?.value||"",10)||Zo(oe?.getToolbarState?.()),o=Number(t.dataset.fontSizeStep||0)<0?[...vr].reverse().find(a=>a<s)||vr[0]:vr.find(a=>a>s)||vr[vr.length-1];r&&(r.value=String(o)),oe?.runCommand("fontSize",`${o}px`,t)},docsOpenFontSizeMenu(t,e){e.preventDefault(),el(t,"fontSize",ME())},docsOpenTextColorMenu(t,e){e.preventDefault(),el(t,"color",Nh("color",[...gE.map(n=>({value:n})),{value:"reset",label:"Default color"}],!0))},docsOpenHighlightMenu(t,e){e.preventDefault(),el(t,"highlightColor",Nh("highlightColor",[...yE.map(n=>({value:n})),{value:"reset",label:"Remove highlight"}],!0))},docsOpenTableInsert(t,e){e.preventDefault(),oe?.captureSelection?.(),EE(t)},docsToolbarMenuCommand(t){oe?.runCommand(t.dataset.menuCommand,t.dataset.value,t),sn.close()},"[data-doc-command]"(t,e){e.preventDefault(),!t.classList.contains("is-disabled")&&oe?.runCommand(t.dataset.docCommand,t.dataset.value,t)}});An.change.register({"[data-doc-font-size-input]"(t){yg(t)}});An.keydown.register({keys:["Enter"],target:"[data-doc-font-size-input]"},(t,e)=>{e.preventDefault(),yg(t,!0)});async function DE(t){const e=Number(t?.id||0);if(!e)throw new Error("A document requires a numeric set id.");const n=Tt+1;Tt=n,Pr=e,er=[],bs=null,ks?.(),ks=null,_e.setViewClasses("docs-editor-popup"),_e.get().dataset.libraryFeature=Cn.t
429ype,_e.setBackPath(Wh),_e.setTitle("Docs"),_e.getViewElement().innerHTML=Th({loading:!0}),_e.setActions(zg({...t,type:Cn.type})),_e.setEmpty(""),_e.setLoading(!1);const r=Bn.getPayload(e),[s]=await Promise.all([r||An.fetch({action:"docs:get",setId:e}),LE()]);if(n!==Tt)return null;Bn.setPayload(e,s);const i=Bn.upsert({...s.set,type:Cn.type});(Array.isArray(s?.entities)?s.entities:[]).forEach(l=>{Oo.push(l)}),er=Yl(s?.linkedSets,"docs-linked-flashcards"),_e.setSet(i),_e.getViewElement().innerHTML=Th({linkedSets:er}),bg(s,n);const o=_e.getViewElement().querySelector("[data-docs-editor]");if(n!==Tt)return null;oe=pE({set:s.set,content:s.content,collab:s.collab,editorEl:o,onStatus:SE,onStateChange:Rh,onSaved(l){l&&Object.keys(l).length&&Bn.updateMeta(e,l)}});const a=_e.getViewElement()?.querySelector("[data-docs-toolbar]");return a&&(a.addEventListener("mousedown",Eh),ks=()=>{a.removeEventListener("mousedown",Eh)}),Rh(oe.getToolbarState?.()),_e.setLoading(!1),i}async function PE(){Tt+=1,ks?.(),ks=null,await sn.close(),ys?.destroy?.(),ys=null,er=[],bs=null,Pr=0,await IE()}function $E(){return Wh}const BA={buildDocsRoute:My,close:PE,getBackPath:$E,render:DE};export{Wh as DOCS_ROUTE,mT as buildDocImageUrl,My as buildDocsRoute,PE as close,pE as createDocsEditorRuntime,BA as default,Bn as docsState,$E as getBackPath,FA as getDocsSearchText,DE as render,ph as uploadDocImage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.