1import{a as Cn,a_ as Ot,r as S,a$ as lf,b0 as Ag,j as y,b1 as xl,b2 as Ng,A as Og,y as Rg,b3 as ka,b4 as Dg,b as He,b5 as Sa,l as uo,m as cf,Q as df,v as vl,b6 as uf,b7 as Ig,V as Lg,s as Pg,b8 as jg,g as Nc,T as Zr,b9 as Se,L as Er,X as xn,C as ff,af as Fn,aM as wl,ba as $g,bb as zg,W as hf,as as Bg,o as pf,Y as Hg,bc as _g,bd as Ca,I as mf,be as Fg,ag as Vg,bf as ls,ak as Wg,h as Ug,i as qg,bg as Kg,bh as Jg,D as gf,F as yf,bi as Gg,bj as Yg,bk as Oc,bl as Rc,w as Ta,al as Xg,bm as bf,z as Qg,P as Zg,d as ey,bn as ty,bo as xf,bp as Dc,bq as ny,br as Ho,bs as Ic,aq as vf,bt as ry,a0 as iy,t as sy,$ as oy,a4 as ay,k as ly,aV as cy,aW as dy,aZ as uy,bu as fy,bv as hy}from"./index-BawMCgu8.js";import{u as wf}from"./chat-Cp3tSG9E.js";import{u as Fe,P as py}from"./index-CKRYCHHU.js";import{B as my,I as gy,A as yy,a as by,b as xy,U as vy}from"./undo-2-B7yg3O6I.js";import{U as wy,S as ky,H as kf,a as Sf,b as Cf}from"./underline-x2bjYOL2.js";import{F as Sy}from"./file-up-DwQYvKZ7.js";import{R as Cy}from"./redo-2-BNRfpAAM.js";import{T as Ty}from"./table-DvUKeEob.js";import{F as Tf,e as Ey}from"./index-xSdyNPg7.js";import{F as My}from"./file-type-nKRGBr5R.js";import{u as Lc}from"./useMutation-D0Pwndul.js";import{A as Ay}from"./arrow-down-to-line-B7YpRwzl.js";import{S as Ny}from"./save-BInnCtLF.js";import{F as Oy}from"./focus-B2P-yv9L.js";import{H as Ry}from"./history-CWHZzLwH.js";import"./locale-en-B8Z5F_o1.js";import"./locale-zh-CN-CFdD1mPv.js";import"./locale-fr-j4CMJpfE.js";import"./locale-de-DuE2gagy.js";import"./locale-it-C6yb6RzN.js";import"./locale-ja-VjZBy5eF.js";import"./locale-ko-Cl0W-Az5.js";import"./locale-es-DwboUZze.js";import"./locale-zh-Hant-uT5aTnfX.js";import"./locale-ru-DEr1xfTZ.js";import"./locale-id-Buh3Uolz.js";import"./locale-pt-BR-CqD5J4_0.js";/** 2 * @license lucide-react v0.309.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Dy=Cn("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** 7 * @license lucide-react v0.309.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Iy=Cn("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7.5L14.5 2H6a2 2 0 0 0-2 2v4",key:"702lig"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M4 18h2",key:"1xrofg"}],["path",{d:"M5 12v6",key:"150t9c"}]]);/** 12 * @license lucide-react v0.309.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Ef=Cn("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/** 17 * @license lucide-react v0.309.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const Ly=Cn("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** 22 * @license lucide-react v0.309.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const Py=Cn("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** 27 * @license lucide-react v0.309.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const jy=Cn("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/** 32 * @license lucide-react v0.309.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const $y=Cn("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** 37 * @license lucide-react v0.309.0 - ISC 38 * 39 * This source code is licensed under the ISC license. 40 * See the LICENSE file in the root directory of this source tree. 41 */const zy=Cn("Unlink2",[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",ke
vendor: 10,219 bytes, line 41
41y:"1re2ne"}]]);function Me(t){this.content=t}Me.prototype={constructor:Me,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,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Me(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Me(n)},addToStart:function(t,e){return new Me([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Me(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new Me(i)},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=Me.from(t),t.size?new Me(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Me.from(t),t.size?new Me(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Me.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}};Me.from=function(t){if(t instanceof Me)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Me(e)};function Mf(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=Mf(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Af(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),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,d=Math.min(o.text.length,a.text.length);for(;c<d&&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=Af(o.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class N{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,i=0,s){for(let o=0,a=0;a<n;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&r(l,i+a,s||null,o)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),r,i+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",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?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new N(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let a=this.content[s],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),i+=a.nodeSize),o=l}return new N(r,i)}cutByIndex(e,n){return e==n?N.empty:e==0&&n==this.content.length?this:new N(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new N(i,s)}addToStart(e){return new N([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new N(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 i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Mf(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Af(this,e,n,r)}findIndex(e){if(e==0)return Fi(0,e);if(e==this.size)return Fi(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 i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?Fi(n+1,s):Fi(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return N.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new N(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return N.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new N(n||e,r)}static from(e){if(!e)return N.empty;if(e instanceof N)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new N([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}N.empty=new N([],0);const _o={index:0,offset:0};function Fi(t,e){return _o.index=t,_o.offset=e,_o}function ys(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(!ys(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ys(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let oe=class Ea{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}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&&ys(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 i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}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 Ea.none;if(e instanceof Ea)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};oe.none=[];class bs extends Error{}class ${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=Of(this.content,e+this.openStart,n);return r&&new $(r,this.openStart,this.openEnd)}removeBetween(e,n){return new $(Nf(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return $.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new $(N.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new $(e,r,i)}}$.empty=new $(N.empty,0,0);function Nf(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.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,s.copy(Nf(s.content,e-i-1,n-i-1)))}function Of(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=Of(o.content,e-s-1,n,o);return a&&t.replaceChild(i,o.copy(a))}function By(t,e,n){if(n.openStart>t.depth)throw new bs("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new bs("Inconsistent open depths");return Rf(t,e,n,0)}function Rf(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=Rf(t,e,n,r+1);return s.copy(s.content.replaceChild(i,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 Wn(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=Hy(n,t);return Wn(s,If(t,o,a,e,r))}else return Wn(s,xs(t,e,r))}function Df(t,e){if(!e.type.compatibleContent(t.type))throw new bs("Cannot join "+e.type.name+" onto "+t.type.name)}function Ma(t,e,n){let r=t.node(n);return Df(r,e.node(n)),r}function Vn(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)}
vendor: 12,047 bytes, lines 41-42
41function ei(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Vn(t.nodeAfter,r),s++));for(let a=s;a<o;a++)Vn(i.child(a),r);e&&e.depth==n&&e.textOffset&&Vn(e.nodeBefore,r)}function Wn(t,e){return t.type.checkContent(e),t.copy(e)}function If(t,e,n,r,i){let s=t.depth>i&&Ma(t,e,i+1),o=r.depth>i&&Ma(n,r,i+1),a=[];return ei(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(Df(s,o),Vn(Wn(s,If(t,e,n,r,i+1)),a)):(s&&Vn(Wn(s,xs(t,e,i+1)),a),ei(e,n,i,a),o&&Vn(Wn(o,xs(n,r,i+1)),a)),ei(r,null,i,a),new N(a)}function xs(t,e,n){let r=[];if(ei(null,t,n,r),t.depth>n){let i=Ma(t,e,n+1);Vn(Wn(i,xs(t,e,n+1)),r)}return ei(e,null,n,r),new N(r)}function Hy(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(N.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class pi{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],i=e.child(n);return r?e.child(n).cut(r):i}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],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return oe.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let a=r;r=i,i=a}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].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 vs(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=[],i=0,s=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),c=s-l;if(r.push(o,a,i+l),!c||(o=o.child(a),o.isText))break;s=c-1,i+=l+1}return new pi(n,r,s)}static resolveCached(e,n){let r=Pc.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else Pc.set(e,r=new _y);let i=r.elts[r.i]=pi.resolve(e,n);return r.i=(r.i+1)%Fy,i}}class _y{constructor(){this.elts=[],this.i=0}}const Fy=12,Pc=new WeakMap;class vs{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 Vy=Object.create(null);let hn=class Aa{constructor(e,n,r,i=oe.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||N.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,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ys(this.attrs,n||e.defaultAttrs||Vy)&&oe.sameSet(this.marks,r||oe.none)}copy(e=null){return e==this.content?this:new Aa(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Aa(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 $.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),a=i.start(o),c=i.node(o).content.cut(i.pos-a,s.pos-a);return new $(c,i.depth-o,s.depth-o)}replace(e,n,r){return By(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+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 i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return pi.resolveCached(this,e)}resolveNoCache(e){return pi.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Lf(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=N.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.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=oe.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!oe.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=N.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};hn.prototype.text=void 0;class ws extends hn{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Lf(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 ws(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ws(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 Lf(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Yn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Wy(e,n);if(r.next==null)return Yn.empty;let i=Pf(r);r.next&&r.err("Unexpected trailing text");let s=Xy(Yy(i));return Qy(s,r),s}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 i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}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 i=[this];function s(o,a){let l=o.matchFragment(e,r);if(l&&(!n||l.validEnd))return N.from(a.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let f=s(u,a.concat(d));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let 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 i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let a=i;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:a,next:l}=s.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),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 i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(` 42`)}}Yn.empty=new Yn(!0);class Wy{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?
vendor: 9,749 bytes, line 42
42=\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 Pf(t){let e=[];do e.push(Uy(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Uy(t){let e=[];do e.push(qy(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function qy(t){let e=Gy(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=Ky(t,e);else break;return e}function jc(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Ky(t,e){let n=jc(t),r=n;return t.eat(",")&&(t.next!="}"?r=jc(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Jy(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function Gy(t){if(t.eat("(")){let e=Pf(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=Jy(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 Yy(t){let e=[[]];return i(s(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 i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=s(o.exprs[l],a);if(l==o.exprs.length-1)return c;i(c,a=n())}else if(o.type=="star"){let l=n();return r(a,l),i(s(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=n();return i(s(o.expr,a),l),i(s(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c<o.min;c++){let d=n();i(s(o.expr,l),d),l=d}if(o.max==-1)i(s(o.expr,l),l);else for(let c=o.min;c<o.max;c++){let d=n();r(l,d),i(s(o.expr,l),d),l=d}return[r(l)]}else{if(o.type=="name")return[r(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function jf(t,e){return e-t}function $c(t,e){let n=[];return r(e),n.sort(jf);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:a,to:l}=s[o];!a&&n.indexOf(l)==-1&&r(l)}}}function Xy(t){let e=Object.create(null);return n($c(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<i.length;d++)i[d][0]==a&&(c=i[d][1]);$c(t,l).forEach(d=>{c||i.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[r.join(",")]=new Yn(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let a=i[o][1].sort(jf);s.next.push({type:i[o][0],next:e[a.join(",")]||n(a)})}return s}}function Qy(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];o.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function $f(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 zf(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function Bf(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let s=t[i];s.validate&&s.validate(e[i])}}function Hf(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new eb(t,r,e[r]);return n}let zc=class _f{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=Hf(e,r.attrs),this.defaultAttrs=$f(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==Yn.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:zf(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new hn(this,this.computeAttrs(e),N.from(n),oe.setFrom(r))}createChecked(e=null,n,r){return n=N.from(n),this.checkContent(n),new hn(this,this.computeAttrs(e),n,oe.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=N.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(N.empty,!0);return s?new hn(this,e,n.append(s),oe.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Bf(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:oe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new _f(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Zy(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class eb{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Zy(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class fo{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Hf(e,i.attrs),this.excluded=null;let s=$f(this.attrs);this.instance=s?new oe(this,s):null}create(e=null){return!e&&this.instance?this.instance:new oe(this,zf(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new fo(s,i++,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){Bf(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ff{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Me.from(e.nodes),n.marks=Me.from(e.marks||{}),this.nodes=zc.compile(this.spec.nodes,this),this.marks=fo.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Yn.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=a=="_"?null:a?Bc(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Bc(this,o.split(" "))}this.nodeFromJSON=i=>hn.fromJSON(this,i),this.markFromJSON=i=>oe.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof zc){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,i)}text(e,n){let r=this.nodes.text;return new ws(r,r.defaultAttrs,e,oe.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Bc(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let a in t.marks){let l=t.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function tb(t){return t.tag!=null}function nb(t){return t.style!=null}class pn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];
vendor: 5,132 bytes, lines 42-43
42n.forEach(i=>{if(tb(i))this.tags.push(i);else if(nb(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new _c(this,n,!1);return r.addAll(e,oe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new _c(this,n,!0);return r.addAll(e,oe.none,n.from,n.to),$.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(sb(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],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(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let a=n[o];if((a.priority==null?50:a.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Fc(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Fc(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new pn(e,pn.schemaRules(e)))}}const Vf={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},rb={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Wf={ol:!0,ul:!0},mi=1,Na=2,ti=4;function Hc(t,e,n){return e!=null?(e?mi:0)|(e==="full"?Na:0):t&&t.whitespace=="pre"?mi|Na:n&~ti}class Vi{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=oe.none,this.match=s||(o&ti?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(N.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&mi)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=N.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(N.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&&!Vf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class _c{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=Hc(null,n.preserveWhitespace,0)|(r?ti:0);i?s=new Vi(i.type,i.attrs,oe.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new Vi(null,null,oe.none,!0,null,o):s=new Vi(e.schema.topNodeType,null,oe.none,!0,null,o),this.nodes=[s],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,i=this.top,s=i.options&Na?"full":this.localPreserveWS||(i.options&mi)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,` 43`);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=i.content[i.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 i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;Wf.hasOwnProperty(o)&&this.parser.normalizeLists&&ib(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:rb.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,d=this.needsBlock;
vendor: 4,817 bytes, lines 43-44
43if(Vf.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let u=l&&l.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` 44`),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 i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(s,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,i){let s,o;if(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&&(s=!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(i)this.addElement(e,r,i);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)}s&&this.sync(a)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];o!=a;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=oe.none;for(let a of i.concat(e.marks))(s.type?s.type.allowsMarkType(a.type):Vc(a.type,e.type))&&(o=a.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=Hc(e,s,o.options);o.options&ti&&o.content.length==0&&(a|=ti);let l=oe.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Vc(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Vi(e,n,l,i,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|=mi)}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 i=r.length-1;i>=0;i--)e+=r[i].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 i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].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,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?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>=s;l--)if(o(a-1,l))return!0;return!1}else{let d=l>
vendor: 8,228 bytes, line 44
440||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return 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];if(r.isTextblock&&r.defaultAttrs)return r}}}function ib(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Wf.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function sb(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Fc(t){let e={};for(let n in t)e[n]=t[n];return e}function Vc(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class ir{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Fo(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let a=0,l=0;for(;a<s.length&&l<o.marks.length;){let c=o.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)i=s.pop()[1];for(;l<o.marks.length;){let c=o.marks[l++],d=this.serializeMark(c,o.isInline,n);d&&(s.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=cs(Fo(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&cs(Fo(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return cs(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ir(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Wc(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Wc(e.marks)}}function Wc(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Fo(t){return t.document||window.document}const Uc=new WeakMap;function ob(t){let e=Uc.get(t);return e===void 0&&Uc.set(t,e=ab(t)),e}function ab(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 i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function cs(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=ob(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?l.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&l.style?l.style.cssText=c[u]:l.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:p}=cs(t,f,n,r);if(l.appendChild(h),p){if(a)throw new RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}const Uf=65535,qf=Math.pow(2,16);function lb(t,e){return t+e*qf}function qc(t){return t&Uf}function cb(t){return(t-(t&Uf))/qf}const Kf=1,Jf=2,ds=4,Gf=8;class Oa{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Gf)>0}get deletedBefore(){return(this.delInfo&(Kf|ds))>0}get deletedAfter(){return(this.delInfo&(Jf|ds))>0}get deletedAcross(){return(this.delInfo&ds)>0}}class Je{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Je.empty)return Je.empty}recover(e){let n=0,r=qc(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+cb(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 i=0,s=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?i:0);if(l>e)break;let c=this.ranges[a+s],d=this.ranges[a+o],u=l+c;if(e<=u){let f=c?e==l?-1:e==u?1:n:n,h=l+i+(f<0?0:d);if(r)return h;let p=e==(n<0?l:u)?null:lb(a/3,e-l),m=e==l?Jf:e==u?Kf:ds;return(n<0?e!=l:e!=u)&&(m|=Gf),new Oa(h,m,p)}i+=d-c}return r?e+i:new Oa(e+i,0,null)}touches(e,n){let r=0,i=qc(n),s=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+s],d=l+c;if(e<=d&&a==i*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 i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],a=o-(this.inverted?s:0),l=o+(this.inverted?0:s),c=this.ranges[i+n],d=this.ranges[i+r];e(a,a+c,l,l+d),s+=d-c}}invert(){return new Je(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Je.empty:new Je(e<0?[0,-e,0]:[0,0,e])}}Je.empty=new Je([]);class gi{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new gi(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 i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i: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 i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new gi;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 i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],a=o.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new Oa(e,i,null)}}const Vo=Object.create(null);class Pe{getMap(){return Je.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Vo[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 Vo)throw new RangeError("Duplicate use of step JSON ID "+e);return Vo[e]=n,n.prototype.jsonID=e,n}}class ye{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ye(e,null)}static fail(e){return new ye(null,e)}static fromReplace(e,n,r,i){try{return ye.ok(e.replace(n,r,i))}catch(s){if(s instanceof bs)return ye.fail(s.message);throw s}}}function kl(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(kl(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return N.fromArray(r)}class dn extends Pe{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),i=r.no
vendor: 7,124 bytes, line 44
44de(r.sharedDepth(this.to)),s=new $(kl(n.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return ye.fromReplace(e,this.from,this.to,s)}invert(){return new pt(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 dn(n.pos,r.pos,this.mark)}merge(e){return e instanceof dn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new dn(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 dn(n.from,n.to,e.markFromJSON(n.mark))}}Pe.jsonID("addMark",dn);class pt extends Pe{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 $(kl(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ye.fromReplace(e,this.from,this.to,r)}invert(){return new dn(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 pt(n.pos,r.pos,this.mark)}merge(e){return e instanceof pt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pt(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 pt(n.from,n.to,e.markFromJSON(n.mark))}}Pe.jsonID("removeMark",pt);class un extends Pe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ye.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ye.fromReplace(e,this.pos,this.pos+1,new $(N.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 i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new un(this.pos,n.marks[i]);return new un(this.pos,this.mark)}}return new Xn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new un(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 un(n.pos,e.markFromJSON(n.mark))}}Pe.jsonID("addNodeMark",un);class Xn extends Pe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ye.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ye.fromReplace(e,this.pos,this.pos+1,new $(N.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new un(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Xn(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 Xn(n.pos,e.markFromJSON(n.mark))}}Pe.jsonID("removeNodeMark",Xn);class Ce extends Pe{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Ra(e,this.from,this.to)?ye.fail("Structure replace would overwrite content"):ye.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Je([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ce(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Ce(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ce)||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?$.empty:new $(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ce(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?$.empty:new $(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ce(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 Ce(n.from,n.to,$.fromJSON(e,n.slice),!!n.structure)}}Pe.jsonID("replace",Ce);class Te extends Pe{constructor(e,n,r,i,s,o,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=a}apply(e){if(this.structure&&(Ra(e,this.from,this.gapFrom)||Ra(e,this.gapTo,this.to)))return ye.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ye.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ye.fromReplace(e,this.from,this.to,r):ye.fail("Content does not fit in gap")}getMap(){return new Je([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 Te(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),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new Te(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,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 Te(n.from,n.to,n.gapFrom,n.gapTo,$.fromJSON(e,n.slice),n.insert,!!n.structure)}}Pe.jsonID("replaceAround",Te);function Ra(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function db(t,e,n,r){let i=[],s=[],o,a;t.doc.nodesBetween(e,n,(l,c,d)=>
vendor: 7,711 bytes, lines 44-45
44{if(!l.isInline)return;let u=l.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+l.nodeSize,n),p=r.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(o&&o.to==f&&o.mark.eq(u[m])?o.to=h:i.push(o=new pt(f,h,u[m])));a&&a.to==f?a.to=h:s.push(a=new dn(f,h,r))}}),i.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function ub(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(r instanceof fo){let c=o.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.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 d=0;d<l.length;d++){let u=l[d],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&u.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:u,from:Math.max(a,e),to:c,step:s})}}}),i.forEach(o=>t.step(new pt(o.from,o.to,o.style)))}function Sl(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Ce(a,d,$.empty));else{r=u;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new pt(a,d,c.marks[f]));if(i&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new $(N.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Ce(a+f.index,a+f.index+f[0].length,p))}}a=d}if(!r.validEnd){let l=r.fillBefore(N.empty,!0);t.replace(a,a,new $(l,0,0))}for(let l=o.length-1;l>=0;l--)t.step(o[l])}function fb(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,i=0,s=0;;--r){let o=t.$from.node(r),a=t.$from.index(r)+i,l=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(a,l,n))return r;if(r==0||o.type.spec.isolating||!fb(o,a,l))break;a&&(i=1),l<o.childCount&&(s=1)}return null}function hb(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),a=i.after(s+1),l=o,c=a,d=N.empty,u=0;for(let p=s,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,d=N.from(r.node(p).copy(d)),u++):l--;let f=N.empty,h=0;for(let p=s,m=!1;p>n;p--)m||i.after(p+1)<i.end(p)?(m=!0,f=N.from(i.node(p).copy(f)),h++):c++;t.step(new Te(l,c,o,a,new $(d.append(f),u,h),d.size-u,!0))}function Cl(t,e,n=null,r=t){let i=pb(t,e),s=i&&mb(r,e);return s?i.map(Kc).concat({type:e,attrs:n}).concat(s.map(Kc)):null}function Kc(t){return{type:t,attrs:null}}function pb(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function mb(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:o}function gb(t,e,n){let r=N.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=N.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new Te(i,s,i,s,new $(r,0,0),n.length,!0))}function yb(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,a)=>{let l=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,l)&&bb(t.doc,t.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Xf(t,o,a,s),Sl(t,t.mapping.slice(s).map(a,1),r,void 0,c===null);let d=t.mapping.slice(s),u=d.map(a,1),f=d.map(a+o.nodeSize,1);return t.step(new Te(u,f,u+1,f-1,new $(N.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&Yf(t,o,a,s),!1}})}function Yf(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(i.text);){let l=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function Xf(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(` 45`))}})}function bb(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function xb(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Te(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new $(N.from(o),0,0),1,!0))}function Kt(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=n-2;c>s;c--,d--){let u=i.node(c),f=i.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function vb(t,e,n=1,r){let i=t.doc.resolve(e),s=N.empty,o=N.empty;for(let a=i.depth,l=i.depth-n,c=n-1;a>l;a--,c--){s=N.from(i.node(a).copy(s));let d=r&&r[c];o=N.from(d?d.type.create(d.attrs,o):i.node(a).copy(o))}t.step(new Ce(e,e,new $(s.append(o),n,n),!0))}function Tn(t,e){let n=t.resolve(e),r=n.index();return Qf(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function wb(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function Qf(t,e){return!!(t&&e&&!t.isLeaf&&wb(t,e))}function ho(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,a=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),a++,o=r.node(i).maybeChild(a)):(s=r.node(i).maybeChild(a-1),o=r.node(i+1)),s&&!s.isTextblock&&Qf(s,o)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function kb(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(i);d&&!u?r=!1:!d&&u&&(r=!0)}let a=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);Xf(t,d.node(),d.before(),a)}o.inlineContent&&Sl(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new Ce(c,l.map(e+n,-1),$.empty,!0)),r===!0){let d=t.doc.resolve(c);Yf(t,d.node(),d.before(),t.steps.length)}return t}function Sb(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 i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Zf(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)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: 10,275 bytes, line 45
45index(o)+(a>0?1:0),c=r.node(o),d=!1;if(s==1)d=c.canReplace(l,l,i);else{let u=c.contentMatchAt(l).findWrapping(i.firstChild.type);d=u&&c.canReplaceWith(l,l,u[0])}if(d)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function po(t,e,n=e,r=$.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return eh(i,s,r)?new Ce(e,n,r):new Cb(i,s,r).fit()}function eh(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Cb{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=N.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=N.from(e.node(i).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,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,a=i.depth;for(;o&&a&&s.childCount==1;)s=s.firstChild.content,o--,a--;let l=new $(s,o,a);return e>-1?new Te(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ce(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Wo(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,u=null;if(n==1&&(o?c.matchType(o.type)||(u=c.fillBefore(N.from(o),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:u};if(n==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:d};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Wo(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new $(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Wo(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new $(Jr(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new $(Jr(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,a=r?r.content:o.content,l=o.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[n];if(i){for(let m=0;m<i.childCount;m++)d.push(i.child(m));u=u.matchFragment(i)}let h=a.size+e-(o.content.size-o.openEnd);for(;c<a.childCount;){let m=a.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||l==0||m.content.size)&&(u=g,d.push(th(m.mark(f.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?h:-1)))}let p=c==a.childCount;p||(h=-1),this.placed=Gr(this.placed,n,N.from(d)),this.frontier[n].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?$.empty:new $(Jr(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new $(Jr(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||!Uo(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,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Uo(e,n,i,r,s);if(o){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=Uo(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:s?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=Gr(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Gr(this.placed,this.depth,N.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(N.empty,!0);n.childCount&&(this.placed=Gr(this.placed,this.frontier.length,n))}}function Jr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Jr(t.firstChild.content,e-1,n)))}function Gr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Gr(t.lastChild.content,e-1,n)))}function Wo(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function th(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,th(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(N.empty,!0)))),t.copy(r)}function Uo(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!Tb(n,s.content,o)?a:null}function Tb(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Eb(t){return t.spec.defining||t.spec.definingForContent}function Mb(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(eh(i,s,r))return t.step(new Ce(e,n,r));let o=rh(i,s);o[o.length-1]==0&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?a=f:i.before(f)==h&&o.splice(1,0,-f)}let l=o.indexOf(a),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=Eb(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(a)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+l)%o.length],b=!0;g<0&&(b=!1,g=-g);let v=i.node(g-1),k=i.index(g-1);if(v.canReplaceWith(k,k,p.type,p.marks))return t.replace(i.before(g),b?s.after(g):n,new $(nh(r.content,0,r.openStart,h),h,r.openEnd))}}let u=t.steps.length;for(let f=o.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>u));f--){let h=o[f];h<0||(e=i.before(h),n=s.after(h))}}function nh(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(nh(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(N.empty,!0))}return t}function Ab(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Sb(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new $(N.from(r),0,0))}function Nb(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=rh(r,i);for(let o=0;o<s.length;o++){let a=s[o],l=o==s.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return t.delete(r.start(a),i.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return t.delete(r.before(a),i.after(a))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function rh(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class kr extends Pe{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 ye.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ye.fromReplace(e,this.pos,this.pos+1,new $(N.from(i),0,n.isLeaf?0:1))}getMap(){return Je.empty}invert(e){return new kr(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 kr(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 kr(n.pos,n.attr,n.value)}}Pe.jsonID("attr",kr);class yi extends Pe{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ye.ok(r)}getMap(){return Je.empty}invert(e){return new yi(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 yi(n.attr,n.value)}}Pe.jsonID("docAttr",yi);let Mr=class extends Error{};Mr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Mr.prototype=Object.create(Error.prototype);Mr.prototype.constructor=Mr;Mr.prototype.name="TransformError";class Tl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new gi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Mr(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 i=this.mapping.maps[r];
vendor: 10,289 bytes, line 45
45r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((s,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=$.empty){let i=po(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new $(N.from(r),0,0))}delete(e,n){return this.replace(e,n,$.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Mb(this,e,n,r),this}replaceRangeWith(e,n,r){return Ab(this,e,n,r),this}deleteRange(e,n){return Nb(this,e,n),this}lift(e,n){return hb(this,e,n),this}join(e,n=1){return kb(this,e,n),this}wrap(e,n){return gb(this,e,n),this}setBlockType(e,n=e,r,i=null){return yb(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return xb(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new kr(e,n,r)),this}setDocAttribute(e,n){return this.step(new yi(e,n)),this}addNodeMark(e,n){return this.step(new un(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof oe)n.isInSet(r.marks)&&this.step(new Xn(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new Xn(e,s)),i=s.removeFromSet(i);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(e,n=1,r){return vb(this,e,n,r),this}addMark(e,n,r){return db(this,e,n,r),this}removeMark(e,n,r){return ub(this,e,n,r),this}clearIncompatible(e,n,r){return Sl(this,e,n,r),this}}const qo=Object.create(null);class q{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new ih(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=$.empty){let r=n.content.lastChild,i=null;for(let a=0;a<n.openEnd;a++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:c}=o[a],d=e.mapping.slice(s);e.replaceRange(d.map(l.pos),d.map(c.pos),a?$.empty:n),a==0&&Yc(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:a}=i[s],l=e.mapping.slice(r),c=l.map(o.pos),d=l.map(a.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),Yc(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new U(e):yr(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=n<0?yr(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):yr(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ye(e.node(0))}static atStart(e){return yr(e,e,0,0,1)||new Ye(e)}static atEnd(e){return yr(e,e,e.content.size,e.childCount,-1)||new Ye(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=qo[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 qo)throw new RangeError("Duplicate use of selection JSON ID "+e);return qo[e]=n,n.prototype.jsonID=e,n}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}q.prototype.visible=!0;class ih{constructor(e,n){this.$from=e,this.$to=n}}let Jc=!1;function Gc(t){!Jc&&!t.parent.inlineContent&&(Jc=!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){Gc(e),Gc(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 i=e.resolve(n.map(this.anchor));return new U(i.parent.inlineContent?i:r,r)}replace(e,n=$.empty){if(super.replace(e,n),n==$.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 mo(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 i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(s)n=s.$head;else return q.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new U(e,n)}}q.jsonID("text",U);class mo{constructor(e,n){this.anchor=e,this.head=n}map(e){return new mo(e.map(this.anchor),e.map(this.head))}resolve(e){return U.between(e.resolve(this.anchor),e.resolve(this.head))}}class W 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:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?q.near(s):new W(s)}content(){return new $(N.from(this.node),0,0)}eq(e){return e instanceof W&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new El(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new W(e.resolve(n.anchor))}static create(e,n){return new W(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}W.prototype.visible=!1;q.jsonID("node",W);class El{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new mo(r,r):new El(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&W.isSelectable(r)?new W(n):q.near(n)}}class Ye extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=$.empty){if(n==$.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 Ye(e)}map(e){return new Ye(e)}eq(e){return e instanceof Ye}getBookmark(){return Ob}}q.jsonID("all",Ye);const Ob={map(){return this},resolve(t){return new Ye(t)}};function yr(t,e,n,r,i,s=!1){if(e.inlineContent)return U.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let a=e.child(o);if(a.isAtom){if(!s&&W.isSelectable(a))return W.create(t,n-(i<0?a.nodeSize:0))}else{let l=yr(t,a,n+i,i<0?a.childCount:0,i,s);if(l)return l}n+=a.nodeSize*i}return null}function Yc(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ce||i instanceof Te))return;let s=t.mapping.maps[r],o;s.forEach((a,l,c,d)=>{o==null&&(o=d)}),t.setSelection(q.near(t.doc.resolve(o),n))}const Xc=1,Wi=2,Qc=4;class Rb extends Tl{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|Xc)&~Wi,this.storedMarks=null,this}get selectionSet(){return(this.updated&Xc)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Wi,this}ensureMarks(e){return oe.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Wi)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Wi,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||oe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!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|=Qc,this}get scrolledIntoView(){return(this.updated&Qc)>0}}function Zc(t,e){return!e||!t?t:t.bind(e)}class Yr{constructor(e,n,r){this.name=e,this.init=Zc(n.init,r),this.apply=Zc(n.apply,r)}}const Db=[new Yr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Yr("selection",{init(t,e){return t.selection||q.atStart(e.doc)},apply(t){return t.selection}}),new Yr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Yr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Ko{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Db.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 Yr(r.key,r.spec.state,r))})}}class wr{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}
vendor: 4,619 bytes, line 45
45apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let a=this.config.plugins[o];if(a.spec.appendTransaction){let l=i?i[o].n:0,c=i?i[o].state:this,d=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let u=0;u<this.config.plugins.length;u++)i.push(u<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new wr(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new Rb(this)}static create(e){let n=new Ko(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new wr(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new Ko(this.schema,e.plugins),r=n.fields,i=new wr(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}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 i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.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 i=new Ko(e.schema,e.plugins),s=new wr(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=hn.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=q.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.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)){s[o.name]=c.fromJSON.call(l,e,n[a],s);return}}s[o.name]=o.init(e,s)}}),s}}function sh(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=sh(i,e,{})),n[r]=i}return n}class ie{constructor(e){this.spec=e,this.props={},e.props&&sh(e.props,this,this.props),this.key=e.key?e.key.key:oh("plugin")}getState(e){return e[this.key]}}const Jo=Object.create(null);function oh(t){return t in Jo?t+"$"+ ++Jo[t]:(Jo[t]=0,t+"$")}class ce{constructor(e="key"){this.key=oh(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ml=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ah(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const lh=(t,e,n)=>{let r=ah(t,n);if(!r)return!1;let i=Al(r);if(!i){let o=r.blockRange(),a=o&&_r(o);return a==null?!1:(e&&e(t.tr.lift(o,a).scrollIntoView()),!0)}let s=i.nodeBefore;if(yh(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Ar(s,"end")||W.isSelectable(s)))for(let o=r.depth;;o--){let a=po(t.doc,r.before(o),r.after(o),$.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(Ar(s,"end")?q.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):W.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Ib=(t,e,n)=>{let r=ah(t,n);if(!r)return!1;let i=Al(r);return i?ch(t,i,e):!1},Lb=(t,e,n)=>{let r=uh(t,n);if(!r)return!1;let i=Nl(r);return i?ch(t,i,e):!1};function ch(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=po(t.doc,s,l,$.empty);if(!c||c.from!=s||c instanceof Ce&&c.slice.size>=l-s)return!1;if(n){let d=t.tr.step(c);d.setSelection(U.create(d.doc,s)),n(d.scrollIntoView())}return!0}function Ar(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;
vendor: 5,731 bytes, lines 45-46
45if(n&&r.childCount!=1)return!1}return!1}const dh=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Al(r)}let o=s&&s.nodeBefore;return!o||!W.isSelectable(o)?!1:(e&&e(t.tr.setSelection(W.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Al(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 uh(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const fh=(t,e,n)=>{let r=uh(t,n);if(!r)return!1;let i=Nl(r);if(!i)return!1;let s=i.nodeAfter;if(yh(t,i,e,1))return!0;if(r.parent.content.size==0&&(Ar(s,"start")||W.isSelectable(s))){let o=po(t.doc,r.before(),r.after(),$.empty);if(o&&o.slice.size<o.to-o.from){if(e){let a=t.tr.step(o);a.setSelection(Ar(s,"start")?q.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):W.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},hh=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Nl(r)}let o=s&&s.nodeAfter;return!o||!W.isSelectable(o)?!1:(e&&e(t.tr.setSelection(W.create(t.doc,s.pos)).scrollIntoView()),!0)};function Nl(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 Pb=(t,e)=>{let n=t.selection,r=n instanceof W,i;if(r){if(n.node.isTextblock||!Tn(t.doc,n.from))return!1;i=n.from}else if(i=ho(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(W.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},jb=(t,e)=>{let n=t.selection,r;if(n instanceof W){if(n.node.isTextblock||!Tn(t.doc,n.to))return!1;r=n.to}else if(r=ho(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},$b=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&_r(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},ph=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` 46`).scrollIntoView()),!0)};function Ol(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 zb=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=Ol(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,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},mh=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ye||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Ol(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,a=t.tr.insert(o,s.createAndFill());a.setSelection(U.create(a.doc,o+1)),e(a.scrollIntoView())}return!0},gh=(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 s=n.before();if(Kt(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&_r(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Bb(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof W&&e.selection.node.isBlock)return!r.parentOffset||!Kt(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,a,l=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){l=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),a=Ol(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(l&&a?{type:a}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof U||e.selection instanceof Ye)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=Kt(d.doc,u,s.length,s);if(f||(s[0]=a?{type:a}:null,f=Kt(d.doc,u,s.length,s)),!f)return!1;if(d.split(u,s.length,s),!l&&c&&r.node(o).type!=a){let h=d.mapping.map(r.before(o)),p=d.doc.resolve(h);a&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(o)),a)}return n&&n(d.scrollIntoView()),!0}}const Hb=Bb(),_b=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(W.create(t.doc,i))),!0)};function Fb(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Tn(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function yh(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,a,l=i.type.spec.isolating||s.type.spec.isolating;if(!l&&Fb(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(a=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&a.matchType(o[0]||s.type).validEnd){if(n){let h=e.pos+s.nodeSize,p=N.empty;for(let b=o.length-1;b>=0;b--)p=N.from(o[b].create(null,p));p=N.from(i.copy(p));let m=t.tr.step(new Te(e.pos-1,h,e.pos,h,new $(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Tn(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&l?null:q.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&_r(u);
vendor: 4,809 bytes, line 46
46if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(u,f).scrollIntoView()),!0;if(c&&Ar(s,"start",!0)&&Ar(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let b=N.empty;for(let k=p.length-1;k>=0;k--)b=N.from(p[k].copy(b));let v=t.tr.step(new Te(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new $(b,p.length,0),0,!0));n(v.scrollIntoView())}return!0}}return!1}function bh(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(U.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const Vb=bh(-1),Wb=bh(1);function Ub(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&Cl(o,t,e);return a?(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0):!1}}function ed(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:a}}=n.selection.ranges[s];n.doc.nodesBetween(o,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let d=n.doc.resolve(c),u=d.index();i=d.parent.canReplaceWith(u,u+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[o];s.setBlockType(a,l,t,e)}r(s.scrollIntoView())}return!0}}function Rl(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Rl(Ml,lh,dh);Rl(Ml,fh,hh);Rl(ph,mh,gh,Hb);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function qb(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let a=r?n.tr:null;return Kb(a,o,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function Kb(t,e,n,r=null){let i=!1,s=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);s=new vs(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new vs(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=Cl(s,n,r,e);return a?(t&&Jb(t,e,a,i,n),!0):!1}function Jb(t,e,n,r,i){let s=N.empty;for(let d=n.length-1;d>=0;d--)s=N.from(n[d].type.create(n[d].attrs,s));t.step(new Te(e.start-(r?2:0),e.end,e.start,e.end,new $(s,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let a=n.length-o,l=e.start+n.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&Kt(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return t}function Gb(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?Yb(e,n,t,s):Xb(e,n,s):!0:!1}}function Yb(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Te(s-1,o,s,o,new $(N.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new vs(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const a=_r(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(s,-1)-1);return Tn(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function Xb(t,e,n){let r=t.tr,i=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,c=s.node(-1),d=s.index(-1);if(!c.canReplace(d+(a?0:1),d+1,o.content.append(l?N.empty:N.from(i))))return!1;let u=s.pos,f=u+o.nodeSize;return r.step(new Te(u-(a?1:0),f+(l?1:0),u+1,f-1,new $((a?N.empty:N.from(i.copy(N.empty))).append(l?N.empty:N.from(i.copy(N.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function Qb(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,d=N.from(c?t.create():null),u=new $(N.from(t.create(null,N.from(a.type.create(null,d)))),c?3:1,0),f=s.start,h=s.end;n(e.tr.step(new Te(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}const Ae=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Nr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Da=null;const Wt=function(t,e,n){let r=Da||(Da=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Zb=function(){Da=null},Qn=function(t,e,n,r){return n&&(td(t,e,n,r,-1)||td(t,e,n,r,1))},ex=/^(img|br|input|textarea|hr)$/i;function td(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;
vendor: 6,613 bytes, line 46
46if(e==(i<0?0:rt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ni(t)||ex.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ae(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?rt(t):0}else return!1}}function rt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function tx(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=rt(t)}else if(t.parentNode&&!Ni(t))e=Ae(t),t=t.parentNode;else return null}}function nx(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&&!Ni(t))e=Ae(t)+1,t=t.parentNode;else return null}}function rx(t,e,n){for(let r=e==0,i=e==rt(t);r||i;){if(t==n)return!0;let s=Ae(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==rt(t)}}function Ni(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 go=function(t){return t.focusNode&&Qn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function zn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function ix(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function sx(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(rt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(rt(r.startContainer),r.startOffset)}}}const Rt=typeof navigator<"u"?navigator:null,nd=typeof document<"u"?document:null,En=Rt&&Rt.userAgent||"",Ia=/Edge\/(\d+)/.exec(En),xh=/MSIE \d/.exec(En),La=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(En),We=!!(xh||La||Ia),mn=xh?document.documentMode:La?+La[1]:Ia?+Ia[1]:0,it=!We&&/gecko\/(\d+)/i.test(En);it&&+(/Firefox\/(\d+)/.exec(En)||[0,0])[1];const Pa=!We&&/Chrome\/(\d+)/.exec(En),Oe=!!Pa,vh=Pa?+Pa[1]:0,Ie=!We&&!!Rt&&/Apple Computer/.test(Rt.vendor),Or=Ie&&(/Mobile\/\w+/.test(En)||!!Rt&&Rt.maxTouchPoints>2),nt=Or||(Rt?/Mac/.test(Rt.platform):!1),wh=Rt?/Win/.test(Rt.platform):!1,Ut=/Android \d/.test(En),Oi=!!nd&&"webkitFontSmoothing"in nd.documentElement.style,ox=Oi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ax(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 Bt(t,e){return typeof t=="number"?t:t[e]}function lx(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 rd(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Nr(o);continue}let a=o,l=a==s.body,c=l?ax(s):lx(a),d=0,u=0;if(e.top<c.top+Bt(r,"top")?u=-(c.top-e.top+Bt(i,"top")):e.bottom>c.bottom-Bt(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Bt(i,"top")-c.top:e.bottom-c.bottom+Bt(i,"bottom")),e.left<c.left+Bt(r,"left")?d=-(c.left-e.left+Bt(i,"left")):e.right>c.right-Bt(r,"right")&&(d=e.right-c.right+Bt(i,"right")),d||u)if(l)s.defaultView.scrollBy(d,u);else{let h=a.scrollLeft,p=a.scrollTop;u&&(a.scrollTop+=u),d&&(a.scrollLeft+=d);let m=a.scrollLeft-h,g=a.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Nr(o)}}function cx(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let a=t.root.elementFromPoint(s,o);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:kh(t.dom)}}function kh(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Nr(r));return e}function dx({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Sh(n,r==0?0:r-e)}function Sh(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let hr=null;function ux(t){if(t.setActive)return t.setActive();if(hr)return t.focus(hr);let e=kh(t);t.focus(hr==null?{get preventScroll(){return hr={preventScroll:!0},!0}}:void 0),hr||(hr=!1,Sh(e,0))}function Ch(t,e){let n,r=2e8,i,s=0,o=e.top,a=e.top,l,c;for(let d=t.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=Wt(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];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=d,r=m,i=m&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(s=u+(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=d,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)&&(s=u+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?fx(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:Ch(n,i)}function fx(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let o=nn(r,1);if(o.top!=o.bottom&&Dl(e,o)){i={node:t,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function Dl(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function hx(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function px(t,e,n){let{node:r,offset:i}=Ch(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function mx(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let a=t.docView.nearestDesc(s,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!o&&l.left>r.left||l.top>
vendor: 4,373 bytes, line 46
46r.top?i=a.posBefore:(!o&&l.right<r.left||l.bottom<r.top)&&(i=a.posAfter),o=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;s=a.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function Th(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let o=t.childNodes[s];if(o.nodeType==1){let a=o.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Dl(e,c))return Th(o,e,c)}}if((s=(s+1)%r)==i)break}return t}function gx(t,e){let n=t.dom.ownerDocument,r,i=0,s=sx(n,e.left,e.top);s&&({node:r,offset:i}=s);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(!Dl(e,c)||(o=Th(t.dom,e,c),!o))return null}if(Ie)for(let c=o;r&&c;c=Nr(c))c.draggable&&(r=void 0);if(o=hx(o,e),r){if(it&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&i++}let c;Oi&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=mx(t,r,i,e))}a==null&&(a=px(t,o,e));let l=t.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function id(t){return t.top<t.bottom||t.left<t.right}function nn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(id(r))return r}return Array.prototype.find.call(n,id)||t.getBoundingClientRect()}const yx=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Eh(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Oi||it;if(r.nodeType==3)if(o&&(yx.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=nn(Wt(r,i,i),n);if(it&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=nn(Wt(r,i-1,i-1),-1);if(c.top==l.top){let d=nn(Wt(r,i,i+1),-1);if(d.top!=l.top)return Vr(d,d.left<c.left)}}return l}else{let l=i,c=i,d=n<0?1:-1;return n<0&&!i?(c++,d=-1):n>=0&&i==r.nodeValue.length?(l--,d=1):n<0?l--:c++,Vr(nn(Wt(r,l,c),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==rt(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return Go(l.getBoundingClientRect(),!1)}if(s==null&&i<rt(r)){let l=r.childNodes[i];if(l.nodeType==1)return Go(l.getBoundingClientRect(),!0)}return Go(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==rt(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Wt(l,rt(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Vr(nn(c,1),!1)}if(s==null&&i<rt(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Wt(l,0,o?0:1):l.nodeType==1?l:null:null;if(c)return Vr(nn(c,-1),!0)}return Vr(nn(r.nodeType==3?Wt(r):r,-n),n>=0)}function Vr(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 Go(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 Mh(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function bx(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Mh(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let o=Eh(t,i.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Wt(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const xx=/[\u0590-\u08ac]/;function vx(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=t.domSelection();return a?!xx.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?s:o:Mh(t,e,()=>
vendor: 7,093 bytes, lines 46-47
46{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:u}=t.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||l==p&&c==m;try{a.collapse(d,u),l&&(l!=d||c!=u)&&a.extend&&a.extend(l,c)}catch{}return f!=null&&(a.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let sd=null,od=null,ad=!1;function wx(t,e,n){return sd==e&&od==n?ad:(sd=e,od=n,ad=n=="up"||n=="down"?bx(t,e,n):vx(t,e,n))}const st=0,ld=1,Bn=2,Dt=3;class Ri{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=st,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 i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Ae(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}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 i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let a=i.children[o];if(a.size){i=a;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],a=s+o.size;if(a>e||o instanceof Nh){i=e-s;break}s=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ah&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Ae(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Ae(s.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 i=-1,s=-1;for(let o=r,a=0;;a++){let l=this.children[a],c=o+l.size;if(i==-1&&e<=c){let d=o+l.border;if(e>=d&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,d);e=o;for(let u=a;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Ae(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>n||a==this.children.length-1)){n=c;for(let d=a+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=Ae(u.dom);break}n+=u.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}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,i=!1){let s=Math.min(e,n),o=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,n-p-m.border,r,i);p=g}let a=this.domFromPos(e,e?-1:1),l=n==e?a:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((it||Ie)&&e==n){let{node:h,offset:p}=a;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==` 47`),u&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:Ae(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(it&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||u&&Ie)&&Qn(a.node,a.offset,d.anchorNode,d.anchorOffset)&&Qn(l.node,l.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(u&&it)){c.collapse(a.node,a.offset);try{e!=n&&c.extend(l.node,l.offset),f=!0}catch{}}if(!f){if(e>n){let p=a;a=l,l=p}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let a=r+s.border,l=o-s.border;if(e>=a&&n<=l){this.dirty=e==r||n==o?Bn:ld,e==a&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Dt:s.markDirty(e-a,n-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Bn:Dt}r=o}this.dirty=Bn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Bn:ld;n.dirty<r&&(n.dirty=r)}
vendor: 3,737 bytes, line 47
47}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ah extends Ri{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!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,s=this}matchesWidget(e){return this.dirty==st&&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 kx extends Ri{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}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 Zn extends Ri{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=ir.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Zn(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Dt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Dt&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=st){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=st}}slice(e,n,r){let i=Zn.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=$a(s,n,o,r)),e>0&&(s=$a(s,0,e,r));for(let a=0;a<s.length;a++)s[a].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class gn extends Ri{constructor(e,n,r,i,s,o,a,l,c){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=a}static create(e,n,r,i,s,o){let a=s.nodeViews[n.type.name],l,c=a&&a(n,s,()=>{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,i),d=c&&c.dom,u=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=ir.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!u&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Dh(d,r,n),c?l=new Sx(e,n,r,i,d,u||null,f,c,s,o+1):n.isText?new yo(e,n,r,i,d,f,s):new gn(e,n,r,i,d,u||null,f,s,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=()=>N.empty)}return e}matchesNode(e,n,r){return this.dirty==st&&e.eq(this.node)&&ks(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}
vendor: 12,369 bytes, line 47
47updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new Tx(this,o&&o.node,e);Ax(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!u&&l.syncToMarks(d==this.node.childCount?oe.none:this.node.child(d).marks,r,e,d),l.placeWidget(c,e,i)},(c,d,u,f)=>{l.syncToMarks(c.marks,r,e,f);let h;l.findNodeMatch(c,d,u,f)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(c,d,u,h,e)||l.updateNextNode(c,d,u,e,f,i)||l.addNode(c,d,u,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Bn)&&(o&&this.protectLocalComposition(e,o),Oh(this.contentDOM,this.children,e),Or&&Nx(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof U)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,a=Ox(this.node.content,o,r-n,i-n);return a<0?null:{node:s,pos:a,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new kx(this,s,n,i);e.input.compositionNodes.push(o),this.children=$a(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Dt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=st}updateOuterDeco(e){if(ks(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Rh(this.dom,this.nodeDOM,ja(this.outerDeco,this.node,n),ja(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 cd(t,e,n,r,i){Dh(r,e,t);let s=new gn(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class yo extends gn{constructor(e,n,r,i,s,o,a){super(e,n,r,i,s,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,i){return this.dirty==Dt||this.dirty!=st&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=st||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=st,!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 i=this.node.cut(e,n),s=document.createTextNode(i.text);return new yo(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Dt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Nh extends Ri{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==st&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Sx extends gn{constructor(e,n,r,i,s,o,a,l,c,d){super(e,n,r,i,s,o,a,c,d),this.spec=l}update(e,n,r,i){if(this.dirty==Dt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}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 Oh(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],a=o.dom;if(a.parentNode==t){for(;a!=r;)r=dd(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(o instanceof Zn){let l=r?r.previousSibling:t.lastChild;Oh(o.contentDOM,o.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=dd(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const ni=function(t){t&&(this.nodeName=t)};ni.prototype=Object.create(null);const Hn=[new ni];function ja(t,e,n){if(t.length==0)return Hn;let r=n?Hn[0]:new ni,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new ni(o.nodeName));for(let a in o){let l=o[a];l!=null&&(n&&i.length==1&&i.push(r=new ni(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 i}function Rh(t,e,n,r){if(n==Hn&&r==Hn)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],a=n[s];if(s){let l;a&&a.nodeName==o.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==o.nodeName||(l=document.createElement(o.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=Hn[0]),i=l}Cx(i,a||Hn[0],o)}return i}function Cx(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):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Dh(t,e,n){return Rh(t,t,Hn,ja(e,n,t.nodeType!=1))}function ks(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 dd(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Tx{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ex(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,i){let s=0,o=this.stack.length>>1,a=Math.min(o,e.length);for(;s<a&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=st,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;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[o])&&!this.isLocked(u.dom)){l=d;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let d=Zn.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=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)){s=a;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==Dt&&o.dom==o.contentDOM&&(o.dirty=Bn),o.update(e,n,r,s)?(this.destroyBetween(this.index,i),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 i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof gn){let c=this.preMatch.matched.get(l);if(c!=null&&c!=s)return!1;let d=l.dom,u,f=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=Dt&&ks(n,l.outerDeco));if(!f&&l.update(e,n,r,i))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(l,e,n,r,i,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Bn,u.updateChildren(i,o+1),u.dirty=st),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!ks(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=gn.create(this.top,n,r,i,s,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,i,s){let o=gn.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Ah(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Zn;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof yo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ie||Oe)&&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 i=new Nh(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Ex(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof Zn)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(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}function Mx(t,e){return t.type.side-e.type.side}function Ax(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);r(d,i,e.forChild(s,d),c),s+=d.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){let d,u;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Mx);for(let g=0;g<u.length;g++)n(u[g],c,!!l)}else n(d,c,!!l);let f,h;if(l)h=-1,f=l,l=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=s&&a.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o<i.length&&i[o].from<g&&(g=i[o].from);for(let b=0;b<a.length;b++)a[b].to<g&&(g=a[b].to);g<p&&(l=f.cut(g-s),f=f.cut(0,g-s),p=g,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=f.isInline&&!f.isLeaf?a.filter(g=>!g.inline):a.slice();r(f,m,e.forChild(s,f),h),s=p}}
vendor: 9,532 bytes, line 47
47function Nx(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 Ox(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<t.childCount;){let c=t.child(i++);if(s+=c.nodeSize,!c.isText)break;l+=c.text}if(s>=n){if(s>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=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 $a(t,e,n,r,i){let s=[];for(let o=0,a=0;o<t.length;o++){let l=t[o],c=a,d=a+=l.size;c>=n||d<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),i&&(s.push(i),i=void 0),d>n&&s.push(l.slice(n-c,l.size,r)))}return s}function Il(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if(go(n)){for(l=o;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&W.isSelectable(u)&&i.parent&&!(u.isInline&&rx(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;c=new W(o==f?a:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let u=o,f=o;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);u=Math.min(u,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[l,o]=f==t.state.selection.anchor?[f,u]:[u,f],a=r.resolve(o)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let u=e=="pointer"||t.state.selection.head<a.pos&&!s?1:-1;c=Ll(t,d,a,u)}return c}function Ih(t){return t.editable?t.hasFocus():Ph(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Jt(t,e=!1){let n=t.state.selection;if(Lh(t,n),!!Ih(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Oe){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Qn(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Dx(t);else{let{anchor:r,head:i}=n,s,o;ud&&!(n instanceof U)&&(n.$from.parent.inlineContent||(s=fd(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=fd(t,n.to))),t.docView.setSelection(r,i,t,e),ud&&(s&&hd(s),o&&hd(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Rx(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const ud=Ie||Oe&&vh<63;function fd(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Ie&&i&&i.contentEditable=="false")return Yo(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Yo(i);if(s)return Yo(s)}}function Yo(t){return t.contentEditable="true",Ie&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function hd(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Rx(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Ih(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Dx(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ae(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&We&&mn<=11&&(n.disabled=!0,n.disabled=!1)}function Lh(t,e){if(e instanceof W){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(pd(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else pd(t)}function pd(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ll(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||U.between(e,n,r)}function md(t){return t.editable&&!t.hasFocus()?!1:Ph(t)}function Ph(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 Ix(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Qn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function za(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&q.findFrom(s,e)}function rn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function gd(t,e,n){let r=t.state.selection;if(r instanceof U)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return rn(t,new U(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=za(t.state,e);return i&&i instanceof W?rn(t,i):!1}else if(!(nt&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let a=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(a))&&!o.contentDOM?W.isSelectable(s)?rn(t,new W(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Oi?rn(t,new U(t.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof W&&r.node.isInline)return rn(t,new U(e>0?r.$to:r.$from));{let i=za(t.state,e);return i?rn(t,i):!1}}}function Ss(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ri(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function pr(t,e){return e<0?Lx(t):Px(t)}function Lx(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(it&&n.nodeType==1&&r<Ss(n)&&ri(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(ri(a,-1))i=n,s=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(jh(n))break;{let a=n.previousSibling;for(;a&&ri(a,-1);)i=n.parentNode,s=Ae(a),a=a.previousSibling;if(a)n=a,r=Ss(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Ba(t,n,r):i&&Ba(t,i,s)}function Px(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Ss(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let a=n.childNodes[r];if(ri(a,1))s=n,o=++r;else break}else{if(jh(n))break;{let a=n.nextSibling;for(;a&&ri(a,1);)s=a.parentNode,o=Ae(a)+1,a=a.nextSibling;if(a)n=a,r=0,i=Ss(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&Ba(t,s,o)}function jh(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function jx(t,e){for(;t&&e==t.childNodes.length&&!Ni(t);)e=Ae(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 $x(t,e){for(;t&&!e&&!Ni(t);)e=Ae(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 Ba(t,e,n){if(e.nodeType!=3){let s,o;(o=jx(e,n))?(e=o,n=0):(s=$x(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(go(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Jt(t)},50)}function yd(t,e){let n=t.state.doc.resolve(e);if(!(Oe||wh)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function bd(t,e,n){let r=t.state.selection;if(r instanceof U&&!r.empty||n.indexOf("s")>-1||nt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=za(t.state,e);if(o&&o instanceof W)return rn(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,a=r instanceof Ye?q.near(o,e):q.findFrom(o,e);return a?rn(t,a):!1}return!1}function xd(t,e){if(!(t.state.selection instanceof U))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function vd(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function zx(t){if(!Ie||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;vd(t,r,"true"),setTimeout(()=>vd(t,r,"false"),20)}return!1}function Bx(t){let e="";
vendor: 4,149 bytes, lines 47-50
47return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Hx(t,e){let n=e.keyCode,r=Bx(e);if(n==8||nt&&n==72&&r=="c")return xd(t,-1)||pr(t,-1);if(n==46&&!e.shiftKey||nt&&n==68&&r=="c")return xd(t,1)||pr(t,1);if(n==13||n==27)return!0;if(n==37||nt&&n==66&&r=="c"){let i=n==37?yd(t,t.state.selection.from)=="ltr"?-1:1:-1;return gd(t,i,r)||pr(t,i)}else if(n==39||nt&&n==70&&r=="c"){let i=n==39?yd(t,t.state.selection.from)=="ltr"?1:-1:1;return gd(t,i,r)||pr(t,i)}else{if(n==38||nt&&n==80&&r=="c")return bd(t,-1,r)||pr(t,-1);if(n==40||nt&&n==78&&r=="c")return zx(t)||bd(t,1,r)||pr(t,1);if(r==(nt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Pl(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||ir.fromSchema(t.state.schema),a=Fh(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=_h[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=a.createElement(d[h]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),u++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${u?` -${u}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,` 48 49`);return{dom:l,text:f,slice:e}}function $h(t,e,n,r,i){let s=i.parent.type.spec.code,o,a;if(!n&&!e)return null;let l=!!e&&(r||s||!n);if(l){if(t.someProp("transformPastedText",f=>{e=f(e,s||r,t)}),s)return a=new $(N.from(t.state.schema.text(e.replace(/\r\n?/g,` 50`))),0,0),t.someProp("transformPasted",f=>{a=f(a,t,!0)}),a;let u=t.someProp("clipboardTextParser",f=>f(e,i,r,t));if(u)a=u;else{let f=i.marks(),{schema:h}=t.state,p=ir.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),o=Wx(n),Oi&&Ux(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||pn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!_x.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)a=qx(wd(a,+d[1],+d[2]),d[4]);else if(a=$.maxOpen(Fx(a.content,i),!0),a.openStart||a.openEnd){let u=0,f=0;for(let h=a.content.firstChild;u<a.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=a.content.lastChild;f<a.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);a=wd(a,u,f)}return t.someProp("transformPasted",u=>{a=u(a,t,l)}),a}const _x=/^(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 Fx(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(a=>{if(!o)return;let l=i.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&s.length&&Bh(l,s,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Hh(o[o.length-1],s.length));let d=zh(a,l);o.push(d),i=i.matchType(d.type),s=l}}),o)return N.from(o)}return t}function zh(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,N.from(t));return t}function Bh(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Bh(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(N.from(zh(n,t,i+1))))}}function Hh(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Hh(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(N.empty,!0);return t.copy(n.append(r))}
vendor: 4,199 bytes, line 50
50function Ha(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,a=o.content;return t.childCount>1&&(s=0),i<r-1&&(a=Ha(a,e,n,r,i+1,s)),i>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(N.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function wd(t,e,n){return e<t.openStart&&(t=new $(Ha(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new $(Ha(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const _h={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 kd=null;function Fh(){return kd||(kd=document.implementation.createHTMLDocument("title"))}let Xo=null;function Vx(t){let e=window.trustedTypes;return e?(Xo||(Xo=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Xo.createHTML(t)):t}function Wx(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Fh().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&_h[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=Vx(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function Ux(t){let e=t.querySelectorAll(Oe?"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 qx(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:i,openStart:s,openEnd:o}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=N.from(l.create(r[a+1],i)),s++,o++}return new $(i,s,o)}const ze={},Be={},Kx={touchstart:!0,touchmove:!0};class Jx{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 Gx(t){for(let e in ze){let n=ze[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Xx(t,r)&&!jl(t,r)&&(t.editable||!(r.type in Be))&&n(t,r)},Kx[e]?{passive:!0}:void 0)}Ie&&t.dom.addEventListener("input",()=>null),_a(t)}function fn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Yx(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 _a(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>jl(t,r))})}function jl(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Xx(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 Qx(t,e){!jl(t,e)&&ze[e.type]&&(t.editable||!(e.type in Be))&&ze[e.type](t,e)}Be.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Wh(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ut&&Oe&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Or&&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",i=>i(t,zn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Hx(t,n)?n.preventDefault():fn(t,"key")};Be.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};
vendor: 7,371 bytes, line 50
50Be.keypress=(t,e)=>{let n=e;if(Wh(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||nt&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof U)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function bo(t){return{left:t.clientX,top:t.clientY}}function Zx(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function $l(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,a=>o>s.depth?a(t,n,s.nodeAfter,s.before(o),i,!0):a(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function Sr(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 ev(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&W.isSelectable(r)?(Sr(t,new W(n)),!0):!1}function tv(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof W&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let a=o>s.depth?s.nodeAfter:s.node(o);if(W.isSelectable(a)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(Sr(t,W.create(t.state.doc,i)),!0):!1}function nv(t,e,n,r,i){return $l(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?tv(t,n):ev(t,n))}function rv(t,e,n,r){return $l(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function iv(t,e,n,r){return $l(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||sv(t,n,r)}function sv(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Sr(t,U.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),a=i.before(s);if(o.inlineContent)Sr(t,U.create(r,a+1,a+1+o.content.size));else if(W.isSelectable(o))Sr(t,W.create(r,a));else continue;return!0}}function zl(t){return Cs(t)}const Vh=nt?"metaKey":"ctrlKey";ze.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=zl(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&Zx(n,t.input.lastClick)&&!n[Vh]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let o=t.posAtCoords(bo(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new ov(t,o,n,!!r)):(s=="doubleClick"?rv:iv)(t,o.pos,o.inside,n)?n.preventDefault():fn(t,"pointer"))};class ov{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Vh],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);s=d.parent,o=d.depth?d.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof W&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&it&&!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)),fn(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(()=>Jt(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?fn(this.view,"pointer"):nv(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ie&&this.mightDrag&&!this.mightDrag.node.isAtom||Oe&&!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)?(Sr(this.view,q.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):fn(this.view,"pointer")}move(e){this.updateAllowDefault(e),fn(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ze.touchstart=t=>{t.input.lastTouch=Date.now(),zl(t),fn(t,"pointer")};ze.touchmove=t=>{t.input.lastTouch=Date.now(),fn(t,"pointer")};ze.contextmenu=t=>zl(t);function Wh(t,e){return t.composing?!0:Ie&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const av=Ut?5e3:-1;Be.compositionstart=Be.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)||Oe&&wh&&lv(t)))t.markCursor=t.state.storedMarks||n.marks(),Cs(t,!0),t.markCursor=null;else if(Cs(t,!e.selection.empty),it&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let a=t.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}Uh(t,av)};function lv(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"}Be.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++,Uh(t,20))};function Uh(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Cs(t),e))}function qh(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=dv());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function cv(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=tx(e.focusNode,e.focusOffset),r=nx(e.focusNode,e.focusOffset);
vendor: 13,879 bytes, line 50
50if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.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 dv(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Cs(t,e=!1){if(!(Ut&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),qh(t),e||t.docView&&t.docView.dirty){let n=Il(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 uv(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(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const bi=We&&mn<15||Or&&ox<604;ze.copy=Be.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=bi?null:n.clipboardData,o=r.content(),{dom:a,text:l}=Pl(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):uv(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function fv(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function hv(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 i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?xi(t,r.value,null,i,e):xi(t,r.textContent,r.innerHTML,i,e)},50)}function xi(t,e,n,r,i){let s=$h(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,s||$.empty)))return!0;if(!s)return!1;let o=fv(s),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Kh(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," "):""}Be.paste=(t,e)=>{let n=e;if(t.composing&&!Ut)return;let r=bi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&xi(t,Kh(r),r.getData("text/html"),i,n)?n.preventDefault():hv(t,n)};class Jh{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const pv=nt?"altKey":"ctrlKey";function Gh(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[pv]}ze.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(bo(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof W?i.to-1:i.to))){if(r&&r.mightDrag)o=W.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(o=W.create(t.state.doc,u.posBefore))}}let a=(o||t.state.selection).content(),{dom:l,text:c,slice:d}=Pl(t,a);(!n.dataTransfer.files.length||!Oe||vh>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(bi?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",bi||n.dataTransfer.setData("text/plain",c),t.dragging=new Jh(d,Gh(t,n),o)};ze.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Be.dragover=Be.dragenter=(t,e)=>e.preventDefault();Be.drop=(t,e)=>{try{mv(t,e,t.dragging)}finally{t.dragging=null}};function mv(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(bo(e));if(!r)return;let i=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",h=>{s=h(s,t,!1)}):s=$h(t,Kh(e.dataTransfer),bi?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&Gh(t,e));if(t.someProp("handleDrop",h=>h(t,e,s||$.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let a=s?Zf(t.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let l=t.state.tr;if(o){let{node:h}=n;h?h.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=l.doc;if(d?l.replaceRangeWith(c,c,s.content.firstChild):l.replaceRange(c,c,s),l.doc.eq(u))return;let f=l.doc.resolve(c);if(d&&W.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))l.setSelection(new W(f));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((p,m,g,b)=>h=b),l.setSelection(Ll(t,f,l.doc.resolve(h)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}ze.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())&&Jt(t)},20))};ze.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)};ze.beforeinput=(t,e)=>{if(Oe&&Ut&&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",s=>s(t,zn(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Be)ze[t]=Be[t];function vi(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 Ts{constructor(e,n){this.toDOM=e,this.spec=n||Un,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new be(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ts&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&vi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class yn{constructor(e,n){this.attrs=e,this.spec=n||Un}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new be(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof yn&&vi(this.attrs,e.attrs)&&vi(this.spec,e.spec)}static is(e){return e.type instanceof yn}destroy(){}}class Bl{constructor(e,n){this.attrs=e,this.spec=n||Un}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new be(s.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof Bl&&vi(this.attrs,e.attrs)&&vi(this.spec,e.spec)}destroy(){}}class be{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new be(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 be(e,e,new Ts(n,r))}static inline(e,n,r,i){return new be(e,n,new yn(r,i))}static node(e,n,r,i){return new be(e,n,new Bl(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof yn}get widget(){return this.type instanceof Ts}}const br=[],Un={};class se{constructor(e,n){this.local=e.length?e:br,this.children=n.length?n:br}static create(e,n){return n.length?Es(n,e,0,Un):De}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=n&&a.to>=e&&(!s||s(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}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,i+a,s)}}map(e,n,r){return this==De||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Un)}mapInner(e,n,r,i,s){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,i);l&&l.type.valid(n,l)?(o||(o=[])).push(l):s.onRemove&&s.onRemove(this.local[a].spec)}return this.children.length?gv(this.children,o||[],e,n,r,i,s):o?new se(o.sort(qn),br):De}add(e,n){return n.length?this==De?se.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((a,l)=>{let c=l+r,d;if(d=Xh(n,a,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<l;)s+=3;i[s]==l?i[s+2]=i[s+2].addInner(a,d,c+1):i.splice(s,0,l,l+a.nodeSize,Es(d,a,c+1,Un)),s+=3}});let o=Yh(s?Qh(n):n,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new se(o.length?this.local.concat(o).sort(qn):this.local,i||this.children)}remove(e){return e.length==0||this==De?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,a=r[s]+n,l=r[s+1]+n;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>a&&u.to<l&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,a+1);c!=De?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let a=0;a<i.length;a++)i[a].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new se(i,r):De}forChild(e,n){if(this==De)return this;if(n.isLeaf)return se.empty;let r,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let s=e+1,o=s+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>s&&l.type instanceof yn){let c=Math.max(s,l.from)-s,d=Math.min(o,l.to)-s;c<d&&(i||(i=[])).push(l.copy(c,d))}}if(i){let a=new se(i.sort(qn),br);return r?new an([a,r]):a}return r||De}eq(e){if(this==e)return!0;if(!(e instanceof se)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let 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 Hl(this.localsInner(e))}localsInner(e){if(this==De)return br;if(e.inlineContent||!this.local.some(yn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof yn||n.push(this.local[r]);return n}forEachSet(e){e(this)}}se.empty=new se([],[]);se.removeOverlap=Hl;const De=se.empty;class an{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Un));return an.from(r)}forChild(e,n){if(n.isLeaf)return se.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=De&&(s instanceof an?r=r.concat(s.members):r.push(s))}return an.from(r)}eq(e){if(!(e instanceof an)||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 i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let o=0;o<s.length;o++)n.push(s[o])}}return n?Hl(r?n:n.sort(qn)):br}static from(e){switch(e.length){case 0:return De;case 1:return e[0];default:return new an(e.every(n=>n instanceof se)?e:e.reduce((n,r)=>n.concat(r instanceof se?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function gv(t,e,n,r,i,s,o){let a=t.slice();for(let c=0,d=s;c<n.maps.length;c++){let u=0;n.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let b=0;b<a.length;b+=3){let v=a[b+1];if(v<0||f>v+d-u)continue;let k=a[b]+d-u;h>=k?a[b+1]=f<=k?-2:-1:f>=d&&g&&(a[b]+=g,a[b+1]+=g)}u+=g}),d=n.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=n.map(t[c]+s),u=d-i;if(u<0||u>=r.content.size){l=!0;continue}let f=n.map(t[c+1]+s,-1),h=f-i,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let b=a[c+2].mapInner(n,g,d+1,t[c]+s+1,o);b!=De?(a[c]=u,a[c+1]=h,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=yv(a,t,e,n,i,s,o),d=Es(c,r,0,o);e=d.local;for(let u=0;u<a.length;u+=3)a[u+1]<0&&(a.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<a.length&&a[f]<h;)f+=3;a.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new se(e.sort(qn),a)}function Yh(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new be(i.from+e,i.to+e,i.type))}return n}function yv(t,e,n,r,i,s,o){function a(l,c){for(let d=0;d<l.local.length;d++){let u=l.local[d].map(r,i,c);u?n.push(u):o.onRemove&&o.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+s+1);return n}function Xh(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function Qh(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Es(t,e,n,r){let i=[],s=!1;e.forEach((a,l)=>{let c=Xh(t,a,l+n);if(c){s=!0;let d=Es(c,a,n+l+1,r);d!=De&&i.push(l,l+a.nodeSize,d)}});let o=Yh(s?Qh(t):t,-n).sort(qn);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||i.length?new se(o,i):De}function qn(t,e){return t.from-e.from||t.to-e.to}function Hl(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),Sd(e,i+1,s.c
vendor: 9,892 bytes, line 50
50opy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),Sd(e,i,r.copy(s.from,r.to)));break}}}return e}function Sd(t,e,n){for(;e<t.length&&qn(n,t[e])>0;)e++;t.splice(e,0,n)}function Qo(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=De&&e.push(r)}),t.cursorWrapper&&e.push(se.create(t.state.doc,[t.cursorWrapper.deco])),an.from(e)}const bv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xv=We&&mn<=11;class vv{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 wv{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new vv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);We&&mn<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Ie&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),xv&&(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,bv)),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(md(this.view)){if(this.suppressingSelectionUpdates)return Jt(this.view);if(We&&mn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qn(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 s=e.focusNode;s;s=Nr(s))n.add(s);for(let s=e.anchorNode;s;s=Nr(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.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(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&md(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,a=!1,l=[];if(e.editable)for(let d=0;d<n.length;d++){let u=this.registerMutation(n[d],l);u&&(s=s<0?u.from:Math.min(u.from,s),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(a=!0))}if(l.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of l)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;u&&u.nodeType==1&&u.contentEditable=="false"&&d.parentNode.removeChild(d)}}else if(it&&l.length){let d=l.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||Cv(e,u)!=h)&&f.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&go(r)&&(c=Il(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Jt(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),kv(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Tv(e,l)),this.handleDOMChange(s,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Jt(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 d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];n.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(We&&mn<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?Ae(i)+1:0,a=r.localPosFromDOM(e.target,o,-1),l=s&&s.parentNode==e.target?Ae(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Cd=new WeakMap,Td=!1;function kv(t){if(!Cd.has(t)&&(Cd.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=it,Td)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."),Td=!0}}function Ed(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Qn(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function Sv(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Ed(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Ed(t,n):null}function Cv(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 Tv(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=s.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(s,a.firstChild),r==s&&t.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function Ev(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:o,to:a}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,d=l.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],go(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Oe&&t.input.lastKeyCode===8)for(let g=s;g>i;g--){let b=r.childNodes[g-1],v=b.pmViewDesc;if(b.nodeName=="BR"&&!v){s=g;break}if(!v||v.size)break}let u=t.state.doc,f=t.someProp("domParser")||pn.fromSchema(t.state.schema),h=u.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Mv,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:a}}function Mv(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ie&&/^(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||Ie&&/^(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 Av=/^(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 Nv(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,A=Il(t,C);if(A&&!t.state.selection.eq(A)){if(Oe&&Ut&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",I=>I(t,zn(13,"Enter"))))return;let D=t.state.tr.setSelection(A);C=="pointer"?D.setMeta("pointer",!0):C=="key"&&D.scrollIntoView(),s&&D.setMeta("composition",s),t.dis
vendor: 4,876 bytes, line 50
50patch(D)}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=Ev(t,e,n),d=t.state.doc,u=d.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=Dv(u.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(Or&&t.input.lastIOSEnter>Date.now()-225||Ut)&&i.some(C=>C.nodeType==1&&!Av.test(C.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",C=>C(t,zn(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 C=Md(t,t.state.doc,c.sel);if(C&&!C.eq(t.state.selection)){let A=t.state.tr.setSelection(C);s&&A.setMeta("composition",s),t.dispatch(A)}}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)),We&&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),b=d.resolve(p.start),v=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA;if((Or&&t.input.lastIOSEnter>Date.now()-225&&(!v||i.some(C=>C.nodeName=="DIV"||C.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",C=>C(t,zn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Rv(d,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",C=>C(t,zn(8,"Backspace")))){Ut&&Oe&&t.domObserver.suppressSelectionUpdates();return}Oe&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Ut&&!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(C){return C(t,zn(13,"Enter"))})},20));let k=p.start,x=p.endA,w=C=>{let A=C||t.state.tr.replace(k,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let D=Md(t,A.doc,c.sel);D&&!(Oe&&t.composing&&D.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(D.head==k||D.head==A.mapping.map(x)-1)||We&&D.empty&&D.head==k)&&A.setSelection(D)}return s&&A.setMeta("composition",s),A.scrollIntoView()},T;if(v)if(m.pos==g.pos){We&&mn<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Jt(t),20));let C=w(t.state.tr.delete(k,x)),A=d.resolve(p.start).marksAcross(d.resolve(p.endA));A&&C.ensureMarks(A),t.dispatch(C)}else if(p.endA==p.endB&&(T=Ov(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let C=w(t.state.tr);T.type=="add"?C.addMark(k,x,T.mark):C.removeMark(k,x,T.mark),t.dispatch(C)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let C=m.parent.textBetween(m.parentOffset,g.parentOffset),A=()=>w(t.state.tr.insertText(C,k,x));t.someProp("handleTextInput",D=>D(t,k,x,C,A))||t.dispatch(A())}else t.dispatch(w());else t.dispatch(w())}function Md(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ll(t,e.resolve(n.anchor),e.resolve(n.head))}function Ov(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,a,l;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)s=n[d].removeFromSet(s);if(i.length==1&&s.length==0)a=i[0],o="add",l=d=>d.mark(a.addToSet(d.marks));else if(i.length==0&&s.length==1)a=s[0],o="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(N.from(c).eq(t))return{mark:a,type:o}}function Rv(t,e,n,r,i){if(n-e<=i.pos-r.pos||Zo(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let a=s.nodeAfter;return a!=null&&n==e+a.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Zo(s,!0,!0));return!o.parent.isTextblock||o.pos>n||Zo(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Zo(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Dv(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);
vendor: 4,498 bytes, line 50
50if(i=="end"){let l=Math.max(0,s-Math.min(o,a));r-=o+l-s}if(o<s&&t.size<e.size){let l=r<=s&&r>=o?s-r:0;s-=l,s&&s<e.size&&Ad(e.textBetween(s-1,s+1))&&(s+=l?1:-1),a=s+(a-o),o=s}else if(a<s){let l=r<=s&&r>=a?s-r:0;s-=l,s&&s<t.size&&Ad(t.textBetween(s-1,s+1))&&(s+=l?1:-1),o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}function Ad(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 Zh{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 Jx,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Id),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=Rd(this),Od(this),this.nodeViews=Dd(this),this.docView=cd(this.state.doc,Nd(this),Qo(this),this.dom,this),this.domObserver=new wv(this,(r,i,s,o)=>Nv(this,r,i,s,o)),this.domObserver.start(),Gx(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&&_a(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Id),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 i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(qh(this),o=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Dd(this);Lv(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&_a(this),this.editable=Rd(this),Od(this);let l=Qo(this),c=Nd(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,l);(u||!e.selection.eq(i.selection))&&(o=!0);let f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&cx(this);if(o){this.domObserver.stop();let h=u&&(We||Oe)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Iv(i.selection,e.selection);if(u){let p=Oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=cv(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=cd(e.doc,c,l,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ix(this))?Jt(this,h):(Lh(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&dx(f)}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 W){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&rd(this,n.getBoundingClientRect(),e)}else rd(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,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;
vendor: 5,943 bytes, line 50
50else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Jh(e.slice,e.move,i<0?void 0:W.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let a=this.directPlugins[o].props[e];if(a!=null&&(i=n?n(a):a))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let a=s[o].props[e];if(a!=null&&(i=n?n(a):a))return i}}hasFocus(){if(We){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&&ux(this.dom),Jt(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 gx(this,e)}coordsAtPos(e,n=1){return Eh(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 i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return wx(this,n||this.state,e)}pasteHTML(e,n){return xi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return xi(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Pl(this,e)}destroy(){this.docView&&(Yx(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Zb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Qx(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ie&&this.root.nodeType===11&&ix(this.dom.ownerDocument)==this.dom&&Sv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Zh.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Nd(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"),[be.node(0,t.state.doc.content.size,e)]}function Od(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:be.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Rd(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Iv(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Dd(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Lv(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Id(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var vn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ms={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Pv=typeof navigator<"u"&&/Mac/.test(navigator.platform),jv=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ne=0;Ne<10;Ne++)vn[48+Ne]=vn[96+Ne]=String(Ne);for(var Ne=1;Ne<=24;Ne++)vn[Ne+111]="F"+Ne;for(var Ne=65;Ne<=90;Ne++)vn[Ne]=String.fromCharCode(Ne+32),Ms[Ne]=String.fromCharCode(Ne);for(var ea in vn)Ms.hasOwnProperty(ea)||(Ms[ea]=vn[ea]);function $v(t){var e=Pv&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||jv&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ms:vn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const zv=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Bv=typeof navigator<"u"&&/Win/.test(navigator.platform);function Hv(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,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))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))zv?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function _v(t){let e=Object.create(null);for(let n in t)e[Hv(n)]=t[n];return e}
vendor: 56,530 bytes, lines 50-93
50function ta(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 Fv(t){return new ie({props:{handleKeyDown:_l(t)}})}function _l(t){let e=_v(t);return function(n,r){let i=$v(r),s,o=e[ta(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[ta(i,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Bv&&r.ctrlKey&&r.altKey)&&(s=vn[r.keyCode])&&s!=i){let a=e[ta(s,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var Vv=Object.defineProperty,Fl=(t,e)=>{for(var n in e)Vv(t,n,{get:e[n],enumerable:!0})};function xo(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=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 s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var vo=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:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,a])=>[o,(...c)=>{const d=a(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],a=!!t,l=t||i.tr,c=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),o.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(n).map(([u,f])=>[u,(...p)=>{const m=this.buildProps(l,e),g=f(...p)(m);return o.push(g),d}])),run:c};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>l(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:t,editor:r,view:s,state:xo({state:i,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}},ep={};Fl(ep,{blur:()=>Wv,clearContent:()=>Uv,clearNodes:()=>qv,command:()=>Kv,createParagraphNear:()=>Jv,cut:()=>Gv,deleteCurrentNode:()=>Yv,deleteNode:()=>Xv,deleteRange:()=>Qv,deleteSelection:()=>Zv,enter:()=>e0,exitCode:()=>t0,extendMarkRange:()=>n0,first:()=>r0,focus:()=>s0,forEach:()=>o0,insertContent:()=>a0,insertContentAt:()=>d0,joinBackward:()=>h0,joinDown:()=>f0,joinForward:()=>p0,joinItemBackward:()=>m0,joinItemForward:()=>g0,joinTextblockBackward:()=>y0,joinTextblockForward:()=>b0,joinUp:()=>u0,keyboardShortcut:()=>v0,lift:()=>w0,liftEmptyBlock:()=>k0,liftListItem:()=>S0,newlineInCode:()=>C0,resetAttributes:()=>T0,scrollIntoView:()=>E0,selectAll:()=>M0,selectNodeBackward:()=>A0,selectNodeForward:()=>N0,selectParentNode:()=>O0,selectTextblockEnd:()=>R0,selectTextblockStart:()=>D0,setContent:()=>I0,setMark:()=>X0,setMeta:()=>Q0,setNode:()=>Z0,setNodeSelection:()=>ew,setTextDirection:()=>tw,setTextSelection:()=>nw,sinkListItem:()=>rw,splitBlock:()=>iw,splitListItem:()=>sw,toggleList:()=>ow,toggleMark:()=>aw,toggleNode:()=>lw,toggleWrap:()=>cw,undoInputRule:()=>dw,unsetAllMarks:()=>uw,unsetMark:()=>fw,unsetTextDirection:()=>hw,updateAttributes:()=>pw,wrapIn:()=>mw,wrapInList:()=>gw});var Wv=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),Uv=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),qv=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(l)),f=c.resolve(d.map(l+a.nodeSize)),h=u.blockRange(f);if(!h)return;const p=_r(h);if(a.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Kv=t=>e=>t(e),Jv=()=>({state:t,dispatch:e})=>mh(t,e),Gv=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new U(r.doc.resolve(Math.max(o-1,0)))),!0},Yv=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const a=i.before(s),l=i.after(s);t.delete(a,l).scrollIntoView()}return!0}return!1};function xe(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var Xv=t=>({tr:e,state:n,dispatch:r})=>{const i=xe(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const l=s.before(o),c=s.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},Qv=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},Zv=()=>({state:t,dispatch:e})=>Ml(t,e),e0=()=>({commands:t})=>t.keyboardShortcut("Enter"),t0=()=>({state:t,dispatch:e})=>zb(t,e);function Vl(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function As(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Vl(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function tp(t,e,n={}){return t.find(r=>r.type===e&&As(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function Ld(t,e,n={}){return!!tp(t,e,n)}function Wl(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!tp([...i.node.marks],e,n)))return;let o=i.index,a=t.start()+i.offset,l=o+1,c=a+i.node.nodeSize;for(;o>0&&Ld([...t.parent.child(o-1).marks],e,n);)o-=1,a-=t.parent.child(o).nodeSize;for(;l<t.parent.childCount&&Ld([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function Yt(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 n0=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Yt(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:d}=a;if(i){const u=Wl(l,s,e);if(u&&u.from<=c&&u.to>=d){const f=U.create(o,u.from,u.to);n.setSelection(f)}}return!0},r0=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 Ul(t){return t instanceof U}function qt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function np(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 i=n.from,s=r.to;return e==="all"?U.create(t,qt(0,i,s),qt(t.content.size,i,s)):U.create(t,qt(e,i,s),qt(e,i,s))}function Fa(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function wi(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function i0(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var s0=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(wi()||Fa())&&r.dom.focus(),i0()&&!wi()&&!Fa()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(s&&t===null&&!Ul(n.state.selection))return o(),!0;const a=np(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},o0=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),a0=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),rp=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&&rp(r)}return t};function Ui(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 rp(n)}function ki(t,e,n){if(t instanceof hn||t instanceof N)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return N.fromArray(t.map(a=>e.nodeFromJSON(a)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),ki("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,a="";const l=new Ff({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?pn.fromSchema(l).parseSlice(Ui(t),n.parseOptions):pn.fromSchema(l).parse(Ui(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=pn.fromSchema(e);return n.slice?s.parseSlice(Ui(t),n.parseOptions).content:s.parse(Ui(t),n.parseOptions)}return ki("",e,n)}function l0(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ce||i instanceof Te))return;const s=t.mapping.maps[r];let o=0;s.forEach((a,l,c,d)=>{o===0&&(o=d)}),t.setSelection(q.near(t.doc.resolve(o),n))}var c0=t=>!("type"in t),d0=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{ki(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=ki(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return l(g),!1}let{from:d,to:u}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((c0(a)?a:[a]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof N){let g="";e.forEach(b=>{b.text&&(g+=b.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,d,u)}else{m=a;const g=r.doc.resolve(d),b=g.node(),v=g.parentOffset===0,k=b.isText||b.isTextblock,x=b.content.size>0;v&&k&&x&&(d=Math.max(0,d-1)),r.replaceWith(d,u,m)}n.updateSelection&&l0(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:m})}return!0},u0=()=>({state:t,dispatch:e})=>Pb(t,e),f0=()=>({state:t,dispatch:e})=>jb(t,e),h0=()=>({state:t,dispatch:e})=>lh(t,e),p0=()=>({state:t,dispatch:e})=>fh(t,e),m0=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ho(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},g0=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ho(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},y0=()=>({state:t,dispatch:e})=>Ib(t,e),b0=()=>({state:t,dispatch:e})=>Lb(t,e);function ip(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function x0(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,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))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))wi()||ip()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var v0=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=x0(t).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l==null||l.steps.forEach(c=>{const d=c.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function wn(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?xe(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(i,f+u.nodeSize);a.push({node:u,from:h,to:p})});const l=i-r,c=a.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>As(u.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=l}var w0=(t,e={})=>({state:n,dispatch:r})=>{const i=xe(t,n.schema);return wn(n,i,e)?$b(n,r):!1},k0=()=>({state:t,dispatch:e})=>gh(t,e),S0=t=>({state:e,dispatch:n})=>{const r=xe(t,e.schema);return Gb(r)(e,n)},C0=()=>({state:t,dispatch:e})=>ph(t,e);function wo(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,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var T0=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=wo(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(s=xe(t,r.schema)),a==="mark"&&(o=Yt(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{s&&s===d.type&&(l=!0,i&&n.setNodeMarkup(u,void 0,Pd(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(f=>{o===f.type&&(l=!0,i&&n.addMark(u,u+d.nodeSize,o.create(Pd(f.attrs,e))))})})}),l},E0=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),M0=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ye(t.doc);t.setSelection(n)}return!0},A0=()=>({state:t,dispatch:e})=>dh(t,e),N0=()=>({state:t,dispatch:e})=>hh(t,e),O0=()=>({state:t,dispatch:e})=>_b(t,e),R0=()=>({state:t,dispatch:e})=>Wb(t,e),D0=()=>({state:t,dispatch:e})=>Vb(t,e);function Va(t,e,n={},r={}){return ki(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var I0=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:a})=>{const{doc:l}=s;if(r.preserveWhitespace!=="full"){const c=Va(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function sp(t,e){const n=Yt(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function op(t,e){const n=new Tl(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function L0(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 Wa(t,e){const n=[];return t.descendants((r,i)=>{e(r)&&n.push({node:r,pos:i})}),n}function P0(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function ap(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 ko(t){return e=>ap(e.$from,t)}function V(t,e,n){return t.config[e]===void 0&&t.parent?V(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?V(t.parent,e,n):null}):t.config[e]}function ql(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=V(e,"addExtensions",n);return r?[e,...ql(r())]:e}).flat(10)}function Kl(t,e){const n=ir.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function lp(t){return typeof t=="function"}function ne(t,e=void 0,...n){return lp(t)?e?t.bind(e)(...n):t(...n):t}function j0(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Rr(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function cp(t){const e=[],{nodeExtensions:n,markExtensions:r}=Rr(t),i=[...n,...r],s={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 d={name:c.name,options:c.options,storage:c.storage,extensions:i},u=V(c,"addGlobalAttributes",d);if(!u)return;u().forEach(h=>{let p;Array.isArray(h.types)?p=h.types:h.types==="*"?p=l:h.types==="nodes"?p=o:h.types==="marks"?p=a:p=[],p.forEach(m=>{Object.entries(h.attributes).forEach(([g,b])=>{e.push({type:m,name:g,attribute:{...s,...b}})})})})}),i.forEach(c=>{const d={name:c.name,options:c.options,storage:c.storage},u=V(c,"addAttributes",d);if(!u)return;const f=u();Object.entries(f).forEach(([h,p])=>{const m={...s,...p};typeof(m==null?void 0:m.default)=="function"&&(m.default=m.default()),m!=null&&m.isRequired&&(m==null?void 0:m.default)===void 0&&delete m.default,e.push({type:c.name,name:h,attribute:m})})}),e}function le(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const a=s?String(s).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(d=>!l.includes(d));r[i]=[...l,...c].join(" ")}else if(i==="style"){const a=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;l.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),a.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),r[i]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[i]=s}),r},{})}function Dr(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)=>le(n,r),{})}function $0(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function jd(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 i=e.reduce((s,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(n):$0(n.getAttribute(o.name));return a==null?s:{...s,[o.name]:a}},{});return{...r,...i}}}}function $d(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&j0(n)?!1:n!=null))}function zd(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function z0(t,e){var n;const r=cp(t),{nodeExtensions:i,markExtensions:s}=Rr(t),o=(n=i.find(c=>V(c,"topNode")))==null?void 0:n.name,a=Object.fromEntries(i.map(c=>{const d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((b,v)=>{const k=V(v,"extendNodeSchema",u);return{...b,...k?k(c):{}}},{}),h=$d({...f,content:ne(V(c,"content",u)),marks:ne(V(c,"marks",u)),group:ne(V(c,"group",u)),inline:ne(V(c,"inline",u)),atom:ne(V(c,"atom",u)),selectable:ne(V(c,"selectable",u)),draggable:ne(V(c,"draggable",u)),code:ne(V(c,"code",u)),whitespace:ne(V(c,"whitespace",u)),linebreakReplacement:ne(V(c,"linebreakReplacement",u)),defining:ne(V(c,"defining",u)),isolating:ne(V(c,"isolating",u)),attrs:Object.fromEntries(d.map(zd))}),p=ne(V(c,"parseHTML",u));p&&(h.parseDOM=p.map(b=>jd(b,d)));const m=V(c,"renderHTML",u);m&&(h.toDOM=b=>m({node:b,HTMLAttributes:Dr(b,d)}));const g=V(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),l=Object.fromEntries(s.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((g,b)=>{const v=V(b,"extendMarkSchema",u);return{...g,...v?v(c):{}}},{}),h=$d({...f,inclusive:ne(V(c,"inclusive",u)),excludes:ne(V(c,"excludes",u)),group:ne(V(c,"group",u)),spanning:ne(V(c,"spanning",u)),code:ne(V(c,"code",u)),attrs:Object.fromEntries(d.map(zd))}),p=ne(V(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>jd(g,d)));const m=V(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:Dr(g,d)})),[c.name,h]}));return new Ff({topNode:o,nodes:a,marks:l})}function B0(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function ii(t){return t.sort((n,r)=>{const i=V(n,"priority")||100,s=V(r,"priority")||100;return i>s?-1:i<s?1:0})}function dp(t){const e=ii(ql(t)),n=B0(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 up(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=` 51 52`,textSerializers:o={}}=n||{};let a="";return t.nodesBetween(r,i,(l,c,d,u)=>{var f;l.isBlock&&c>r&&(a+=s);const h=o==null?void 0:o[l.type.name];if(h)return d&&(a+=h({node:l,pos:c,parent:d,index:u,range:e})),!1;l.isText&&(a+=(f=l==null?void 0:l.text)==null?void 0:f.slice(Math.max(r,c)-c,i-c))}),a}function fp(t,e){const n={from:0,to:t.content.size};return up(t,n,e)}function Jl(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function H0(t,e){const n=xe(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,a=>{s.push(a)});const o=s.reverse().find(a=>a.type.name===n.name);return o?{...o.attrs}:{}}function hp(t,e){const n=wo(typeof e=="string"?e:e.name,t.schema);return n==="node"?H0(t,e):n==="mark"?sp(t,e):{}}function _0(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function F0(t){const e=_0(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function pp(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=n[s];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const c=e.slice(s).map(a,-1),d=e.slice(s).map(l),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),F0(r)}function Gl(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=Wl(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var V0=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,o=null;for(;s>0&&o===null;){const a=i.node(s);(a==null?void 0:a.type.name)===e?o=a:s-=1}return[o,s]};function Wr(t,e){return e.nodes[t]||e.marks[t]||null}function us(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var W0=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,a)=>{var l,c;const d=((c=(l=i.type.spec).toText)==null?void 0:c.call(l,{node:i,pos:s,parent:o,index:a}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-s))}),n};function Ua(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Yt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>As(u.attrs,n,{strict:!1}));let o=0;const a=[];if(i.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;t.doc.nodesBetween(h,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;const b=Math.max(h,g),v=Math.min(p,g+m.nodeSize),k=v-b;o+=k,a.push(...m.marks.map(x=>({mark:x,from:b,to:v})))})}),o===0)return!1;const l=a.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>As(u.mark.attrs,n,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=a.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,f)=>u+f.to-f.from,0);return(l>0?l+c:l)>=o}function U0(t,e,n={}){if(!e)return wn(t,null,n)||Ua(t,null,n);const r=wo(e,t.schema);return r==="node"?wn(t,e,n):r==="mark"?Ua(t,e,n):!1}var q0=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=ko(a=>a.type.name===e)(t.selection);if(!s)return!1;const o=t.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},K0=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Bd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Hd(t,e){const{nodeExtensions:n}=Rr(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=ne(V(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function So(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.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 i=!0;return t.content.forEach(s=>{i!==!1&&(So(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function mp(t){return t instanceof W}var gp=class yp{constructor(e){this.position=e}static fromJSON(e){return new yp(e.position)}toJSON(){return{position:this.position}}};function J0(t,e){const n=e.mapping.mapResult(t.position);return{position:new gp(n.pos),mapResult:n}}function G0(t){return new gp(t)}function bp(t,e,n){const i=t.state.doc.content.size,s=qt(e,0,i),o=qt(n,0,i),a=t.coordsAtPos(s),l=t.coordsAtPos(o,-1),c=Math.min(a.top,l.top),d=Math.max(a.bottom,l.bottom),u=Math.min(a.left,l.left),f=Math.max(a.right,l.right),h=f-u,p=d-c,b={top:c,bottom:d,left:u,right:f,width:h,height:p,x:u,y:c};return{...b,toJSON:()=>b}}function Y0(t,e,n){var r;const{selection:i}=e;let s=null;if(Ul(i)&&(s=i.$cursor),s){const a=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(c=>c.type.excludes(n)))}const{ranges:o}=i;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,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var X0=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:a}=s,l=Yt(t,r.schema);if(i)if(o){const c=sp(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(b=>b.type===l)?f.marks.forEach(b=>{l===b.type&&n.addMark(p,m,l.create({...b.attrs,...e}))}):n.addMark(p,m,l.create(e))})});return Y0(r,n,l)},Q0=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Z0=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=xe(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:a})=>ed(s,{...o,...e})(n)?!0:a.clearNodes()).command(({state:a})=>ed(s,{...o,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ew=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=qt(t,0,r.content.size),s=W.create(r,i);e.setSelection(s)}return!0},tw=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=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=s.from,a=s.to),i&&n.doc.nodesBetween(o,a,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},nw=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=U.atStart(r).from,a=U.atEnd(r).to,l=qt(i,o,a),c=qt(s,o,a),d=U.create(r,l,c);e.setSelection(d)}return!0},rw=t=>({state:e,dispatch:n})=>{const r=xe(t,e.schema);return Qb(r)(e,n)};function _d(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}var iw=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:a,$to:l}=s,c=i.extensionManager.attributes,d=us(c,a.node().type.name,a.node().attrs);if(s instanceof W&&s.node.isBlock)return!a.parentOffset||!Kt(o,a.pos)?!1:(r&&(t&&_d(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,f=a.depth===0?void 0:L0(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=Kt(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!p&&Kt(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(s instanceof U&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,h),f&&!u&&!a.parentOffset&&a.parent.type!==f)){const m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&_d(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},sw=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const a=xe(t,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const u=l.node(-1);if(u.type!==a)return!1;const f=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let b=N.empty;const v=l.index(-1)?1:l.index(-2)?2:3;for(let A=l.depth-v;A>=l.depth-3;A-=1)b=N.from(l.node(A).copy(b));const k=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,x={...us(f,l.node().type.name,l.node().attrs),...e},w=((o=a.contentMatch.defaultType)==null?void 0:o.createAndFill(x))||void 0;b=b.append(N.from(a.createAndFill(null,w)||void 0));const T=l.before(l.depth-(v-1));n.replace(T,l.after(-k),new $(b,4-v,0));let C=-1;n.doc.nodesBetween(T,n.doc.content.size,(A,D)=>{if(C>-1)return!1;A.isTextblock&&A.content.size===0&&(C=D+1)}),C>-1&&n.setSelection(U.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,p={...us(f,u.type.name,u.attrs),...e},m={...us(f,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const g=h?[{type:a,attrs:p},{type:h,attrs:m}]:[{type:a,attrs:p}];if(!Kt(n.doc,l.pos,2))return!1;if(i){const{selection:b,storedMarks:v}=r,{splittableMarks:k}=s.extensionManager,x=v||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!x||!i)return!0;const w=x.filter(T=>k.includes(T.type.name));n.ensureMarks(w)}return!0},na=(t,e)=>{const n=ko(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 i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Tn(t.doc,n.pos)&&t.join(n.pos),!0},ra=(t,e)=>{const n=ko(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 i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Tn(t.doc,r)&&t.join(r),!0},ow=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=i.extensionManager,h=xe(t,o.schema),p=xe(e,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:v}=m,k=b.blockRange(v),x=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;const w=ko(T=>Hd(T.type.name,u))(m);if(k.depth>=1&&w&&k.depth-w.depth<=1){if(w.node.type===h)return c.liftListItem(p);if(Hd(w.node.type.name,u)&&h.validContent(w.node.content)&&a)return l().command(()=>(s.setNodeMarkup(w.pos,h),!0)).command(()=>na(s,h)).command(()=>ra(s,h)).run()}return!n||!x||!a?l().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>na(s,h)).command(()=>ra(s,h)).run():l().command(()=>{const T=d().wrapInList(h,r),C=x.filter(A=>f.includes(A.type.name));return s.ensureMarks(C),T?!0:c.clearNodes()}).wrapInList(h,r).command(()=>na(s,h)).command(()=>ra(s,h)).run()},aw=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Yt(t,r.schema);return Ua(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},lw=(t,e,n={})=>({state:r,commands:i})=>{const s=xe(t,r.schema),o=xe(e,r.schema),a=wn(r,s,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(o,l):i.setNode(s,{...l,...n})},cw=(t,e={})=>({state:n,commands:r})=>{const i=xe(t,n.schema);return wn(n,i,e)?r.lift(i):r.wrapIn(i,e)},dw=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const o=t.tr,a=s.transform;for(let l=a.steps.length-1;l>=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(s.text){const l=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,l))}else o.delete(s.from,s.to)}return!0}}return!1},uw=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},fw=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=Yt(t,r.schema),{$from:c,empty:d,ranges:u}=a;if(!i)return!0;if(d&&o){let{from:f,to:h}=a;const p=(s=c.marks().find(g=>g.type===l))==null?void 0:s.attrs,m=Wl(c,l,p);m&&(f=m.from,h=m.to),n.removeMark(f,h,l)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},hw=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,o;return typeof t=="number"?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(a,l)=>{if(a.isText)return;const c={...a.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},pw=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=wo(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(s=xe(t,r.schema)),a==="mark"&&(o=Yt(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let f,h,p,m;n.selection.empty?r.doc.nodesBetween(d,u,(g,b)=>{s&&s===g.type&&(l=!0,p=Math.max(b,d),m=Math.min(b+g.nodeSize,u),f=b,h=g)}):r.doc.nodesBetween(d,u,(g,b)=>{b<d&&s&&s===g.type&&(l=!0,p=Math.max(b,d),m=Math.min(b+g.nodeSize,u),f=b,h=g),b>=d&&b<=u&&(s&&s===g.type&&(l=!0,i&&n.setNodeMarkup(b,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(v=>{if(o===v.type&&(l=!0,i)){const k=Math.max(b,d),x=Math.min(b+g.nodeSize,u);n.addMark(k,x,o.create({...v.attrs,...e}))}}))}),h&&(f!==void 0&&i&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&i&&n.addMark(p,m,o.create({...g.attrs,...e}))}))}),l},mw=(t,e={})=>({state:n,dispatch:r})=>{const i=xe(t,n.schema);return Ub(i,e)(n,r)},gw=(t,e={})=>({state:n,dispatch:r})=>{const i=xe(t,n.schema);return qb(i,e)(n,r)},yw=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={}}},Co=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},bw=(t,e)=>{if(Vl(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 qi(t){var e;const{editor:n,from:r,to:i,text:s,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(f=>f.type.spec.code))return!1;let d=!1;const u=W0(c)+s;return o.forEach(f=>{if(d)return;const h=bw(u,f.find);if(!h)return;const p=l.state.tr,m=xo({state:l.state,transaction:p}),g={from:r-(h[0].length-s.length),to:i},{commands:b,chain:v,can:k}=new vo({editor:n,state:m});f.handler({state:m,range:g,match:h,commands:b,chain:v,can:k})===null||!p.steps.length||(f.undoable&&p.setMeta(a,{transform:p,from:r,to:i,text:s}),l.dispatch(p),d=!0)}),d}function xw(t){const{editor:e,rules:n}=t,r=new ie({state:{init(){return null},apply(i,s,o){const a=i.getMeta(r);if(a)return a;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=Kl(N.from(d),o.schema);const{from:u}=l,f=u+d.length;qi({editor:e,from:u,to:f,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,a){return qi({editor:e,from:s,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&qi({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?qi({editor:e,from:o.pos,to:o.pos,text:` 53`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function vw(t){return Object.prototype.toString.call(t).slice(8,-1)}function Ki(t){return vw(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function xp(t,e){const n={...t};return Ki(t)&&Ki(e)&&Object.keys(e).forEach(r=>{Ki(e[r])&&Ki(t[r])?n[r]=xp(t[r],e[r]):n[r]=e[r]}),n}var Yl=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{...ne(V(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ne(V(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>xp(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Mn=class vp extends Yl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new vp(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const l=o.find(c=>(c==null?void 0:c.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.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 ww(t){return typeof t=="number"}var kw=class{constructor(t){this.find=t.find,this.handler=t.handler}},Sw=(t,e,n)=>{if(Vl(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function Cw(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:a}=t,{commands:l,chain:c,can:d}=new vo({editor:e,state:n}),u=[];return n.doc.nodesBetween(r,i,(h,p)=>{var m,g,b,v,k;if((g=(m=h.type)==null?void 0:m.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;const x=(k=(v=(b=h.content)==null?void 0:b.size)!=null?v:h.nodeSize)!=null?k:0,w=Math.max(r,p),T=Math.min(i,p+x);if(w>=T)return;const C=h.isText?h.text||"":h.textBetween(w-p,T-p,void 0,"");Sw(C,s.find,o).forEach(D=>{if(D.index===void 0)return;const I=w+D.index+1,j=I+D[0].length,O={from:n.tr.mapping.map(I),to:n.tr.mapping.map(j)},M=s.handler({state:n,range:O,match:D,commands:l,chain:c,can:d,pasteEvent:o,dropEvent:a});u.push(M)})}),u.every(h=>h!==null)}var Ji=null,Tw=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function Ew(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!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:d,from:u,to:f,rule:h,pasteEvt:p})=>{const m=d.tr,g=xo({state:d,transaction:m});if(!(!Cw({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,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(d=>new ie({view(u){const f=p=>{var m;r=(m=u.dom.parentElement)!=null&&m.contains(p.target)?u.dom.parentElement:null,r&&(Ji=e)},h=()=>{Ji&&(Ji=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(s=r===u.dom.parentElement,a=f,!s){const h=Ji;h!=null&&h.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return o=f,i=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,b=p.getMeta("applyPasteRules"),v=!!b;if(!m&&!g&&!v)return;if(v){let{text:w}=b;typeof w=="string"?w=w:w=Kl(N.from(w),h.schema);const{from:T}=b,C=T+w.length,A=Tw(w);return l({rule:d,state:h,from:T,to:{b:C},pasteEvt:A})}const k=f.doc.content.findDiffStart(h.doc.content),x=f.doc.content.findDiffEnd(h.doc.content);if(!(!ww(k)||!x||k===x.b))return l({rule:d,state:h,from:k,to:x,pasteEvt:o})}}))}var To=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=dp(t),this.schema=z0(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:Wr(e.name,this.schema)},r=V(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return ii([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Wr(r.name,this.schema)},s=[],o=V(r,"addKeyboardShortcuts",i);let a={};if(r.type==="mark"&&V(r,"exitable",i)&&(a.ArrowRight=()=>Mn.handleExit({editor:t,mark:r})),o){const f=Object.fromEntries(Object.entries(o()).map(([h,p])=>[h,()=>p({editor:t})]));a={...a,...f}}const l=Fv(a);s.push(l);const c=V(r,"addInputRules",i);if(Bd(r,t.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=xw({editor:t,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}const d=V(r,"addPasteRules",i);if(Bd(r,t.options.enablePasteRules)&&d){const f=d();if(f&&f.length){const h=Ew({editor:t,rules:f});s.push(...h)}}const u=V(r,"addProseMirrorPlugins",i);if(u){const f=u();s.push(...f)}return s})}get attributes(){return cp(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Rr(this.extensions);return Object.fromEntries(e.filter(n=>!!V(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:xe(n.name,this.schema)},s=V(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const a=(l,c,d,u,f)=>{const h=Dr(l,r);return o({node:l,view:c,getPos:d,decorations:u,innerDecorations:f,editor:t,extension:n,HTMLAttributes:h})};return[n.name,a]}))}dispatchTransaction(t){const{editor:e}=this;return ii([...this.extensions].reverse()).reduceRight((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Wr(i.name,this.schema)},o=V(i,"dispatchTransaction",s);return o?a=>{o.call(s,{transaction:a,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return ii([...this.extensions]).reduce((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Wr(i.name,this.schema)},o=V(i,"transformPastedHTML",s);return o?(a,l)=>{const c=r(a,l);return o.call(s,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=Rr(this.extensions);return Object.fromEntries(e.filter(n=>!!V(n,"addMarkView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Yt(n.name,this.schema)},s=V(n,"addMarkView",i);if(!s)return[];const o=(a,l,c)=>{const d=Dr(a,r);return s()({mark:a,view:l,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:u=>{_w(a,t,u)}})};return[n.name,o]}))}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:Wr(e.name,this.schema)};e.type==="mark"&&((n=ne(V(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=V(e,"onBeforeCreate",r),s=V(e,"onCreate",r),o=V(e,"onUpdate",r),a=V(e,"onSelectionUpdate",r),l=V(e,"onTransaction",r),c=V(e,"onFocus",r),d=V(e,"onBlur",r),u=V(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};To.resolve=dp;To.sort=ii;To.flatten=ql;var Mw={};Fl(Mw,{ClipboardTextSerializer:()=>kp,Commands:()=>Sp,Delete:()=>Cp,Drop:()=>Tp,Editable:()=>Ep,FocusEvents:()=>Ap,Keymap:()=>Np,Paste:()=>Op,Tabindex:()=>Rp,TextDirection:()=>Dp,focusEventsPluginKey:()=>Mp});var de=class wp extends Yl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new wp(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},kp=de.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ie({key:new ce("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(d=>d.$from.pos)),a=Math.max(...s.map(d=>d.$to.pos)),l=Jl(n);return up(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Sp=de.create({name:"commands",addCommands(){return{...ep}}}),Cp=de.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{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 d=op(t.before,[t,...e]);pp(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,m)=>{const g=m+p.nodeSize-2,b=h.oldRange.from<=m&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:d.mapping.map(m),newTo:d.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const f=d.mapping;d.steps.forEach((h,p)=>{var m,g;if(h instanceof pt){const b=f.slice(p).map(h.from,-1),v=f.slice(p).map(h.to),k=f.invert().map(b,-1),x=f.invert().map(v),w=(m=d.doc.nodeAt(b-1))==null?void 0:m.marks.some(C=>C.eq(h.mark)),T=(g=d.doc.nodeAt(v))==null?void 0:g.marks.some(C=>C.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:k,to:x},newRange:{from:b,to:v},partial:!!(T||w),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),Tp=de.create({name:"drop",addProseMirrorPlugins(){return[new ie({key:new ce("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Ep=de.create({name:"editable",addProseMirrorPlugins(){return[new ie({key:new ce("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Mp=new ce("focusEvents"),Ap=de.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ie({key:Mp,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}}}})]}}),Np=de.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:d,$anchor:u}=l,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?a.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,b=m&&p.parent.childCount===1?g===u.pos:q.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!b||b&&u.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()},i={...r},s={...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 wi()||ip()?s:i},addProseMirrorPlugins(){return[new ie({key:new ce("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),i=t.some(m=>m.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:a}=e.selection,l=q.atStart(e.doc).from,c=q.atEnd(e.doc).to;if(s||!(o===l&&a===c)||!So(n.doc))return;const f=n.tr,h=xo({state:n,transaction:f}),{commands:p}=new vo({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),Op=de.create({name:"paste",addProseMirrorPlugins(){return[new ie({key:new ce("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Rp=de.create({name:"tabindex",addProseMirrorPlugins(){return[new ie({key:new ce("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Dp=de.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Rr(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 ie({key:new ce("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),Aw=class Xr{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}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 Xr(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 Xr(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 Xr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,o=n.isInline,a=this.pos+r+(s?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(a);if(!i&&!o&&l.depth<=this.depth)return;const c=new Xr(l,this.editor,i,i||o?n:null);i&&(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,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let a=0;a<o.length;a+=1){const l=o[a];if(s[l]!==n[l])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(l=>n[l]===o.node.attrs[l])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},Nw=`.ProseMirror { 54 position: relative; 55} 56 57.ProseMirror { 58 word-wrap: break-word; 59 white-space: pre-wrap; 60 white-space: break-spaces; 61 -webkit-font-variant-ligatures: none; 62 font-variant-ligatures: none; 63 font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ 64} 65 66.ProseMirror [contenteditable="false"] { 67 white-space: normal; 68} 69 70.ProseMirror [contenteditable="false"] [contenteditable="true"] { 71 white-space: pre-wrap; 72} 73 74.ProseMirror pre { 75 white-space: pre-wrap; 76} 77 78img.ProseMirror-separator { 79 display: inline !important; 80 border: none !important; 81 margin: 0 !important; 82 width: 0 !important; 83 height: 0 !important; 84} 85 86.ProseMirror-gapcursor { 87 display: none; 88 pointer-events: none; 89 position: absolute; 90 margin: 0; 91} 92 93.ProseMirror-gapcursor:after {
94 content: ""; 95 display: block; 96 position: absolute; 97 top: -2px; 98 width: 20px; 99 border-top: 1px solid black; 100 animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; 101} 102 103@keyframes ProseMirror-cursor-blink { 104 to { 105 visibility: hidden; 106 } 107} 108 109.ProseMirror-hideselection *::selection { 110 background: transparent; 111} 112 113.ProseMirror-hideselection *::-moz-selection { 114 background: transparent; 115} 116 117.ProseMirror-hideselection * { 118 caret-color: transparent; 119} 120 121.ProseMirror-focused .ProseMirror-gapcursor { 122 display: block; 123}`;function Ow(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var Rw=class extends yw{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:J0,createMappablePosition:G0},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:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=np(e,this.options.autofocus);this.editorState=wr.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!=null&&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=Ow(Nw,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}
vendor: 8,342 bytes, lines 123-125
123),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=lp(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(i=>{const s=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(s))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[Ep,kp.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Sp,Ap,Np,Rp,Tp,Op,Cp,Dp.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new To(r,this)}createCommandManager(){this.commandManager=new vo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Va(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=Va(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),i=n?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new Zh(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:i,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 d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)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==null?void 0:o.getMeta("focus"),l=o==null?void 0: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)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return hp(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return U0(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Kl(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` 124 125`,textSerializers:n={}}=t||{};return fp(this.state.doc,{blockSeparator:e,textSerializers:{...Jl(this.schema),...n}})}get isEmpty(){return So(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new Aw(e,this)}get $doc(){return this.$pos(0)}};function er(t){return new Co({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ne(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),c=n.from+a.indexOf(o),d=c+o.length;if(Gl(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;d<n.to&&s.delete(d,n.to),c>n.from&&s.delete(n.from+l,c);const f=n.from+l+o.length;s.addMark(n.from+l,f,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function Dw(t){return new Co({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ne(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let a=n.to;const l=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=o+c;d>a?d=a:a=d+r[1].length;const u=r[0][r[0].length-1];s.insertText(u,o+r[0].length-1),s.replaceWith(d,a,l)}else if(r[0]){const c=t.type.isInline?o:o-1;s.insert(c,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(a))}s.scrollIntoView()},undoable:t.undoable})}function qa(t){return new Co({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=ne(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function Ir(t){return new Co({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=ne(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),c=l&&Cl(l,t.type,s);if(!c)return null;if(o.wrap(l,c),t.keepMarks&&t.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(t.keepAttributes){const u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,s).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Tn(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}function Iw(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof W){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function Lw(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Pw={};Fl(Pw,{createAtomBlockMarkdownSpec:()=>jw,createBlockMarkdownSpec:()=>$w,createInlineMarkdownSpec:()=>Hw,parseAttributes:()=>Xl,parseIndentedBlocks:()=>Ka,renderNestedMarkdownContent:()=>Zl,serializeAttributes:()=>Ql});function Xl(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}
125__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(d=>d.trim().slice(1));e.class=c.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,d])=>{var u;const f=parseInt(((u=d.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),h=n[f];h&&(e[c]=h.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(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function Ql(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 jw(t){const{nodeName:e,name:n,parseAttributes:r=Xl,serializeAttributes:i=Ql,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:a}=t,l=n||e,c=d=>
vendor: 4,463 bytes, lines 125-136
125{if(!a)return d;const u={};return a.forEach(f=>{f in d&&(u[f]=d[f])}),u};return{parseMarkdown:(d,u)=>{const f={...s,...d.attributes};return u.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;const f=new RegExp(`^:::${l}(?:\\s|$)`,"m"),h=(u=d.match(f))==null?void 0:u.index;return h!==void 0?h:-1},tokenize(d,u,f){const h=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=d.match(h);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:d=>{const u=c(d.attrs||{}),f=i(u),h=f?` {${f}}`:"";return`:::${l}${h} :::`}}}function $w(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=Xl,serializeAttributes:s=Ql,defaultAttributes:o={},content:a="block",allowedAttributes:l}=t,c=n||e,d=u=>{if(!l)return u;const f={};return l.forEach(h=>{h in u&&(f[h]=u[h])}),f};return{parseMarkdown:(u,f)=>{let h;if(r){const m=r(u);h=typeof m=="string"?[{type:"text",text:m}]:m}else a==="block"?h=f.parseChildren(u.tokens||[]):h=f.parseInline(u.tokens||[]);const p={...o,...u.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var f;const h=new RegExp(`^:::${c}`,"m"),p=(f=u.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(u,f,h){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(m);if(!g)return;const[b,v=""]=g,k=i(v);let x=1;const w=b.length;let T="";const C=/^:::([\w-]*)(\s.*)?/gm,A=u.slice(w);for(C.lastIndex=0;;){const D=C.exec(A);if(D===null)break;const I=D.index,j=D[1];if(!((p=D[2])!=null&&p.endsWith(":::"))){if(j)x+=1;else if(x-=1,x===0){const O=A.slice(0,I);T=O.trim();const M=u.slice(0,w+I+D[0].length);let z=[];if(T)if(a==="block")for(z=h.blockTokens(O),z.forEach(R=>{R.text&&(!R.tokens||R.tokens.length===0)&&(R.tokens=h.inlineTokens(R.text))});z.length>0;){const R=z[z.length-1];if(R.type==="paragraph"&&(!R.text||R.text.trim()===""))z.pop();else break}else z=h.inlineTokens(T);return{type:e,raw:M,attributes:k,content:T,tokens:z}}}}}},renderMarkdown:(u,f)=>{const h=d(u.attrs||{}),p=s(h),m=p?` {${p}}`:"",g=f.renderChildren(u.content||[],` 126 127`);return`:::${c}${m} 128 129${g} 130 131:::`}}}function zw(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,o]=r;e[i]=s||o,r=n.exec(t)}return e}function Bw(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function Hw(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=zw,serializeAttributes:s=Bw,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=t,c=n||e,d=f=>{if(!l)return f;const h={};return l.forEach(p=>{const m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in f){const b=f[m];if(g!==void 0&&b===g)return;h[m]=b}}),h},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{const p={...o,...f.attributes};if(a)return h.createNode(e,p);const m=r?r(f):f.content||"";return m?h.createNode(e,p,[h.createTextNode(m)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=a?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),p=f.match(h),m=p==null?void 0:p.index;return m!==void 0?m:-1},tokenize(f,h,p){const m=a?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),g=f.match(m);if(!g)return;let b="",v="";if(a){const[,x]=g;v=x}else{const[,x,w]=g;v=x,b=w||""}const k=i(v.trim());return{type:e,raw:g[0],content:b.trim(),attributes:k}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const p=d(f.attrs||{}),m=s(p),g=m?` ${m}`:"";return a?`[${c}${g}]`:`[${c}${g}]${h}[/${c}]`}}}function Ka(t,e,n){var r,i,s,o;const a=t.split(` 132`),l=[];let c="",d=0;const u=e.baseIndentSize||2;for(;d<a.length;){const f=a[d],h=f.match(e.itemPattern);if(!h){if(l.length>0)break;if(f.trim()===""){d+=1,c=`${c}${f} 133`;continue}else return}const p=e.extractItemData(h),{indentLevel:m,mainContent:g}=p;c=`${c}${f} 134`;const b=[g];for(d+=1;d<a.length;){const w=a[d];if(w.trim()===""){const C=a.slice(d+1).findIndex(I=>I.trim()!=="");if(C===-1)break;if((((i=(r=a[d+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>m){b.push(w),c=`${c}${w} 135`,d+=1;continue}else break}if((((o=(s=w.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>m)b.push(w),c=`${c}${w} 136`,d+=1;else break}let v;
136const k=b.slice(1);if(k.length>0){const w=k.map(T=>T.slice(m+u)).join(` 137`);w.trim()&&(e.customNestedParser?v=e.customNestedParser(w):v=n.blockTokens(w))}const x=e.createToken(p,v);l.push(x)}if(l.length!==0)return{items:l,raw:c}}function Zl(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...o]=t.content,a=e.renderChildren([s]),l=[`${i}${a}`];return o&&o.length>0&&o.forEach(c=>{const d=e.renderChildren([c]);if(d){const u=d.split(` 138`).map(f=>f?e.indent(f):"").join(` 139`);l.push(u)}}),l.join(` 140`)}function _w(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((a,l)=>{const c=s.mapping.map(l),d=s.mapping.map(l)+a.nodeSize;let u=null;if(a.marks.forEach(h=>{if(h!==o)return!1;u=h}),!u)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==u.attrs[h]&&(f=!0)}),f){const h=t.type.create({...t.attrs,...n});s.removeMark(c,d,t.type),s.addMark(c,d,h)}}),s.docChanged&&e.view.dispatch(s)}var ve=class Ip extends Yl{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Ip(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Fw=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,i,s,o,a;const{view:l}=this.editor,c=t.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!d)return;let u=0,f=0;if(this.dom!==d){const v=this.dom.getBoundingClientRect(),k=d.getBoundingClientRect(),x=(i=t.offsetX)!=null?i:(r=t.nativeEvent)==null?void 0:r.offsetX,w=(o=t.offsetY)!=null?o:(s=t.nativeEvent)==null?void 0:s.offsetY;u=k.x-v.x+x,f=k.y-v.y+w}const h=this.dom.cloneNode(!0);try{const v=this.dom.getBoundingClientRect();h.style.width=`${Math.round(v.width)}px`,h.style.height=`${Math.round(v.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(a=t.dataTransfer)==null||a.setDragImage(h,u,f)}finally{p&&setTimeout(()=>{try{p==null||p.remove()}catch{}},0)}const m=this.getPos();if(typeof m!="number")return;const g=W.create(l.state.doc,m),b=l.state.tr.setSelection(g);l.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const i=t.type.startsWith("drag"),s=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!s&&!i)return!0;const{isEditable:a}=this.editor,{isDragging:l}=this,c=!!this.node.type.spec.draggable,d=W.isSelectable(this.node),u=t.type==="copy",f=t.type==="paste",h=t.type==="cut",p=t.type==="mousedown";if(!c&&d&&i&&t.target===this.dom&&t.preventDefault(),c&&i&&!l&&t.target===this.dom)return t.preventDefault(),!1;if(c&&a&&!l&&p){const m=n.closest("[data-drag-handle]");m&&(this.dom===m||this.dom.contains(m))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||s||u||f||h||p&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(wi()||Fa())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes
140)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function kn(t){return new kw({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=ne(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const d=l.search(/\S/),u=n.from+l.indexOf(a),f=u+a.length;if(Gl(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===t.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;f<n.to&&o.delete(f,n.to),u>n.from&&o.delete(n.from+d,u),c=n.from+d+a.length,o.addMark(n.from+d,c,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:Vw,getOwnPropertySymbols:Ww}=Object,{hasOwnProperty:Uw}=Object.prototype;function ia(t,e){return function(r,i,s){return t(r,i,s)&&e(r,i,s)}}function Gi(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:s}=i,o=s.get(n),a=s.get(r);if(o&&a)return o===r&&a===n;s.set(n,r),s.set(r,n);const l=t(n,r,i);return s.delete(n),s.delete(r),l}}function qw(t){return t!=null?t[Symbol.toStringTag]:void 0}function Fd(t){return Vw(t).concat(Ww(t))}const Kw=Object.hasOwn||((t,e)=>Uw.call(t,e));function sr(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const Jw="__v",Gw="__o",Yw="_owner",{getOwnPropertyDescriptor:Vd,keys:Wd}=Object;function Xw(t,e){return t.byteLength===e.byteLength&&Ns(new Uint8Array(t),new Uint8Array(e))}function Qw(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function Zw(t,e){return t.byteLength===e.byteLength&&Ns(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function e1(t,e){return sr(t.getTime(),e.getTime())}function t1(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function n1(t,e){return t===e}function Ud(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=t.entries();let o,a,l=0;for(;(o=s.next())&&!o.done;){const c=e.entries();let d=!1,u=0;for(;(a=c.next())&&!a.done;){if(i[u]){u++;continue}const f=o.value,h=a.value;if(n.equals(f[0],h[0],l,u,t,e,n)&&n.equals(f[1],h[1],f[0],h[0],t,e,n)){d=i[u]=!0;break}u++}if(!d)return!1;l++}return!0}const r1=sr;function i1(t,e,n){const r=Wd(t);let i=r.length;if(Wd(e).length!==i)return!1;for(;i-- >0;)if(!Lp(t,e,n,r[i]))return!1;return!0}function Ur(t,e,n){const r=Fd(t);let i=r.length;if(Fd(e).length!==i)return!1;let s,o,a;for(;i-- >0;)if(s=r[i],!Lp(t,e,n,s)||(o=Vd(t,s),a=Vd(e,s),(o||a)&&(!o||!a||o.configurable!==a.configurable||o.enumerable!==a.enumerable||o.writable!==a.writable)))return!1;return!0}function s1(t,e){return sr(t.valueOf(),e.valueOf())}function o1(t,e){return t.source===e.source&&t.flags===e.flags}function qd(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=t.values();let o,a;for(;(o=s.next())&&!o.done;){const l=e.values();let c=!1,d=0;for(;(a=l.next())&&!a.done;){if(!i[d]&&n.equals(o.value,a.value,o.value,a.value,t,e,n)){c=i[d]=!0;break}d++}if(!c)return!1}return!0}function Ns(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function a1(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Lp(t,e,n,r){return(r===Yw||r===Gw||r===Jw)&&(t.$$typeof||e.$$typeof)?!0:Kw(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const l1="[object ArrayBuffer]",c1="[object Arguments]",d1="[object Boolean]",u1="[object DataView]",f1="[object Date]",h1="[object Error]",p1="[object Map]",m1="[object Number]",g1="[object Object]",y1="[object RegExp]",b1="[object Set]",x1="[object String]",v1={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array
140]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},w1="[object URL]",k1=Object.prototype.toString;function S1({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:s,areMapsEqual:o,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(g,b,v){if(g===b)return!0;if(g==null||b==null)return!1;const k=typeof g;if(k!==typeof b)return!1;if(k!=="object")return k==="number"?a(g,b,v):k==="function"?s(g,b,v):!1;const x=g.constructor;if(x!==b.constructor)return!1;if(x===Object)return l(g,b,v);if(Array.isArray(g))return e(g,b,v);if(x===Date)return r(g,b,v);if(x===RegExp)return d(g,b,v);if(x===Map)return o(g,b,v);if(x===Set)return u(g,b,v);const w=k1.call(g);if(w===f1)return r(g,b,v);if(w===y1)return d(g,b,v);if(w===p1)return o(g,b,v);if(w===b1)return u(g,b,v);if(w===g1)return typeof g.then!="function"&&typeof b.then!="function"&&l(g,b,v);if(w===w1)return h(g,b,v);if(w===h1)return i(g,b,v);if(w===c1)return l(g,b,v);if(v1[w])return f(g,b,v);if(w===l1)return t(g,b,v);if(w===u1)return n(g,b,v);if(w===d1||w===m1||w===x1)return c(g,b,v);if(p){let T=p[w];if(!T){const C=qw(g);C&&(T=p[C])}if(T)return T(g,b,v)}return!1}}function C1({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:Xw,areArraysEqual:n?Ur:Qw,areDataViewsEqual:Zw,areDatesEqual:e1,areErrorsEqual:t1,areFunctionsEqual:n1,areMapsEqual:n?ia(Ud,Ur):Ud,areNumbersEqual:r1,areObjectsEqual:n?Ur:i1,arePrimitiveWrappersEqual:s1,areRegExpsEqual:o1,areSetsEqual:n?ia(qd,Ur):qd,areTypedArraysEqual:n?ia(Ns,Ur):Ns,areUrlsEqual:a1,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=Gi(r.areArraysEqual),s=Gi(r.areMapsEqual),o=Gi(r.areObjectsEqual),a=Gi(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:s,areObjectsEqual:o,areSetsEqual:a})}return r}function T1(t){return function(e,n,r,i,s,o,a){return t(e,n,a)}}function E1({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(a,l){const{cache:c=t?new WeakMap:void 0,meta:d}=n();return e(a,l,{cache:c,equals:r,meta:d,strict:i})};if(t)return function(a,l){return e(a,l,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const s={cache:void 0,equals:r,meta:void 0,strict:i};return function(a,l){return e(a,l,s)}}const M1=An();An({strict:!0});An({circular:!0});An({circular:!0,strict:!0});An({createInternalComparator:()=>sr});An({strict:!0,createInternalComparator:()=>sr});An({circular:!0,createInternalComparator:()=>sr});An({circular:!0,createInternalComparator:()=>sr,strict:!0});function An(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,s=C1(t),o=S1(s),a=n?n(o):T1(o);return E1({circular:e,comparator:o,createState:r,equals:a,strict:i})}var A1=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},N1=({contentComponent:t})=>{const e=lf.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return y.jsx(y.Fragment,{children:Object.values(e)})};function O1(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Ng.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var R1=class extends Ot.Component{constructor(t){var e;super(t),this.editorContentRef=Ot.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=O1(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:A1(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&y.jsx(N1,{contentComponent:t.contentComponent})]})}},D1=S.forwardRef((t,e)=>{const n=Ot.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Ot.createElement(R1,{key:n,innerRef:e,...t})}),Pp=Ot.memo(D1),I1=typeof window<"u"?S.useLayoutEffect:S.useEffect,L1=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0}
140,this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function P1(t){var e;const[n]=S.useState(()=>new L1(t.editor)),r=Ag.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:M1);return I1(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var j1=!1,Ja=typeof window>"u",$1=Ja||!!(typeof window<"u"&&window.next),z1=class jp{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Ja||$1?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new Rw(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,s)=>{var o;return i===((o=n.extensions)==null?void 0:o[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?jp.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}
140):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function B1(t={},e=[]){const n=S.useRef(t);n.current=t;const[r]=S.useState(()=>new z1(n)),i=lf.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(i),S.useEffect(r.onRender(e)),P1({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var ec=S.createContext({editor:null});ec.Consumer;var $p=()=>S.useContext(ec),zp=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),H1=()=>S.useContext(zp),Kd=Ot.forwardRef((t,e)=>{const{onDragStart:n}=H1(),r=t.as||"div";return y.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function Jd(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function Gd(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function _1(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function F1(t){if(Jd(t)||Gd(t))return!0;if(_1(t)){const e=t.type;if(e)return Jd(e)||Gd(e)}return!1}function V1(){try{if(S.version)return parseInt(S.version.split(".")[0],10)>=19}catch{}return!1}var Bp=class{constructor(t,{editor:e,props:n={},as:r="div",className:i=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?xl.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,i=V1(),s=F1(e),o={...n};o.ref&&!(i||s)&&delete o.ref,!o.ref&&(i||s)&&(o.ref=a=>{this.ref=a}),this.reactElement=y.jsx(e,{...o}),(t=r==null?void 0:r.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.destroyed||(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e==null?void 0:e.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};Ot.createContext({markViewContentRef:()=>{}});var W1=class extends Fw{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,i){var s;return r==="storage"?(s=t.storage[e.name])!=null?s:{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode(),ref:S.createRef()};if(!this.component.displayName){const l=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=l(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:l=>{l&&this.contentDOMElement&&l.firstChild!==this.contentDOMElement&&(l.hasAttribute("data-node-view-wrapper")&&l.removeAttribute("data-node-view-wrapper"),l.appendChild(this.contentDOMElement))}},i=this.component,s=S.memo(l=>y.jsx(zp.Provider,{value:r,children:S.createElement(i,l)}));s.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:a=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Bp(s,{editor:this.editor,props:t,as:o,className:`node-${this.node.type.n
140ame} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,o=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:s,newNode:t,newDecorations:e,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=Dr(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function U1(t,e){return n=>n.editor.contentComponent?new W1(t,n,e):{}}var tc=S.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});tc.displayName="TiptapContext";var q1=()=>S.useContext(tc);function Hp({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=S.useMemo(()=>({editor:r}),[r]),s=S.useMemo(()=>({editor:r}),[r]);return y.jsx(ec.Provider,{value:s,children:y.jsx(tc.Provider,{value:i,children:n})})}Hp.displayName="Tiptap";function _p({...t}){const{editor:e}=q1();return y.jsx(Pp,{editor:e,...t})}_p.displayName="Tiptap.Content";Object.assign(Hp,{Content:_p});var Os=(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]},K1=/^\s*>\s$/,J1=ve.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Os("blockquote",{...le(this.options.HTMLAttributes,t),children:Os("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const a=e.renderChildren([i]).split(` 141`).map(l=>l.trim()===""?n:`${n} ${l}`);r.push(a.join(` 142`))}),r.join(` 143${n} 144`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}}
vendor: 9,020 bytes, lines 144-165
144,addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ir({find:K1,type:this.type})]}}),G1=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Y1=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,X1=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Q1=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Z1=Mn.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 Os("strong",{...le(this.options.HTMLAttributes,t),children:Os("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[er({find:G1,type:this.type}),er({find:X1,type:this.type})]},addPasteRules(){return[kn({find:Y1,type:this.type}),kn({find:Q1,type:this.type})]}}),ek=/(^|[^`])`([^`]+)`(?!`)$/,tk=/(^|[^`])`([^`]+)`(?!`)/g,nk=Mn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",le(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[er({find:ek,type:this.type})]},addPasteRules(){return[kn({find:tk,type:this.type})]}}),sa=4,rk=/^```([a-z]+)?[\s\n]$/,ik=/^~~~([a-z]+)?[\s\n]$/,Fp=ve.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:sa,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 s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",le(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(` 145`):r=`\`\`\`${i} 146 147\`\`\``,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:sa,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.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:d}=i,h=r.doc.textBetween(c,d,` 148`,` 149`).split(` 150`).map(p=>a+p).join(` 151`);return l.replaceWith(c,d,r.schema.text(h)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:sa,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?t.commands.command(({tr:a})=>{var l;const{pos:c}=s,d=s.start(),u=s.end(),h=r.doc.textBetween(d,u,` 152`,` 153`).split(` 154`);let p=0,m=0;const g=c-d;for(let T=0;T<h.length;T+=1){if(m+h[T].length>=g){p=T;break}m+=h[T].length+1}const v=((l=h[p].match(/^ */))==null?void 0:l[0])||"",k=Math.min(v.length,n);if(k===0)return!0;let x=d;for(let T=0;T<p;T+=1)x+=h[T].length+1;return a.delete(x,x+k),c-x<=k&&a.setSelection(U.create(a.doc,x)),!0}):t.commands.command(({tr:a})=>{const{from:l,to:c}=i,f=r.doc.textBetween(l,c,` 155`,` 156`).split(` 157`).map(h=>{var p;const m=((p=h.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,n);return h.slice(g)}).join(` 158`);return a.replaceWith(l,c,r.schema.text(f)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` 159 160`);return!s||!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:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const a=i.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[qa({find:rk,type:this.type,getAttributes:t=>({language:t[1]})}),qa({find:ik,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ie({key:new ce("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"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;if(!n||!s)return!1;const{tr:o,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,` 161`));return o.replaceSelectionWith(this.type.create({language:s},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}}})]}}),sk=ve.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` 162 163`):""}),ok=ve.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",le(this.options.HTMLAttributes,t)]},renderText(){return` 164`},renderMarkdown:()=>` 165`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&o){const u=l.filter(f=>a.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),ak=ve.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(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]}`,le(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,i="#".repeat(r);return t.content?`${i} ${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=>qa({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}}
165)\\s$`),type:this.type,getAttributes:{level:t}}))}}),lk=ve.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",le(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Iw(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return mp(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,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(W.create(o.doc,l.pos)):o.setSelection(U.create(o.doc,l.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,u=d==null?void 0:d.create();u&&(o.insert(c,u),o.setSelection(U.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Dw({find:/^(?:---|â-|___\s|\*\*\*\s)$/,type:this.t
vendor: 1,036 bytes, line 165
165ype})]}}),ck=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,dk=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,uk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,fk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,hk=Mn.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",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[er({find:ck,type:this.t
165ype}),er({find:uk,type:this.type})]},addPasteRules(){return[kn({find:dk,type:this.type}),kn({find:fk,type:this.type})]}});const pk="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yac
165hts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",mk="ελ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",Ga="numeric",Ya="ascii",Xa="alpha",si="asciinumeric",Qr="alphanumeric",Qa="domain",Vp="emoji",gk="scheme",yk="slashscheme",oa="whitespace";function bk(t,e){return t in e||(e[t]=[]),e[t]}function _n(t,e,n){e[Ga]&&(e[si]=!0,e[Qr]=!0),e[Ya]&&(e[si]=!0,e[Xa]=!0),e[si]&&(e[Qr]=!0),e[Xa]&&(e[Qr]=!0),e[Qr]&&(e[Qa]=!0),e[Vp]&&(e[Qa]=!0);for(const r in e){const i=bk(r,n);i.indexOf(t)<0&&i.push(t)}}function xk(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ve(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ve.groups={};Ve.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 i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Ve.groups;let i;return e&&e.j?i=e:(i=new Ve(e),n&&r&&_n(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Ve.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,a=i.go(t);if(a?(o=new Ve,Object.assign(o.j,a.j),o.jr.push.apply(o.jr,a.jr),o.jd=a.jd,o.t=a.t):o=new Ve,s){if(r)if(o.t&&typeof o.t=="string"){const l=Object.assign(xk(o.t,r),n);_n(s,l,r)}else n&&_n(s,n,r);o.t=s}return i.j[t]=o,o}};const G=(t,e,n,r,i)=>t.ta(e,n,r,i),fe=(t,e,n,r,i)=>t.tr(e,n,r,i),Yd=(t,e,n,r,i)=>t.ts(e,n,r,i),P=(t,e,n,r,i)=>t.tt(e,n,r,i),Ft="WORD",Za="UWORD",Wp="ASCIINUMERICAL",Up="ALPHANUMERICAL",Si="LOCALHOST",el="TLD",tl="UTLD",fs="SCHEME",xr="SLASH_SCHEME",nc="NUM",nl="WS",rc="NL",oi="OPENBRACE",ai="CLOSEBRACE",Rs="OPENBRACKET",Ds="CLOSEBRACKET",Is="OPENPAREN",Ls="CLOSEPAREN",Ps="OPENANGLEBRACKET",js="CLOSEANGLEBRACKET",$s="FULLWIDTHLEFTPAREN",zs="FULLWIDTHRIGHTPAREN",Bs="LEFTCORNERBRACKET",Hs="RIGHTCORNERBRACKET",_s="LEFTWHITECORNERBRACKET",Fs="RIGHTWHITECORNERBRACKET",Vs="FULLWIDTHLESSTHAN",Ws="FULLWIDTHGREATERTHAN",Us="AMPERSAND",qs="APOSTROPHE",Ks="ASTERISK",sn="AT",Js="BACKSLASH",Gs="BACKTICK",Ys="CARET",ln="COLON",ic="COMMA",Xs="DOLLAR",kt="DOT",Qs="EQUALS",sc="EXCLAMATION",tt="HYPHEN",li="PERCENT",Zs="PIPE",eo="PLUS",to="POUND",ci="QUERY",oc="QUOTE",qp="FULLWIDTHMIDDLEDOT",ac="SEMI",St="SLASH",di="TILDE",no="UNDERSCORE",Kp="EMOJI",ro="SYM";var Jp=Object.freeze({__proto__:null,ALPHANUMERICAL:Up,AMPERSAND:Us,APOSTROPHE:qs,ASCIINUMERICAL:Wp,ASTERISK:Ks,AT:sn,BACKSLASH:Js,BACKTICK:Gs,CARET:Ys,CLOSEANGLEBRACKET:js,CLOSEBRACE:ai,CLOSEBRACKET:Ds,CLOSEPAREN:Ls,COLON:ln,COMMA:ic,DOLLAR:Xs,DOT:kt,EMOJI:Kp,EQUALS:Qs,EXCLAMATION:sc,FULLWIDTHGREATERTHAN:Ws,FULLWIDTHLEFTPAREN:$s,FULLWIDTHLESSTHAN:Vs,FULLWIDTHMIDDLEDOT:qp,FULLWIDTHRIGHTPAREN:zs,HYPHEN:tt,LEFTCORNERBRACKET:Bs,LEFTWHITECORNERBRACKET:_s,LOCALHOST:Si,NL:rc,NUM:nc,OPENANGLEBRACKET:Ps,OPENBRACE:oi,OPENBRACKET:Rs,OPENPAREN:Is,PERCENT:li,PIPE:Zs,PLUS:eo,POUND:to,QUERY:ci,QUOTE:oc,RIGHTCORNERBRACKET:Hs,RIGHTWHITECORNERBRACKET:Fs,SCHEME:fs,SEMI:ac,SLASH:St,SLASH_SCHEME:xr,SYM:ro,TILDE:di,TLD:el,UNDERSCORE:no,UTLD:tl,UWORD:Za,WORD:Ft,WS:nl});const Ht=/[a-z]/,qr=new RegExp("\\p{L}","u"),aa=new RegExp("\\p{Emoji}","u"),_t=/\d/,la=/\s/,Xd="\r",ca=` 166`,vk="ï¸",wk="â",da="";let Yi=null,Xi=null;function kk(t=[]){const e={};Ve.groups=e;const n=new Ve;Yi==null&&(Yi=Qd(pk)),Xi==null&&(Xi=Qd(mk)),P(n,"'",qs),P(n,"{",oi),P(n,"}",ai),P(n,"[",Rs),P(n,"]",Ds),P(n,"(",Is),P(n,")",Ls),P(n,"<",Ps),P(n,">",js),P(n,"ï¼",$s),P(n,"ï¼",zs),P(n,"ã",Bs),P(n,"ã",Hs),P(n,"ã",_s),P(n,"ã",Fs),P(n,"ï¼",Vs),P(n,"ï¼",Ws),P(n,"&",Us),P(n,"*",Ks),P(n,"@",sn),P(n,"`",Gs),P(n,"^",Ys),P(n,":",ln),P(n,",",ic),P(n,"$",Xs),P(n,".",kt),P(n,"=",Qs),P(n,"!",sc),P(n,"-",tt),P(n,"%",li),P(n,"|",Zs),P(n,"+",eo),P(n,"#",to),P(n,"?",ci),P(n,'"',oc),P(n,"/",St),P(n,";",ac),P(n,"~",di),P(n,"_",no),P(n,"\\",Js),P(n,"ã»",qp);const r=fe(n,_t,nc,{[Ga]:!0});fe(r,_t,r);const i=fe(r,Ht,Wp,{[si]:!0}),s=fe(r,qr,Up,{[Qr]:!0}),o=fe(n,Ht,Ft,{[Ya]:!0});fe(o,_t,i),fe(o,Ht,o),fe(i,_t,i),fe(i,Ht,i);const a=fe(n,qr,Za,{[Xa]:!0});fe(a,Ht),fe(a,_t,s),fe(a,qr,a),fe(s,_t,s),fe(s,Ht),fe(s,qr,s);const l=P(n,ca,rc,{[oa]:!0}),c=P(n,Xd,nl,{[oa]:!0}),d=fe(n,la,nl,{[oa]:!0});P(n,da,d),P(c,ca,l),P(c,da,d),fe(c,la,d),P(d,Xd),P(d,ca),fe(d,la,d),P(d,da,d);const u=fe(n,aa,Kp,{[Vp]:!0});P(u,"#"),fe(u,aa,u),P(u,vk,u);const f=P(u,wk);P(f,"#"),fe(f,aa,u);const h=[[Ht,o],[_t,i]],p=[[Ht,null],[qr,a],[_t,s]];for(let m=0;m<Yi.length;m++)en(n,Yi[m],el,Ft,h);for(let m=0;m<Xi.length;m++)en(n,Xi[m],tl,Za,p);_n(el,{tld:!0,ascii:!0},e),_n(tl,{utld:!0,alpha:!0},e),en(n,"file",fs,Ft,h),en(n,"mailto",fs,Ft,h),en(n,"http",xr,Ft,h),en(n,"https",xr,Ft,h),en(n,"ftp",xr,Ft,h),en(n,"ftps",xr,Ft,h),_n(fs,{scheme:!0,ascii:!0},e),_n(xr,{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]?{[gk]:!0}:{[yk]:!0};g.indexOf("-")>
vendor: 9,880 bytes, lines 166-169
166=0?v[Qa]=!0:Ht.test(g)?_t.test(g)?v[si]=!0:v[Ya]=!0:v[Ga]=!0,Yd(n,g,g,v)}return Yd(n,"localhost",Si,{ascii:!0}),n.jd=new Ve(ro),{start:n,tokens:Object.assign({groups:e},Jp)}}function Gp(t,e){const n=Sk(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o<r;){let a=t,l=null,c=0,d=null,u=-1,f=-1;for(;o<r&&(l=a.go(n[o]));)a=l,a.accepts()?(u=0,f=0,d=a):u>=0&&(u+=n[o].length,f++),c+=n[o].length,s+=n[o].length,o++;s-=u,o-=f,c-=u,i.push({t:d.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function Sk(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function en(t,e,n,r,i){let s;const o=e.length;for(let a=0;a<o-1;a++){const l=e[a];t.j[l]?s=t.j[l]:(s=new Ve(r),s.jr=i.slice(),t.j[l]=s),t=s}return s=new Ve(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function Qd(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const Ci={defaultProtocol:"http",events:null,format:Zd,formatHref:Zd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function lc(t,e=null){let n=Object.assign({},Ci);t&&(n=Object.assign(n,t instanceof lc?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}lc.prototype={o:Ci,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:Ci[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},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 Zd(t){return t}function Yp(t,e){this.t="token",this.v=t,this.tk=e}Yp.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=Ci.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),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),u=t.getObj("events",n,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:i,attributes:o,content:s,eventListeners:u}}};function Eo(t,e){class n extends Yp{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const eu=Eo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),tu=Eo("text"),Ck=Eo("nl"),Qi=Eo("url",{isLink:!0,toHref(t=Ci.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Si&&t[1].t===ln}}),et=t=>new Ve(t);function Tk({groups:t}){const e=t.domain.concat([Us,Ks,sn,Js,Gs,Ys,Xs,Qs,tt,nc,li,Zs,eo,to,St,ro,di,no]),n=[qs,ln,ic,kt,sc,li,ci,oc,ac,Ps,js,oi,ai,Ds,Rs,Is,Ls,$s,zs,Bs,Hs,_s,Fs,Vs,Ws],r=[Us,qs,Ks,Js,Gs,Ys,Xs,Qs,tt,oi,ai,li,Zs,eo,to,ci,St,ro,di,no],i=et(),s=P(i,di);G(s,r,s),G(s,t.domain,s);const o=et(),a=et(),l=et();G(i,t.domain,o),G(i,t.scheme,a),G(i,t.slashscheme,l),G(o,r,s),G(o,t.domain,o);const c=P(o,sn);P(s,sn,c),P(a,sn,c),P(l,sn,c);const d=P(s,kt);G(d,r,s),G(d,t.domain,s);const u=et();G(c,t.domain,u),G(u,t.domain,u);const f=P(u,kt);G(f,t.domain,u);const h=et(eu);G(f,t.tld,h),G(f,t.utld,h),P(c,Si,h);const p=P(u,tt);P(p,tt,p),G(p,t.domain,u),G(h,t.domain,u),P(h,kt,f),P(h,tt,p);const m=P(h,ln);G(m,t.numeric,eu);const g=P(o,tt),b=P(o,kt);P(g,tt,g),G(g,t.domain,o),G(b,r,s),G(b,t.domain,o);const v=et(Qi);G(b,t.tld,v),G(b,t.utld,v),G(v,t.domain,o),G(v,r,s),P(v,kt,b),P(v,tt,g),P(v,sn,c);const k=P(v,ln),x=et(Qi);G(k,t.numeric,x);const w=et(Qi),T=et();G(w,e,w),G(w,n,T),G(T,e,w),G(T,n,T),P(v,St,w),P(x,St,w);const C=P(a,ln),A=P(l,ln),D=P(A,St),I=P(D,St);G(a,t.domain,o),P(a,kt,b),P(a,tt,g),G(l,t.domain,o),P(l,kt,b),P(l,tt,g),G(C,t.domain,w),P(C,St,w),P(C,ci,w),G(I,t.domain,w),G(I,e,w),P(I,St,w);const j=[[oi,ai],[Rs,Ds],[Is,Ls],[Ps,js],[$s,zs],[Bs,Hs],[_s,Fs],[Vs,Ws]];for(let O=0;O<j.length;O++){const[M,z]=j[O],R=P(w,M);P(T,M,R),P(R,z,w);const L=et(Qi);G(R,e,L);const F=et();G(R,n),G(L,e,L),G(L,n,F),G(F,e,L),G(F,n,F),P(L,z,w),P(F,z,w)}return P(i,Si,v),P(i,rc,Ck),{start:i,tokens:Jp}}function Ek(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let a=t,l=null,c=null,d=0,u=null,f=-1;for(;i<r&&!(l=a.go(n[i].t));)o.push(n[i++]);for(;i<r&&(c=l||a.go(n[i].t));)l=null,a=c,a.accepts()?(f=0,u=a):f>=0&&f++,i++,d++;if(f<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(ua(tu,e,o)),o=[]),i-=f,d-=f;const h=u.t,p=n.slice(i-d,i);s.push(ua(h,e,p))}}return o.length>0&&s.push(ua(tu,e,o)),s}function ua(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const Mk=typeof console<"u"&&console&&console.warn||(()=>{}),Ak="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ue={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Nk(){return Ve.groups={},ue.scanner=null,ue.parser=null,ue.tokenQueue=[],ue.pluginQueue=[],ue.customSchemes=[],ue.initialized=!1,ue}function nu(t,e=!1){if(ue.initialized&&Mk(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Ak}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1671. Must only contain digits, lowercase ASCII letters or "-" 1682. Cannot start or end with "-" 1693. "-" cannot repeat`);ue.customSchemes.push([t,e])}function Ok(){ue.scanner=kk(ue.customSchemes);for(let t=0;t<ue.tokenQueue.length;t++)ue.tokenQueue[t][1]({scanner:ue.scanner});ue.parser=Tk(ue.scanner.tokens);for(let t=0;t<ue.pluginQueue.length;t++)ue.pluginQueue[t][1]({scanner:ue.scanner,parser:ue.parser});return ue.initialized=!0,ue}function cc(t){return ue.initialized||Ok(),Ek(ue.parser.start,t,Gp(ue.scanner.start,t))}cc.scan=Gp;function Xp(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 lc(n),i=cc(t),s=[];for(let o=0;o<i.length;o++){const a=i[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&s.push(a.toFormattedObject(r))}return s}var dc="[\0-  áá â-\u2029âã]",Rk=new RegExp(dc),Dk=new RegExp(`${dc}$`),Ik=new RegExp(dc,"g");function Lk(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Pk(t){return new ie({key:new ce("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,a=op(n.doc,[...e]);if(pp(a).forEach(({newRange:c})=>{const d=P0(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!Dk.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){const h=f.split(Rk).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],m=u.pos+f.lastIndexOf(p);if(!p)return!1;const g=cc(p).map(b=>b.toObject(t.defaultProtocol));if(!Lk(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Gl(b.from,b.to,r.doc).some(v=>v.mark.type===t.type)||o.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function jk(t){return new ie({key:new ce("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;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=hp(e.state,t.type.name),c=(i=o.href)!=null?i:l.href,d=(s=o.target)!=null?s:l.target;c&&(window.open(c,d),a=!0)}return a}}})}function $k(t){return new ie({key:new ce("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(d=>{l+=d.textContent});const c=Xp(l,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===l);return!l||!c||i!==void 0&&!i(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function jn(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(Ik,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Qp=Mn.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 `val
169idate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){nu(t);return}nu(t.scheme,t.optionalSlashes)})},onDestroy(){Nk()},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)=>!!jn(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 i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},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=>!!jn(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=>!!jn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",le(this.options.HTMLAttributes,t),0]:["a",le(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,i,s;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",a=(s=(i=t.attrs)==null?void 0:i.title)!=null?s:"",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=>!!jn(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=>!!jn(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[kn({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Xp(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!jn(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e}
vendor: 11,953 bytes, lines 169-179
169,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(Pk({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!jn(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(jk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push($k({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),zk=Qp,Bk=Object.defineProperty,Hk=(t,e)=>{for(var n in e)Bk(t,n,{get:e[n],enumerable:!0})},_k="listItem",ru="textStyle",iu=/^\s*([-+*])\s$/,Zp=ve.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",le(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,` 170`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(_k,this.editor.getAttributes(ru)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ir({find:iu,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ir({find:iu,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ru),editor:this.editor})),[t]}}),em=ve.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",le(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),a=e.parseChildren(o);n.push(...a)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Zl(t,e,r=>{var i,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.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)}}}),Fk={};Hk(Fk,{findListItemPos:()=>Di,getNextListDepth:()=>uc,handleBackspace:()=>rl,handleDelete:()=>il,hasListBefore:()=>tm,hasListItemAfter:()=>Vk,hasListItemBefore:()=>nm,listItemHasSubList:()=>rm,nextListIsDeeper:()=>im,nextListIsHigher:()=>sm});var Di=(t,e)=>{const{$from:n}=e.selection,r=xe(t,e.schema);let i=null,s=n.depth,o=n.pos,a=null;for(;s>0&&a===null;)i=n.node(s),i.type===r?a=s:(s-=1,o-=1);return a===null?null:{$pos:e.doc.resolve(o),depth:a}},uc=(t,e)=>{const n=Di(t,e);if(!n)return!1;const[,r]=V0(e,t,n.$pos.pos+4);return r},tm=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},nm=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},rm=(t,e,n)=>{if(!n)return!1;const r=xe(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},rl=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!wn(t.state,e)&&tm(t.state,e,n)){const{$anchor:a}=t.state.selection,l=t.state.doc.resolve(a.before()-1),c=[];l.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const d=c.at(-1);if(!d)return!1;const u=t.state.doc.resolve(l.start()+d.pos+1);return t.chain().cut({from:a.start()-1,to:a.end()+1},u.end()).joinForward().run()}if(!wn(t.state,e)||!K0(t.state))return!1;const r=Di(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=rm(e,t.state,s);return nm(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},im=(t,e)=>{const n=uc(t,e),r=Di(t,e);return!r||!n?!1:n>r.depth},sm=(t,e)=>{const n=uc(t,e),r=Di(t,e);return!r||!n?!1:n<r.depth},il=(t,e)=>{if(!wn(t.state,e)||!q0(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:im(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():sm(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Vk=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},om=de.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&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&&rl(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&&rl(t,n,r)&&(e=!0)}),e}}}}),su=/^(\s*)(\d+)\.\s+(.*)$/,Wk=/^\s/;function Uk(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(su);if(!s)break;const[,o,a,l]=s,c=o.length;let d=l,u=n+1;const f=[i];for(;u<t.length;){const h=t[u];if(h.match(su))break;if(h.trim()==="")f.push(h),d+=` 171`,u+=1;else if(h.match(Wk))f.push(h),d+=` 172${h.slice(c+2)}`,u+=1;else break}e.push({indent:c,number:parseInt(a,10),content:d.trim(),raw:f.join(` 173`)}),r=u,n=u}return[e,r]}function am(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const o=t[s];if(o.indent===e){const a=o.content.split(` 174`),l=((r=a[0])==null?void 0:r.trim())||"",c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const d=a.slice(1).join(` 175`).trim();if(d){const h=n.blockTokens(d);c.push(...h)}let u=s+1;const f=[];for(;u<t.length&&t[u].indent>e;)f.push(t[u]),u+=1;if(f.length>0){const h=Math.min(...f.map(m=>m.indent)),p=am(f,h,n);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(m=>m.raw).join(` 176`)})}i.push({type:"list_item",raw:o.raw,tokens:c}),s=u}else s+=1}return i}function qk(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(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var Kk="listItem",ou="textStyle",au=/^(\d+)\.\s$/,lm=ve.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML: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",le(this.options.HTMLAttributes,n),0]:["ol",le(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?qk(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,` 177`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(` 178`),[s,o]=Uk(i);if(s.length===0)return;const a=am(s,0,n);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:a,raw:i.slice(0,o).join(` 179`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Kk,this.editor.getAttributes(ou)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ir({find:au,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=Ir({find:au,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(ou)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Jk=/^\s*(\[([( |x])?\])\s$/,cm=ve.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML: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",le(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 i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Zl(t,e,i)},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 i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=u=>{var f,h;a.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,u,a.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};
179c(t),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",u=>u.preventDefault()),a.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:f}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=n();if(typeof p!="number")return!1;const m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m==null?void 0:m.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{i.setAttribute(u,f)}),i.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,s.append(a,o),i.append(s,l),Object.entries(e).forEach(([u,f])=>{i.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:i,contentDOM:l,update:u=>{if(u.type!==this.type)return!1;i.dataset.checked=u.attrs.checked,a.checked=u.attrs.checked,c(u);const f=r.extensionManager.attributes,h=Dr(u,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return d.forEach(g=>{p.has(g)||(g in m?i.setAttribute(g,m[g]):i.removeAttribute(g))}),Object.entries(h).forEach(([g,b])=>{b==null?g in m?i.setAttribute(g,m[g]):i.removeAttribute(g):i.setAttribute(g,b)}),d=p,!0}}}}
vendor: 9,036 bytes, lines 179-180
179,addInputRules(){return[Ir({find:Jk,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),dm=ve.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",le(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,` 180`):"",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=s=>{const o=Ka(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(s)},i=Ka(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.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()}}});de.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Zp.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(em.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(om.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(lm.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(cm.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(dm.configure(this.options.taskList)),t}});var lu=" ",Gk="Â ",Yk=ve.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",le(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 r.length===1&&r[0].type==="text"&&(r[0].text===lu||r[0].text===Gk)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?lu:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Xk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Qk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Zk=Mn.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",le(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[er({find:Xk,type:this.type})]},addPasteRules(){return[kn({find:Qk,type:this.type})]}}),eS=ve.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),um=Mn.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",le(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 i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},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()}}}),tS=um;function nS(t={}){return new ie({view(e){return new rS(e,t)}})}class rS{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(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}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,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,a=s.height/i.offsetHeight;if(n){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=u?p.bottom:p.top;u&&f&&(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 u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=l.getBoundingClientRect(),f=u.width/l.offsetWidth,h=u.height/l.offsetHeight;c=u.left-l.scrollLeft*f,d=u.top-l.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/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),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Zf(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 he extends q{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return he.valid(r)?new he(r):q.near(r)}content(){return $.empty}eq(e){return e instanceof he&&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 he(e.resolve(n.pos))}getBookmark(){return new fc(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!iS(e)||!sS(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&he.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let a=e.node(o);if(n>
vendor: 20,861 bytes, line 180
1800?e.indexAfter(o)<a.childCount:e.index(o)>0){s=a.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let l=e.doc.resolve(i);if(he.valid(l))return l}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!W.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let a=e.doc.resolve(i);if(he.valid(a))return a}return null}}}he.prototype.visible=!1;he.findFrom=he.findGapCursorFrom;q.jsonID("gapcursor",he);class fc{constructor(e){this.pos=e}map(e){return new fc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return he.valid(n)?new he(n):q.near(n)}}function fm(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function iS(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 i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||fm(i.type))return!0;if(i.inlineContent)return!1}}return!0}function sS(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 i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||fm(i.type))return!0;if(i.inlineContent)return!1}}return!0}function oS(){return new ie({props:{decorations:dS,createSelectionBetween(t,e,n){return e.pos==n.pos&&he.valid(n)?new he(n):null},handleClick:lS,handleKeyDown:aS,handleDOMEvents:{beforeinput:cS}}})}const aS=_l({ArrowLeft:Zi("horiz",-1),ArrowRight:Zi("horiz",1),ArrowUp:Zi("vert",-1),ArrowDown:Zi("vert",1)});function Zi(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof U){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=he.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new he(c))),!0):!1}}function lS(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!he.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&W.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new he(r))),!0)}function cS(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof he))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 i=N.empty;for(let o=r.length-1;o>=0;o--)i=N.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new $(i,0,0));return s.setSelection(U.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function dS(t){if(!(t.selection instanceof he))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",se.create(t.doc,[be.widget(t.selection.head,e,{key:"gapcursor"})])}var io=200,Ee=function(){};Ee.prototype.append=function(e){return e.length?(e=Ee.from(e),!this.length&&e||e.length<io&&this.leafAppend(e)||this.length<io&&e.leafPrepend(this)||this.appendInner(e)):this};Ee.prototype.prepend=function(e){return e.length?Ee.from(e).append(this):this};Ee.prototype.appendInner=function(e){return new uS(this,e)};Ee.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ee.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ee.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ee.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)};Ee.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};Ee.from=function(e){return e instanceof Ee?e:e&&e.length?new hm(e):Ee.empty};var hm=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(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,a){for(var l=s;l<o;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,a){for(var l=s-1;l>=o;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=io)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=io)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Ee);Ee.empty=new hm([]);var uS=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,i,s,o){var a=this.left.length;if(i<a&&this.left.forEachInner(r,i,Math.min(s,a),o)===!1||s>a&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,s)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(s,a)-a,o+a)===!1||s<a&&this.left.forEachInvertedInner(r,Math.min(i,a),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,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}(Ee);const fS=500;class ht{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 i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,a,l,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,d.push(u);return}if(i){d.push(new Ct(u.map));let h=u.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Ct(p,void 0,void 0,c.length+d.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(u.step);if(u.selection)return a=i?u.selection.map(i.slice(s)):u.selection,l=new ht(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,n,r,i){let s=[],o=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new Ct(e.mapping.maps[d],u,n),h;(h=l&&l.merge(f))&&(f=h,d?s.pop():a=a.slice(0,a.length-1)),s.push(f),n&&(o++,n=void 0),i||(l=f)}let c=o-r.depth;return c>pS&&(a=hS(a,c),o-=c),new ht(a.append(s),o)}remapping(e,n){let r=new gi;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new ht(this.items.append(e.map(n=>new Ct(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=n;this.items.forEach(f=>{let h=s.getMirror(--l);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(l+1,h));g&&a++,r.push(new Ct(p,m,g))}else r.push(new Ct(p))},i);let c=[];for(let f=n;f<o;f++)c.push(new Ct(s.maps[f]));let d=this.items.slice(0,i).append(c).append(r),u=new ht(d,a);return u.emptyItemCount()>fS&&(u=u.compress(this.items.length-r.length)),u}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,i=[],s=0;return this.items.forEach((o,a)=>{if(a>=e)i.push(o),o.selection&&s++;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 d=o.selection&&o.selection.map(n.slice(r));d&&s++;let u=new Ct(c.invert(),l,d),f,h=i.length-1;(f=i.length&&i[h].merge(u))?i[h]=f:i.push(u)}}else o.map&&r--},this.items.length,0),new ht(Ee.from(i.reverse()),s)}}ht.empty=new ht(Ee.empty,0);function hS(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Ct{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Ct(n.getMap().invert(),n,this.selection)}}}class on{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const pS=20;function mS(t,e,n,r){let i=n.getMeta(Kn),s;if(i)return i.historyState;n.getMeta(bS)&&(t=new on(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Kn))return o.getMeta(Kn).redo?new on(t.done.addTransform(n,void 0,r,hs(e)),t.undone,cu(n.mapping.maps),t.prevTime,t.prevComposition):new on(t.done,t.undone.addTransform(n,void 0,r,hs(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||!gS(n,t.prevRanges)),c=o?fa(t.prevRanges,n.mapping):cu(n.mapping.maps);return new on(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,hs(e)),ht.empty,c,n.time,a??t.prevComposition)}else return(s=n.getMeta("rebased"))?new on(t.done.rebased(n,s),t.undone.rebased(n,s),fa(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new on(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),fa(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function gS(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function cu(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,o)=>e.push(s,o));return e}function fa(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function yS(t,e,n){let r=hs(e),i=Kn.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),a=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),l=new on(n?a:s.remaining,n?s.remaining:a,null,0,-1);return s.transform.setSelection(o).setMeta(Kn,{redo:n,historyState:l})}let ha=!1,du=null;function hs(t){let e=t.plugins;if(du!=e){ha=!1,du=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){ha=!0;break}}return ha}const Kn=new ce("history"),bS=new ce("closeHistory");function xS(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ie({key:Kn,state:{init(){return new on(ht.empty,ht.empty,null,0,-1)},apply(e,n,r){return mS(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?mm:r=="historyRedo"?gm:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function pm(t,e){return(n,r)=>{let i=Kn.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=yS(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const mm=pm(!1,!0),gm=pm(!0,!0);de.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0: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==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ie({key:new ce("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-i,a=0,l=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(a,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=s-r,c=a-l,d=a;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}});var vS=de.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[nS(this.options)]}});de.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ie({key:new ce("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return se.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(i>=c&&i<=c+l.nodeSize-1))return!1;o+=1});let a=0;return t.descendants((l,c)=>{if(l.isText||!(i>=c&&i<=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";s.push(be.node(c,c+l.nodeSize,{class:this.options.className}))}),se.create(t,s)}}})]}});var wS=de.create({name:"gapCursor",addProseMirrorPlugins(){return[oS()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ne(V(t,"allowGapCursor",n)))!=null?e:null}}}),uu="placeholder";function kS(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var SS=de.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:uu,placeholder:"Write something â¦",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${kS(this.options.dataAttribute)}`:`data-${uu}`;return[new ie({key:new ce("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,s=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((a,l)=>{const c=i>=l&&i<=l+a.nodeSize,d=!a.isLeaf&&So(a);if((c||!this.options.showOnlyCurrent)&&d){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const f=be.node(l,l+a.nodeSize,{class:u.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:c}):this.options.placeholder});s.push(f)}return this.options.includeChildren}),se.create(e,s)}}})]}});de.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ie({key:new ce("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||mp(n.selection)||t.view.dragging?null:se.create(n.doc,[be.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function fu({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var CS=de.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ce(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(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new ie({key:e,appendTransaction:(i,s,o)=>{const{doc:a,tr:l,schema:c}=o,d=e.getState(o),u=a.content.size,f=c.nodes[n];if(d)return l.insert(u,f.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!fu({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!fu({node:o,types:r})}}})]}}),TS=de.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>mm(t,e),redo:()=>({state:t,dispatch:e})=>gm(t,e)}},addProseMirrorPlugins(){return[xS(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()}}}),ES=de.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(Z1.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(J1.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Zp.configure(this.options.bulletList)),this.options.code!==!1&&i.push(nk.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(Fp.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(sk.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(vS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(wS.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(ok.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(ak.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(TS.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(lk.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(hk.configure(this.options.italic)),this.options.listItem!==!1&&i.push(em.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(om.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Qp.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(lm.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(Yk.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(Zk.configure(this.options.strike)),this.options.text!==!1&&i.push(eS.configure(this.options.text)),this.options.underline!==!1&&i.push(um.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(CS.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),MS=ES,AS=SS,NS=de.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}},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")}}}),OS=NS,RS=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,DS=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,IS=Mn.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",le(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>
180e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const i=/^(==)([^=]+)(==)/.exec(t);if(i){const s=i[2].trim(),o=n.inlineTokens(s);return{type:"highlight",raw:i[0],text:s,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[er({find:RS,type:this.type})]},addPasteRules(){return[kn({find:DS,type:this.type})]}}),LS=IS;function PS({node:t,updateAttributes:e,selected:n}){const[r,i]=S.useState(!1),s=S.useRef(null),o=S.useRef({x:0,y:0,width:0}),a=S.useCallback(u=>{u.preventDefault(),u.stopPropagation();const f=s.current;if(!f)return;o.current={x:u.clientX,y:u.clientY,width:f.offsetWidth},i(!0);const h=m=>{const g=m.clientX-o.current.x,b=Math.max(80,o.current.width+g);e({width:b})},p=()=>{i(!1),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)},[e]),l=t.attrs.width,c={width:typeof l=="number"?`${l}px`:l||void 0,maxWidth:"100%"},d=t.attrs.dataAssetState;return d==="in_recycle_bin"||d==="hard_deleted"?y.jsx(Kd,{className:"relative inline-block",style:c,children:y.jsx(Og,{data:{assetState:d,recycleBinDaysLeft:t.attrs.dataRecycleDays?Number(t.attrs.dataRecycleDays):void 0},contentWidth:"100%",contentHeight:160,assetId:t.attrs.dataAssetId,onRestored:async()=>{if(t.attrs.dataAssetId)try{const u=await Rg.getUrl(t.attrs.dataAssetId);e({src:u,dataAssetState:null,dataRecycleDays:null})}catch{}}})}):y.jsxs(Kd,{className:"relative inline-block",style:c,children:[y.jsx("img",{ref:s,src:t.attrs.src,alt:t.attrs.alt||"",title:t.attrs.title||void 0,crossOrigin:t.attrs.src&&ka(t.attrs.src),draggable:!1,className:`block w-full rounded-md ${n?"ring-2 ring-purple-500":""} ${r?"opacity-70":""}`}),n&&y.jsx("div",{onMouseDown:a,className:"absolute bottom-0 right-0 w-3 h-3 bg-purple-500 rounded-sm cursor-nwse-resize translate-x-1/2 translate-y-1/2 hover:bg-purple-600 transition-colors"})]})}const jS=ve.create({name:"image",group:"block",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{},allowBase64:!0}},addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},dataAssetId:{default:null,parseHTML:t=>t.getAttribute("data-asset-id"),renderHTML:t=>t.dataAssetId?{"data-asset-id":t.dataAssetId}:{}},dataAssetState:{default:null,parseHTML:t=>t.getAttribute("data-asset-state"),renderHTML:()=>({})},dataRecycleDays:{default:null,parseHTML:t=>t.getAttribute("data-recycle-days"),renderHTML:()=>({})}}},parseHTML(){return[{tag:"img[src]"}]},renderHTML({HTMLAttributes:t}){const{width:e,...n}=t,r=e?`width: ${typeof e=="number"?`${e}px`:e}; max-width: 100%;`:"max-width: 100%;";return["img",le(this.options.HTMLAttributes,n,{style:r})]},addNodeView(){return U1(PS)},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}});let sl,ol;if(typeof WeakMap<"u"){let t=new WeakMap;sl=e=>t.get(e),ol=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;sl=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},ol=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var pe=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,i=e/this.width|0;let s=r+1,o=i+1;for(let a=1;s<this.width&&this.map[e+a]==n;a++)s++;for(let a=1;o<this.height&&this.map[e+this.width*a]==n;a++)o++;return{left:r,top:i,right:s,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:i,top:s,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:i==this.width)?null:this.map[s*this.width+(n<0?r-1:i)]:(n<0?s==0:o==this.height)?null:this.map[r+this.width*(n<0?s-1:o)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:s}=this.findCell(t),{left:o,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(i,l),right:Math.max(r,a),bottom:Math.max(s,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const s=r*this.width+i,o=this.map[s];n[o]||(n[o]=!0,!(i==t.left&&i&&this.map[s-1]==o||r==t.top&&r&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const s=i+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]<i;)o++;return o==a?s-1:this.map[o]}i=s}}static get(t){return sl(t)||ol(t,$S(t))}};function $S(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=zS(t),n=t.childCount,r=[];let i=0,s=null;const o=[];for(let c=0,d=e*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){const u=t.child(c);d++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==u.childCount)break;const m=u.child(p),{colspan:g,rowspan:b,colwidth:v}=m.attrs;for(let k=0;k<b;k++){if(k+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:d,n:b-k});break}const x=i+k*e;for(let w=0;w<g;w++){r[x+w]==0?r[x+w]=d:(s||(s=[])).push({type:"collision",row:c,pos:d,n:g-w});const T=v&&v[w];if(T){const C=(x+w)%e*2,A=o[C];
180A==null||A!=T&&o[C+1]==1?(o[C]=T,o[C+1]=1):A==T&&o[C+1]++}}}i+=g,d+=m.nodeSize}const f=(c+1)*e;let h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),d++}(e===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});const a=new pe(e,n,r,s);let l=!1;for(let c=0;!l&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(l=!0);return l&&BS(a,o,t),a}function zS(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let s=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&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){const a=i.child(o);s+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function BS(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const s=t.map[i];if(r[s])continue;r[s]=!0;const o=n.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let a=null;const l=o.attrs;for(let c=0;c<l.colspan;c++){const d=e[(i+c)%t.width*2];d!=null&&(!l.colwidth||l.colwidth[c]!=d)&&((a||(a=HS(l)))[c]=d)}a&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:a})}}function HS(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Le(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const cn=new ce("selectingCells");function tr(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 _S(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 xt(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 Mo(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=tr(e.$head)||FS(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function FS(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 al(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function VS(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function hc(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function ym(t,e,n){const r=t.node(-1),i=pe.get(r),s=t.start(-1),o=i.nextCell(t.pos-s,e,n);return o==null?null:t.node(0).resolve(s+o)}function nr(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(i=>i>0)||(r.colwidth=null)),r}function bm(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function WS(t,e,n){const r=Le(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}var ae=class Vt extends q{constructor(e,n=e){const r=e.node(-1),i=pe.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,n.pos-s),a=e.node(0),l=i.cellsInRect(o).filter(d=>d!=n.pos-s);l.unshift(n.pos-s);const c=l.map(d=>{const u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=s+d+1;return new ih(a.resolve(f),a.resolve(f+u.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)),i=e.resolve(n.map(this.$headCell.pos));if(al(r)&&al(i)&&hc(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Vt.rowSelection(r,i):s&&this.isColSelection()?Vt.colSelection(r,i):new Vt(r,i)}return U.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=pe.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let d=l*n.width+i.left,u=i.left;u<i.right;u++,d++){const f=n.map[d];if(s[f])continue;s[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=i.left-h.left,g=h.right-i.right;if(m>0||g>0){let b=p.attrs;if(m>0&&(b=nr(b,0,m)),g>0&&(b=nr(b,b.colspan-g,g)),h.left<i.left){if(p=p.type.createAndFill(b),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(h.top<i.top||h.bottom>i.bottom){const b={...p.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top<i.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(l).copy(N.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:o;return new $(N.from(a),1,1)}replace(e,n=$.empty){const r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){const{$from:a,$to:l}=i[o],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),o?$.empty:n)}const s=q.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,n){this.replace(e,new $(N.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=pe.get(n),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;
vendor: 4,125 bytes, line 180
180o++)e(n.nodeAt(s[o]),i+s[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,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=pe.get(r),s=e.start(-1),o=i.findCell(e.pos-s),a=i.findCell(n.pos-s),l=e.node(0);return o.top<=a.top?(o.top>0&&(e=l.resolve(s+i.map[o.left])),a.bottom<i.height&&(n=l.resolve(s+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(s+i.map[a.left])),o.bottom<i.height&&(e=l.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new Vt(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=pe.get(e),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),s=n.colCount(this.$headCell.pos-r);if(Math.min(i,s)>0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,a=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,a)==n.width}eq(e){return e instanceof Vt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=pe.get(r),s=e.start(-1),o=i.findCell(e.pos-s),a=i.findCell(n.pos-s),l=e.node(0);return o.left<=a.left?(o.left>0&&(e=l.resolve(s+i.map[o.top*i.width])),a.right<i.width&&(n=l.resolve(s+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(s+i.map[a.top*i.width])),o.right<i.width&&(e=l.resolve(s+i.map[i.width*(o.top+1)-1]))),new Vt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Vt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Vt(e.resolve(n),e.resolve(r))}getBookmark(){return new US(this.$anchorCell.pos,this.$headCell.pos)}};ae.prototype.visible=!1;q.jsonID("cell",ae);var US=class xm{constructor(e,n){this.anchor=e,this.head=n}map(e){return new xm(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&&hc(n,r)?new ae(n,r):q.near(r,1)}};function qS(t){if(!(t.selection instanceof ae))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(be.node(r,r+n.nodeSize,{class:"selectedCell"}))}),se.create(t.doc,e)}function KS({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function JS({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function GS(t,e,n){const r=(e||t).selection,i=(e||t).doc;let s,o;if(r instanceof W&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=ae.create(i,r.from);else if(o=="row"){const a=i.resolve(r.from+1);s=ae.rowSelection(a,a)}else if(!n){const a=pe.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];s=ae.create(i,l+1,c)}}else r instanceof U&&KS(r)?s=U.create(i,r.from):r instanceof U&&JS(r)&&(s=U.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}const YS=new ce("fix-tables");function vm(t,e,n,r){const i=t.childCount,s=e.childCount;e:for(let o=0,a=0;o<s;o++){const l=e.child(o);for(let c=a,d=Math.min(i,o+3);c<d;c++)if(t.child(c)==l){a=c+1,n+=l.nodeSize;continue e}r(l,n),a<i&&t.child(a).sameMarkup(l)?vm(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function wm(t,e){let n;const r=(i,s)=>{i.type.spec.tableRole=="table"&&(n=XS(t,i,s,n))};return e?e.doc!=t.doc&&vm(e.doc,t.doc,0,r):t.doc.descendants(r),n}function XS(t,e,n,r){const i=pe.get(e);if(!i.problems)return r;r||(r=t.tr);const s=[];for(let l=0;l<i.height;l++)s.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];
180if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)s[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,nr(u,u.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+e.nodeSize)}}let o,a;for(let l=0;l<s.length;l++)s[l]&&(o==null&&(o=l),a=l);for(let l=0,c=n+1;l<i.height;l++){const d=e.child(l),u=c+d.nodeSize,f=s[l];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<f;g++){const b=Le(t.schema)[h].createAndFill();b&&p.push(b)}const m=(l==0||o==l-1)&&a==l?c+1:u-1;r.insert(r.mapping.map(m),p)}c=u}return r.setMeta(YS,{fixTables:!0})}function jt(t){const e=t.selection,n=Mo(t),r=n.node(-1),i=n.start(-1),s=pe.get(r);return{...e instanceof ae?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(n.pos-i),tableStart:i,map:s,table:r}}function km(t,{map:e,tableStart:n,table:r},i){let s=i>0?-1:0;WS(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){const a=o*e.width+i;
180if(i>0&&i<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,bm(c.attrs,i-e.colCount(l))),o+=c.attrs.rowspan-1}else{const l=s==null?Le(r.type.schema).cell:r.nodeAt(e.map[a+s]).type,c=e.positionAt(o,i,r);t.insert(t.mapping.map(n+c),l.createAndFill())}}return t}function QS(t,e){if(!xt(t))return!1;if(e){const n=jt(t);e(km(t.tr,n,n.left))}return!0}function ZS(t,e){if(!xt(t))return!1;if(e){const n=jt(t);e(km(t.tr,n,n.right))}return!0}function eC(t,{map:e,table:n,tableStart:r},i){const s=t.mapping.maps.length;for(let o=0;o<e.height;){const a=o*e.width+i,l=e.map[a],c=n.nodeAt(l),d=c.attrs;if(i>0&&e.map[a-1]==l||i<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(s).map(r+l),null,nr(d,i-e.colCount(l)));else{const u=t.mapping.slice(s).map(r+l);t.delete(u,u+c.nodeSize)}o+=d.rowspan}}function tC(t,e){if(!xt(t))return!1;if(e){const n=jt(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;eC(r,n,i),i!=n.left;i--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=pe.get(s)}e(r)}return!0}function nC(t,e,n){var r;const i=Le(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((r=e.nodeAt(t.map[s+n*t.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function Sm(t,{map:e,tableStart:n,table:r},i){let s=n;for(let c=0;c<i;c++)s+=r.child(c).nodeSize;const o=[];let a=i>0?-1:0;nC(e,r,i+a)&&(a=i==0||i==e.height?null:0);for(let c=0,d=e.width*i;c<e.width;c++,d++)if(i>0&&i<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=r.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var l;const u=a==null?Le(r.type.schema).cell:(l=r.nodeAt(e.map[d+a*e.width]))===null||l===void 0?void 0:l.type,f=u==null?void 0:u.createAndFill();f&&o.push(f)}return t.insert(s,Le(r.type.schema).row.create(null,o)),t}function rC(t,e){if(!xt(t))return!1;if(e){const n=jt(t);e(Sm(t.tr,n,n.top))}return!0}function iC(t,e){if(!xt(t))return!1;if(e){const n=jt(t);e(Sm(t.tr,n,n.bottom))}return!0}function sC(t,{map:e,table:n,tableStart:r},i){let s=0;for(let c=0;c<i;c++)s+=n.child(c).nodeSize;const o=s+n.child(i).nodeSize,a=t.mapping.maps.length;t.delete(s+r,o+r);const l=new Set;for(let c=0,d=i*e.width;c<e.width;c++,d++){const u=e.map[d];if(!l.has(u)){if(l.add(u),i>0&&u==e.map[d-e.width]){const f=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(a).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(i<e.height&&u==e.map[d+e.width]){const f=n.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(i+1,c,n);t.insert(t.mapping.slice(a).map(r+m),p),c+=h.colspan-1}}}}function oC(t,e){if(!xt(t))return!1;if(e){const n=jt(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;sC(r,n,i),i!=n.top;i--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=pe.get(n.table)}e(r)}return!0}function hu(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function aC({width:t,height:e,map:n},r){let i=r.top*t+r.left,s=i,o=(r.bottom-1)*t+r.left,a=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[s]==n[s-1]||r.right<t&&n[a]==n[a+1])return!0;s+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[o]==n[o+t])return!0;i++,o++}return!1}function pu(t,e){const n=t.selection;if(!(n instanceof ae)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=jt(t),{map:i}=r;if(aC(i,r))return!1;if(e){const s=t.tr,o={};let a=N.empty,l,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const f=i.map[d*i.width+u],h=r.table.nodeAt(f);if(!(o[f]||!h))if(o[f]=!0,l==null)l=f,c=h;else{hu(h)||(a=a.append(h.content));const p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(l==null||c==null)return!0;if(s.setNodeMarkup(l+r.tableStart,null,{...bm(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const d=l+1+c.content.size,u=hu(c)?l+1:d;s.replaceWith(u+r.tableStart,d+r.tableStart,a)}s.setSelection(new ae(s.doc.resolve(l+r.tableStart))),e(s)}return!0}function mu(t,e){const n=Le(t.schema);return lC(({node:r})=>n[r.type.spec.tableRole])(t,e)}function lC(t){return(e,n)=>{const r=e.selection;let i,s;if(r instanceof ae){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var o;if(i=_S(r.$from),!i)return!1;s=(o=tr(r.$from))===null||o===void 0?void 0:o.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let a=i.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const d=jt(e),u=e.tr;for(let h=0;h<d.right-d.left;
vendor: 9,322 bytes, line 180
180h++)l.push(c?{...a,colwidth:c&&c[h]?[c[h]]:null}:a);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=i.nodeSize);for(let m=d.left,g=0;m<d.right;m++,g++)m==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),t({node:i,row:h,col:m}).createAndFill(l[g]))}u.setNodeMarkup(s,t({node:i,row:d.top,col:d.left}),l[0]),r instanceof ae&&u.setSelection(new ae(u.doc.resolve(r.$anchorCell.pos),f?u.doc.resolve(f):void 0)),n(u)}return!0}}function cC(t,e){return function(n,r){if(!xt(n))return!1;const i=Mo(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const s=n.tr;n.selection instanceof ae?n.selection.forEachCell((o,a)=>{o.attrs[t]!==e&&s.setNodeMarkup(a,null,{...o.attrs,[t]:e})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(s)}return!0}}function dC(t){return function(e,n){if(!xt(e))return!1;if(n){const r=Le(e.schema),i=jt(e),s=e.tr,o=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=o.map(l=>i.table.nodeAt(l));for(let l=0;l<o.length;l++)a[l].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[l],r.cell,a[l].attrs);if(s.steps.length===0)for(let l=0;l<o.length;l++)s.setNodeMarkup(i.tableStart+o[l],r.header_cell,a[l].attrs);n(s)}return!0}}function gu(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 i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==n.header_cell)return!1}return!0}function Ti(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?dC(t):function(n,r){if(!xt(n))return!1;if(r){const i=Le(n.schema),s=jt(n),o=n.tr,a=gu("row",s,i),l=gu("column",s,i),c=(t==="column"?a:t==="row"&&l)?1:0,d=t=="column"?{left:0,top:c,right:1,bottom:s.map.height}:t=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,u=t=="column"?l?i.cell:i.header_cell:t=="row"?a?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(f=>{const h=f+s.tableStart,p=o.doc.nodeAt(h);p&&o.setNodeMarkup(h,u,p.attrs)}),r(o)}return!0}}Ti("row",{useDeprecatedLogic:!0});Ti("column",{useDeprecatedLogic:!0});const uC=Ti("cell",{useDeprecatedLogic:!0});function fC(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const s=t.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.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),i=t.after();r<n.childCount;r++){const s=n.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}return null}function yu(t){return function(e,n){if(!xt(e))return!1;const r=fC(Mo(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(U.between(i,VS(i))).scrollIntoView())}return!0}}function hC(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 es(t,e){const n=t.selection;if(!(n instanceof ae))return!1;if(e){const r=t.tr,i=Le(t.schema).cell.createAndFill().content;n.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new $(i,0,0))}),r.docChanged&&e(r)}return!0}function pC(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 i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,a=[];if(s=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const d=l?0:Math.max(0,n-1),u=l<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=ll(Le(o).row,new $(c,d,u)).content),a.push(c)}else if(s=="cell"||s=="header_cell")a.push(n||r?ll(Le(o).row,new $(e,n,r)).content:e);else return null;return mC(o,a)}function mC(t,e){const n=[];for(let i=0;i<e.length;i++){const s=e[i];for(let o=s.childCount-1;o>=0;o--){const{rowspan:a,colspan:l}=s.child(o).attrs;for(let c=i;c<i+a;c++)n[c]=(n[c]||0)+l}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(N.empty),n[i]<r){const s=Le(t).cell.createAndFill(),o=[];for(let a=n[i];a<r;a++)o.push(s);e[i]=e[i].append(N.from(o))}return{height:e.length,width:r,rows:e}}function ll(t,e){const n=t.createAndFill();return new Tl(n).replace(0,n.content.size,e).doc}function gC({width:t,height:e,rows:n},r,i){if(t!=r){const s=[],o=[];for(let a=0;a<n.length;a++){const l=n[a],c=[];for(let d=s[a]||0,u=0;d<r;u++){let f=l.child(u%l.childCount);d+f.attrs.colspan>r&&(f=f.type.createChecked(nr(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[a+h]=(s[a+h]||0)+f.attrs.colspan}o.push(N.from(c))}n=o,t=r}if(e!=i){const s=[];for(let o=0,a=0;o<i;o++,a++){const l=[],c=n[a%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);o+u.attrs.rowspan>i&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,i-u.attrs.rowspan)},u.content)),l.push(u)}s.push(N.from(l))}n=s,e=i}return{width:t,height:e,rows:n}}function yC(t,e,n,r,i,s,o){const a=t.doc.type.schema,l=Le(a);let c,d;if(i>e.width)for(let u=0,f=0;u<e.height;u++){const h=n.child(u);f+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==l.cell?m=c||(c=l.cell.createAndFill()):m=d||(d=l.header_cell.createAndFill());for(let g=e.width;g<i;g++)p.push(m);t.insert(t.mapping.slice(o).map(f-1+r),p)}if(s>e.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,i);p++){const g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==l.header_cell;u.push(g?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const f=l.row.create(null,N.from(u)),h=[];for(let p=e.height;p<s;p++)h.push(f);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),h)}return!!(c||d)}function bu(t,e,n,r,i,s,o,a){if(o==0||o==e.height)return!1;let l=!1;for(let c=i;c<s;c++){const d=o*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){l=!0;const f=n.nodeAt(u),{top:h,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(a).map(u+r),null,{...f.attrs,rowspan:o-h}),t.insert(t.mapping.slice(a).map(e.positionAt(o,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return l}function xu(t,e,n,r,i,s,o,a){if(o==0||o==e.width)return!1;let l=!1;for(let c=i;c<s;c++){const d=c*e.width+o,u=e.map[d];if(e.map[d-1]==u){l=!0;const f=n.nodeAt(u),h=e.colCount(u),p=t.mapping.slice(a).map(u+r);t.setNodeMarkup(p,null,nr(f.attrs,o-h,f.attrs.colspan-(o-h))),t.insert(p+f.nodeSize,f.type.createAndFill(nr(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return l}function vu(t,e,n,r,i){let s=n?t.doc.nodeAt(n-1):t.doc;if(!s)throw new Error("No table found");let o=pe.get(s);const{top:a,left:l}=r,c=l+i.width,d=a+i.height,u=t.tr;let f=0;function h(){if(s=n?u.doc.nodeAt(n-1):u.doc,!s)throw new Error("No table found");o=pe.get(s),f=u.mapping.maps.length}yC(u,o,s,n,c,d,f)&&h(),bu(u,o,s,n,l,c,a,f)&&h(),bu(u,o,s,n,l,c,d,f)&&h(),xu(u,o,s,n,a,d,l,f)&&h(),xu(u,o,s,n,a,d,c,f)&&h();for(let p=a;p<d;p++){const m=o.positionAt(p,l,s),g=o.positionAt(p,c,s);u.replace(u.mapping.slice(f).map(m+n),u.mapping.slice(f).map(g+n),new $(i.rows[p-a],0,0))}h(),u.setSelection(new ae(u.doc.resolve(n+o.positionAt(a,l,s)),u.doc.resolve(n+o.positionAt(d-1,c-1,s)))),e(u)}const bC=_l({ArrowLeft:ts("horiz",-1),ArrowRight:ts("horiz",1),ArrowUp:ts("vert",-1),ArrowDown:ts("vert",1),"Shift-ArrowLeft":ns("horiz",-1),"Shift-ArrowRight":ns("horiz",1),"Shift-ArrowUp":ns("vert",-1),"Shift-ArrowDown":ns("vert",1),Backspace:es,"Mod-Backspace":es,Delete:es,"Mod-Delete":es});function ps(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function ts(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;if(s instanceof ae)return ps(n,r,q.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const o=Cm(i,t,e);if(o==null)return!1;if(t=="horiz")return ps(n,r,q.near(n.doc.resolve(s.head+e),e));{const a=n.doc.resolve(o),l=ym(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),ps(n,r,c)}}}function ns(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;let o;if(s instanceof ae)o=s;else{const l=Cm(i,t,e);if(l==null)return!1;o=new ae(n.doc.resolve(l))}const a=ym(o.$headCell,t,e);return a?ps(n,r,new ae(o.$anchorCell,a)):!1}}function xC(t,e){const n=t.state.doc,r=tr(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new ae(r))),!0):!1}function vC(t,e,n){if(!xt(t.state))return!1;let r=pC(n);const i=t.state.selection;if(i instanceof ae){r||(r={width:1,height:1,rows:[N.from(ll(Le(t.state.schema).cell,n))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),a=pe.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=gC(r,a.right-a.left,a.bottom-a.top),vu(t.state,t.dispatch,o,a,r),!0}else if(r){const s=Mo(t.state),o=s.start(-1);return vu(t.state,t.dispatch,o,pe.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function wC(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=wu(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof ae)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=tr(t.state.selection.$anchor))!=null&&((n=pa(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(l,c){let d=pa(t,c);
180const u=cn.getState(t.state)==null;if(!d||!hc(l,d))if(u)d=l;else return;const f=new ae(l,d);if(u||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);u&&h.setMeta(cn,l.pos),t.dispatch(h)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",a),cn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(cn,-1))}function a(l){const c=l,d=cn.getState(t.state);let u;if(d!=null)u=t.state.doc.resolve(d);else if(wu(t,c.target)!=r&&(u=pa(t,e),!u))return o();u&&s(u,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",a)}function Cm(t,e,n){if(!(t.state.selection instanceof U))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const o=r.before(i),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?o:null}}return null}function wu(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function pa(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&tr(t.state.doc.resolve(r))||tr(t.state.doc.resolve(i))}var kC=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")),cl(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,cl(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function cl(t,e,n,r,i,s){let o=0,a=!0,l=e.firstChild;const c=t.firstChild;if(c){for(let u=0,f=0;u<c.childCount;u++){const{colspan:h,colwidth:p}=c.child(u).attrs;for(let m=0;m<h;m++,f++){const g=i==f?s:p&&p[m],b=g?g+"px":"";if(o+=g||r,g||(a=!1),l)l.style.width!=b&&(l.style.width=b),l=l.nextSibling;else{const v=document.createElement("col");v.style.width=b,e.appendChild(v)}}}for(;l;){var d;const u=l.nextSibling;(d=l.parentNode)===null||d===void 0||d.removeChild(l),l=u}a?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const Ge=new ce("tableColumnResizing");function SC({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=kC,lastColumnResizable:i=!0}={}){const s=new ie({key:Ge,state:{init(o,a){var l;const c=(l=s.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,d=Le(a.schema).table.name;return r&&c&&(c[d]=(u,f)=>new r(u,n,f)),new CC(-1,!1)},apply(o,a){return a.apply(o)}},props:{attributes:o=>{const a=Ge.getState(o);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,a)=>{TC(o,a,t,i)},mouseleave:o=>{EC(o)},mousedown:(o,a)=>{MC(o,a,e,n)}},decorations:o=>{const a=Ge.getState(o);if(a&&a.activeHandle>-1)return DC(o,a.activeHandle)},nodeViews:{}}});return s}var CC=class ms{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Ge);if(r&&r.setHandle!=null)return new ms(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new ms(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return al(e.doc.resolve(i))||(i=-1),new ms(i,n.dragging)}return n}};function TC(t,e,n,r){if(!t.editable)return;const i=Ge.getState(t.state);if(i&&!i.dragging){const s=NC(e.target);let o=-1;if(s){const{left:a,right:l}=s.getBoundingClientRect();e.clientX-a<=n?o=ku(t,e,"left",n):l-e.clientX<=n&&(o=ku(t,e,"right",n))}if(o!=i.activeHandle){if(!r&&o!==-1){const a=t.state.doc.resolve(o),l=a.node(-1),c=pe.get(l),d=a.start(-1);if(c.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==c.width-1)return}Tm(t,o)}}}function EC(t){if(!t.editable)return;const e=Ge.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Tm(t,-1)}function MC(t,e,n,r){var i;if(!t.editable)return!1;const s=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,o=Ge.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const a=t.state.doc.nodeAt(o.activeHandle),l=AC(t,o.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Ge,{setDragging:{startX:e.clientX,startWidth:l}}));function c(u){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",d);const f=Ge.getState(t.state);f!=null&&f.dragging&&(OC(t,f.activeHandle,Su(f.dragging,u,n)),t.dis
180patch(t.state.tr.setMeta(Ge,{setDragging:null})))}function d(u){if(!u.which)return c(u);const f=Ge.getState(t.state);if(f&&f.dragging){const h=Su(f.dragging,u,n);Cu(t,f.activeHandle,h,r)}}return Cu(t,o.activeHandle,l,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",d),e.preventDefault(),!0}function AC(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=t.domAtPos(e);let o=s.node.childNodes[s.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(o-=r[l],a--);return o/a}function NC(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function ku(t,e,n,r){const i=n=="right"?-r:r,s=t.posAtCoords({left:e.clientX+i,top:e.clientY});if(!s)return-1;const{pos:o}=s,a=tr(t.state.doc.resolve(o));if(!a)return-1;if(n=="right")return a.pos;const l=pe.get(a.node(-1)),c=a.start(-1),d=l.map.indexOf(a.pos-c);return d%l.width==0?-1:c+l.map[d-1]}function Su(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Tm(t,e){t.dispatch(t.state.tr.setMeta(Ge,{setHandle:e}))}function OC(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),s=pe.get(i),o=r.start(-1),a=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let c=0;c<s.height;c++){const d=c*s.width+a;if(c&&s.map[d]==s.map[d-s.width])continue;const u=s.map[d],f=i.nodeAt(u).attrs,h=f.colspan==1?0:a-s.colCount(u);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():RC(f.colspan);p[h]=n,l.setNodeMarkup(o+u,null,{...f,colwidth:p})}l.docChanged&&t.dispatch(l)}function Cu(t,e,n,r){const i=t.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),a=pe.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1;let l=t.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&cl(s,l.firstChild,l,r,a,n)}function RC(t){return Array(t).fill(0)}function DC(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return se.empty;const s=pe.get(i),o=r.start(-1),a=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const d=a+c*s.width;if((a==s.width-1||s.map[d]!=s.map[d+1])&&(c==0||s.map[d]!=s.map[d-s.width])){var l;const u=s.map[d],f=o+u+i.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((l=Ge.getState(t))===null||l===void 0)&&l.dragging&&n.push(be.node(o+u,o+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),n.push(be.widget(f,h))}}return se.create(t.doc,n)}function IC({allowTableNodeSelection:t=!1}={}){return new ie({key:cn,state:{init(){return null},apply(e,n){const r=e.getMeta(cn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:s}=e.mapping.mapResult(n);return i?null:s}},props:{decorations:qS,handleDOMEvents:{mousedown:wC},createSelectionBetween(e){return cn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:xC,handleKeyDown:bC,handlePaste:vC},appendTransaction(e,n,r){return GS(r,wm(r,n),t)}})}var Em=ve.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"),i=r?r.split(",").map(s=>parseInt(s,10)):null;if(!i){const s=(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&&s&&s[o]){const a=s[o].getAttribute("width");return a?[parseInt(a,10)]:null}}return i}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",le(this.options.HTMLAttributes,t),0]}}),Mm=ve.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}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",le(this.options.HTMLAttributes,t),0]}}),Am=ve.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",le(this.options.HTMLAttributes,t),0]}});function dl(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Tu(t,e,n,r,i,s){var o;let a=0,l=!0,c=e.firstChild;const d=t.firstChild;if(d!==null)for(let f=0,h=0;f<d.childCount;f+=1){const{colspan:p,colwidth:m}=d.child(f).attrs;for(let g=0;g<p;g+=1,h+=1){const b=i===h?s:m&&m[g],v=b?`${b}px`:"";if(a+=b||r,b||(l=!1),c){if(c.style.width!==v){const[k,x]=dl(r,b);c.style.setProperty(k,x)}c=c.nextSibling}
180else{const k=document.createElement("col"),[x,w]=dl(r,b);k.style.setProperty(x,w),e.appendChild(k)}}}for(;c;){const f=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=f}const u=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!u?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}var LC=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")),Tu(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,Tu(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 PC(t,e,n,r){let i=0,s=!0;const o=[],a=t.firstChild;if(!a)return{};for(let u=0,f=0;u<a.childCount;u+=1){const{colspan:h,colwidth:p}=a.child(u).attrs;for(let m=0;m<h;m+=1,f+=1){const g=n===f?r:p&&p[m];i+=g||e,g||(s=!1);const[b,v]=dl(e,g);o.push(["col",{style:`${b}: ${v}`}])}}const l=s?`${i}px`:"",c=s?"":`${i}px`;return{colgroup:["colgroup",{},...o],tableWidth:l,tableMinWidth:c}}function Eu(t,e){return t.createAndFill()}function jC(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 $C(t,e,n,r,i){const s=jC(t),o=[],a=[];for(let c=0;c<n;c+=1){const d=Eu(s.cell);if(d&&a.push(d),r){const u=Eu(s.header_cell);u&&o.push(u)}}const l=[];for(let c=0;c<e;c+=1)l.push(s.row.createChecked(null,r&&c===0?o:a));return s.table.createChecked(null,l)}function zC(t){return t instanceof ae}var rs=({editor:t})=>{const{selection:e}=t.state;if(!zC(e))return!1;let n=0;const r=ap(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},BC="�";function HC(t){return(t||"").replace(/\s+/g," ").trim()}function _C(t,e,n={}){var r;const i=(r=n.cellLineSeparator)!=null?r:BC;if(!t||!t.content||t.content.length===0)return"";const s=[];t.content.forEach(p=>{const m=[];p.content&&p.content.forEach(g=>{let b="";g.content&&Array.isArray(g.content)&&g.content.length>1?b=g.content.map(w=>e.renderChildren(w)).join(i):b=g.content?e.renderChildren(g.content):"";const v=HC(b),k=g.type==="tableHeader";m.push({text:v,isHeader:k})}),s.push(m)});const o=s.reduce((p,m)=>Math.max(p,m.length),0);if(o===0)return"";const a=new Array(o).fill(0);s.forEach(p=>{var m;for(let g=0;g<o;g+=1){const v=(((m=p[g])==null?void 0:m.text)||"").length;v>a[g]&&(a[g]=v),a[g]<3&&(a[g]=3)}});const l=(p,m)=>p+" ".repeat(Math.max(0,m-p.length)),c=s[0],d=c.some(p=>p.isHeader);let u=` 181`;const f=new Array(o).fill(0).map((p,m)=>d&&c[m]&&c[m].text||"");return u+=`| ${f.map((p,m)=>l(p,a[m])).join(" | ")} | 182`,u+=`| ${a.map(p=>"-".repeat(Math.max(3,p))).join(" | ")} |
183`,(d?s.slice(1):s).forEach(p=>{u+=`| ${new Array(o).fill(0).map((m,g)=>l(p[g]&&p[g].text||"",a[g])).join(" | ")} | 184`}),u}var FC=_C,Nm=ve.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:LC,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:i}=PC(t,this.options.cellMinWidth),s=e.style;function o(){return s||(r?`width: ${r}`:`min-width: ${i}`)}const a=["table",le(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},a]:a},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(i=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const i=[];r.forEach(s=>{i.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>FC(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const o=$C(s.schema,t,e,n);if(i){const a=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(U.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>QS(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>ZS(t,e),deleteColumn:()=>({state:t,dispatch:e})=>tC(t,e),addRowBefore:()=>({state:t,dispatch:e})=>rC(t,e),addRowAfter:()=>({state:t,dispatch:e})=>iC(t,e),deleteRow:()=>({state:t,dispatch:e})=>oC(t,e),deleteTable:()=>({state:t,dispatch:e})=>hC(t,e),mergeCells:()=>({state:t,dispatch:e})=>pu(t,e),splitCell:()=>({state:t,dispatch:e})=>mu(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Ti("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Ti("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>uC(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>pu(t,e)?!0:mu(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>cC(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>yu(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>yu(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&wm(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=ae.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:rs,"Mod-Backspace":rs,Delete:rs,"Mod-Delete":rs}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[SC({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],IC({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:ne(V(t,"tableRole",e))}}});de.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(Nm.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Em.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Mm.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Am.configure(this.options.tableRow)),t}});function Om(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?Om(n.children,r):{text:n.value,classes:r}})}function Mu(t){return t.value||t.children||[]}function VC(t){return!!Dg.getLanguage(t)}function Au({doc:t,name:e,lowlight:n,defaultLanguage:r}){const i=[];return Wa(t,s=>s.type.name===e).forEach(s=>{var o;let a=s.pos+1;const l=s.node.attrs.language||r,c=n.listLanguages(),d=l&&(c.includes(l)||VC(l)||(o=n.registered)!=null&&o.call(n,l))?Mu(n.highlight(l,s.node.textContent)):Mu(n.highlightAuto(s.node.textContent));
184Om(d).forEach(u=>{const f=a+u.text.length;if(u.classes.length){const h=be.inline(a,f,{class:u.classes.join(" ")});i.push(h)}a=f})}),se.create(t,i)}function WC(t){return typeof t=="function"}function UC({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(i=>WC(e[i])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new ie({key:new ce("lowlight"),state:{init:(i,{doc:s})=>Au({doc:s,name:t,lowlight:e,defaultLanguage:n}),apply:(i,s,o,a)=>{const l=o.selection.$head.parent.type.name,c=a.selection.$head.parent.type.name,d=Wa(o.doc,f=>f.type.name===t),u=Wa(a.doc,f=>f.type.name===t);return i.docChanged&&([l,c].includes(t)||u.length!==d.length||i.steps.some(f=>f.from!==void 0&&f.to!==void 0&&d.some(h=>h.pos>=f.from&&h.pos+h.node.nodeSize<=f.to)))?Au({doc:i.doc,name:t,lowlight:e,defaultLanguage:n}):s.map(i.mapping,i.doc)}},props:{decorations(i){return r.getState(i)}}});return r}var qC=Fp.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))||[],UC({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),KC=qC,JC=dm,GC=cm;const re=({onClick:t,isActive:e,disabled:n,title:r,children:i})=>y.jsx("button",{onClick:t,disabled:n,title:r,className:`p-1.5 rounded transition-colors ${e?"bg-[var(--bg-hover)] text-[var(--text-primary)]":"text-[var(--text-tertiary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]"} disabled:opacity-30 disabled:cursor-not-allowed`,children:i}),tn=()=>y.jsx("div",{className:"w-px h-5 bg-ui-border mx-1"}),YC=S.memo(function({editor:e,onOpenMediaDialog:n}){const{t:r}=He(),[i,s]=S.useState(!1),[o,a]=S.useState(""),l=S.useRef(null),c=S.useCallback(()=>{e&&o.trim()&&(e.chain().focus().extendMarkRange("link").setLink({href:o.trim()}).run(),a(""),s(!1))},[e,o]),d=S.useCallback(f=>{var m;const h=(m=f.target.files)==null?void 0:m[0];if(!h||!e)return;const p=new FileReader;p.onload=async g=>{var v;const b=(v=g.target)==null?void 0:v.result;if(b){const k=await Sa(b);e.commands.setContent(k)}},p.readAsText(h),f.target.value=""},[e]);if(!e)return null;const u=e.isActive("table");return y.jsxs("div",{className:"flex items-center gap-0.5 px-3 py-2 bg-[var(--bg-tertiary)] border-b border-ui-border rounded-t-lg flex-wrap relative",children:[y.jsx(re,{onClick:()=>e.chain().focus().toggleBold().run(),isActive:e.isActive("bold"),title:r("writing.bold"),children:y.jsx(my,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),title:r("writing.italic"),children:y.jsx(gy,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),title:r("writing.underline"),children:y.jsx(wy,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),title:r("writing.strikethrough"),children:y.jsx(ky,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),title:r("writing.highlight"),children:y.jsx(Ef,{className:"w-4 h-4"})}),y.jsx(tn,{}),y.jsx(re,{onClick:()=>e.chain().focus().toggleHeading({level:1}).run(),isActive:e.isActive("heading",{level:1}),title:r("writing.heading1"),children:y.jsx(kf,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),isActive:e.isActive("heading",{level:2}),title:r("writing.heading2"),children:y.jsx(Sf,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().toggleHeading({level:3}).run(),isActive:e.isActive("heading",{level:3}),title:r("writing.heading3"),children:y.jsx(Cf,{className:"w-4 h-4"})}),y.jsx(tn,{}),y.jsx(re,{onClick:()=>e.chain().focus().toggleBulletList().run(),isActive:e.isActive("bulletList"),title:r("writing.bulletList"),children:y.jsx(uo,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().toggleOrderedList().run(),isActive:e.isActive("orderedList"),title:r("writing.orderedList"),children:y.jsx(cf,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().toggleTaskList().run(),isActive:e.isActive("taskList"),title:r("writing.taskList"),children:y.jsx(Ly,{className:"w-4 h-4"})}),y.jsx(tn,{}),y.jsx(re,{onClick:()=>e.chain().focus().toggleBlockquote().run(),isActive:e.isActive("blockquote"),title:r("writing.blockquote"),children:y.jsx(df,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().toggleCodeBlock().run(),isActive:e.isActive("codeBlock"),title:r("writing.codeBlock"),children:y.jsx(vl,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().setHorizontalRule().run(),title:r("writing.horizontalRule"),children:y.jsx(uf,{className:"w-4 h-4"})}),y.jsx(tn,{}),y.jsx(re,{onClick:()=>n==null?void 0:n("image"),title:r("writing.insertImage"),children:y.jsx(Ig,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>n==null?void 0:n("video"),title:r("writing.insertVideo"),children:y.jsx(Lg,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),isActive:u,title:r("writing.insertTable"),children:y.jsx(Pg,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>{e.isActive("link")?e.chain().focus().unsetLink().run():s(!i)},isActive:e.isActive("link")||i,title:e.isActive("link")?r("writing.removeLink"):r("writing.insertLink"),children:e.isActive("link")?y.jsx(zy,{className:"w-4 h-4"}):y.jsx(jg,{className:"w-4 h-4"})}),y.jsx(tn,{}),u&&y.jsxs(y.Fragment,{children:[y.jsx(re,{onClick:()=>e.chain().focus().addRowAfter().run(),title:r("writing.addRow"),children:y.jsxs("span",{className:"flex items-center text-xs font-medium gap-0.5",children:[y.jsx(Nc,{className:"w-3 h-3"}),"R"]})}),y.jsx(re,{onClick:()=>e.chain().focus().addColumnAfter().run(),title:r("writing.addColumn"),children:y.jsxs("span",{className:"flex items-center text-xs font-medium gap-0.5",children:[y.jsx(Nc,{className:"w-3 h-3"}),"C"]})}),y.jsx(re,{onClick:()=>e.chain().focus().deleteRow().run(),title:r("writing.deleteRow"),children:y.jsxs("span",{className:"flex items-center text-xs font-medium gap-0.5",children:[y.jsx(Zr,{className:"w-3 h-3"}),"R"]})}),y.jsx(re,{onClick:()=>e.chain().focus().deleteColumn().run(),title:r("writing.deleteColumn"),children:y.jsxs("span",{className:"flex items-center text-xs font-medium gap-0.5",children:[y.jsx(Zr,{className:"w-3 h-3"}),"C"]})}),y.jsx(re,{onClick:()=>e.chain().focus().deleteTable().run(),title:r("writing.deleteTable"),children:y.jsx(Zr,{className:"w-4 h-4 text-red-500"})}),y.jsx(tn,{})]}),y.jsx(re,{onClick:()=>e.chain().focus().setTextAlign("left").run(),isActive:e.isActive({textAlign:"left"}),title:r("writing.alignLeft"),children:y.jsx(yy,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().setTextAlign("center").run(),isActive:e.isActive({textAlign:"center"}),title:r("writing.alignCenter"),children:y.jsx(by,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().setTextAlign("right").run(),isActive:e.isActive({textAlign:"right"}),title:r("writing.alignRight"),children:y.jsx(xy,{className:"w-4 h-4"})}),y.jsx(tn,{}),y.jsx(re,{onClick:()=>{var f;return(f=l.current)==null?void 0:f.click()},title:r("writing.importMarkdown"),children:y.jsx(Sy,{className:"w-4 h-4"})}),y.jsx("input",{ref:l,type:"file",accept:".md,.markdown,.txt",onCh
vendor: 4,103 bytes, line 184
184ange:d,className:"hidden"}),y.jsx(tn,{}),y.jsx(re,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().undo(),title:r("writing.undo"),children:y.jsx(vy,{className:"w-4 h-4"})}),y.jsx(re,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().redo(),title:r("writing.redo"),children:y.jsx(Cy,{className:"w-4 h-4"})}),i&&y.jsxs("div",{className:"absolute top-full left-0 mt-1 z-10 bg-[var(--bg-primary)] border border-ui-border rounded-lg shadow-lg p-3 flex gap-2",children:[y.jsx("input",{type:"url",value:o,onChange:f=>a(f.target.value),placeholder:"https://...",maxLength:500,className:"px-3 py-1.5 text-sm border border-ui-border rounded bg-[var(--bg-secondary)] text-[var(--text-primary)] w-64",onKeyDown:f=>{f.key==="Enter"&&!f.nativeEvent.isComposing&&c(),f.key==="Escape"&&s(!1)},autoFocus:!0}),y.jsx("button",{onClick:c,className:"px-3 py-1.5 text-sm bg-[var(--bg-brand)] text-white rounded hover:opacity-90",children:r("writing.insertLink")})]})]})}),Rm=["top","right","bottom","left"],Nu=["start","end"],Ou=Rm.reduce((t,e)=>t.concat(e,e+"-"+Nu[0],e+"-"+Nu[1]),[]),It=Math.min,$e=Math.max,so=Math.round,Mt=t=>({x:t,y:t}),XC={left:"right",right:"left",bottom:"top",top:"bottom"},QC={start:"end",end:"start"};function ul(t,e,n){return $e(t,It(e,n))}function Xt(t,e){return typeof t=="function"?t(e):t}function at(t){return t.split("-")[0]}function gt(t){return t.split("-")[1]}function Dm(t){return t==="x"?"y":"x"}function pc(t){return t==="y"?"height":"width"}const ZC=new Set(["top","bottom"]);function Et(t){return ZC.has(at(t))?"y":"x"}function mc(t){return Dm(Et(t))}function Im(t,e,n){n===void 0&&(n=!1);const r=gt(t),i=mc(t),s=pc(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=ao(o)),[o,ao(o)]}function eT(t){const e=ao(t);return[oo(t),e,oo(e)]}function oo(t){return t.replace(/start|end/g,e=>QC[e])}const Ru=["left","right"],Du=["right","left"],tT=["top","bottom"],nT=["bottom","top"];function rT(t,e,n){switch(t){case"top":case"bottom":return n?e?Du:Ru:e?Ru:Du;case"left":case"right":return e?tT:nT;default:return[]}}function iT(t,e,n,r){const i=gt(t);let s=rT(at(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(oo)))),s}function ao(t){return t.replace(/left|right|bottom|top/g,e=>XC[e])}function sT(t){return{top:0,right:0,bottom:0,left:0,...t}}function gc(t){return typeof t!="number"?sT(t):{top:t,right:t,bottom:t,left:t}}function Lr(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function Iu(t,e,n){let{reference:r,floating:i}=t;const s=Et(e),o=mc(e),a=pc(o),l=at(e),c=s==="y",d=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2;let h;switch(l){case"top":h={x:d,y:r.y-i.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:u};break;case"left":h={x:r.x-i.width,y:u};break;default:h={x:r.x,y:r.y}}switch(gt(e)){case"start":h[o]-=f*(n&&c?-1:1);break;case"end":h[o]+=f*(n&&c?-1:1);break}return h}const oT=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:u}=Iu(c,r,l),f=r,h={},p=0;for(let m=0;m<a.length;m++){const{name:g,fn:b}=a[m],{x:v,y:k,data:x,reset:w}=await b({x:d,y:u,initialPlacement:r,placement:f,strategy:i,middlewareData:h,rects:c,platform:o,elements:{reference:t,floating:e}});d=v??d,u=k??u,h={...h,[g]:{...h[g],...x}},w&&p<=50&&(p++,typeof w=="object"&&(w.placement&&(f=w.placement),w.rects&&(c=w.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):w.rects),{x:d,y:u}=Iu(c,f,l)),m=-1)}return{x:d,y:u,placement:f,strategy:i,middlewareData:h}};async function Pr(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:f=!1,padding:h=0}=Xt(e,t),p=gc(h),g=a[f?u==="floating"?"reference":"floating":u],b=Lr(await s.getClippingRect
vendor: 4,822 bytes, line 184
184({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),v=u==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),x=await(s.isElement==null?void 0:s.isElement(k))?await(s.getScale==null?void 0:s.getScale(k))||{x:1,y:1}:{x:1,y:1},w=Lr(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:k,strategy:l}):v);return{top:(b.top-w.top+p.top)/x.y,bottom:(w.bottom-b.bottom+p.bottom)/x.y,left:(b.left-w.left+p.left)/x.x,right:(w.right-b.right+p.right)/x.x}}const aT=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:d=0}=Xt(t,e)||{};if(c==null)return{};const u=gc(d),f={x:n,y:r},h=mc(i),p=pc(h),m=await o.getDimensions(c),g=h==="y",b=g?"top":"left",v=g?"bottom":"right",k=g?"clientHeight":"clientWidth",x=s.reference[p]+s.reference[h]-f[h]-s.floating[p],w=f[h]-s.reference[h],T=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let C=T?T[k]:0;(!C||!await(o.isElement==null?void 0:o.isElement(T)))&&(C=a.floating[k]||s.floating[p]);const A=x/2-w/2,D=C/2-m[p]/2-1,I=It(u[b],D),j=It(u[v],D),O=I,M=C-m[p]-j,z=C/2-m[p]/2+A,R=ul(O,z,M),L=!l.arrow&>(i)!=null&&z!==R&&s.reference[p]/2-(z<O?I:j)-m[p]/2<0,F=L?z<O?z-O:z-M:0;return{[h]:f[h]+F,data:{[h]:R,centerOffset:z-R-F,...L&&{alignmentOffset:F}},reset:L}}});function lT(t,e,n){return(t?[...n.filter(i=>gt(i)===t),...n.filter(i=>gt(i)!==t)]:n.filter(i=>at(i)===i)).filter(i=>t?gt(i)===t||(e?oo(i)!==i:!1):!0)}const cT=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,i;const{rects:s,middlewareData:o,placement:a,platform:l,elements:c}=e,{crossAxis:d=!1,alignment:u,allowedPlacements:f=Ou,autoAlignment:h=!0,...p}=Xt(t,e),m=u!==void 0||f===Ou?lT(u||null,h,f):f,g=await Pr(e,p),b=((n=o.autoPlacement)==null?void 0:n.index)||0,v=m[b];if(v==null)return{};const k=Im(v,s,await(l.isRTL==null?void 0:l.isRTL(c.floating)));if(a!==v)return{reset:{placement:m[0]}};const x=[g[at(v)],g[k[0]],g[k[1]]],w=[...((r=o.autoPlacement)==null?void 0:r.overflows)||[],{placement:v,overflows:x}],T=m[b+1];if(T)return{data:{index:b+1,overflows:w},reset:{placement:T}};const C=w.map(I=>{const j=gt(I.placement);return[I.placement,j&&d?I.overflows.slice(0,2).reduce((O,M)=>O+M,0):I.overflows[0],I.overflows]}).sort((I,j)=>I[1]-j[1]),D=((i=C.filter(I=>I[2].slice(0,gt(I[0])?2:3).every(j=>j<=0))[0])==null?void 0:i[0])||C[0][0];return D!==a?{data:{index:b+1,overflows:w},reset:{placement:D}}:{}}}},dT=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=Xt(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=at(i),v=Et(a),k=at(a)===a,x=await(l.isRTL==null?void 0:l.isRTL(c.floating)),w=f||(k||!m?[ao(a)]:eT(a)),T=p!=="none";!f&&T&&w.push(...iT(a,m,p,x));const C=[a,...w],A=await Pr(e,g),D=[];let I=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&D.push(A[b]),u){const z=Im(i,o,x);D.push(A[z[0]],A[z[1]])}if(I=[...I,{placement:i,overflows:D}],!D.every(z=>z<=0)){var j,O;const z=(((j=s.flip)==null?void 0:j.index)||0)+1,R=C[z];if(R&&(!(u==="alignment"?v!==Et(R):!1)||I.every(H=>Et(H.placement)===v?H.overflows[0]>0:!0)))return{data:{index:z,overflows:I},reset:{placement:R}};let L=(O=I.filter(F=>F.overflows[0]<=0).sort((F,H)=>F.overflows[1]-H.overflows[1])[0])==null?void 0:O.placement;if(!L)switch(h){case"bestFit":{var M;const F=(M=I.filter(H=>{if(T){const J=Et(H.placement);return J===v||J==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(J=>J>0).reduce((J,B)=>J+B,0)]).sort((H,J)=>H[1]-J[1])[0])==null?void 0:M[0];F&&(L=F);break}case"initialPlacement":L=a;break}if(i!==L)return{reset:{placement:L}}}return{}}}};function Lu(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Pu(t){return Rm.some(e=>t[e]>=0)}const uT=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=Xt(t,e);switch(r){case"referenceHidden":{const s=await Pr(e,{...i,elementContext:"reference"}),o=Lu(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Pu(o)}}}case"escaped":{const s=await Pr(e,{...i,altBoundary:!0}),o=Lu(s,n.floating);return{data:{escapedOffsets:o,escaped:Pu(o)}}}default:return{}}}}};function Lm(t){const e=It(...t.map(s=>
184s.left)),n=It(...t.map(s=>s.top)),r=$e(...t.map(s=>s.right)),i=$e(...t.map(s=>s.bottom));return{x:e,y:n,width:r-e,height:i-n}}function fT(t){const e=t.slice().sort((i,s)=>i.y-s.y),n=[];let r=null;for(let i=0;i<e.length;i++){const s=e[i];!r||s.y-r.y>r.height/2?n.push([s]):n[n.length-1].push(s),r=s}return n.map(i=>Lr(Lm(i)))}const hT=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:i,platform:s,strategy:o}=e,{padding:a=2,x:l,y:c}=Xt(t,e),d=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(r.reference))||[]),u=fT(d),f=Lr(Lm(d)),h=gc(a);function p(){if(u.length===2&&u[0].left>u[1].right&&l!=null&&c!=null)return u.find(g=>l>g.left-h.left&&l<g.right+h.right&&c>g.top-h.top&&c<g.bottom+h.bottom)||f;if(u.length>=2){if(Et(n)==="y"){const I=u[0],j=u[u.length-1],O=at(n)==="top",M=I.top,z=j.bottom,R=O?I.left:j.left,L=O?I.right:j.right,F=L-R,H=z-M;return{top:M,bottom:z,left:R,right:L,width:F,height:H,x:R,y:M}}const g=at(n)==="left",b=$e(...u.map(I=>I.right)),v=It(...u.map(I=>I.left)),k=u.filter(I=>g?I.left===v:I.right===b),x=k[0].top,w=k[k.length-1].bottom,T=v,C=b,A=C-T,D=w-x;return{top:x,bottom:w,left:T,right:C,width:A,height:D,x:T,y:x}}return f}const m=await s.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:o});return i.reference.x!==m.reference.x||i.reference.y!==m.reference.y||i.reference.width!==m.reference.width||i.reference.height!==m.reference.height?{reset:{rects:m}}:{}}}},pT=new Set(["left","top"]);async function mT(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=at(n),a=gt(n),l=Et(n)==="y",c=pT.has(o)?-1:1,d=s&&l?-1:1,u=Xt(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),l?{x:h*d,y:f*c}:{x:f*c,y:h*d}}const gT=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=e,l=await mT(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},yT=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:g=>{let{x:b,y:v}=g;return{x:b,y:v}}},...l}=Xt(t,e),c={x:n,y:r},d=await Pr(e,l),u=Et(at(i)),f=Dm(u);let h=c[f],p=c[u];if(s){const g=f==="y"?"top":"left",b=f==="y"?"bottom":"right",v=h+d[g],k=h-d[b];h=ul(v,h,k)}if(o){const g=u==="y"?"top":"left",b=u==="y"?"bottom":"right",v=p+d[g],k=p-d[b];p=ul(v,p,k)}const m=a.fn({...e,[f]:h,[u]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[f]:s,[u]:o}}}}}},bT=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:o,elements:a}=e,{apply:l=()=>{},...c}=Xt(t,e),d=await Pr(e,c),u=at(i),f=gt(i),h=Et(i)==="y",{width:p,height:m}=s.floating;let g,b;u==="top"||u==="bottom"?(g=u,b=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(b=u,g=f==="end"?"top":"bottom");const v=m-d.top-d.bottom,k=p-d.left-d.right,x=It(m-d[g],v),w=It(p-d[b],k),T=!e.middlewareData.shift;let C=x,A=w;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(A=k),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(C=v),T&&!f){const I=$e(d.left,0),j=$e(d.right,0),O=$e(d.top,0),M=$e(d.bottom,0);h?A=p-2*(I!==0||j!==0?I+j:$e(d.left,d.right)):C=m-2*(O!==0||M!==0?O+M:$e(d.top,d.bottom))}await l({...e,availableWidth:A,availableHeight:C});const D=await o.getDimensions(a.floating);return p!==D.width||m!==D.height?{reset:{rects:!0}}:{}}}};function Ao(){return typeof window<"u"}function Fr(t){return Pm(t)?(t.nodeName||"").toLowerCase():"#document"}function Xe(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Qt(t){var e;return(e=(Pm(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Pm(t){return Ao()?t instanceof Node||t instanceof Xe(t).Node:!1}function yt(t){return Ao()?t instanceof Element||t instanceof Xe(t).Element:!1}function Lt(t){return Ao()?t instanceof HTMLElement||t instanceof Xe(t).HTMLElement:!1}function ju(t){return!Ao()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Xe(t).ShadowRoot}const xT=new Set(["inline","contents"]);function Ii(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=bt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!xT.has(i)}const vT=new Set(["table","td","th"]);function wT(t){return vT.has(Fr(t))}const kT=[":popover-open",":modal"];function No(t){return kT.some(e=>{try{return t.matches(e)}catch{return!1}})}const ST=["transform","translate","scale","rotate","perspective"],CT=["transform","translate","scale","rotate","perspective","filter"],TT=["paint","layout","strict","content"];function yc(t){const e=bc(),n=yt(t)?bt(t):t;return ST.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||CT.some(r=>(n.willChange||"").includes(r))||TT.some(r=>(n.contain||"").includes(r))}function ET(t){let e=Sn(t);for(;Lt(e)&&!jr(e);){if(yc(e))return e;if(No(e))return null;e=Sn(e)}return null}function bc(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const MT=new Set(["html","body","#document"]);function jr(t){return MT.has(Fr(t))}function bt(t){return Xe(t).getComputedStyle(t)}function Oo(t){return yt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Sn(t){if(Fr(t)==="html")return t;const e=t.assignedSlot||t.parentNode||ju(t)&&t.host||Qt(t);return ju(e)?e.host:e}function jm(t){const e=Sn(t);return jr(e)?t.ownerDocument?t.ownerDocument.body:t.body:Lt(e)&&Ii(e)?e:jm(e)}function $m(t,e,n){var r;e===void 0&&(e=[]);const i=jm(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=Xe(i);
184return s?(fl(o),e.concat(o,o.visualViewport||[],Ii(i)?i:[],[])):e.concat(i,$m(i,[]))}function fl(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function zm(t){const e=bt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Lt(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=so(n)!==s||so(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function Bm(t){return yt(t)?t:t.contextElement}function Cr(t){const e=Bm(t);if(!Lt(e))return Mt(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=zm(e);let o=(s?so(n.width):n.width)/r,a=(s?so(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const AT=Mt(0);function Hm(t){const e=Xe(t);return!bc()||!e.visualViewport?AT:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function NT(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Xe(t)?!1:e}function Ei(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=Bm(t);let o=Mt(1);e&&(r?yt(r)&&(o=Cr(r)):o=Cr(t));const a=NT(s,n,r)?Hm(s):Mt(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,d=i.width/o.x,u=i.height/o.y;if(s){const f=Xe(s),h=r&&yt(r)?Xe(r):r;let p=f,m=fl(p);for(;m&&r&&h!==p;){const g=Cr(m),b=m.getBoundingClientRect(),v=bt(m),k=b.left+(m.clientLeft+parseFloat(v.paddingLeft))*g.x,x=b.top+(m.clientTop+parseFloat(v.paddingTop))*g.y;l*=g.x,c*=g.y,d*=g.x,u*=g.y,l+=k,c+=x,p=Xe(m),m=fl(p)}}return Lr({width:d,height:u,x:l,y:c})}function Ro(t,e){const n=Oo(t).scrollLeft;return e?e.left+n:Ei(Qt(t)).left+n}function _m(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Ro(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function OT(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=Qt(r),a=e?No(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Mt(1);const d=Mt(0),u=Lt(r);if((u||!u&&!s)&&((Fr(r)!=="body"||Ii(o))&&(l=Oo(r)),Lt(r))){const h=Ei(r);c=Cr(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const f=o&&!u&&!s?_m(o,l):Mt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+f.x,y:n.y*c.y-l.scrollTop*c.y+d.y+f.y}}function RT(t){return Array.from(t.getClientRects())}function DT(t){const e=Qt(t),n=Oo(t),r=t.ownerDocument.body,i=$e(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=$e(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Ro(t);const a=-n.scrollTop;return bt(r).direction==="rtl"&&(o+=$e(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const $u=25;function IT(t,e){const n=Xe(t),r=Qt(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const d=bc();(!d||d&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}const c=Ro(r);if(c<=0){const d=r.ownerDocument,u=d.body,f=getComputedStyle(u),h=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-u.clientWidth-h);p<=$u&&(s-=p)}else c<=$u&&(s+=c);return{width:s,height:o,x:a,y:l}}const LT=new Set(["absolute","fixed"]);function PT(t,e){const n=Ei(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Lt(t)?Cr(t):Mt(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function zu(t,e,n){let r;if(e==="viewport")r=IT(t,n);else if(e==="document")r=DT(Qt(t));else if(yt(e))r=PT(e,n);else{const i=Hm(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Lr(r)}function Fm(t,e){const n=Sn(t);return n===e||!yt(n)||jr(n)?!1:bt(n).position==="fixed"||Fm(n,e)}function jT(t,e){const n=e.get(t);if(n)return n;let r=$m(t,[]).filter(a=>yt(a)&&Fr(a)!=="body"),i=null;const s=bt(t).position==="fixed";let o=s?Sn(t):t;for(;yt(o)&&!jr(o);){const a=bt(o),l=yc(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&<.has(i.position)||Ii(o)&&!l&&Fm(t,o))?r=r.filter(d=>d!==o):i=a,o=Sn(o)}return e.set(t,r),r}function $T(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?No(e)?[]:jT(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((c,d)=>{const u=zu(e,d,i);return c.top=$e(u.top,c.top),c.right=It(u.right,c.right),c.bottom=It(u.bottom,c.bottom),c.left=$e(u.left,c.left),c},zu(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function zT(t){const{width:e,height:n}=zm(t);return{width:e,height:n}}function BT(t,e,n){const r=Lt(e),i=Qt(e),s=n==="fixed",o=Ei(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Mt(0);function c(){l.x=Ro(i)}if(r||!r&&!s)if((Fr(e)!=="body"||Ii(i))&&(a=Oo(e)),r){const h=Ei(e,!0,s,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else i&&c();s&&!r&&i&&c();const d=i&&!r&&!s?_m(i,a):Mt(0),u=o.left+a.scrollLeft-l.x-d.x,f=o.top+a.scrollTop-l.y-d.y;return{x:u,y:f,width:o.width,height:o.height}}function ma(t){return bt(t).position==="static"}function Bu(t,e){if(!Lt(t)||bt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Qt(t)===n&&(n=n.ownerDocument.body),n}function Vm(t,e){const n=Xe(t);if(No(t))return n;if(!Lt(t)){let i=Sn(t);for(;i&&!jr(i);){if(yt(i)&&!ma(i))return i;i=Sn(i)}return n}let r=Bu(t,e);for(;r&&wT(r)&&ma(r);)r=Bu(r,e);return r&&jr(r)&&ma(r)&&!yc(r)?n:r||ET(t)||n}const HT=async function(t){const e=this.getOffsetParent||Vm,n=this.getDimensions,r=await n(t.floating);return{reference:BT(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function _T(t){return bt(t).direction==="rtl"}const FT={convertOffsetParentRelativeRectToViewportRelativeRect:OT,getDocumentElement:Qt,getClippingRect:$T,getOffsetParent:Vm,getElementRects:HT,getClientRects:RT,getDimensions:zT,getScale:Cr,isElement:yt,isRTL:_T},Wm=gT,Um=cT,qm=yT,Km=dT,Jm=bT,Gm=uT,Ym=aT,Xm=hT,Qm=(t,e,n)=>{const r=new Map,i={platform:FT,...n},s={...i.platform,_c:r};return oT(t,e,{...i,platform:s})};function VT(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-i,a=r-n,l=i,c=n;return new DOMRect(l,c,o,a)}var WT=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:i=250,resizeDelay:s=60,shouldShow:o,appendTo:a,getReferencedVirtualElement:l,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:u,state:f,from:h,to:p})=>{const{doc:m,selection:g}=f,{empty:b}=g,v=!m.textBetween(h,p).length&&Ul(f.selection),k=this.element.contains(document.activeElement);return!(!(u.hasFocus()||k)||b||v||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((f=this.element.parentNode)!=null&&f.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,f)=>{const h=!(f!=null&&f.selection.eq(u.state.selection)),p=!(f!=null&&f.doc.eq(u.state.doc));!h&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,h,p,f)},this.updateDelay))},this.updateHandler=(u,f,h,p)=>{const{composing:m}=u;if(m||!f&&!h)return;if(!this.getShouldShow(p)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:u})=>{const f=u.getMeta(this.pluginKey);f==="updatePosition"?this.updatePosition():f&&typeof f=="object"&&f.type==="updateOptions"&&this.updateOptions(f.options)};var d;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=s,this.appendTo=a,this.scrollTarget=(d=c==null?void 0:c.scrollTarget)!=null?d:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.get
184ShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(Km(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(qm(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Wm(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(Ym(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Jm(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(Um(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(Gm(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Xm(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,i=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(i)return i;if(!((n=(e=this.view)==null?void 0:e.dom)!=null&&n.parentNode))return;const s=bp(this.view,r.from,r.to);let o={getBoundingClientRect:()=>s,getClientRects:()=>[s]};if(r instanceof W){let a=this.view.nodeDOM(r.from);const l=a.dataset.nodeViewWrapper?a:a.querySelector("[data-node-view-wrapper]");l&&(a=l),a&&(o={getBoundingClientRect:()=>a.getBoundingClientRect(),getClientRects:()=>[a.getBoundingClientRect()]})}if(r instanceof ae){const{$anchorCell:a,$headCell:l}=r,c=a?a.pos:l.pos,d=l?l.pos:a.pos,u=this.view.nodeDOM(c),f=this.view.nodeDOM(d);if(!u||!f)return;const h=u===f?u.getBoundingClientRect():VT(u.getBoundingClientRect(),f.getBoundingClientRect());o={getBoundingClientRect:()=>h,getClientRects:()=>[h]}}return o}updatePosition(){const t=this.virtualElement;t&&Qm(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r,middlewareData:i})=>{var s,o;if((s=i.hide)!=null&&s.referenceHidden||(o=i.hide)!=null&&o.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const i=!(e!=null&&e.selection.eq(t.state.selection)),s=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,i,s,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,s=Math.min(...i.map(l=>l.$from.pos)),o=Math.max(...i.map(l=>l.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:s,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Zm=t=>new ie({key:typeof t.pluginKey=="string"?new ce(t.pluginKey):t.pluginKey,view:e=>
184new WT({view:e,...t})});de.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Zm({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var UT=class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:i=250,resizeDelay:s=60,options:o,appendTo:a,shouldShow:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:d,state:u})=>{const{selection:f}=u,{$anchor:h,empty:p}=f,m=h.depth===1,g=h.parent.isTextblock&&!h.parent.type.spec.code&&!h.parent.textContent&&h.parent.childCount===0&&!this.getTextContent(h.parent);return!(!d.hasFocus()||!p||!m||!g||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(d,u,f,h)=>{const{composing:p}=d;if(p||!u&&!f)return;if(!this.getShouldShow(h)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:d})=>{var u;if(this.preventHide){this.preventHide=!1;return}d!=null&&d.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(d.relatedTarget))||(d==null?void 0:d.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:d})=>{const u=d.getMeta(this.pluginKey);u==="updatePosition"?this.updatePosition():u&&typeof u=="object"&&u.type==="updateOptions"&&this.updateOptions(u.options)},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=s,this.appendTo=a,this.scrollTarget=(c=o==null?void 0:o.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return fp(t,{textSerializers:Jl(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(Km(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(qm(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Wm(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(Ym(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Jm(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(Um(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(Gm(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Xm(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,s=Math.min(...i.map(l=>l.$from.pos)),o=Math.max(...i.map(l=>l.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:s,to:o})}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){const{selection:t}=this.editor.state,e=bp(this.view,t.from,t.to);Qm({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:i,strategy:s,middlewareData:o})=>{var a,l;if((a=o.hide)!=null&&a.referenceHidden||(l=o.hide)!=null&&l.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${r}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!(e!=null&&e.selection.eq(t.state.selection)),r
184=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},eg=t=>new ie({key:typeof t.pluginKey=="string"?new ce(t.pluginKey):t.pluginKey,view:e=>new UT({view:e,...t})});de.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[eg({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var qT=Ot.forwardRef(({pluginKey:t="bubbleMenu",editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:s=null,getReferencedVirtualElement:o,options:a,children:l,...c},d)=>{const u=S.useRef(document.createElement("div"));typeof d=="function"?d(u.current):d&&(d.current=u.current);const{editor:f}=$p(),h=e||f,p={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:t,shouldShow:s,getReferencedVirtualElement:o,options:a},m=S.useRef(p);m.current=p;const[g,b]=S.useState(!1),v=S.useRef(!0);return S.useEffect(()=>{if(h!=null&&h.isDestroyed)return;if(!h){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const k=u.current;k.style.visibility="hidden",k.style.position="absolute";const x=Zm({...m.current,editor:h,element:k});h.registerPlugin(x);const w=m.current.pluginKey;return v.current=!0,b(!0),()=>{b(!1),h.unregisterPlugin(w),window.requestAnimationFrame(()=>{k.parentNode&&k.parentNode.removeChild(k)})}},[h]),S.useEffect(()=>{if(!(!g||!h||h.isDestroyed)){if(v.current){v.current=!1;return}h.view.dispatch(h.state.tr.setMeta(t,{type:"updateOptions",options:m.current}))}},[g,h,n,r,s,a,i,o]),xl.createPortal(y.jsx("div",{...c,children:l}),u.current)});Ot.forwardRef(({pluginKey:t="floatingMenu",editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:s=null,options:o,children:a,...l},c)=>{const d=S.useRef(document.createElement("div"));typeof c=="function"?c(d.current):c&&(c.current=d.current);const{editor:u}=$p(),f=e||u,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:t,shouldShow:s,options:o},p=S.useRef(h);p.current=h;const[m,g]=S.useState(!1),b=S.useRef(!0);return S.useEffect(()=>{if(f!=null&&f.isDestroyed)return;if(!f){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const v=d.current;v.style.visibility="hidden",v.style.position="absolute";const k=eg({...p.current,editor:f,element:v});f.registerPlugin(k);const x=p.current.pluginKey;return b.current=!0,g(!0),()=>{g(!1),f.unregisterPlugin(x),window.requestAnimationFrame(()=>{v.parentNode&&v.parentNode.removeChild(v)})}},[f]),S.useEffect(()=>{if(!(!m||!f||f.isDestroyed)){if(b.current){b.current=!1;return}f.view.dispatch(f.state.tr.setMeta(t,{type:"updateOptions",options:p.current}))}},[m,f,n,r,s,o,i]),xl.createPortal(y.jsx("div",{...l,children:a}),d.current)});const Hu=[{id:"polish",icon:y.jsx(hf,{className:"w-3.5 h-3.5"}),labelKey:"writing.ai.polish",defaultLabel:"Polish"},{id:"rewrite",icon:y.jsx(Bg,{className:"w-3.5 h-3.5"}),labelKey:"writing.ai.rewrite",defaultLabel:"Rewrite"},{id:"continue",icon:y.jsx(pf,{className:"w-3.5 h-3.5"}),labelKey:"writing.ai.continue",defaultLabel:"Continue"},{id:"translate",icon:y.jsx(Hg,{className:"w-3.5 h-3.5"}),labelKey:"writing.ai.translate",defaultLabel:"Translate"},{id:"expand",icon:y.jsx(_g,{className:"w-3.5 h-3.5"}),labelKey:"writing.ai.expand",defaultLabel:"Expand"},{id:"summarize",icon:y.jsx(jy,{className:"w-3.5 h-3.5"}),labelKey:"writing.ai.summarize",defaultLabel:"Summarize"}],KT={polish:[{labelKey:"writingSuggestions.polish.formal",instructionKey:"writing.ai.instructions.polishFormal"},{labelKey:"writingSuggestions.polish.casual",instructionKey:"writing.ai.instructions.polishCasual"},{labelKey:"writingSuggestions.polish.concise",instructionKey:"writing.ai.instructions.polishConcise"},{labelKey:"writingSuggestions.polish.elegant",instructionKey:"writing.ai.instructions.polishElegant"}],rewrite:[{labelKey:"writingSuggestions.rewrite.angle",instructionKey:"writing.ai.instructions.rewriteAngle"},{labelKey:"writingSuggestions.rewrite.vivid",instructionKey:"writing.ai.instructions.rewriteVivid"},{labelKey:"writingSuggestions.rewrite.academic",instructionKey:"writing.ai.instructions.rewriteAcademic"},{labelKey:"writingSuggestions.rewrite.style",instructionKey:"writing.ai.instructions.rewriteStyle"}],continue:[{labelKey:"writingSuggestions.continue.elaborate",instructionKey:"writing.ai.instructions.continueElaborate"},{labelKey:"writingSuggestions.continue.addExample",instructionKey:"writing.ai.instructions.continueAddExample"},{labelKey:"writingSuggestions.continue.summarize",instructionKey:"writing.ai.instructions.continueSummarize"},{labelKey:"writingSuggestions.continue.transition",instructionKey:"writing.ai.instructions.continueTransition"}],expand:[{labelKey:"writingSuggestions.expand.details",instructionKey:"writing.ai.instructions.expandDetails"},{labelKey:"writingSuggestions.expand.background",instructionKey:"writing.ai.instructions.expandBackgroun
184d"},{labelKey:"writingSuggestions.expand.argument",instructionKey:"writing.ai.instructions.expandArgument"},{labelKey:"writingSuggestions.expand.data",instructionKey:"writing.ai.instructions.expandData"}],summarize:[{labelKey:"writingSuggestions.summarize.core",instructionKey:"writing.ai.instructions.summarizeCore"},{labelKey:"writingSuggestions.summarize.oneLiner",instructionKey:"writing.ai.instructions.summarizeOneLiner"},{labelKey:"writingSuggestions.summarize.keyPoints",instructionKey:"writing.ai.instructions.summarizeKeyPoints"},{labelKey:"writingSuggestions.summarize.half",instructionKey:"writing.ai.instructions.summarizeHalf"}]};function JT({editor:t,model:e}){const{t:n}=He(),[r,i]=S.useState(!1),[s,o]=S.useState(!1),[a,l]=S.useState(""),[c,d]=S.useState(0),[u,f]=S.useState(0),[h,p]=S.useState(!1),[m,g]=S.useState([]),[b,v]=S.useState(null),[k,x]=S.useState(""),w=S.useRef(null);S.useEffect(()=>{Se.prompts.list().then(R=>{var L;g(((L=R.data)==null?void 0:L.slice(0,4))??[])}).catch(()=>{})},[]),S.useEffect(()=>()=>{var R;(R=w.current)==null||R.abort()},[]);const T=S.useCallback(()=>{const{from:R,to:L}=t.state.selection;return t.state.doc.textBetween(R,L," ")},[t]),C=S.useCallback(async(R,L,F)=>{const H=T();if(!H.trim())return;const{from:J,to:B}=t.state.selection;d(J),f(B),i(!0),o(!1),l(""),v(null),x(""),p(!1),w.current=new AbortController;const X=w.current.signal;try{let Y="";if(L)Y=(await Se.rewrite({content:H,instructions:L,model:e})).data.content,l(Y);else switch(R){case"polish":{const te=Se.polishStream({content:H,model:e},X);for await(const me of te)Y+=me,l(Y);break}case"rewrite":{Y=(await Se.rewrite({content:H,instructions:n("writing.ai.instructions.rewriteStyle"),model:e})).data.content,l(Y);break}case"continue":{const te=Se.continueStream({content:H,model:e},X);for await(const me of te)Y+=me,l(Y);break}case"translate":{Y=(await Se.translate({content:H,targetLanguage:F,model:e})).data.content,l(Y);break}case"expand":{Y=(await Se.expand({content:H,model:e})).data.content,l(Y);break}case"summarize":{const te=Se.summarizeStream({text:H,model:e},X);for await(const me of te)Y+=me,l(Y);break}}o(!0)}catch(Y){if(Y.name==="AbortError")return;console.error("AI action failed:",Y)}finally{i(!1),w.current=null}},[t,T,e]),A=S.useCallback(R=>{if(R==="translate"){p(!0),v(null);return}p(!1),v(R),x("")},[]),D=S.useCallback(async R=>{const L=T();if(!L.trim())return;const{from:F,to:H}=t.state.selection;d(F),f(H),i(!0),o(!1),l(""),p(!1),v(null),w.current=new AbortController;try{let J="";const B=Se.prompts.executeStream(R,{content:L,model:e},w.current.signal);for await(const X of B)J+=X,l(J);o(!0)}catch(J){if(J.name==="AbortError")return;console.error("Custom prompt failed:",J)}finally{i(!1),w.current=null}},[t,T,e]),I=S.useCallback(()=>{a&&(t.chain().focus().setTextSelection({from:c,to:u}).deleteSelection().insertContent(a).run(),o(!1),l(""))},[t,a,c,u]),j=S.useCallback(()=>{var R;(R=w.current)==null||R.abort(),i(!1),o(!1),l(""),v(null),x("")},[]),O=b?Hu.find(R=>R.id===b):null,z=(b?KT[b]||[]:[]).map(R=>({label:n(R.labelKey),instruction:n(R.instructionKey)}));return y.jsx(qT,{editor:t,options:{placement:"top"},shouldShow:({from:R,to:L})=>L-R>0||r||s,children:y.jsxs("div",{className:"bg-[var(--bg-primary)] border border-ui-border rounded-lg shadow-lg",children:[r&&y.jsxs("div",{className:"px-4 py-3 flex flex-col gap-2 min-w-[300px]",children:[y.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[y.jsx(Er,{className:"w-4 h-4 animate-spin"}),y.jsx("span",{children:n("writing.ai.processing")}),y.jsx("button",{onClick:j,className:"ml-auto p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-muted)]",children:y.jsx(xn,{className:"w-3.5 h-3.5"})})]}),a&&y.jsx("div",{className:"text-sm text-[var(--text-primary)] bg-[var(--bg-tertiary)] rounded p-2 max-h-[120px] overflow-y-auto whitespace-pre-wrap",children:a})]}),!r&&s&&a&&y.jsxs("div",{className:"px-4 py-3 flex flex-col gap-2 min-w-[300px] max-w-[480px]",children:[y.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:n("writing.ai.result")}),y.jsx("div",{className:"text-sm text-[var(--text-primary)] bg-[var(--bg-tertiary)] rounded p-2 max-h-[160px] overflow-y-auto whitespace-pre-wrap",children:a}),y.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[y.jsxs("button",{onClick:j,className:"flex items-center gap-1 px-3 py-1.5 text-xs text-[var(--text-muted)] hover:bg-[var(--bg-hover)] rounded transition-colors",children:[y.jsx(xn,{className:"w-3 h-3"}),n("common.cancel")]}),y.jsxs("button",{onClick:I,className:"flex items-center gap-1 px-3 py-1.5 text-xs bg-[var(--theme)] text-white rounded hover:bg-[var(--theme-hover)] transition-colors font-medium",children:[y.jsx(ff,{className:"w-3 h-3"}),n("writing.ai.accept")]})]})]}),!r&&!s&&y.jsxs("div",{className:"flex flex-col",children:[y.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-1.5",children:[y.jsx("div",{className:"flex items-center gap-0.5 px-1 text-[var(--text-muted)]",children:y.jsx(Fn,{className:"w-3.5 h-3.5"})}),Hu.map(R=>y.jsxs("button",{onClick:()=>A(R.id),className:`flex items-center gap-1 px-2.5 py-1.5 text-xs rounded transition-colors whitespace-nowrap ${b===R.id?"bg-[var(--accent-primary)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]"}`,title:n(R.labelKey,R.defaultLabel),children:[R.icon,y.jsx("span",{children:n(R.labelKey,R.defaultLabel)})]},R.id))]}),b&&O&&y.jsxs("div",{className:"px-2 pb-2 pt-0.5 border-t border-ui-border",children:[y.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5",children:[y.jsx("input",{type:"text",value:k,onChange:R=>x(R.target.value),onKeyDown:R=>{R.key==="Enter"&&k.trim()&&!R.nativeEvent.isComposing&&(R.preventDefault(),C(b,k))},placeholder:n("writing.ai.inputHint",{action:n(O.labelKey,O.defaultLabel)}),className:"flex-1 px-2.5 py-1.5 text-xs rounded-md border bg-transparent outline-none transition-colors focus:border-[var(--accent-primary)]",style:{borderColor:"var(--border-default)",color:"var(--text-primary)"},autoFocus:!0,maxLength:1e3}),y.jsx("button",{onClick:()=>k.trim()?C(b,k):C(b),className:"p-1.5 rounded-md transition-colors hover:bg-[var(--bg-hover)]",style:{color:"var(--accent-primary)"},title:k.trim()?n("common.send"):n("writing.ai.directExec"),children:y.jsx(wl,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{className:"flex items-center gap-1 mt-1.5 flex-wrap",children:z.map((R,L)=>y.jsx("button",{onClick:()=>C(b,R.instruction),className:"px-2 py-0.5 text-[11px] rounded-full border transition-colors hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]",style:{borderColor:"var(--border-default)",color:"var(--text-tertiary)"},children:R.label},L))})]}),m.length>0&&!b&&y.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 pb-1.5 border-t border-ui-border pt-1.5",children:[y.jsx("span",{className:"text-xs text-[var(--text-muted)] px-1",children:y.jsx($g,{className:"w-3 h-3 inline"})}),m.map(R=>y.jsx("button",{onClick:()=>D(R.id),className:"px-2 py-1 text-xs text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)] rounded transition-colors whitespace-nowrap",title:R.name,children:R.name},R.id))]}),h&&y.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 pb-1.5 border-t border-ui-border pt-1.5",children:[y.jsxs("span",{className:"text-xs text-[var(--text-muted)] px-1",children:[n("writing.selectLanguage"),":"]}),zg.map(R=>y.jsx("button",{onClick:()=>C("translate",void 0,R.code),className:"px-2 py-1 text-xs text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)] rounded transition-colors whitespace-nowrap",children:R.label},R.code))]})]})]})})}function GT({open:t,onClose:e,editor:n,model:r}){const{t:i}=He(),[s,o]=S.useState(""),[a,l]=S.useState(!1),c=S.useRef(null),d=S.useRef(null),u=S.useRef(null),[f,h]=S.useState(null);S.useEffect(()=>{if(!(!t||!n)){o(""),l(!1);try{const{from:g}=n.state.selection,b=n.view.coordsAtPos(g);h({top:b.bottom+4,left:b.left})}catch{const b=n.view.dom.getBoundingClientRect();
184h({top:b.top+40,left:b.left+16})}setTimeout(()=>{var g;return(g=c.current)==null?void 0:g.focus()},0)}},[t,n]),S.useEffect(()=>{if(!t)return;const g=b=>{var v;b.key==="Escape"&&(a&&((v=d.current)==null||v.abort()),e())};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t,a,e]),S.useEffect(()=>{if(!t||a)return;const g=b=>{u.current&&!u.current.contains(b.target)&&e()};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[t,a,e]);const p=S.useCallback(async()=>{if(a)return;l(!0);const g=n.state.doc.textBetween(0,n.state.selection.from,` 185`),b=new AbortController;d.current=b;try{const v=Se.continueStream({content:g,direction:s.trim()||void 0,model:r},b.signal);for await(const k of v)n.chain().focus().insertContent(k).run();e()}catch(v){v instanceof DOMException&&v.name}finally{l(!1),d.current=null}},[n,s,r,a,e]),m=S.useCallback(()=>{var g;(g=d.current)==null||g.abort(),e()},[e]);return!t||!f?null:y.jsx("div",{ref:u,className:"fixed z-50",style:{to
185p:f.top,left:f.left},children:y.jsxs("div",{className:"flex items-center gap-1.5 bg-[var(--bg-primary)] border border-ui-border rounded-lg shadow-lg p-1.5 w-[360px]",children:[y.jsx(Fn,{className:"w-4 h-4 text-purple-500 shrink-0 ml-1"}),a?y.jsxs("div",{className:"flex items-center gap-2 flex-1 px-1",children:[y.jsx(Er,{className:"w-3.5 h-3.5 animate-spin text-purple-500"}),y.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:i("writing.aiWriteGenerating")}),y.jsx("button",{onClick:m,className:"ml-auto p-1 rounded hover:bg-red-500/10 text-red-500 transition-colors",title:i("writing.aiWriteStop"),children:y.jsx(Ca,{className:"w-4 h-4"})})]}):y.jsxs(y.Fragment,{children:[y.jsx("input",{ref:c,type:"text",value:s,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.nativeEvent.isComposing&&(g.preventDefault(),p())},placeholder:i("writing.aiWritePlaceholder"),className:"flex-1 px-2 py-1 text-sm bg-transparent focus:outline-none text-[var(--text-primary)] placeholder:text-[var(--text-muted)]",maxLength:1e3}),y.jsx("button",{onClick:p,className:"p-1.5 rounded-md bg-purple-500 text-white hover:bg-purple-600 transition-colors shrink-0",title:i("writing.aiWriteSend"),children:y.jsx(wl,{className:"w-3.5 h-3.5"})})]})]})})}function YT(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:s,startOfLine:o,$position:a}=t,l=r&&!i,c=Lw(n),d=new RegExp(`\\s${c}$`),u=o?"^":"",f=i?"":c,h=l?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"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(h)).pop();if(!g||g.input===void 0||g.index===void 0)return null;const b=g.input.slice(Math.max(0,g.index-1),g.index),v=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(b);if(s!==null&&!v)return null;const k=m+g.index;let x=k+g[0].length;return l&&d.test(p.slice(x-1,x+1))&&(g[0]+=" ",x+=1),k<a.pos&&x>=a.pos?{range:{from:k,to:x},query:g[0].slice(n.length),text:g[0]}:null}var XT=new ce("suggestion");function QT({pluginKey:t=XT,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:s=[" "],startOfLine:o=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:m=YT,shouldShow:g}){let b;const v=h==null?void 0:h(),k=()=>{const C=e.state.selection.$anchor.pos,A=e.view.coordsAtPos(C),{top:D,right:I,bottom:j,left:O}=A;try{return new DOMRect(O,D,I-O,j-D)}catch{return null}},x=(C,A)=>A?()=>{const D=t.getState(e.state),I=D==null?void 0:D.decorationId,j=C.dom.querySelector(`[data-decoration-id="${I}"]`);return(j==null?void 0:j.getBoundingClientRect())||null}:k;function w(C,A){var D;try{const j=t.getState(C.state),O=j!=null&&j.decorationId?C.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null,M={editor:e,range:(j==null?void 0:j.range)||{from:0,to:0},query:(j==null?void 0:j.query)||null,text:(j==null?void 0:j.text)||null,items:[],command:z=>u({editor:e,range:(j==null?void 0:j.range)||{from:0,to:0},props:z}),decorationNode:O,clientRect:x(C,O)};(D=v==null?void 0:v.onExit)==null||D.call(v,M)}catch{}const I=C.state.tr.setMeta(A,{exit:!0});C.dispatch(I)}const T=new ie({key:t,view(){return{update:async(C,A)=>{var D,I,j,O,M,z,R;const L=(D=this.key)==null?void 0:D.getState(A),F=(I=this.key)==null?void 0:I.getState(C.state),H=L.active&&F.active&&L.range.from!==F.range.from,J=!L.active&&F.active,B=L.active&&!F.active,X=!J&&!B&&L.query!==F.query,Y=J||H&&X,te=X||H,me=B||H&&X;if(!Y&&!te&&!me)return;const ge=me&&!Y?L:F,we=C.dom.querySelector(`[data-decoration-id="${ge.decorationId}"]`);b={editor:e,range:ge.range,query:ge.query,text:ge.text,items:[],command:Ke=>u({editor:e,range:ge.range,props:Ke}),decorationNode:we,clientRect:x(C,we)},Y&&((j=v==null?void 0:v.onBeforeStart)==null||j.call(v,b)),te&&((O=v==null?void 0:v.onBeforeUpdate)==null||O.call(v,b)),(te||Y)&&(b.items=await f({editor:e,query:ge.query})),me&&((M=v==null?void 0:v.onExit)==null||M.call(v,b)),te&&((z=v==null?void 0:v.onUpdate)==null||z.call(v,b)),Y&&((R=v==null?void 0:v.onStart)==null||R.call(v,b))},destroy:()=>{var C;b&&((C=v==null?void 0:v.onExit)==null||C.call(v,b))}}}
185,state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(C,A,D,I){const{isEditable:j}=e,{composing:O}=e.view,{selection:M}=C,{empty:z,from:R}=M,L={...A},F=C.getMeta(t);if(F&&F.exit)return L.active=!1,L.decorationId=null,L.range={from:0,to:0},L.query=null,L.text=null,L;if(L.composing=O,j&&(z||e.view.composing)){(R<A.range.from||R>A.range.to)&&!O&&!A.composing&&(L.active=!1);const H=m({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:s,startOfLine:o,$position:M.$from}),J=`id_${Math.floor(Math.random()*4294967295)}`;H&&p({editor:e,state:I,range:H.range,isActive:A.active})&&(!g||g({editor:e,range:H.range,query:H.query,text:H.text,transaction:C}))?(L.active=!0,L.decorationId=A.decorationId?A.decorationId:J,L.range=H.range,L.query=H.query,L.text=H.text):L.active=!1}else L.active=!1;return L.active||(L.decorationId=null,L.range={from:0,to:0},L.query=null,L.text=null),L}},props:{handleKeyDown(C,A){var D,I,j,O;const{active:M,range:z}=T.getState(C.state);if(!M)return!1;if(A.key==="Escape"||A.key==="Esc"){const L=T.getState(C.state),F=(D=b==null?void 0:b.decorationNode)!=null?D:null,H=F??(L!=null&&L.decorationId?C.dom.querySelector(`[data-decoration-id="${L.decorationId}"]`):null);if(((I=v==null?void 0:v.onKeyDown)==null?void 0:I.call(v,{view:C,event:A,range:L.range}))||!1)return!0;const B={editor:e,range:L.range,query:L.query,text:L.text,items:[],command:X=>u({editor:e,range:L.range,props:X}),decorationNode:H,clientRect:H?()=>H.getBoundingClientRect()||null:null};return(j=v==null?void 0:v.onExit)==null||j.call(v,B),w(C,t),!0}return((O=v==null?void 0:v.onKeyDown)==null?void 0:O.call(v,{view:C,event:A,range:z}))||!1},decorations(C){const{active:A,range:D,decorationId:I,query:j}=T.getState(C);if(!A)return null;const O=!(j!=null&&j.length),M=[l];return O&&M.push(d),se.create(C.doc,[be.inline(D.from,D.to,{nodeName:a,class:M.join(" "),"data-decoration-id":I,"data-decoration-content":c})])}}});return T}var ZT=QT,Ue="top",lt="bottom",ct="right",qe="left",xc="auto",Li=[Ue,lt,ct,qe],$r="start",Mi="end",eE="clippingParents",tg="viewport",Kr="popper",tE="reference",_u=Li.reduce(function(t,e){return t.concat([e+"-"+$r,e+"-"+Mi])},[]),ng=[].concat(Li,[xc]).reduce(function(t,e){return t.concat([e,e+"-"+$r,e+"-"+Mi])},[]),nE="beforeRead",rE="read",iE="afterRead",sE="beforeMain",oE="main",aE="afterMain",lE="beforeWrite",cE="write",dE="afterWrite",uE=[nE,rE,iE,sE,oE,aE,lE,cE,dE];function Pt(t){return t?(t.nodeName||"").toLowerCase():null}function Qe(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function rr(t){var e=Qe(t).Element;return t instanceof e||t instanceof Element}function ot(t){var e=Qe(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function vc(t){if(typeof ShadowRoot>"u")return!1;var e=Qe(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function fE(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},i=e.attributes[n]||{},s=e.elements[n];
vendor: 18,776 bytes, line 185
185!ot(s)||!Pt(s)||(Object.assign(s.style,r),Object.keys(i).forEach(function(o){var a=i[o];a===!1?s.removeAttribute(o):s.setAttribute(o,a===!0?"":a)}))})}function hE(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var i=e.elements[r],s=e.attributes[r]||{},o=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),a=o.reduce(function(l,c){return l[c]="",l},{});!ot(i)||!Pt(i)||(Object.assign(i.style,a),Object.keys(s).forEach(function(l){i.removeAttribute(l)}))})}}const rg={name:"applyStyles",enabled:!0,phase:"write",fn:fE,effect:hE,requires:["computeStyles"]};function At(t){return t.split("-")[0]}var Jn=Math.max,lo=Math.min,zr=Math.round;function hl(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function ig(){return!/^((?!chrome|android).)*safari/i.test(hl())}function Br(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),i=1,s=1;e&&ot(t)&&(i=t.offsetWidth>0&&zr(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&zr(r.height)/t.offsetHeight||1);var o=rr(t)?Qe(t):window,a=o.visualViewport,l=!ig()&&n,c=(r.left+(l&&a?a.offsetLeft:0))/i,d=(r.top+(l&&a?a.offsetTop:0))/s,u=r.width/i,f=r.height/s;return{width:u,height:f,top:d,right:c+u,bottom:d+f,left:c,x:c,y:d}}function wc(t){var e=Br(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function sg(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&vc(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Gt(t){return Qe(t).getComputedStyle(t)}function pE(t){return["table","td","th"].indexOf(Pt(t))>=0}function Nn(t){return((rr(t)?t.ownerDocument:t.document)||window.document).documentElement}function Do(t){return Pt(t)==="html"?t:t.assignedSlot||t.parentNode||(vc(t)?t.host:null)||Nn(t)}function Fu(t){return!ot(t)||Gt(t).position==="fixed"?null:t.offsetParent}function mE(t){var e=/firefox/i.test(hl()),n=/Trident/i.test(hl());if(n&&ot(t)){var r=Gt(t);if(r.position==="fixed")return null}var i=Do(t);for(vc(i)&&(i=i.host);ot(i)&&["html","body"].indexOf(Pt(i))<0;){var s=Gt(i);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return i;i=i.parentNode}return null}function Pi(t){for(var e=Qe(t),n=Fu(t);n&&pE(n)&&Gt(n).position==="static";)n=Fu(n);return n&&(Pt(n)==="html"||Pt(n)==="body"&&Gt(n).position==="static")?e:n||mE(t)||e}function kc(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function ui(t,e,n){return Jn(t,lo(e,n))}function gE(t,e,n){var r=ui(t,e,n);return r>n?n:r}function og(){return{top:0,right:0,bottom:0,left:0}}function ag(t){return Object.assign({},og(),t)}function lg(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var yE=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,ag(typeof e!="number"?e:lg(e,Li))};function bE(t){var e,n=t.state,r=t.name,i=t.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=At(n.placement),l=kc(a),c=[qe,ct].indexOf(a)>=0,d=c?"height":"width";if(!(!s||!o)){var u=yE(i.padding,n),f=wc(s),h=l==="y"?Ue:qe,p=l==="y"?lt:ct,m=n.rects.reference[d]+n.rects.reference[l]-o[l]-n.rects.popper[d],g=o[l]-n.rects.reference[l],b=Pi(s),v=b?l==="y"?b.clientHeight||0:b.clientWidth||0:0,k=m/2-g/2,x=u[h],w=v-f[d]-u[p],T=v/2-f[d]/2+k,C=ui(x,T,w),A=l;n.modifiersData[r]=(e={},e[A]=C,e.centerOffset=C-T,e)}}function xE(t){var e=t.state,n=t.options,r=n.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||sg(e.elements.popper,i)&&(e.elements.arrow=i))}const vE={name:"arrow",enabled:!0,phase:"main",fn:bE,effect:xE,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Hr(t){return t.split("-")[1]}var wE={top:"auto",right:"auto",bottom:"auto",left:"auto"};function kE(t,e){var n=t.x,r=t.y,i=e.devicePixelRatio||1;return{x:zr(n*i)/i||0,y:zr(r*i)/i||0}}function Vu(t){var e,n=t.popper,r=t.popperRect,i=t.placement,s=t.variation,o=t.offsets,a=t.position,l=t.gpuAcceleration,c=t.adaptive,d=t.roundOffsets,u=t.isFixed,f=o.x,h=f===void 0?0:f,p=o.y,m=p===void 0?0:p,g=typeof d=="function"?d({x:h,y:m}):{x:h,y:m};h=g.x,m=g.y;var b=o.hasOwnProperty("x"),v=o.hasOwnProperty("y"),k=qe,x=Ue,w=window;if(c){var T=Pi(n),C="clientHeight",A="clientWidth";if(T===Qe(n)&&(T=Nn(n),Gt(T).position!=="static"&&a==="absolute"&&(C="scrollHeight",A="scrollWidth")),T=T,i===Ue||(i===qe||i===ct)&&s===Mi){x=lt;var D=u&&T===w&&w.visualViewport?w.visualViewport.height:T[C];m-=D-r.height,m*=l?1:-1}if(i===qe||(i===Ue||i===lt)&&s===Mi){k=ct;var I=u&&T===w&&w.visualViewport?w.visualViewport.width:T[A];h-=I-r.width,h*=l?1:-1}}var j=Object.assign({position:a},c&&wE),O=d===!0?kE({x:h,y:m},Qe(n)):{x:h,y:m};if(h=O.x,m=O.y,l){var M;return Object.assign({},j,(M={},M[x]=v?"0":"",M[k]=b?"0":"",M.transform=(w.devicePixelRatio||1)<=1?"translate("+h+"px, "+m+"px)":"translate3d("+h+"px, "+m+"px, 0)",M))}return Object.assign({},j,(e={},e[x]=v?m+"px":"",e[k]=b?h+"px":"",e.transform="",e))}function SE(t){var e=t.state,n=t.options,r=n.gpuAcceleration,i=r===void 0?!0:r,s=n.adaptive,o=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,c={placement:At(e.placement),variation:Hr(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,Vu(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Vu(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const CE={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:SE,data:{}};var is={passive:!0};function TE(t){var e=t.state,n=t.instance,r=t.options,i=r.scroll,s=i===void 0?!0:i,o=r.resize,a=o===void 0?!0:o,l=Qe(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(d){d.addEventListener("scroll",n.update,is)}),a&&l.addEventListener("resize",n.update,is),function(){s&&c.forEach(function(d){d.removeEventListener("scroll",n.update,is)}),a&&l.removeEventListener("resize",n.update,is)}}const EE={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:TE,data:{}};var ME={left:"right",right:"left",bottom:"top",top:"bottom"};function gs(t){return t.replace(/left|right|bottom|top/g,function(e){return ME[e]})}var AE={start:"end",end:"start"};function Wu(t){return t.replace(/start|end/g,function(e){return AE[e]})}function Sc(t){var e=Qe(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Cc(t){return Br(Nn(t)).left+Sc(t).scrollLeft}function NE(t,e){var n=Qe(t),r=Nn(t),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var c=ig();(c||!c&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+Cc(t),y:l}}function OE(t){var e,n=Nn(t),r=Sc(t),i=(e=t.ownerDocument)==null?void 0:e.body,s=Jn(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=Jn(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+Cc(t),l=-r.scrollTop;return Gt(i||n).direction==="rtl"&&(a+=Jn(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}function Tc(t){var e=Gt(t),n=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function cg(t){return["html","body","#document"].indexOf(Pt(t))>=0?t.ownerDocument.body:ot(t)&&Tc(t)?t:cg(Do(t))}function fi(t,e){var n;e===void 0&&(e=[]);var r=cg(t),i=r===((n=t.ownerDocument)==null?void 0:n.body),s=Qe(r),o=i?[s].concat(s.visualViewport||[],Tc(r)?r:[]):r,a=e.concat(o);return i?a:a.concat(fi(Do(o)))}function pl(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function RE(t,e){var n=Br(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function Uu(t,e,n){return e===tg?pl(NE(t,n)):rr(e)?RE(e,n):pl(OE(Nn(t)))}function DE(t){var e=fi(Do(t)),n=["absolute","fixed"].indexOf(Gt(t).position)>=0,r=n&&ot(t)?Pi(t):t;return rr(r)?e.filter(function(i){return rr(i)&&sg(i,r)&&Pt(i)!=="body"}):[]}function IE(t,e,n,r){var i=e==="clippingParents"?DE(t):[].concat(e),s=[].concat(i,[n]),o=s[0],a=s.reduce(function(l,c){var d=Uu(t,c,r);return l.top=Jn(d.top,l.top),l.right=lo(d.right,l.right),l.bottom=lo(d.bottom,l.bottom),l.left=Jn(d.left,l.left),l},Uu(t,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function dg(t){var e=t.reference,n=t.element,r=t.placement,i=r?At(r):null,s=r?Hr(r):null,o=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(i){case Ue:l={x:o,y:e.y-n.height};break;case lt:l={x:o,y:e.y+e.height};break;case ct:l={x:e.x+e.width,y:a};break;case qe:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var c=i?kc(i):null;if(c!=null){var d=c==="y"?"height":"width";switch(s){case $r:l[c]=l[c]-(e[d]/2-n[d]/2);break;case Mi:l[c]=l[c]+(e[d]/2-n[d]/2);break}}return l}function Ai(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=r===void 0?t.placement:r,s=n.strategy,o=s===void 0?t.strategy:s,a=n.boundary,l=a===void 0?eE:a,c=n.rootBoundary,d=c===void 0?tg:c,u=n.elementContext,f=u===void 0?Kr:u,h=n.altBoundary,p=h===void 0?!1:h,m=n.padding,g=m===void 0?0:m,b=ag(typeof g!="number"?g:lg(g,Li)),v=f===Kr?tE:Kr,k=t.rects.popper,x=t.elements[p?v:f],w=IE(rr(x)?x:x.contextElement||Nn(t.elements.popper),l,d,o),T=Br(t.elements.reference),C=dg({reference:T,element:k,placement:i}),A=pl(Object.assign({},k,C)),D=f===Kr?A:T,I={top:w.top-D.top+b.top,bottom:D.bottom-w.bottom+b.bottom,left:w.left-D.left+b.left,right:D.right-w.right+b.right},j=t.modifiersData.offset;if(f===Kr&&j){var O=j[i];Object.keys(I).forEach(function(M){var z=[ct,lt].indexOf(M)>=0?1:-1,R=[Ue,lt].indexOf(M)>=0?"y":"x";I[M]+=O[R]*z})}return I}function LE(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=l===void 0?ng:l,d=Hr(r),u=d?a?_u:_u.filter(function(p){return Hr(p)===d}):Li,f=u.filter(function(p){return c.indexOf(p)>=0});f.length===0&&(f=u);var h=f.reduce(function(p,m){return p[m]=Ai(t,{placement:m,boundary:i,rootBoundary:s,padding:o})[At(m)],p},{});return Object.keys(h).sort(function(p,m){return h[p]-h[m]})}function PE(t){if(At(t)===xc)return[];var e=gs(t);return[Wu(t),e,Wu(e)]}function jE(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,a=o===void 0?!0:o,l=n.fallbackPlacements,c=n.padding,d=n.boundary,u=n.rootBoundary,f=n.altBoundary,h=n.flipVariations,p=h===void 0?!0:h,m=n.allowedAutoPlacements,g=e.options.placement,b=At(g),v=b===g,k=l||(v||!p?[gs(g)]:PE(g)),x=[g].concat(k).reduce(function(me,ge){return me.concat(At(ge)===xc?LE(e,{placement:ge,boundary:d,rootBoundary:u,padding:c,flipVariations:p,allowedAutoPlacements:m}):ge)},[]),w=e.rects.reference,T=e.rects.popper,C=new Map,A=!0,D=x[0],I=0;I<x.length;I++){var j=x[I],O=At(j),M=Hr(j)===$r,z=[Ue,lt].indexOf(O)>=0,R=z?"width":"height",L=Ai(e,{placement:j,boundary:d,rootBoundary:u,altBoundary:f,padding:c}),F=z?M?ct:qe:M?lt:Ue;w[R]>T[R]&&(F=gs(F));var H=gs(F),J=[];if(s&&J.push(L[O]<=0),a&&J.push(L[F]<=0,L[H]<=0),J.every(function(me){return me})){D=j,A=!1;break}C.set(j,J)}if(A)for(var B=p?3:1,X=function(ge){var we=x.find(function(Ke){var _e=C.get(Ke);if(_e)return _e.slice(0,ge).every(function($t){return $t})});if(we)return D=we,"break"},Y=B;Y>0;Y--){var te=X(Y);if(te==="break")break}e.placement!==D&&(e.modifiersData[r]._skip=!0,e.placement=D,e.reset=!0)}}const $E={name:"flip",enabled:!0,phase:"main",fn:jE,requiresIfExists:["offset"],data:{_skip:!1}};function qu(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function Ku(t){return[Ue,ct,lt,qe].some(function(e){return t[e]>=0})}function zE(t){var e=t.state,n=t.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=Ai(e,{elementContext:"reference"}),a=Ai(e,{altBoundary:!0}),l=qu(o,r),c=qu(a,i,s),d=Ku(l),u=Ku(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:d,hasPopperEscaped:u},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":u})}const BE={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:zE};function HE(t,e,n){var r=At(t),i=[qe,Ue].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[qe,ct].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}function _E(t){var e=t.state,n=t.options,r=t.name,i=n.offset,s=i===void 0?[0,0]:i,o=ng.reduce(function(d,u){return d[u]=HE(u,e.rects,s),d},{}),a=o[e.placement],l=a.x,c=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=o}const FE={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:_E};function VE(t){var e=t.state,n=t.name;e.modifiersData[n]=dg({reference:e.rects.reference,element:e.rects.popper,placement:e.placement})}const WE={name:"popperOffsets",enabled:!0,phase:"read",fn:VE,data:{}};function UE(t){return t==="x"?"y":"x"}function qE(t){var e=t.state,n=t.options,r=t.name,i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,a=o===void 0?!1:o,l=n.boundary,c=n.rootBoundary,d=n.altBoundary,u=n.padding,f=n.tether,h=f===void 0?!0:f,p=n.tetherOffset,m=p===void 0?0:p,g=Ai(e,{boundary:l,rootBoundary:c,padding:u,altBoundary:d}),b=At(e.placement),v=Hr(e.placement),k=!v,x=kc(b),w=UE(x),T=e.modifiersData.popperOffsets,C=e.rects.reference,A=e.rects.popper,D=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,I=typeof D=="number"?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),j=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,O={x:0,y:0};if(T){if(s){var M,z=x==="y"?Ue:qe,R=x==="y"?lt:ct,L=x==="y"?"height":"width",F=T[x],H=F+g[z],J=F-g[R],B=h?-A[L]/2:0,X=v===$r?C[L]:A[L],Y=v===$r?-A[L]:-C[L],te=e.elements.arrow,me=h&&te?wc(te):{width:0,height:0},ge=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:og(),we=ge[z],Ke=ge[R],_e=ui(0,C[L],me[L]),$t=k?C[L]/2-B-_e-we-I.mainAxis:X-_e-we-I.mainAxis,dt=k?-C[L]/2+B+_e+Ke+I.mainAxis:Y+_e+Ke+I.mainAxis,vt=e.elements.arrow&&Pi(e.elements.arrow),On=vt?x==="y"?vt.clientTop||0:vt.clientLeft||0:0,zt=(M=j==null?void 0:j[x])!=null?M:0,or=F+$t-zt-On,ar=F+dt-zt,Rn=ui(h?lo(H,or):H,F,h?Jn(J,ar):J);T[x]=Rn,O[x]=Rn-F}if(a){var Dn,lr=x==="x"?Ue:qe,cr=x==="x"?lt:ct,ut=T[w],ft=w==="y"?"height":"width",In=ut+g[lr],wt=ut-g[cr],Zt=[Ue,qe].indexOf(b)!==-1,Ln=(Dn=j==null?void 0:j[w])!=null?Dn:0,Q=Zt?In:ut-C[ft]-A[ft]-Ln+I.altAxis,ke=Zt?ut+C[ft]+A[ft]-Ln-I.altAxis:wt,Re=h&&Zt?gE(Q,ut,ke):ui(h?Q:In,ut,h?ke:wt);T[w]=Re,O[w]=Re-ut}e.modifiersData[r]=O}}const KE={name:"preventOverflow",enabled:!0,phase:"main",fn:qE,requiresIfExists:["offset"]};function JE(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function GE(t){return t===Qe(t)||!ot(t)?Sc(t):JE(t)}function YE(t){var e=t.getBoundingClientRect(),n=zr(e.width)/t.offsetWidth||1,r=zr(e.height)/t.offsetHeight||1;return n!==1||r!==1}function XE(t,e,n){n===void 0&&(n=!1);var r=ot(e),i=ot(e)&&YE(e),s=Nn(e),o=Br(t,i,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((Pt(e)!=="body"||Tc(s))&&(a=GE(e)),ot(e)?(l=Br(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Cc(s))),{x:o.left+a.scrollLeft-l.x,y:o.top+a.scrollTop-l.y,width:o.width,height:o.height}}function QE(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function i(s){n.add(s.name);var o=[].concat(s.requires||[],s.requiresIfExists||[]);o.forEach(function(a){if(!n.has(a)){var l=e.get(a);l&&i(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||i(s)}),r}function ZE(t){var e=QE(t);return uE.reduce(function(n,r){return n.concat(e.filter(function(i){return i.phase===r}))},[])}function eM(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function tM(t){var e=t.reduce(function(n,r){var i=n[r.name];return n[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var Ju={placement:"bottom",modifiers:[],strategy:"absolute"};function Gu(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return!e.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function nM(t){t===void 0&&(t={});var e=t,n=e.defaultModifiers,r=n===void 0?[]:n,i=e.defaultOptions,s=i===void 0?Ju:i;return function(a,l,c){c===void 0&&(c=s);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},Ju,s),modifiersData:{},elements:{reference:a,popper:l},attributes:{},styles:{}},u=[],f=!1,h={state:d,setOptions:function(b){var v=typeof b=="function"?b(d.options):b;m(),d.options=Object.assign({},s,d.options,v),d.scrollParents={reference:rr(a)?fi(a):a.contextElement?fi(a.contextElement):[],popper:fi(l)};var k=ZE(tM([].concat(r,d.options.modifiers)));return d.orderedModifiers=k.filter(function(x){return x.enabled}),p(),h.update()},forceUpdate:function(){if(!f){var b=d.elements,v=b.reference,k=b.popper;if(Gu(v,k)){d.rects={reference:XE(v,Pi(k),d.options.strategy==="fixed"),popper:wc(k)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(I){return d.modifiersData[I.name]=Object.assign({},I.data)});for(var x=0;x<d.orderedModifiers.length;x++){if(d.reset===!0){d.reset=!1,x=-1;continue}var w=d.orderedModifiers[x],T=w.fn,C=w.options,A=C===void 0?{}:C,D=w.name;typeof T=="function"&&(d=T({state:d,options:A,name:D,instance:h})||d)}}}},update:eM(function(){return new Promise(function(g){h.forceUpdate(),g(d)})}),destroy:function(){m(),f=!0}};if(!Gu(a,l))return h;h.setOptions(c).then(function(g){!f&&c.onFirstUpdate&&c.onFirstUpdate(g)});
vendor: 14,479 bytes, line 185
185function p(){d.orderedModifiers.forEach(function(g){var b=g.name,v=g.options,k=v===void 0?{}:v,x=g.effect;if(typeof x=="function"){var w=x({state:d,name:b,instance:h,options:k}),T=function(){};u.push(w||T)}})}function m(){u.forEach(function(g){return g()}),u=[]}return h}}var rM=[EE,WE,CE,rg,FE,$E,KE,vE,BE],iM=nM({defaultModifiers:rM}),sM="tippy-box",ug="tippy-content",oM="tippy-backdrop",fg="tippy-arrow",hg="tippy-svg-arrow",$n={passive:!0,capture:!0},pg=function(){return document.body};function ga(t,e,n){if(Array.isArray(t)){var r=t[e];return r??(Array.isArray(n)?n[e]:n)}return t}function Ec(t,e){var n={}.toString.call(t);return n.indexOf("[object")===0&&n.indexOf(e+"]")>-1}function mg(t,e){return typeof t=="function"?t.apply(void 0,e):t}function Yu(t,e){if(e===0)return t;var n;return function(r){clearTimeout(n),n=setTimeout(function(){t(r)},e)}}function aM(t){return t.split(/\s+/).filter(Boolean)}function vr(t){return[].concat(t)}function Xu(t,e){t.indexOf(e)===-1&&t.push(e)}function lM(t){return t.filter(function(e,n){return t.indexOf(e)===n})}function cM(t){return t.split("-")[0]}function co(t){return[].slice.call(t)}function Qu(t){return Object.keys(t).reduce(function(e,n){return t[n]!==void 0&&(e[n]=t[n]),e},{})}function hi(){return document.createElement("div")}function Io(t){return["Element","Fragment"].some(function(e){return Ec(t,e)})}function dM(t){return Ec(t,"NodeList")}function uM(t){return Ec(t,"MouseEvent")}function fM(t){return!!(t&&t._tippy&&t._tippy.reference===t)}function hM(t){return Io(t)?[t]:dM(t)?co(t):Array.isArray(t)?t:co(document.querySelectorAll(t))}function ya(t,e){t.forEach(function(n){n&&(n.style.transitionDuration=e+"ms")})}function Zu(t,e){t.forEach(function(n){n&&n.setAttribute("data-state",e)})}function pM(t){var e,n=vr(t),r=n[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function mM(t,e){var n=e.clientX,r=e.clientY;return t.every(function(i){var s=i.popperRect,o=i.popperState,a=i.props,l=a.interactiveBorder,c=cM(o.placement),d=o.modifiersData.offset;if(!d)return!0;var u=c==="bottom"?d.top.y:0,f=c==="top"?d.bottom.y:0,h=c==="right"?d.left.x:0,p=c==="left"?d.right.x:0,m=s.top-r+u>l,g=r-s.bottom-f>l,b=s.left-n+h>l,v=n-s.right-p>l;return m||g||b||v})}function ba(t,e,n){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){t[r](i,n)})}function ef(t,e){for(var n=e;n;){var r;if(t.contains(n))return!0;n=n.getRootNode==null||(r=n.getRootNode())==null?void 0:r.host}return!1}var Tt={isTouch:!1},tf=0;function gM(){Tt.isTouch||(Tt.isTouch=!0,window.performance&&document.addEventListener("mousemove",gg))}function gg(){var t=performance.now();t-tf<20&&(Tt.isTouch=!1,document.removeEventListener("mousemove",gg)),tf=t}function yM(){var t=document.activeElement;if(fM(t)){var e=t._tippy;t.blur&&!e.state.isVisible&&t.blur()}}function bM(){document.addEventListener("touchstart",gM,$n),window.addEventListener("blur",yM)}var xM=typeof window<"u"&&typeof document<"u",vM=xM?!!window.msCrypto:!1,wM={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},kM={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},mt=Object.assign({appendTo:pg,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},wM,kM),SM=Object.keys(mt),CM=function(e){var n=Object.keys(e);n.forEach(function(r){mt[r]=e[r]})};function yg(t){var e=t.plugins||[],n=e.reduce(function(r,i){var s=i.name,o=i.defaultValue;if(s){var a;r[s]=t[s]!==void 0?t[s]:(a=mt[s])!=null?a:o}return r},{});return Object.assign({},t,n)}function TM(t,e){var n=e?Object.keys(yg(Object.assign({},mt,{plugins:e}))):SM,r=n.reduce(function(i,s){var o=(t.getAttribute("data-tippy-"+s)||"").trim();if(!o)return i;if(s==="content")i[s]=o;else try{i[s]=JSON.parse(o)}catch{i[s]=o}return i},{});return r}function nf(t,e){var n=Object.assign({},e,{content:mg(e.content,[t])},e.ignoreAttributes?{}:TM(t,e.plugins));return n.aria=Object.assign({},mt.aria,n.aria),n.aria={expanded:n.aria.expanded==="auto"?e.interactive:n.aria.expanded,content:n.aria.content==="auto"?e.interactive?null:"describedby":n.aria.content},n}var EM=function(){return"innerHTML"};function ml(t,e){t[EM()]=e}function rf(t){var e=hi();return t===!0?e.className=fg:(e.className=hg,Io(t)?e.appendChild(t):ml(e,t)),e}function sf(t,e){Io(e.content)?(ml(t,""),t.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?ml(t,e.content):t.textContent=e.content)}function gl(t){var e=t.firstElementChild,n=co(e.children);return{box:e,content:n.find(function(r){return r.classList.contains(ug)}),arrow:n.find(function(r){return r.classList.contains(fg)||r.classList.contains(hg)}),backdrop:n.find(function(r){return r.classList.contains(oM)})}}function bg(t){var e=hi(),n=hi();n.className=sM,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var r=hi();r.className=ug,r.setAttribute("data-state","hidden"),sf(r,t.props),e.appendChild(n),n.appendChild(r),i(t.props,t.props);function i(s,o){var a=gl(e),l=a.box,c=a.content,d=a.arrow;o.theme?l.setAttribute("data-theme",o.theme):l.removeAttribute("data-theme"),typeof o.animation=="string"?l.setAttribute("data-animation",o.animation):l.removeAttribute("data-animation"),o.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof o.maxWidth=="number"?o.maxWidth+"px":o.maxWidth,o.role?l.setAttribute("role",o.role):l.removeAttribute("role"),(s.content!==o.content||s.allowHTML!==o.allowHTML)&&sf(c,t.props),o.arrow?d?s.arrow!==o.arrow&&(l.removeChild(d),l.appendChild(rf(o.arrow))):l.appendChild(rf(o.arrow)):d&&l.removeChild(d)}return{popper:e,onUpdate:i}}bg.$$tippy=!0;var MM=1,ss=[],xa=[];function AM(t,e){var n=nf(t,Object.assign({},mt,yg(Qu(e)))),r,i,s,o=!1,a=!1,l=!1,c=!1,d,u,f,h=[],p=Yu(or,n.interactiveDebounce),m,g=MM++,b=null,v=lM(n.plugins),k={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},x={id:g,reference:t,popper:hi(),popperInstance:b,props:n,state:k,plugins:v,clearDelayTimeouts:Q,setProps:ke,setContent:Re,show:dr,hide:$o,hideWithInteractivity:$i,enable:Zt,disable:Ln,unmount:zi,destroy:Bi};if(!n.render)return x;var w=n.render(x),T=w.popper,C=w.onUpdate;T.setAttribute("data-tippy-root",""),T.id="tippy-"+x.id,x.popper=T,t._tippy=x,T._tippy=x;var A=v.map(function(E){return E.fn(x)}),D=t.hasAttribute("aria-expanded");return vt(),B(),F(),H("onCreate",[x]),n.showOnCreate&&In(),T.addEventListener("mouseenter",function(){x.props.interactive&&x.state.isVisible&&x.clearDelayTimeouts()}),T.addEventListener("mouseleave",function(){x.props.interactive&&x.props.trigger.indexOf("mouseenter")>=0&&z().addEventListener("mousemove",p)}),x;function I(){var E=x.props.touch;return Array.isArray(E)?E:[E,0]}function j(){return I()[0]==="hold"}function O(){var E;return!!((E=x.props.render)!=null&&E.$$tippy)}function M(){return m||t}function z(){var E=M().parentNode;return E?pM(E):document}function R(){return gl(T)}function L(E){return x.state.isMounted&&!x.state.isVisible||Tt.isTouch||d&&d.type==="focus"?0:ga(x.props.delay,E?0:1,mt.delay)}function F(E){E===void 0&&(E=!1),T.style.pointerEvents=x.props.interactive&&!E?"":"none",T.style.zIndex=""+x.props.zIndex}function H(E,_,K){if(K===void 0&&(K=!0),A.forEach(function(Z){Z[E]&&Z[E].apply(Z,_)}),K){var ee;(ee=x.props)[E].apply(ee,_)}}function J(){var E=x.props.aria;if(E.content){var _="aria-"+E.content,K=T.id,ee=vr(x.props.triggerTarget||t);ee.forEach(function(Z){var je=Z.getAttribute(_);if(x.state.isVisible)Z.setAttribute(_,je?je+" "+K:K);else{var Ze=je&&je.replace(K,"").trim();Ze?Z.setAttribute(_,Ze):Z.removeAttribute(_)}})}}function B(){if(!(D||!x.props.aria.expanded)){var E=vr(x.props.triggerTarget||t);E.forEach(function(_){x.props.interactive?_.setAttribute("aria-expanded",x.state.isVisible&&_===M()?"true":"false"):_.removeAttribute("aria-expanded")})}}function X(){z().removeEventListener("mousemove",p),ss=ss.filter(function(E){return E!==p})}function Y(E){if(!(Tt.isTouch&&(l||E.type==="mousedown"))){var _=E.composedPath&&E.composedPath()[0]||E.target;if(!(x.props.interactive&&ef(T,_))){if(vr(x.props.triggerTarget||t).some(function(K){return ef(K,_)})){if(Tt.isTouch||x.state.isVisible&&x.props.trigger.indexOf("click")>=0)return}else H("onClickOutside",[x,E]);x.props.hideOnClick===!0&&(x.clearDelayTimeouts(),x.hide(),a=!0,setTimeout(function(){a=!1}),x.state.isMounted||we())}}}function te(){l=!0}function me(){l=!1}function ge(){var E=z();E.addEventListener("mousedown",Y,!0),E.addEventListener("touchend",Y,$n),E.addEventListener("touchstart",me,$n),E.addEventListener("touchmove",te,$n)}function we(){var E=z();E.removeEventListener("mousedown",Y,!0),E.removeEventListener("touchend",Y,$n),E.removeEventListener("touchstart",me,$n),E.removeEventListener("touchmove",te,$n)}function Ke(E,_){$t(E,function(){!x.state.isVisible&&T.parentNode&&T.parentNode.contains(T)&&_()})}function _e(E,_){$t(E,_)}function $t(E,_){var K=R().box;function ee(Z){Z.target===K&&(ba(K,"remove",ee),_())}if(E===0)return _();ba(K,"remove",u),ba(K,"add",ee),u=ee}function dt(E,_,K){K===void 0&&(K=!1);var ee=vr(x.props.triggerTarget||t);ee.forEach(function(Z){Z.addEventListener(E,_,K),h.push({node:Z,eventType:E,handler:_,options:K})})}function vt(){j()&&(dt("touchstart",zt,{passive:!0}),dt("touchend",ar,{passive:!0})),aM(x.props.trigger).forEach(function(E){if(E!=="manual")switch(dt(E,zt),E){case"mouseenter":dt("mouseleave",ar);break;case"focus":dt(vM?"focusout":"blur",Rn);break;case"focusin":dt("focusout",Rn);break}})}function On(){h.forEach(function(E){var _=E.node,K=E.eventType,ee=E.handler,Z=E.options;_.removeEventListener(K,ee,Z)}),h=[]}function zt(E){var _,K=!1;if(!(!x.state.isEnabled||Dn(E)||a)){var ee=((_=d)==null?void 0:_.type)==="focus";d=E,m=E.currentTarget,B(),!x.state.isVisible&&uM(E)&&ss.forEach(function(Z){return Z(E)}),E.type==="click"&&(x.props.trigger.indexOf("mouseenter")<0||o)&&x.props.hideOnClick!==!1&&x.state.isVisible?K=!0:In(E),E.type==="click"&&(o=!K),K&&!ee&&wt(E)}}function or(E){var _=E.target,K=M().contains(_)||T.contains(_);if(!(E.type==="mousemove"&&K)){var ee=ft().concat(T).map(function(Z){var je,Ze=Z._tippy,ur=(je=Ze.popperInstance)==null?void 0:je.state;return ur?{popperRect:Z.getBoundingClientRect(),popperState:ur,props:n}:null}).filter(Boolean);mM(ee,E)&&(X(),wt(E))}}function ar(E){var _=Dn(E)||x.props.trigger.indexOf("click")>=0&&o;if(!_){if(x.props.interactive){x.hideWithInteractivity(E);return}wt(E)}}function Rn(E){x.props.trigger.indexOf("focusin")<0&&E.target!==M()||x.props.interactive&&E.relatedTarget&&T.contains(E.relatedTarget)||wt(E)}function Dn(E){return Tt.isTouch?j()!==E.type.indexOf("touch")>=0:!1}function lr(){cr();var E=x.props,_=E.popperOptions,K=E.placement,ee=E.offset,Z=E.getReferenceClientRect,je=E.moveTransition,Ze=O()?gl(T).arrow:null,ur=Z?{getBoundingClientRect:Z,contextElement:Z.contextElement||M()}:t,Ac={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Hi){var fr=Hi.state;if(O()){var Mg=R(),Bo=Mg.box;["placement","reference-hidden","escaped"].forEach(function(_i){_i==="placement"?Bo.setAttribute("data-placement",fr.placement):fr.attributes.popper["data-popper-"+_i]?Bo.setAttribute("data-"+_i,""):Bo.removeAttribute("data-"+_i)}),fr.attributes.popper={}}}},Pn=[{name:"offset",options:{offset:ee}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!je}},Ac];O()&&Ze&&Pn.push({name:"arrow",options:{element:Ze,padding:3}}),Pn.push.apply(Pn,(_==null?void 0:_.modifiers)||[]),x.popperInstance=iM(ur,T,Object.assign({},_,{placement:K,onFirstUpdate:f,modifiers:Pn}))}function cr(){x.popperInstance&&(x.popperInstance.destroy(),x.popperInstance=null)}function ut(){var E=x.props.appendTo,_,K=M();x.props.interactive&&E===pg||E==="parent"?_=K.parentNode:_=mg(E,[K]),_.contains(T)||_.appendChild(T),x.state.isMounted=!0,lr()}function ft(){return co(T.querySelectorAll("[data-tippy-root]"))}function In(E){x.clearDelayTimeouts(),E&&H("onTrigger",[x,E]),ge();var _=L(!0),K=I(),ee=K[0],Z=K[1];Tt.isTouch&&ee==="hold"&&Z&&(_=Z),_?r=setTimeout(function(){x.show()},_):x.show()}function wt(E){if(x.clearDelayTimeouts(),H("onUntrigger",[x,E]),!x.state.isVisible){we();return}if(!(x.props.trigger.indexOf("mouseenter")>=0&&x.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(E.type)>=0&&o)){var _=L(!1);_?i=setTimeout(function(){x.state.isVisible&&x.hide()},_):s=requestAnimationFrame(function(){x.hide()})}}function Zt(){x.state.isEnabled=!0}function Ln(){x.hide(),x.state.isEnabled=!1}function Q(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(s)}function ke(E){if(!x.state.isDestroyed){H("onBeforeUpdate",[x,E]),On();var _=x.props,K=nf(t,Object.assign({},_,Qu(E),{ignoreAttributes:!0}));x.props=K,vt(),_.interactiveDebounce!==K.interactiveDebounce&&(X(),p=Yu(or,K.interactiveDebounce)),_.triggerTarget&&!K.triggerTarget?vr(_.triggerTarget).forEach(function(ee){ee.removeAttribute("aria-expanded")}):K.triggerTarget&&t.removeAttribute("aria-expanded"),B(),F(),C&&C(_,K),x.popperInstance&&(lr(),ft().forEach(function(ee){requestAnimationFrame(ee._tippy.popperInstance.forceUpdate)})),H("onAfterUpdate",[x,E])}}function Re(E){x.setProps({content:E})}function dr(){var E=x.state.isVisible,_=x.state.isDestroyed,K=!x.state.isEnabled,ee=Tt.isTouch&&!x.props.touch,Z=ga(x.props.duration,0,mt.duration);if(!(E||_||K||ee)&&!M().hasAttribute("disabled")&&(H("onShow",[x],!1),x.props.onShow(x)!==!1)){if(x.state.isVisible=!0,O()&&(T.style.visibility="visible"),F(),ge(),x.state.isMounted||(T.style.transition="none"),O()){var je=R(),Ze=je.box,ur=je.content;ya([Ze,ur],0)}f=function(){var Pn;if(!(!x.state.isVisible||c)){if(c=!0,T.offsetHeight,T.style.transition=x.props.moveTransition,O()&&x.props.animation){var zo=R(),Hi=zo.box,fr=zo.content;ya([Hi,fr],Z),Zu([Hi,fr],"visible")}
185J(),B(),Xu(xa,x),(Pn=x.popperInstance)==null||Pn.forceUpdate(),H("onMount",[x]),x.props.animation&&O()&&_e(Z,function(){x.state.isShown=!0,H("onShown",[x])})}},ut()}}function $o(){var E=!x.state.isVisible,_=x.state.isDestroyed,K=!x.state.isEnabled,ee=ga(x.props.duration,1,mt.duration);if(!(E||_||K)&&(H("onHide",[x],!1),x.props.onHide(x)!==!1)){if(x.state.isVisible=!1,x.state.isShown=!1,c=!1,o=!1,O()&&(T.style.visibility="hidden"),X(),we(),F(!0),O()){var Z=R(),je=Z.box,Ze=Z.content;x.props.animation&&(ya([je,Ze],ee),Zu([je,Ze],"hidden"))}J(),B(),x.props.animation?O()&&Ke(ee,x.unmount):x.unmount()}}function $i(E){z().addEventListener("mousemove",p),Xu(ss,p),p(E)}function zi(){x.state.isVisible&&x.hide(),x.state.isMounted&&(cr(),ft().forEach(function(E){E._tippy.unmount()}),T.parentNode&&T.parentNode.removeChild(T),xa=xa.filter(function(E){return E!==x}),x.state.isMounted=!1,H("onHidden",[x]))}function Bi(){x.state.isDestroyed||(x.clearDelayTimeouts(),x.unmount(),On(),delete t._tippy,x.state.isDestroyed=!0,H("onDestroy",[x]))}}function ji(t,e){e===void 0&&(e={});var n=mt.plugins.concat(e.plugins||[]);bM();var r=Object.assign({},e,{plugins:n}),i=hM(t),s=i.reduce(function(o,a){var l=a&&AM(a,r);return l&&o.push(l),o},[]);return Io(t)?s[0]:s}ji.defaultProps=mt;ji.setDefaultProps=CM;ji.currentInput=Tt;Object.assign({},rg,{effect:function(e){var n=e.state,r={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,r.popper),n.styles=r,n.elements.arrow&&Object.assign(n.elements.arrow.style,r.arrow)}});ji.setDefaultProps({render:bg});const xg=S.forwardRef(({items:t,command:e},n)=>{const{t:r}=He(),[i,s]=S.useState(0),o=S.useRef(null);S.useEffect(()=>{s(0)},[t]),S.useEffect(()=>{const u=o.current;if(!u)return;const f=u.querySelector(`[data-index="${i}"]`);f&&f.scrollIntoView({block:"nearest"})},[i]);const a=S.useCallback(u=>{const f=t[u];f&&e(f)},[t,e]),l=S.useCallback(u=>u.key==="ArrowUp"?(s(f=>f<=0?t.length-1:f-1),!0):u.key==="ArrowDown"?(s(f=>f>=t.length-1?0:f+1),!0):u.key==="Enter"?(a(i),!0):!1,[t.length,i,a]);if(S.useImperativeHandle(n,()=>({onKeyDown:l})),t.length===0)return y.jsx("div",{className:"bg-[var(--bg-primary)] border border-ui-border rounded-lg shadow-lg p-3 w-64",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)] text-center py-2",children:r("writing.slash.noResults")})});const c=[{key:"ai",label:"AI"},{key:"basic",label:r("writing.slash.basic")},{key:"common",label:r("writing.slash.common")}];let d=0;return y.jsx("div",{className:"bg-[var(--bg-primary)] border border-ui-border rounded-lg shadow-lg w-64 max-h-80 overflow-hidden flex flex-col",children:y.jsx("div",{ref:o,className:"overflow-y-auto flex-1",children:c.map(u=>{const f=t.filter(h=>h.category===u.key);return f.length===0?null:y.jsxs("div",{children:[y.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider",children:u.label}),f.map(h=>{const p=d++;return y.jsxs("button",{"data-index":p,onClick:()=>a(p),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left transition-colors ${p===i?"bg-[var(--bg-hover)] text-[var(--text-primary)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[y.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[var(--text-tertiary)]",children:h.icon}),y.jsx("span",{children:h.label})]},h.id)})]},u.key)})})})});xg.displayName="SlashCommandMenu";function NM(t,e,n){return[{id:"ai-write",label:t("writing.slash.aiWrite"),icon:y.jsx(Fn,{className:"w-4 h-4"}),category:"ai",action:()=>{e==null||e("")}},{id:"text",label:t("writing.slash.text"),icon:y.jsx(pf,{className:"w-4 h-4"}),category:"basic",action:r=>{r.chain().focus().clearNodes().run()}},{id:"heading1",label:t("writing.slash.heading1"),icon:y.jsx(kf,{className:"w-4 h-4"}),category:"basic",action:r=>{r.chain().focus().toggleHeading({level:1}).run()}},{id:"heading2",label:t("writing.slash.heading2"),icon:y.jsx(Sf,{className:"w-4 h-4"}),category:"basic",action:r=>{r.chain().focus().toggleHeading({level:2}).run()}},{id:"heading3",label:t("writing.slash.heading3"),icon:y.jsx(Cf,{className:"w-4 h-4"}),category:"basic",action:r=>{r.chain().focus().toggleHeading({level:3}).run()}},{id:"ordered-list",label:t("writing.slash.orderedList"),icon:y.jsx(cf,{className:"w-4 h-4"}),category:"basic",action:r=>{r.chain().focus().toggleOrderedList().run()}},{id:"unordered-list",label:t("writing.slash.unorderedList"),icon:y.jsx(uo,{className:"w-4 h-4"}),category:"basic",action:r=>{r.chain().focus().toggleBulletList().run()}},{id:"code-block",label:t("writing.slash.codeBlock"),icon:y.jsx(vl,{className:"w-4 h-4"}),category:"basic",action:r=>{r.chain().focus().toggleCodeBlock().run()}},{id:"blockquote",label:t("writing.slash.quote"),icon:y.jsx(df,{className:"w-4 h-4"}),category:"basic",action:r=>{r.chain().focus().toggleBlockquote().run()}},{id:"divider",label:t("writing.slash.divider"),icon:y.jsx(uf,{className:"w-4 h-4"}),category:"basic",action:r=>{r.chain().focus().setHorizontalRule().run()}},{id:"image",label:t("writing.slash.image"),icon:y.jsx(mf,{className:"w-4 h-4"}),category:"common",action:()=>{n==null||n("image")}},{id:"video",label:t("writing.slash.video"),icon:y.jsx(Fg,{className:"w-4 h-4"}),category:"common",action:()=>{n==null||n("video")}},{id:"task-list",label:t("writing.slash.taskList"),icon:y.jsx(Vg,{className:"w-4 h-4"}),category:"common",action:r=>{r.chain().focus().toggleTaskList().run()}},{id:"table",label:t("writing.slash.table"),icon:y.jsx(Ty,{className:"w-4 h-4"}),category:"common",action:r=>{r.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{id:"highlight",label:t("writing.slash.highlight"),icon:y.jsx(Ef,{className:"w-4 h-4"}),category:"common",action:r=>{r.chain().focus().toggleHighlight().run()}}]}const OM=de.create({name:"slashCommand",addOptions(){return{onAIWrite:void 0,onOpenMediaDialog:void 0,t:(t,e)=>e||t}},addProseMirrorPlugins(){return[ZT({editor:this.editor,char:"/",allowSpaces:!1,startOfLine:!1,items:({query:t})=>{const e=NM(this.options.t,this.options.onAIWrite,this.options.onOpenMediaDialog);return t?e.filter(n=>n.label.toLowerCase().includes(t.toLowerCase())):e},render:()=>{let t=null,e=null;return{onStart:n=>{t=new Bp(xg,{props:{items:n.items,command:r=>{var i;r.action(n.editor),n.editor.chain().focus().deleteRange(n.range).run(),(i=e==null?void 0:e[0])==null||i.destroy(),t==null||t.destroy()}},editor:n.editor}),n.clientRect&&(e=ji("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",maxWidth:"none"}))},onUpdate:n=>{var r;t==null||t.updateProps({items:n.items,command:i=>{var s;i.action(n.editor),n.editor.chain().focus().deleteRange(n.range).run(),(s=e==null?void 0:e[0])==null||s.destroy(),t==null||t.destroy()}}),n.clientRect&&((r=e==null?void 0:e[0])==null||r.setProps({getReferenceClientRect:n.clientRect}))},onKeyDown:n=>{var r,i;return n.event.key==="Escape"?((r=e==null?void 0:e[0])==null||r.destroy(),t==null||t.destroy(),!0):((i=t==null?void 0:t.ref)==null?void 0:i.onKeyDown(n.event))??!1},onExit:()=>{var n;(n=e==null?void 0:e[0])==null||n.destroy(),t==null||t.destroy()}}}})]}}),RM=ve.create({name:"video",group:"block",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{src:{default:null},poster:{default:null},width:{default:"100%"},dataAssetId:{default:null,parseHTML:t=>t.getAttribute("data-asset-id"),renderHTML:t=>t.dataAssetId?{"data-asset-id":t.dataAssetId}:{}}}},parseHTML(){return[{tag:"video"}]},renderHTML({HTMLAttributes:t}){return["video",le(this.options.HTMLAttributes,t,{controls:!0,style:`width: ${t.width||"100%"}; max-width: 100%;`})]},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}});function DM({open:t,onClose:e,onInsert:n,mediaType:r}){const{t:i}=He(),[s,o]=S.useState("upload"),[a,l]=S.useState(!1),[c,d]=S.useState(""),[u,f]=S.useState([]),[h,p]=S.useState(1),[m,g]=S.useState(1),[b,v]=S.useState(!1),[k,x]=S.useState(!1),w=S.useRef(null),T=r==="video"?"video/*":r==="image"?"image/*":"image/*,video/*",C=i(r==="image"?"writing.mediaInsertTitleImage":r==="video"?"writing.mediaInsertTitleVideo":"writing.mediaInsertTitle"),A=S.useCallback(async O=>{v(!0);try{const M=r==="all"?void 0:r,R=(await ls.getAssets({type:M,page:O,limit:12})).data;f(R.assets),g(R.pagination.totalPages),p(R.pagination.page)}catch{f([])}finally{v(!1)}},[r]);S.useEffect(()=>{t&&s==="library"&&A(1)},[t,s,A]),S.useEffect(()=>{t||(d(""),l(!1),o("upload"),x(!1))},[t]);const D=S.useCallback(async O=>{l(!0),d("");try{const M=O.type.startsWith("video/"),z=M?await ls.uploadVideo(O):await ls.uploadImage(O);n({type:M?"video":"image",url:z.data.url,assetId:z.data.id})}catch{d(i("writing.mediaInsertUploadError"))}finally{l(!1)}},[n,i]),I=S.useCallback(O=>{var z;const M=(z=O.target.files)==null?void 0:z[0];M&&D(M),O.target.value=""},[D]),j=S.useCallback(O=>{O.preventDefault(),x(!1);const M=O.dataTransfer.files[0];M&&D(M)},[D]);return t?y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:e,children:y.jsxs("div",{className:"bg-[var(--bg-primary)] border border-ui-border rounded-xl shadow-2xl w-[520px] max-h-[80vh] flex flex-col",onClick:O=>O.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-ui-border",children:[y.jsx("h3",{className:"text-base font-semibold text-[var(--text-primary)]",children:C}),y.jsx("button",{onClick:e,className:"p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)]",children:y.jsx(xn,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex border-b border-ui-border",children:[y.jsx("button",{onClick:()=>o("upload"),className:`flex-1 py-2.5 text-sm font-medium transition-colors ${s==="upload"?"text-[var(--text-primary)] border-b-2 border-[var(--bg-brand)]":"text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]"}`,children:i("writing.mediaInsertTabUpload")}),y.jsx("button",{onClick:()=>o("library"),className:`flex-1 py-2.5 text-sm font-medium transition-colors ${s==="library"?"text-[var(--text-primary)] border-b-2 border-[var(--bg-brand)]":"text-[var(--text-tertiary)] hover:text-[var(--text-secondary)]"}`,children:i("writing.mediaInsertTabLibrary")})]}),y.jsx("div",{className:"p-5 flex-1 overflow-y-auto",children:s==="upload"?y.jsxs("div",{children:[y.jsx("div",{onDragOver:O=>{O.preventDefault(),x(!0)},onDragLeave:()=>x(!1),onDrop:j,onClick:()=>{var O;return!a&&((O=w.current)==null?void 0:O.click())},className:`flex flex-col items-center justify-center gap-3 p-10 border-2 border-dashed rounded-lg cursor-pointer transition-colors ${k?"border-[var(--bg-brand)] bg-[var(--bg-brand)]/5":"border-ui-border hover:border-[var(--text-tertiary)]"}`,children:a?y.jsxs(y.Fragment,{children:[y.jsx(Er,{className:"w-8 h-8 text-[var(--text-tertiary)] animate-spin"}),y.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:i("writing.mediaInsertUploading")})]}):y.jsxs(y.Fragment,{children:[y.jsx(Wg,{className:"w-8 h-8 text-[var(--text-tertiary)]"}),y.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:i("writing.mediaInsertDragOrClick")})]})}),y.jsx("input",{ref:w,type:"file",accept:T,onChange:I,className:"hidden"}),c&&y.jsx("p",{className:"mt-3 text-sm text-red-500 text-center",children:c})]}):y.jsx("div",{children:b?y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(Er,{className:"w-6 h-6 text-[var(--text-tertiary)] animate-spin"})}):u.length===0?y.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-[var(--text-muted)]",children:[y.jsx(mf,{className:"w-10 h-10 mb-2 opacity-50"}),y.jsx("span",{className:"text-sm",children:i("writing.mediaInsertN
185oAssets")})]}):y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"grid grid-cols-3 gap-3",children:u.map(O=>y.jsxs("button",{onClick:()=>n({type:O.type,url:O.url,assetId:O.id}),className:"relative group aspect-square rounded-lg overflow-hidden border border-ui-border hover:border-[var(--bg-brand)] transition-colors",children:[O.type==="image"?y.jsx("img",{src:O.url,alt:O.filename,crossOrigin:ka(O.url),className:"w-full h-full object-cover"}):y.jsx("video",{src:O.url,preload:"metadata",muted:!0,crossOrigin:ka(O.url),className:"w-full h-full object-cover"}),y.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:y.jsx("span",{className:"opacity-0 group-hover:opacity-100 text-white text-xs font-medium bg-black/50 px-2 py-1 rounded",children:i("writing.mediaInsertInsert")})})]},O.id))}),m>1&&y.jsxs("div",{className:"flex items-center justify-center gap-4 mt-4",children:[y.jsx("button",{onClick:()=>A(h-1),disabled:h<=1,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] disabled:opacity-30 disabled:cursor-not-allowed text-[var(--text-tertiary)]",children:y.jsx(Ug,{className:"w-4 h-4"})}),y.jsxs("span",{className:"text-sm text-[var(--text-muted)]",children:[h," / ",m]}),y.jsx("button",{onClick:()=>A(h+1),disabled:h>=m,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] disabled:opacity-30 disabled:cursor-not-allowed text-[var(--text-tertiary)]",children:y.jsx(qg,{className:"w-4 h-4"})})]})]})})})]})}):null}const IM=Kg(Jg),vg=S.forwardRef(function({content:e,onChange:n,placeholder:r,editable:i=!0,model:s},o){const{t:a}=He(),[l,c]=S.useState(!1),[d,u]=S.useState("image"),[f,h]=S.useState(!1),p=S.useCallback(b=>{u(b),c(!0)},[]),m=B1({extensions:[MS.configure({heading:{levels:[1,2,3]},codeBlock:!1}),tS,AS.configure({placeholder:r||a("writingExtra.startWriting")}),OS.configure({types:["heading","paragraph"]}),LS,jS.configure({allowBase64:!0}),RM,Nm.configure({resizable:!0}),Am,Em,Mm,KC.configure({lowlight:IM}),zk.configure({openOnClick:!1}),JC,GC.configure({nested:!0}),OM.configure({onAIWrite:()=>h(!0),onOpenMediaDialog:p,t:(b,v)=>a(b,v??"")})],content:e,editable:i,onUpdate:({editor:b})=>{n(b.getHTML())},editorProps:{handlePaste:(b,v)=>{var x;const k=(x=v.clipboardData)==null?void 0:x.items;if(!k)return!1;for(const w of k)if(w.type.startsWith("image/")){v.preventDefault();const T=w.getAsFile();return T?(ls.uploadImage(T).then(C=>{const A=C.data.url,D=C.data.id;A&&b.dispatch(b.state.tr.replaceSelectionWith(b.state.schema.nodes.image.create({src:A,...D?{dataAssetId:D}:{}})))}),!0):!1}return!1}}}),g=S.useCallback(b=>{if(!m)return;const v=b.assetId?{dataAssetId:b.assetId}:{};b.type==="image"?m.chain().focus().setImage({src:b.url,...v}).run():m.chain().focus().setVideo({src:b.url,...v}).run(),c(!1)},[m]);return S.useImperativeHandle(o,()=>({getEditor:()=>m}),[m]),S.useEffect(()=>{if(!m||e===m.getHTML())return;const b=requestAnimationFrame(()=>{m.isDestroyed||e===m.getHTML()||m.commands.setContent(e,{emitUpdate:!1})});return()=>cancelAnimationFrame(b)},[e]),y.jsxs("div",{className:"border border-ui-border rounded-lg overflow-hidden",children:[i&&y.jsx(YC,{editor:m,onOpenMediaDialog:p}),i&&m&&y.jsx(JT,{editor:m,model:s}),y.jsx(Pp,{editor:m,className:"prose prose-sm dark:prose-invert max-w-none p-4 min-h-[200px] focus-within:outline-none [&_.tiptap]:outline-none [&_.tiptap]:min-h-[180px] [&_.tiptap_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.tiptap_p.is-editor-empty:first-child::before]:text-[var(--text-muted)] [&_.tiptap_p.is-editor-empty:first-child::before]:float-left [&_.tiptap_p.is-editor-empty:first-child::before]:h-0 [&_.tiptap_p.is-editor-empty:first-child::before]:pointer-events-none [&_.tiptap_table]:border-collapse [&_.tiptap_table]:w-full [&_.tiptap_td]:border [&_.tiptap_td]:border-ui-border [&_.tiptap_td]:p-2 [&_.tiptap_th]:border [&_.tiptap_th]:border-ui-border [&_.tiptap_th]:p-2 [&_.tiptap_th]:bg-[var(--bg-tertiary)] [&_.tiptap_th]:font-semibold [&_.tiptap_pre]:bg-[var(--bg-tertiary)] [&_.tiptap_pre]:rounded-md [&_.tiptap_pre]:p-4 [&_.tiptap_pre_code]:bg-transparent [&_.tiptap_img]:max-w-full [&_.tiptap_img]:rounded-md [&_.tiptap_video]:max-w-full [&_.tiptap_video]:rounded-md [&_.tiptap_a]:text-[var(--text-link)] [&_.tiptap_a]:underline [&_.tiptap_ul[data-type=taskList]]:list-none [&_.tiptap_ul[data-type=taskList]]:pl-0 [&_.tiptap_ul[data-type=taskList]_li]:flex [&_.tiptap_ul[data-type=taskList]_li]:items-start [&_.tiptap_ul[data-type=taskList]_li]:gap-2 [&_.tiptap_ul[data-type=taskList]_li_label]:mt-0.5"}),y.jsx(DM,{open:l,onClose:()=>c(!1),onInsert:g,mediaType:d}),m&&y.jsx(GT,{open:f,onClose:()=>h(!1),editor:m,model:s})]})});function LM(t){let e=t;return e=e.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1 186 187`),e=e.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1 188 189`),e=e.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1 190 191`),e=e.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),e=e.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),e=e.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),e=e.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),e=e.replace(/<u[^>]*>(.*?)<\/u>/gi,"$1"),e=e.replace(/<s[^>]*>(.*?)<\/s>/gi,"~~$1~~"),e=e.replace(/<del[^>]*>(.*?)<\/del>/gi,"~~$1~~"),e=e.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),e=e.replace(/<pre[^>]*><code[^>]*>(.*?)<\/code><\/pre>/gis,"```\n$1\n```\n\n"),e=e.replace(/<blockquote[^>]*>(.*?)<\/blockquote>/gis,(n,r)=>r.replace(/<\/?p[^>]*>/gi,"").trim().split(` 192`).map(s=>`> ${s}`).join(` 193`)+` 194 195`),e=e.replace(/<ul[^>]*>(.*?)<\/ul>/gis,(n,r)=>r.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1 196`)+` 197`),e=e.replace(/<ol[^>]*>(.*?)<\/ol>/gis,(n,r)=>{let i=1;return r.replace(/<li[^>]*>(.*?)<\/li>/gi,()=>`${i++}. $1 198`)+` 199`}),e=e.replace(/<br\s*\/?>/gi,` 200`),e=e.replace(/<p[^>]*>(.*?)<\/p>/gis,`$1 201 202`),e=e.replace(/<[^>]*>/g,""),e=e.replace(/\n{3,}/g,` 203 204`).trim(),e}const wg=` 205 @page { size: A4; margin: 2cm; } 206 body { 207 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif; 208 max-width: 800px; margin: 0 auto; padding: 2rem; 209 line-height: 1.8; font-size: 14px; color: #333; 210 } 211 h1 { font-size: 24px; font-weight: 700; margin: 1.5em 0 0.6em; border-bottom: 1px solid #eee; padding-bottom: 0.3em; } 212 h2 { font-size: 20px; font-weight: 700; margin: 1.4em 0 0.5em; } 213 h3 { font-size: 16px; font-weight: 600; margin: 1.3em 0 0.4em; } 214 p { margin: 0.6em 0; } 215 strong, b { font-weight: 700; } 216 em, i { font-style: italic; } 217 blockquote { 218 border-left: 4px solid #ddd; margin: 1em 0; padding: 0.5em 1em; 219 color: #666; background: #fafafa; 220 } 221 code { 222 background: #f4f4f4; padding: 0.2em 0.4em; border-radius: 3px; 223 font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; 224 font-size: 0.9em; 225 } 226 pre { background: #f4f4f4; border-radius: 6px; padding: 1em; overflow-x: auto; margin: 1em 0; } 227 pre code { background: none; padding: 0; font-size: 13px; } 228 ul, ol { padding-left: 2em; margin: 0.6em 0; } 229 li { margin: 0.3em 0; } 230 img { max-width: 100%; height: auto; margin: 1em 0; border-radius: 4px; } 231 table { border-collapse: collapse; width: 100%; margin: 1em 0; } 232 th, td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; } 233 th { background: #f5f5f5; font-weight: 600; } 234 hr { border: none; border-top: 1px solid #eee; margin: 1.5em 0; } 235 a { color: #0066cc; text-decoration: underline; } 236 mark { background: #fff3b0; padding: 0.1em 0.2em; } 237`;function kg(t,e){return`<!DOCTYPE html> 238<html> 239<head> 240<meta charset="utf-8"> 241<title>${e||"Untitled"}</title> 242<style>${wg}</style> 243</head> 244<body> 245${t} 246</body> 247</html>`}function PM(t,e){const n=kg(t,e),r=window.open("","_blank");if(!r)return;r.document.write(n),r.document.close();const i=r.document.querySelectorAll("img");let s=0;const o=i.length,a=()=>{r.focus(),r.print()};o===0?setTimeout(a,100):i.forEach(l=>{l.complete?(s++,s===o&&setTimeout(a,100)):l.onload=l.onerror=()=>{s++,s===o&&setTimeout(a,100)}})}
247function jM(t,e){const n=`<html xmlns:o="urn:schemas-microsoft-com:office:office" 248 xmlns:w="urn:schemas-microsoft-com:office:word" 249 xmlns="http://www.w3.org/TR/REC-html40"> 250<head> 251<meta charset="utf-8"> 252<title>${e||"Untitled"}</title> 253<!--[if gte mso 9]> 254<xml> 255<w:WordDocument> 256<w:View>Print</w:View> 257<w:Zoom>100</w:Zoom> 258<w:DoNotOptimizeForBrowser/> 259</w:WordDocument> 260</xml> 261<![endif]--> 262<style> 263 ${wg} 264 /* Word-specific overrides */ 265 @page WordSection1 { size: 595.3pt 841.9pt; margin: 72pt 72pt 72pt 72pt; } 266 div.WordSection1 { page: WordSection1; } 267 table { mso-table-lspace: 0; mso-table-rspace: 0; } 268 img { -ms-interpolation-mode: bicubic; } 269</style> 270</head> 271<body> 272<div class="WordSection1"> 273${t} 274</div> 275</body> 276</html>`,r=new Blob(["\uFEFF"+n],{type:"application/msword;charset=utf-8"});Tf.saveAs(r,`${e}.doc`)}function $M({isOpen:t,onClose:e,title:n,htmlContent:r}){const{t:i}=He(),[s,o]=S.useState("markdown"),[a,l]=S.useState(!1),c=S.useCallback(async()=>{const u=(n||"untitled").replace(/[^a-zA-Z0-9\u4e00-\u9fff_-]/g,"_");l(!0);try{if(s==="pdf"){PM(r,u),e();return}if(s==="word"){jM(r,u),e();return}let f,h,p;s==="markdown"?(f=LM(r),h="md",p="text/markdown"):(f=kg(r,n),h="html",p="text/html");const m=new Blob([f],{type:`${p};charset=utf-8`});Tf.saveAs(m,`${u}.${h}`),e()}finally{l(!1)}},[s,n,r,e]);if(!t)return null;const d=[{id:"markdown",label:"Markdown",ext:".md",icon:y.jsx(yf,{className:"w-6 h-6 text-[var(--text-secondary)]"})},{id:"html",label:"HTML",ext:".html",icon:y.jsx(vl,{className:"w-6 h-6 text-[var(--text-secondary)]"})},{id:"pdf",label:"PDF",ext:".pdf",icon:y.jsx(My,{className:"w-6 h-6 text-[var(--text-secondary)]"})},{id:"word",label:"Word",ext:".doc",icon:y.jsx(Iy,{className:"w-6 h-6 text-[var(--text-secondary)]"})}];return y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:e,children:y.jsxs("div",{className:"bg-[var(--bg-primary)] border border-ui-border rounded-xl shadow-xl w-[480px] max-w-[90vw]",onClick:u=>u.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-ui-border",children:[y.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)]",children:i("writing.export")}),y.jsx("button",{onClick:e,className:"p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-muted)] transition-colors",children:y.jsx(xn,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"p-5 space-y-4",children:[y.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-3",children:i("writing.exportFormat")}),y.jsx("div",{className:"grid grid-cols-4 gap-3",children:d.map(u=>y.jsxs("button",{onClick:()=>o(u.id),className:`flex flex-col items-center gap-2 p-4 rounded-lg border transition-colors ${s===u.id?"border-[var(--text-primary)] bg-[var(--bg-tertiary)]":"border-ui-border hover:bg-[var(--bg-hover)]"}`,children:[u.icon,y.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:u.label}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:u.ext})]},u.id))})]}),y.jsxs("div",{className:"flex items-center justify-end gap-3 px-5 py-4 border-t border-ui-border",children:[y.jsx("button",{onClick:e,className:"px-4 py-2 text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] rounded-lg transition-colors",children:i("common.cancel")}),y.jsxs("button",{onClick:c,disabled:a,className:"flex items-center gap-2 px-4 py-2 text-sm bg-[var(--theme)] text-white rounded-lg hover:bg-[var(--theme-hover)] disabled:opacity-50 transition-colors font-medium",children:[y.jsx(gf,{className:"w-4 h-4"}),i(a?"writing.exporting":"writing.exportDownload")]})]})]})})}const zM=3e3;function BM(t){const e=S.useRef(""),n=S.useRef(),r=S.useRef(!1),i=Fe(k=>k.currentDraft),s=Fe(k=>k.updateDraft),o=Fe(k=>k.setSaveStatus),a=Fe(k=>k.saveStatus),l=Fe(k=>k.mode),c=Fe(k=>k.format),d=Fe(k=>k.length),u=Fe(k=>k.tone),f=Fe(k=>k.language),h=Fe(k=>k.results),p=S.useCallback(()=>JSON.stringify({content:t,mode:l,format:c,length:d,tone:u,language:f,results:h}),[t,l,c,d,u,f,h]),m=S.useRef({content:t,mode:l,format:c,length:d,tone:u,language:f,results:h});m.current={content:t,mode:l,format:c,length:d,tone:u,language:f,results:h};const g=S.useRef(i==null?void 0:i.id);g.current=i==null?void 0:i.id,S.useEffect(()=>
276{i&&(e.current=p())},[i==null?void 0:i.id]);const b=S.useCallback(async()=>{var T;const k=g.current;if(!k||r.current)return;const x=Fe.getState();if(!(x.isDraftLoading||((T=x.currentDraft)==null?void 0:T.id)!==k||JSON.stringify(m.current)===e.current)){r.current=!0;try{const C=m.current;await s(k,{content:C.content,mode:C.mode,settings:{format:C.format,length:C.length,tone:C.tone,language:C.language,model:""},results:C.results}),e.current=JSON.stringify(m.current)}catch{}finally{r.current=!1}}},[s]);S.useEffect(()=>{if(!(!i||p()===e.current))return o("unsaved"),n.current&&clearTimeout(n.current),n.current=setTimeout(b,zM),()=>{n.current&&clearTimeout(n.current)}},[p,i,t,l,c,d,u,f,h,b,o]),S.useEffect(()=>()=>{n.current&&(clearTimeout(n.current),b())},[b]);const v=S.useCallback(async()=>{i&&(await s(i.id,{content:t,mode:l,settings:{format:c,length:d,tone:u,language:f,model:""},results:h}),e.current=p())},[i,s,t,l,c,d,u,f,h,p]);return{saveStatus:a,save:v}}function HM({isOpen:t,onClose:e,draftId:n,onRestore:r}){var k,x;const{t:i}=He(),s=Gg(),{confirm:o,ConfirmDialogElement:a}=Yg(),[l,c]=S.useState(null),[d,u]=S.useState(1),{data:f,isLoading:h}=Oc({queryKey:["writing-versions",n,d],queryFn:()=>Se.drafts.versions.list(n,{page:d,limit:20}),enabled:t&&!!n}),{data:p}=Oc({queryKey:["writing-version",n,l],queryFn:()=>Se.drafts.versions.get(n,l),enabled:!!l}),m=Lc({mutationFn:w=>Se.drafts.versions.restore(n,w),onSuccess:()=>{Qg.success(i("writing.versionRestored")),s.invalidateQueries({queryKey:["writing-versions",n]}),s.invalidateQueries({queryKey:["writing-draft",n]}),r()}}),g=Lc({mutationFn:w=>Se.drafts.versions.delete(n,w),onSuccess:()=>{s.invalidateQueries({queryKey:["writing-versions",n]}),c(null)}}),b=((k=f==null?void 0:f.data)==null?void 0:k.versions)??[],v=((x=f==null?void 0:f.data)==null?void 0:x.totalPages)??1;return t?y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:e}),y.jsxs("div",{className:"fixed inset-y-0 right-0 w-96 bg-[var(--bg-primary)] border-l border-ui-border shadow-xl z-50 flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ui-border",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Rc,{className:"w-4 h-4 text-[var(--text-secondary)]"}),y.jsx("h3",{className:"font-medium text-[var(--text-primary)]",children:i("writing.versionHistory")})]}),y.jsx("button",{onClick:e,className:"p-1 rounded hover:bg-[var(--bg-hover)]",children:y.jsx(xn,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h?y.jsx("div",{className:"flex items-center justify-center py-12 text-[var(--text-muted)]",children:y.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-current border-t-transparent rounded-full"})}):b.length===0?y.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-[var(--text-muted)] text-sm",children:[y.jsx(Rc,{className:"w-8 h-8 mb-2 opacity-50"}),i("writing.noVersions")]}):y.jsx("div",{className:"divide-y divide-ui-border",children:b.map(w=>y.jsxs("div",{className:"group",children:[y.jsxs("button",{onClick:()=>c(l===w.id?null:w.id),className:"w-full px-4 py-3 flex items-center gap-3 hover:bg-[var(--bg-hover)] text-left",children:[y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsx("div",{className:"text-sm text-[var(--text-primary)] truncate",children:w.title||i("writing.untitled")}),y.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-[var(--text-muted)]",children:[y.jsx("span",{children:new Date(w.createdAt).toLocaleString()}),y.jsx("span",{children:"·"}),y.jsxs("span",{children:[w.wordCount," ",i("writing.wordCount")]})]})]}),y.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${w.source==="auto"?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"}`,children:w.source==="auto"?i("writing.autoVersion"):i("writing.manualVersion")}),y.jsx(Ta,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${l===w.id?"rotate-180":""}`})]}),l===w.id&&(p==null?void 0:p.data)&&y.jsxs("div",{className:"px-4 pb-3",children:[y.jsx("div",{className:"bg-[var(--bg-secondary)] rounded-lg p-3 mb-2 max-h-60 overflow-y-auto",children:y.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none text-xs",dangerouslySetInnerHTML:{__html:Xg(p.data.content||"")}})}),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("button",{onClick:async()=>{await o({message:i("writing.restoreVersionConfirm"),variant:"default"})&&m.mutate(w.id)},disabled:m.isPending,className:"flex items-center gap-1 px-3 py-1.5 text-xs bg-[var(--bg-brand)] text-white rounded hover:opacity-90 disabled:opacity-50",children:[y.jsx(bf,{className:"w-3 h-3"}),i("writing.restoreVersion")]}),y.jsx("button",{onClick:async()=>{await o({message:i("writing.deleteVersionConfirm"),variant:"danger"})&&g.mutate(w.id)},disabled:g.isPending,className:"flex items-center gap-1 px-3 py-1.5 text-xs text-red-500 border border-red-200 dark:border-red-800 rounded hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50",children:y.jsx(Zr,{className:"w-3 h-3"})})]})]})]},w.id))}),v>1&&y.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 border-t border-ui-border",children:[y.jsx("button",{onClick:()=>u(w=>Math.max(1,w-1)),disabled:d<=1,className:"px-3 py-1 text-xs rounded border border-ui-border disabled:opacity-30",children:"â¹"}),y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:[d," / ",v]}),y.jsx("button",{onClick:()=>u(w=>Math.min(v,w+1)),disabled:d>=v,className:"px-3 py-1 text-xs rounded border border-ui-border disabled:opacity-30",children:"âº"})]})]})]}),a]}):null}function _M({content:t,onChange:e,onExit:n,wordCountGoal:r,model:i}){const{t:s}=He(),[o,a]=S.useState(25*60),[l,c]=S.useState(!1),d=S.useRef(null),u=S.useMemo(()=>
276{const m=document.createElement("div");m.innerHTML=t;const g=m.textContent||"",b=(g.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g)||[]).length,v=g.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").trim().split(/\s+/).filter(Boolean).length;return b+v},[t]),f=r?Math.min(100,Math.round(u/r*100)):0;S.useEffect(()=>(l&&o>0&&(d.current=setInterval(()=>{a(m=>m<=1?(c(!1),0):m-1)},1e3)),()=>{d.current&&clearInterval(d.current)}),[l,o]),S.useEffect(()=>{const m=g=>{g.key==="Escape"&&n()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n]);const h=S.useCallback(m=>{const g=Math.floor(m/60),b=m%60;return`${g.toString().padStart(2,"0")}:${b.toString().padStart(2,"0")}`},[]),p=S.useCallback(()=>{c(!1),a(25*60)},[]);return y.jsxs("div",{className:"fixed inset-0 z-50 bg-[var(--bg-primary)] flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-ui-border",children:[y.jsx("div",{className:"flex items-center gap-4",children:r?y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:[u," / ",r," ",s("writing.wordCount")]}),y.jsx("div",{className:"w-32 h-1.5 bg-[var(--bg-tertiary)] rounded-full overflow-hidden",children:y.jsx("div",{className:"h-full bg-green-500 rounded-full transition-all",style:{width:`${f}%`}})}),y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:[f,"%"]})]}):y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:[u," ",s("writing.wordCount")]})}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsxs("div",{className:"flex items-center gap-1.5 bg-[var(--bg-tertiary)] rounded-lg px-3 py-1.5",children:[y.jsx($y,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"}),y.jsx("span",{className:`text-sm font-mono ${o===0?"text-red-500":"text-[var(--text-secondary)]"}`,children:h(o)}),y.jsx("button",{onClick:()=>c(!l),className:"p-0.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)]",children:l?y.jsx(Zg,{className:"w-3.5 h-3.5"}):y.jsx(ey,{className:"w-3.5 h-3.5"})}),y.jsx("button",{onClick:p,className:"p-0.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)]",children:y.jsx(bf,{className:"w-3.5 h-3.5"})})]}),y.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] rounded-lg transition-colors",children:[y.jsx(xn,{className:"w-4 h-4"}),s("writing.exitFocusMode")]})]})]}),y.jsx("div",{className:"flex-1 overflow-y-auto",children:y.jsx("div",{className:"max-w-3xl mx-auto py-8 px-6",children:y.jsx(vg,{content:t,onChange:e,placeholder:s("writing.focusPlaceholder"),model:i})})})]})}function FM({editor:t,isOpen:e,onClose:n}){const{t:r}=He(),[i,s]=S.useState([]),o=S.useCallback(()=>{if(!t)return;const l=[];t.state.doc.descendants((c,d)=>{c.type.name==="heading"&&l.push({id:`heading-${d}`,level:c.attrs.level,text:c.textContent,pos:d})}),s(l)},[t]);S.useEffect(()=>{if(!t||!e)return;o();const l=()=>o();return t.on("update",l),()=>{t.off("update",l)}},[t,e,o]);const a=S.useCallback(l=>{if(!t)return;t.chain().focus().setTextSelection(l).run();const c=t.view.domAtPos(l),d=c.node instanceof HTMLElement?c.node:c.node.parentElement;d==null||d.scrollIntoView({behavior:"smooth",block:"center"})},[t]);return e?y.jsxs("div",{className:"flex flex-col h-full",children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ui-border",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(uo,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),y.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("writing.tableOfContents")})]}),y.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-muted)] transition-colors",children:y.jsx(xn,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:i.length===0?y.jsx("div",{className:"text-xs text-[var(--text-muted)] text-center py-8",children:r("writing.noHeadings")}):y.jsx("nav",{className:"space-y-0.5",children:i.map(l=>y.jsx("button",{onClick:()=>a(l.pos),className:"w-full text-left px-2 py-1.5 rounded hover:bg-[var(--bg-hover)] transition-colors text-sm truncate",style:{paddingLeft:`${(l.level-1)*16+8}px`},children:y.jsx("span",{className:l.level===1?"text-[var(--text-primary)] font-medium":l.level===2?"text-[var(--text-secondary)]":"text-[var(--text-tertiary)] text-xs",children:l.text})},l.id))})})]}):null}var Gn={},bn={},Sg={};
276(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=1,n=function(){return"".concat(e++)};t.default=n})(Sg);var Lo={},Po={},Mc={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:60,s=null;return function(){for(var o=this,a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];clearTimeout(s),s=setTimeout(function(){r.apply(o,l)},i)}};t.default=e})(Mc);var Nt={};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.SizeSensorId=Nt.SensorTabIndex=Nt.SensorClassName=void 0;var VM="size-sensor-id";Nt.SizeSensorId=VM;var WM="size-sensor-object";Nt.SensorClassName=WM;var UM="-1";Nt.SensorTabIndex=UM;Object.defineProperty(Po,"__esModule",{value:!0});Po.createSensor=void 0;var qM=KM(Mc),va=Nt;function KM(t){return t&&t.__esModule?t:{default:t}}var JM=function(e,n){var r=void 0,i=[],s=function(){getComputedStyle(e).position==="static"&&(e.style.position="relative");var u=document.createElement("object");return u.onload=function(){u.contentDocument.defaultView.addEventListener("resize",o),o()},u.style.display="block",u.style.position="absolute",u.style.top="0",u.style.left="0",u.style.height="100%",u.style.width="100%",u.style.overflow="hidden",u.style.pointerEvents="none",u.style.zIndex="-1",u.style.opacity="0",u.setAttribute("class",va.SensorClassName),u.setAttribute("tabindex",va.SensorTabIndex),u.type="text/html",e.appendChild(u),u.data="about:blank",u},o=(0,qM.default)(function(){i.forEach(function(d){d(e)})}),a=function(u){r||(r=s()),i.indexOf(u)===-1&&i.push(u)},l=function(){r&&r.parentNode&&(r.contentDocument&&r.contentDocument.defaultView.removeEventListener("resize",o),r.parentNode.removeChild(r),e.removeAttribute(va.SizeSensorId),r=void 0,i=[],n&&n())},c=function(u){var f=i.indexOf(u);f!==-1&&i.splice(f,1),i.length===0&&r&&l()};return{element:e,bind:a,destroy:l,unbind:c}};Po.createSensor=JM;var jo={};Object.defineProperty(jo,"__esModule",{value:!0});jo.createSensor=void 0;var GM=Nt,YM=XM(Mc);function XM(t){return t&&t.__esModule?t:{default:t}}var QM=function(e,n){var r=void 0,i=[],s=(0,YM.default)(function(){i.forEach(function(d){d(e)})}),o=function(){var u=new ResizeObserver(s);return u.observe(e),s(),u},a=function(u){r||(r=o()),i.indexOf(u)===-1&&i.push(u)},l=function(){r.disconnect(),i=[],r=void 0,e.removeAttribute(GM.SizeSensorId),n&&n()},c=function(u){var f=i.indexOf(u);f!==-1&&i.splice(f,1),i.length===0&&r&&l()};return{element:e,bind:a,destroy:l,unbind:c}};jo.createSensor=QM;Object.defineProperty(Lo,"__esModule",{value:!0});Lo.createSensor=void 0;var ZM=Po,eA=jo,tA=typeof ResizeObserver<"u"?eA.createSensor:ZM.createSensor;Lo.createSensor=tA;Object.defineProperty(bn,"__esModule",{value:!0});bn.removeSensor=bn.getSensor=bn.Sensors=void 0;var nA=iA(Sg),rA=Lo,yl=Nt;function iA(t){return t&&t.__esModule?t:{default:t}}var Tr={};bn.Sensors=Tr;function Cg(t){t&&Tr[t]&&delete Tr[t]}var sA=function(e){var n=e.getAttribute(yl.SizeSensorId);if(n&&Tr[n])return Tr[n];var r=(0,nA.default)();e.setAttribute(yl.SizeSensorId,r);var i=(0,rA.createSensor)(e,function(){return Cg(r)});return Tr[r]=i,i};bn.getSensor=sA;var oA=function(e){var n=e.element.getAttribute(yl.SizeSensorId);e.destroy(),Cg(n)};bn.removeSensor=oA;Object.defineProperty(Gn,"__esModule",{value:!0});Gn.ver=Eg=Gn.clear=Tg=Gn.bind=void 0;var bl=bn,aA=function(e,n){var r=(0,bl.getSensor)(e);return r.bind(n),function(){r.unbind(n)}},Tg=Gn.bind=aA,lA=function(e){var n=(0,bl.getSensor)(e);(0,bl.removeSensor)(n)},Eg=Gn.clear=lA,cA="1.0.2";Gn.ver=cA;function of(t,e){var n={};return e.forEach(function(r){n[r]=t[r]}),n}function wa(t){return typeof t=="function"}function af(t){return typeof t=="string"}var dA=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var o=s[i];if(!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n};const mr=ty(dA);var uA=function(t){xf(e,t);function e(n){var r=t.call(this,n)||this;return r.echarts=n.echarts,r.ele=null,r.isInitialResize=!0,r}return e.prototype.componentDidMount=function(){this.renderNewEch
276arts()},e.prototype.componentDidUpdate=function(n){var r=this.props.shouldSetOption;if(!(wa(r)&&!r(n,this.props))){if(!mr(n.theme,this.props.theme)||!mr(n.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}var i=this.getEchartsInstance();mr(n.onEvents,this.props.onEvents)||(this.offEvents(i,n.onEvents),this.bindEvents(i,this.props.onEvents));var s=["option","notMerge","replaceMerge","lazyUpdate","showLoading","loadingOption"];mr(of(this.props,s),of(n,s))||this.updateEChartsOption(),(!mr(n.style,this.props.style)||!mr(n.className,this.props.className))&&this.resize()}},e.prototype.componentWillUnmount=function(){this.dispose()},e.prototype.initEchartsInstance=function(){return Dc(this,void 0,void 0,function(){var n=this;return Ic(this,function(r){return[2,new Promise(function(i){n.echarts.init(n.ele,n.props.theme,n.props.opts);var s=n.getEchartsInstance();s.on("finished",function(){var o=n.ele.clientWidth,a=n.ele.clientHeight;n.echarts.dispose(n.ele);var l=Ho({width:o,height:a},n.props.opts);i(n.echarts.init(n.ele,n.props.theme,l))})})]})})},e.prototype.getEchartsInstance=function(){return this.echarts.getInstanceByDom(this.ele)},e.prototype.dispose=function(){if(this.ele){try{Eg(this.ele)}catch(n){console.warn(n)}this.echarts.dispose(this.ele)}},e.prototype.renderNewEcharts=function(){return Dc(this,void 0,void 0,function(){var n,r,i,s,o,a,l=this;return Ic(this,function(c){switch(c.label){case 0:return n=this.props,r=n.onEvents,i=n.onChartReady,s=n.autoResize,o=s===void 0?!0:s,[4,this.initEchartsInstance()];case 1:return c.sent(),a=this.updateEChartsOption(),this.bindEvents(a,r||{}),wa(i)&&i(a),this.ele&&o&&Tg(this.ele,function(){l.resize()}),[2]}})})},e.prototype.bindEvents=function(n,r){function i(o,a){af(o)&&wa(a)&&n.on(o,function(l){a(l,n)})}for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&i(s,r[s])},e.prototype.offEvents=function(n,r){if(r)for(var i in r)af(i)&&n.off(i,r[i])},e.prototype.updateEChartsOption=function(){var n=this.props,r=n.option,i=n.notMerge,s=i===void 0?!1:i,o=n.replaceMerge,a=o===void 0?null:o,l=n.lazyUpdate,c=l===void 0?!1:l,d=n.showLoading,u=n.loadingOption,f=u===void 0?null:u,h=this.getEchartsInstance();return h.setOption(r,{notMerge:s,replaceMerge:a,lazyUpdate:c}),d?h.showLoading(f):h.hideLoading(),h},e.prototype.resize=function(){var n=this.getEchartsInstance();if(!this.isInitialResize)try{n.resize({width:"auto",height:"auto"})}catch(r){console.warn(r)}this.isInitialResize=!1},e.prototype.render=function(){var n=this,r=this.props,i=r.style,s=r.className,o=s===void 0?"":s;r.echarts,r.option,r.theme,r.notMerge,r.replaceMerge,r.lazyUpdate,r.showLoading,r.loadingOption,r.opts,r.onChartReady,r.onEvents,r.shouldSetOption,r.autoResize;var a=ny(r,["style","className","echarts","option","theme","notMerge","replaceMerge","lazyUpdate","showLoading","loadingOption","opts","onChartReady","onEvents","shouldSetOption","autoResize"]),l=Ho({height:300},i);return Ot.createElement("div",Ho({ref:function(c){n.ele=c},style:l,className:"echarts-for-react ".concat(o)},a))},e}(S.PureComponent),fA=function(t){xf(e,t);function e(n){var r=t.call(this,n)||this;return r.echarts=Ey,r}return e}(uA);function hA({isOpen:t,onClose:e}){const{t:n}=He(),[r,i]=S.useState("month"),[s,o]=S.useState(null),[a,l]=S.useState(0),[c,d]=S.useState(!1),u=S.useCallback(async()=>{d(!0);try{const[m,g]=await Promise.all([Se.statistics.get({period:r}),Se.statistics.getStreak()]);o(m.data),l(g.data.streak??0)}catch{}finally{d(!1)}},[r]);if(S.useEffect(()=>{t&&u()},[t,u]),!t)return null;const f={tooltip:{trigger:"axis",formatter:m=>{const g=m[0];return`${g.name}<br/>${g.value} ${n("writing.wordCount")}`}},grid:{left:"3%",right:"4%",bottom:"3%",top:"10%",containLabel:!0},xAxis:{type:"category",data:(s==null?void 0:s.statistics.map(m=>m.date.slice(5)))??[],axisLabel:{fontSize:11,color:"var(--text-muted)"},axisLine:{lineStyle:{color:"var(--border-color)"}}},yAxis:{type:"value",axisLabel:{fontSize:11,color:"var(--text-muted)"},splitLine:{lineStyle:{color:"var(--border-color)",opacity:.3}}},series:[{type:"bar",data:(s==null?void 0:s.statistics.map(m=>m.wordCount))??[],itemStyle:{color:"#6366f1",borderRadius:[4,4,0,0]},barMaxWidth:32}]},h=[{id:"week",label:n("writing.statsWeek")},{id:"month",label:n("writing.statsMonth")},{id:"year",label:n("writing.statsYear")}],p=[{label:n("writing.totalWordsWritten"),value:(s==null?void 0:s.summary.totalWords)??0,icon:y.jsx(yf,{className:"w-4 h-4"}),color:"text-blue-500"},{label:n("writing.wordsToday"),value:(s==null?void 0:s.summary.wordsToday)??0,icon:y.jsx(vf,{className:"w-4 h-4"}),color:"text-green-500"},{label:n("writing.avgDailyWords"),value:(s==null?void 0:s.summary.avgDailyWords)??0,icon:y.jsx(ry,{className:"w-4 h-4"}),color:"text-purple-500"},{label:n("writing.writingStreak"),value:`${a} ${n("writing.days")}`,icon:y.jsx(iy,{className:"w-4 h-4"}),color:"text-orange-500"}];return y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:e,children:y.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-xl shadow-xl w-full max-w-2xl max-h-[80vh] overflow-y-auto",onClick:m=>m.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-ui-border",children:[y.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:n("writing.statistics")}),y.jsx("button",{onClick:e,className:"p-1.5 rounded-lg hover:bg-[var(--bg-hover)] text-[var(--text-muted)] transition-colors",children:y.jsx(xn,{className:"w-5 h-5"})})]}),y.jsxs("div",{className:"p-6 space-y-6",children:[y.jsx("div",{className:"flex gap-1 bg-[var(--bg-tertiary)] rounded-lg p-1
276w-fit",children:h.map(m=>y.jsx("button",{onClick:()=>i(m.id),className:`px-4 py-1.5 text-sm rounded-md transition-colors ${r===m.id?"bg-[var(--bg-primary)] text-[var(--text-primary)] shadow-sm font-medium":"text-[var(--text-muted)] hover:text-[var(--text-primary)]"}`,children:m.label},m.id))}),y.jsx("div",{className:"grid grid-cols-4 gap-4",children:p.map(m=>y.jsxs("div",{className:"bg-[var(--bg-tertiary)] rounded-lg p-4",children:[y.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${m.color} mb-2`,children:[m.icon,y.jsx("span",{children:m.label})]}),y.jsx("div",{className:"text-xl font-bold text-[var(--text-primary)]",children:c?"...":typeof m.value=="number"?m.value.toLocaleString():m.value})]},m.label))}),y.jsxs("div",{children:[y.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] mb-3",children:n("writing.dailyWordCount")}),y.jsx("div",{className:"bg-[var(--bg-tertiary)] rounded-lg p-4",children:s&&s.statistics.length>0?y.jsx(fA,{option:f,style:{height:260}}):y.jsx("div",{className:"h-[260px] flex items-center justify-center text-sm text-[var(--text-muted)]",children:c?"...":n("writing.noContent")})})]})]})]})})}const pA=S.memo(function({message:e,isStreaming:n,onInsertToEditor:r}){const{t:i}=He(),{copy:s}=sy();return e.role==="user"?y.jsx("div",{className:"flex justify-end mb-4",children:y.jsxs("div",{className:"flex items-start gap-2 max-w-[85%]",children:[y.jsx("div",{className:"bg-[var(--text-primary)] text-[var(--bg-primary)] rounded-2xl rounded-tr-md px-4 py-2.5 text-sm",children:e.content}),y.jsx("div",{className:"w-7 h-7 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center shrink-0 mt-0.5",children:y.jsx(oy,{className:"w-4 h-4 text-[var(--text-tertiary)]"})})]})}):y.jsx("div",{className:"flex justify-start mb-4",children:y.jsxs("div",{className:"flex items-start gap-2 max-w-[85%]",children:[y.jsx("div",{className:"w-7 h-7 rounded-full bg-gradient-to-br from-purple-500 to-blue-500 flex items-center justify-center shrink-0 mt-0.5",children:y.jsx(Fn,{className:"w-4 h-4 text-white"})}),y.jsx("div",{className:"space-y-2",children:e.content?y.jsxs("div",{children:[y.jsx("div",{className:"bg-[var(--bg-tertiary)] rounded-2xl rounded-tl-md px-4 py-2.5 text-sm text-[var(--text-primary)]",children:y.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&_p]:mb-1.5 [&_p:last-child]:mb-0 [&_pre]:bg-[var(--bg-secondary)] [&_pre]:rounded [&_pre]:p-2 [&_pre]:text-xs [&_code]:text-xs",children:y.jsx(ay,{children:e.content})})}),!n&&y.jsxs("div",{className:"flex items-center gap-1 mt-1 ml-1",children:[y.jsx("button",{onClick:()=>s(e.content),className:"p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors",title:i("writing.chat.copy"),children:y.jsx(ly,{className:"w-3.5 h-3.5"})}),!e.isNotification&&y.jsxs("button",{onClick:()=>r==null?void 0:r(e.content),className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",title:i("writing.chat.insertToEditor"),children:[y.jsx(Ay,{className:"w-3.5 h-3.5"}),i("writing.chat.insertToEditor")]})]})]}):n?y.jsx("div",{className:"bg-[var(--bg-tertiary)] rounded-2xl rounded-tl-md px-4 py-3 text-sm",children:y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--text-muted)] animate-bounce [animation-delay:0ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--text-muted)] animate-bounce [animation-delay:150ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--text-muted)] animate-bounce [animation-delay:300ms]"})]})}):null})]})})}),as=1e3;function mA({draftId:t,editorContent:e,onInsertToEditor:n,collapsed:r,onToggleCollapse:i,onFullRewrite:s,isRewriting:o,onStopRewrite:a,onEnsureDraft:l}){const{t:c}=He(),[d,u]=S.useState(""),[f,h]=S.useState(!1),[p,m]=S.useState(!1),g=S.useRef(null),b=S.useRef(null),v=S.useRef(null),k=S.useRef(null),{chatMessages:x,isChatStreaming:w,sendChatMessage:T,stopChatStream:C,loadChatHistory:A,clearChat:D,setChatMessages:I}=Fe(),{selectedModel:j}=wf(),O=S.useRef(!1);S.useEffect(()=>{t?O.current?O.current=!1:A(t):I([])},[t]),S.useEffect(()=>{var B;(B=g.current)==null||B.scrollIntoView({behavior:"smooth"})},[x]),S.useEffect(()=>{const B=X=>{v.current&&!v.current.contains(X.target)&&h(!1),k.current&&!k.current.contains(X.target)&&m(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const M=S.useCallback(async()=>{const B=d.trim();if(!B||w)return;u("");let X=t;if(!X&&(O.current=!0,X=await(l==null?void 0:l())||"",!X)){O.current=!1;return}await T(X,B,e,j)},[d,w,t,l,T,e,j]),z=B=>
276{B.key==="Enter"&&!B.shiftKey&&!B.nativeEvent.isComposing&&(B.preventDefault(),M())},R=S.useCallback(async B=>{if(w)return;let X=t;if(!X&&(O.current=!0,X=await(l==null?void 0:l())||"",!X)){O.current=!1;return}await T(X,B,e,j)},[t,w,l,T,e,j]);S.useEffect(()=>{const B=b.current;B&&(B.style.height="auto",B.style.height=Math.min(B.scrollHeight,120)+"px")},[d]);const L=e.replace(/<[^>]*>/g,"").trim().length>0,F=w||!L,H=[{id:"professional",label:c("writing.toneMoreProfessional")},{id:"academic",label:c("writing.toneMoreAcademic")},{id:"formal",label:c("writing.toneMoreFormal")},{id:"casual",label:c("writing.toneMoreCasual")},{id:"literary",label:c("writing.toneMoreLiterary")},{id:"internet",label:c("writing.toneMoreInternet")}],J=[{id:"shorten50",label:c("writing.lengthShorten50"),prompt:c("writing.lengthShorten50Prompt")},{id:"shorten25",label:c("writing.lengthShorten25"),prompt:c("writing.lengthShorten25Prompt")},{id:"expand25",label:c("writing.lengthExpand25"),prompt:c("writing.lengthExpand25Prompt")},{id:"expand50",label:c("writing.lengthExpand50"),prompt:c("writing.lengthExpand50Prompt")}];return r?y.jsx("button",{onClick:i,className:"w-10 h-full border-l border-ui-border flex items-center justify-center hover:bg-[var(--bg-hover)] transition-colors",title:c("writing.chat.expandPanel"),children:y.jsx(py,{className:"w-4 h-4 text-[var(--text-tertiary)]"})}):y.jsxs("div",{className:"w-[420px] border-l border-ui-border flex flex-col bg-[var(--bg-primary)]",children:[y.jsxs("div",{className:"px-4 py-3 border-b border-ui-border flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Fn,{className:"w-4 h-4 text-purple-500"}),y.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:c("writing.chat.title")})]}),y.jsxs("div",{className:"flex items-center gap-1",children:[x.length>0&&y.jsx("button",{onClick:()=>D(t),className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)] transition-colors",title:c("writing.chat.clearHistory"),children:y.jsx(Zr,{className:"w-3.5 h-3.5"})}),y.jsx("button",{onClick:i,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)] transition-colors",title:c("writing.chat.collapsePanel"),children:y.jsx(Py,{className:"w-3.5 h-3.5"})})]})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:[x.length===0?y.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center px-6",children:[y.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-purple-500/20 to-blue-500/20 flex items-center justify-center mb-4",children:y.jsx(Fn,{className:"w-6 h-6 text-purple-500"})}),y.jsx("h3",{className:"text-sm font-medium text-[var(--text-primary)] mb-2",children:c("writing.chat.welcomeTitle")}),y.jsx("p",{className:"text-xs text-[var(--text-muted)] mb-4",children:c("writing.chat.welcomeDesc")}),y.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:[c("writing.chat.quickStart1"),c("writing.chat.quickStart2"),c("writing.chat.quickStart3")].map(B=>y.jsx("button",{onClick:()=>R(B),className:"px-3 py-1.5 text-xs text-[var(--text-secondary)] bg-[var(--bg-tertiary)] border border-ui-border rounded-full hover:bg-[var(--bg-hover)] transition-colors",children:B},B))})]}):x.map((B,X)=>y.jsx(pA,{message:B,isStreaming:w&&B.role==="assistant"&&X===x.length-1,onInsertToEditor:n},B.id)),y.jsx("div",{ref:g})]}),y.jsx("div",{className:"px-4 py-2 border-t border-ui-border flex items-center gap-1.5",children:o?y.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[y.jsx(Er,{className:"w-3.5 h-3.5 animate-spin text-purple-500"}),y.jsx("span",{className:"text-xs text-purple-500 font-medium",children:c("writing.chat.rewriting")}),y.jsxs("button",{onClick:a,className:"ml-auto flex items-center gap-1 px-2.5 py-1.5 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg hover:bg-red-500/20 transition-colors",children:[y.jsx(Ca,{className:"w-3.5 h-3.5"}),c("writing.chat.stopRewrite")]})]}):y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"relative",ref:v,children:[y.jsxs("button",{onClick:()=>{h(!f),m(!1)},disabled:F,className:"flex items-center gap-1 px-2.5 py-1.5 text-xs text-[var(--text-secondary)] bg-[var(--bg-tertiary)] border border-ui-border rounded-lg hover:bg-[var(--bg-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsx(hf,{className:"w-3.5 h-3.5"}),c("writing.chat.changeTone"),y.jsx(Ta,{className:"w-3 h-3"})]}),f&&y.jsx("div",{className:"absolute bottom-full left-0 mb-1 w-40 bg-[var(--bg-primary)] border border-ui-border rounded-lg shadow-lg z-50",children:H.map(B=>y.jsx("button",{onClick:()=>{s==null||s({targetTone:B.label,instructions:c("writing.toneAdjustPrompt",{tone:B.label})}),h(!1)},className:"w-full px-3 py-2 text-xs text-left text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:B.label},B.id))})]}),y.jsxs("div",{className:"relative",ref:k,children:[y.jsxs("button",{onClick:()=>{m(!p),h(!1)},disabled:F,className:"flex items-center gap-1 px-2.5 py-1.5 text-xs text-[var(--text-secondary)] bg-[var(--bg-tertiary)] border border-ui-border rounded-lg hover:bg-[var(--bg-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsx(Dy,{className:"w-3.5 h-3.5"}),c("writing.chat.adjustLength"),y.jsx(Ta,{className:"w-3 h-3"})]}),p&&y.jsx("div",{className:"absolute bottom-full left-0 mb-1 w-48 bg-[var(--bg-primary)] border border-ui-border rounded-lg shadow-lg z-50",children:J.map(B=>y.jsx("button",{onClick:()=>{s==null||s({instructions:B.prompt}),m(!1)},className:"w-full px-3 py-2 text-xs text-left text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:B.label},B.id))})]}),y.jsxs("button",{onClick:()=>s==null?void 0:s({}),disabled:F,className:"flex items-center gap-1 px-2.5 py-1.5 text-xs text-[var(--text-secondary)] bg-[var(--bg-tertiary)] border border-ui-border rounded-lg hover:bg-[var(--bg-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsx(Fn,{className:"w-3.5 h-3.5"}),c("writing.chat.polishAll")]})]})}),y.jsx("div",{className:"px-4 py-3 border-t border-ui-border",children:y.jsxs("div",{className:"flex items-end gap-2",children:[y.jsxs("div",{className:"flex-1 flex flex-col",children:[y.jsx("textarea",{ref:b,value:d,onChange:B=>u(B.target.value),onKeyDown:z,placeholder:c("writing.chat.placeholder"),rows:1,disabled:o,maxLength:as,className:"w-full resize-none px-3 py-2 text-sm bg-[var(--bg-tertiary)] border border-ui-border rounded-lg focus:outline-none focus:ring-1 focus:ring-gray-400 text-[var(--text-primary)] placeholder:text-[var(--text-muted)] disabled:opacity-50",style:{maxHeight:"120px"}}),d.length>as*.8&&y.jsxs("span",{className:`input-char-counter ${d.length>=as?"error":"warning"}
276`,children:[d.length.toLocaleString(),"/",as.toLocaleString()]})]}),w?y.jsx("button",{onClick:C,className:"p-2 rounded-lg bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-colors shrink-0",title:c("writing.chat.stop"),children:y.jsx(Ca,{className:"w-5 h-5"})}):y.jsx("button",{onClick:M,disabled:!d.trim(),className:`p-2 rounded-lg transition-all shrink-0 ${d.trim()?"bg-[var(--theme)] text-white hover:bg-[var(--theme-hover)]":"bg-[var(--theme-medium)] text-[var(--text-muted)] cursor-not-allowed"}`,title:c("writing.chat.send"),children:y.jsx(wl,{className:"w-5 h-5"})})]})})]})}const gr=({text:t,children:e})=>y.jsxs("div",{className:"group/tip relative",children:[e,y.jsx("div",{className:"invisible group-hover/tip:visible absolute top-full left-1/2 -translate-x-1/2 mt-1 px-2 py-1 text-xs text-white bg-gray-800 dark:bg-gray-700 rounded whitespace-nowrap z-50 pointer-events-none",children:t})]}),gA=({status:t})=>{const{t:e}=He();return t==="saving"?y.jsxs("span",{className:"text-xs text-[var(--text-muted)] flex items-center gap-1",children:[y.jsx(Er,{className:"w-3 h-3 animate-spin"}),e("writing.saving")]}):t==="saved"?y.jsxs("span",{className:"text-xs text-green-500 flex items-center gap-1",children:[y.jsx(ff,{className:"w-3 h-3"}),e("writing.autoSaved")]}):t==="unsaved"?y.jsx("span",{className:"text-xs text-amber-500",children:e("writing.unsaved")}):null};function UA(){var wt,Zt,Ln;const{t,i18n:e}=He(),{draftId:n}=cy(),r=dy(),[i,s]=S.useState(""),o=S.useRef(""),a=S.useRef(null),[l,c]=S.useState(!1),[d,u]=S.useState(""),f=S.useRef(null),[h,p]=S.useState(!1),[m,g]=S.useState(!1),[b,v]=S.useState(!1),[k,x]=S.useState(!1),[w,T]=S.useState(!1),[C,A]=S.useState(!1),{format:D,length:I,tone:j,language:O,currentDraft:M,isDraftLoading:z,loadDraft:R,updateDraft:L,resetEditor:F,setCurrentDraft:H,loadDrafts:J,createDraft:B,chatMessages:X,setChatMessages:Y}=Fe(),{selectedModel:te,setSelectedModel:me}=wf(),ge=S.useCallback(async()=>{if(n)return n;const Q=await B({content:o.current}),ke=e.language;return r(`/${ke}/app/writing/${Q.id}`,{replace:!0}),Q.id},[n,B,r,e.language]),we=S.useRef(),Ke=S.useRef(!1);S.useEffect(()=>{if(!(n||Ke.current||!i.replace(/<[^>]*>/g,"").trim()))return we.current&&clearTimeout(we.current),we.current=setTimeout(async()=>{if(!Ke.current){Ke.current=!0;try{const ke=await B({content:i}),Re=e.language;r(`/${Re}/app/writing/${ke.id}`,{replace:!0})}finally{Ke.current=!1}}},1500),()=>{we.current&&clearTimeout(we.current)}},[i,n]);const{saveStatus:_e}=BM(i);S.useEffect(()=>{const Q=ke=>{(_e==="unsaved"||_e==="saving")&&ke.preventDefault()};return window.addEventListener("beforeunload",Q),()=>window.removeEventListener("beforeunload",Q)},[_e]);const $t=S.useMemo(()=>{const Q=i.replace(/<[^>]*>/g," "),ke=(Q.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g)||[]).length,Re=Q.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").trim().split(/\s+/).filter(Boolean).length;return ke+Re},[i]);S.useEffect(()=>{n?R(n):(F(),H(null),s(""),o.current="")},[n]),S.useEffect(()=>{M&&M.id===n&&(s(M.content||""),o.current=M.content||"")},[M==null?void 0:M.id]);const dt=S.useCallback(Q=>{s(Q),o.current=Q},[]),[vt,On]=S.useState(!1),zt=S.useRef(null),{requireAuth:or}=uy(),ar=S.useCallback(async Q=>{var Bi;if(!or())return;const ke=(Bi=a.current)==null?void 0:Bi.getEditor();if(!ke||!M||vt)return;let Re;Q.targetTone?Re=t("writing.chat.rewriteTone",{tone:Q.targetTone}):Q.instructions?Re=Q.instructions:Re=t("writing.chat.rewritePolish");const dr={id:`msg_${Date.now()}_rewrite`,role:"user",content:Re,timestamp:new Date().toISOString()};Y([...X,dr]),await Se.drafts.versions.create(M.id,{source:"manual"}),On(!0);const $o=o.current;ke.commands.setContent("");const $i=new AbortController;zt.current=$i;let zi=!1;try{const E=Se.polishStream({content:$o,instructions:Q.instructions,model:te},$i.signal);let _="";for await(const K of E){_+=K;const ee=await Sa(_);ke.commands.setContent(ee)}zi=!0}catch(E){if(!(E instanceof DOMException&&E.name==="AbortError"))throw E}finally{On(!1),zt.current=null;const E={id:`msg_${Date.now()}_rewrite_done`,role:"assistant",content:t(zi?"writing.chat.rewriteDone":"writing.chat.rewriteStopped"),timestamp:new Date().toISOString(),isNotification:!0}
276;Y([...Fe.getState().chatMessages,E])}},[M,te,vt,X,Y,t]),Rn=S.useCallback(()=>{var Q;(Q=zt.current)==null||Q.abort()},[]),Dn=S.useCallback(async Q=>{var dr;const ke=await Sa(Q),Re=(dr=a.current)==null?void 0:dr.getEditor();Re&&Re.chain().focus().insertContent(ke).run()},[]),lr=S.useCallback(async()=>{n&&await R(n)},[n,R]),cr=S.useCallback(async()=>{if(M)try{await L(M.id,{content:o.current,title:M.title,mode:"compose",settings:{...M.settings||{},format:D,length:I,tone:j,language:O,model:te}}),await J()}catch{}},[M,L,D,I,j,O,te,J]),ut=S.useCallback(()=>{u((M==null?void 0:M.title)||""),c(!0),setTimeout(()=>{var Q;return(Q=f.current)==null?void 0:Q.focus()},0)},[M==null?void 0:M.title]),ft=S.useCallback(async()=>{M&&(await L(M.id,{title:d.trim()}),c(!1),J())},[M,d,L,J]),In=z||!!n&&!!M&&M.id!==n;return y.jsxs("div",{className:"flex-1 flex flex-col bg-[var(--bg-primary)] overflow-hidden min-h-0",children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-ui-border",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(fy,{featureKey:"agent_writing",value:te,onChange:me}),M&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"w-px h-4 bg-ui-border"}),l?y.jsx("input",{ref:f,value:d,onChange:Q=>u(Q.target.value),onBlur:ft,onKeyDown:Q=>{Q.key==="Enter"&&!Q.nativeEvent.isComposing&&ft(),Q.key==="Escape"&&c(!1)},className:"text-sm font-medium text-[var(--text-primary)] bg-[var(--bg-tertiary)] border border-ui-border rounded px-2 py-0.5 focus:outline-none focus:ring-1 focus:ring-gray-400 w-[180px]",placeholder:t("writing.untitled"),maxLength:50}):y.jsxs("button",{onClick:ut,className:"flex items-center gap-1 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors group max-w-[180px]",title:t("writing.editTitle"),children:[y.jsx("span",{className:"truncate",children:M.title||t("writing.untitled")}),y.jsx(hy,{className:"w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]}),y.jsx(gA,{status:_e}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:t("writing.totalWords",{count:$t})}),((wt=M==null?void 0:M.settings)==null?void 0:wt.draftGoal)&&y.jsx("div",{className:"w-16 h-1.5 bg-[var(--bg-tertiary)] rounded-full overflow-hidden",children:y.jsx("div",{className:"h-full bg-green-500 rounded-full transition-all",style:{width:`${Math.min(100,Math.round($t/M.settings.draftGoal*100))}%`}})})]})]}),y.jsxs("div",{className:"flex items-center gap-0.5",children:[M&&y.jsxs(y.Fragment,{children:[y.jsx(gr,{text:t("writing.saving"),children:y.jsx("button",{onClick:cr,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)] transition-colors",children:y.jsx(Ny,{className:"w-3.5 h-3.5"})})}),y.jsx(gr,{text:t("writing.export"),children:y.jsx("button",{onClick:()=>p(!0),className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)] transition-colors",children:y.jsx(gf,{className:"w-3.5 h-3.5"})})}),y.jsx(gr,{text:t("writing.focusMode"),children:y.jsx("button",{onClick:()=>v(!0),className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)] transition-colors",children:y.jsx(Oy,{className:"w-3.5 h-3.5"})})}),y.jsx(gr,{text:t("writing.statistics"),children:y.jsx("button",{onClick:()=>x(!0),className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)] transition-colors",children:y.jsx(vf,{className:"w-3.5 h-3.5"})})}),y.jsx(gr,{text:t("writing.versionHistory"),children:y.jsx("button",{onClick:()=>g(!0),className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)] transition-colors",children:y.jsx(Ry,{className:"w-3.5 h-3.5"})})})]}),y.jsx("div",{className:"w-px h-4 bg-ui-border mx-1"}),y.jsx(gr,{text:t("writing.tableOfContents"),children:y.jsx("button",{onClick:()=>T(!w),className:`p-1.5 rounded transition-colors ${w?"text-[var(--text-link)] bg-[var(--bg-hover)]":"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,children:y.jsx(uo,{className:"w-3.5 h-3.5"})})})]})]}),y.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[y.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[w&&y.jsx("div",{className:"w-56 border-r border-ui-border overflow-hidden shrink-0",children:y.jsx(FM,{editor:((Zt=a.current)==null?void 0:Zt.getEditor())??null,isOpen:!0,onClose:()=>T(!1)})}),y.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:y.jsx("div",{className:"flex-1 overflow-y-auto",children:y.jsx("div",{className:"max-w-4xl mx-auto py-6 px-8",children:In?y.jsxs("div",{className:"animate-pulse space-y-3","aria-hidden":!0,
276children:[y.jsx("div",{className:"h-7 rounded w-1/2 mb-6",style:{background:"var(--bg-tertiary)"}}),y.jsx("div",{className:"h-4 rounded w-full",style:{background:"var(--bg-tertiary)"}}),y.jsx("div",{className:"h-4 rounded w-11/12",style:{background:"var(--bg-tertiary)"}}),y.jsx("div",{className:"h-4 rounded w-4/5",style:{background:"var(--bg-tertiary)"}}),y.jsx("div",{className:"h-4 rounded w-full",style:{background:"var(--bg-tertiary)"}}),y.jsx("div",{className:"h-4 rounded w-2/3",style:{background:"var(--bg-tertiary)"}})]}):y.jsx(vg,{ref:a,content:i,onChange:dt,placeholder:t("writing.slash.typePlaceholder"),model:te})})})})]}),y.jsx(mA,{draftId:n||"",editorContent:i,onInsertToEditor:Dn,collapsed:C,onToggleCollapse:()=>A(!C),onFullRewrite:ar,isRewriting:vt,onStopRewrite:Rn,onEnsureDraft:ge})]}),y.jsx($M,{isOpen:h,onClose:()=>p(!1),title:(M==null?void 0:M.title)||"",htmlContent:i}),M&&y.jsx(HM,{isOpen:m,onClose:()=>g(!1),draftId:M.id,onRestore:lr}),b&&y.jsx(_M,{content:i,onChange:dt,onExit:()=>v(!1),wordCountGoal:((Ln=M==null?void 0:M.settings)==null?void 0:Ln.draftGoal)||void 0,model:te}),y.jsx(hA,{isOpen:k,onClose:()=>x(!1)})]})}export{UA as default};
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.