vendor: 13,168 bytes, line 1
1var eu=Object.defineProperty;var tu=(n,e,t)=>e in n?eu(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ao=(n,e,t)=>tu(n,typeof e!="symbol"?e+"":e,t);import{r as N,R as Ae,d as nu,j as f,n as ru,f as su,u as iu}from"./vendor-react-Dqj2_6qb.js";import{b as Q}from"./vendor-utils-CTyG_Lkd.js";import{B as Z,j as er,D as El,l as Tl,n as Ol,o as Al,q as Dl,s as Gr,v as ou,u as au,p as lu}from"./index-DK1dG-sV.js";import{g as Wt,r as jl,P as cu,S as du,O as uu,C as fu,a as hu,W as pu,K as Ir,b as Rr,c as Pr,L as mu,s as Do,D as gu,h as xu}from"./DescriptionGeneratorModal-5-5OjvFW.js";import{i as yu}from"./imageUploadServiceV2-BDfZB78T.js";import{u as bu}from"./useSignedImageUrls-Bv9K_ptW.js";import{u as vu}from"./useCreditsWithRefresh-DeEGyFo8.js";import"./autumnCustomerOptions-BxzfhXpK.js";import{C as En}from"./creditConfig-Kv_DOwgD.js";import"./userTierUtils-BSY6MUk_.js";import{C as jo}from"./TourHelpButton-B9aZNmRN.js";import{U as wu}from"./index-CEWf94fP.js";import{P as ku,a as Su,b as Cu}from"./popover-B0REy4sK.js";import{at as Il,au as Rl,av as Pl,aw as Ll,ax as Bl,R as $l,W as cr,v as fi,ay as Nu,C as hi,az as Mu,c as Ct,ak as In,T as ts,a as Eu,aA as Tu,aB as Ui,f as Lr,aC as Fl,A as dr,ai as pi,e as ur,a2 as Ou,ar as mi,a8 as zl,X as Au,d as Du,aD as ju}from"./vendor-icons-Dgw38bhs.js";import{C as Ps}from"./Card-DUbH0-2G.js";import{s as Io,g as gi,C as Iu,c as Ru,a as Pu,b as Lu}from"./textProcessingUtils-BwOrOY-z.js";import{M as Ro}from"./Modal-CXo_UfDB.js";import{T as Bu,a as $u,b as Po,c as Lo}from"./Tabs--E7JRr_g.js";import"./vendor-supabase-sav_3FMO.js";import"./vendor-forms-CwYtK4zs.js";import"./vendor-ui-D__ZWp3d.js";import"./Textarea-DZvUAaoz.js";import"./propertyEnrichment-QzuC_thX.js";import"./useAnalytics-BvuBIqiM.js";import"./events-BH8spv7l.js";import"./useUserPlanStatus-CRwAFNV6.js";import"./OutOfCreditsModal-DO3Qg6xP.js";import"./propertyConsolidationUtils-CDRnhA-3.js";import"./r2StorageService-lh1P_i_q.js";import"./imageUrlUtils-Dmr_foTf.js";import"./useMemberCredits-Dm7Ww4Oz.js";import"./useFeatureTour-BcvJ44sn.js";function ke(n){this.content=n}ke.prototype={constructor:ke,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new ke(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ke(t)},addToStart:function(n,e){return new ke([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ke(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new ke(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=ke.from(n),n.size?new ke(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ke.from(n),n.size?new ke(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ke.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};ke.from=function(n){if(n instanceof ke)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ke(e)};function Vl(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=Vl(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function Wl(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),a=e.child(--i),l=o.nodeSize;if(o==a){t-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:t,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++,t--,r--;return{a:t,b:r}}if(o.content.size||a.content.size){let c=Wl(o.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}class C{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,a=0;a<t;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&r(l,s+a,i||null,o)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,t-d),r,s+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new C(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let a=this.content[i],l=o+a.nodeSize;l>e&&((o<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,t-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,t-o-1))),r.push(a),s+=a.nodeSize),o=l}return new C(r,s)}cutByIndex(e,t){return e==t?C.empty:e==0&&t==this.content.length?this:new C(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new C(s,i)}addToStart(e){return new C([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new C(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Vl(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Wl(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Br(0,e);if(e==this.size)return Br(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,s=0;;r++){let i=this.child(r),o=s+i.nodeSize;if(o>=e)return o==e||t>0?Br(r+1,o):Br(r,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return C.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new C(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return C.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new C(t||e,r)}static from(e){if(!e)return C.empty;if(e instanceof C)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new C([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}C.empty=new C([],0);const Ls={index:0,offset:0};function Br(n,e){return Ls.index=n,Ls.offset=e,Ls}function ns(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ns(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ns(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let ne=class xi{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ns(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return xi.none;if(e instanceof xi)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};ne.none=[];class rs extends Error{}class I{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ql(this.content,e+this.openStart,t);return r&&new I(r,this.openStart,this.openEnd)}removeBetween(e,t){return new I(Hl(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return I.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new I(C.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new I(e,r,s)}}I.empty=new I(C.empty,0,0);function Hl(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:a}=n.findIndex(t);if(s==e||i.isText){if(a!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Hl(i.content,e-s-1,t-s-1)))}function ql(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let a=ql(o.content,e-i-1,t);return a&&n.replaceChild(s,o.copy(a))}function Fu(n,e,t){if(t.openStart>n.depth)throw new rs("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new rs("Inconsistent open depths");return _l(n,e,t,0)}function _l(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=_l(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,a=o.content;return on(o,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=zu(t,n);return on(i,Kl(n,o,a,e,r))}else return on(i,ss(n,e,r))}function Ul(n,e){if(!e.type.compatibleContent(n.type))throw new rs("Cannot join "+e.type.name+" onto "+n.type.name)}function yi(n,e,t){let r=n.node(t);return Ul(r,e.node(t)),r}function sn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function tr(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(sn(n.nodeAfter,r),i++));for(let a=i;a<o;a++)sn(s.child(a),r);e&&e.depth==t&&e.textOffset&&sn(e.nodeBefore,r)}function on(n,e){return n.type.checkContent(e),n.copy(e)}function Kl(n,e,t,r,s){let i=n.depth>s&&yi(n,e,s+1),o=r.depth>s&&yi(t,r,s+1),a=[];return tr(null,n,s,a),i&&o&&e.index(s)==t.index(s)?(Ul(i,o),sn(on(i,Kl(n,e,t,r,s+1)),a)):(i&&sn(on(i,ss(n,e,s+1)),a),tr(e,t,s,a),o&&sn(on(o,ss(t,r,s+1)),a)),tr(r,null,s,a),new C(a)}function ss(n,e,t){let r=[];if(tr(null,n,t,r),n.depth>t){let s=yi(n,e,t+1);sn(on(s,ss(n,e,t+1)),r)}return tr(e,null,t,r),new C(r)}function zu(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(C.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}
vendor: 9,163 bytes, line 1
1class fr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ne.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let a=r;r=s,s=a}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new is(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(i),c=i-l;if(r.push(o,a,s+l),!c||(o=o.child(a),o.isText))break;i=c-1,s+=l+1}return new fr(t,r,i)}static resolveCached(e,t){let r=Bo.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else Bo.set(e,r=new Vu);let s=r.elts[r.i]=fr.resolve(e,t);return r.i=(r.i+1)%Wu,s}}class Vu{constructor(){this.elts=[],this.i=0}}const Wu=12,Bo=new WeakMap;class is{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Hu=Object.create(null);let $t=class bi{constructor(e,t,r,s=ne.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||C.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&ns(this.attrs,t||e.defaultAttrs||Hu)&&ne.sameSet(this.marks,r||ne.none)}copy(e=null){return e==this.content?this:new bi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new bi(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return I.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),a=s.start(o),c=s.node(o).content.cut(s.pos-a,i.pos-a);return new I(c,s.depth-o,i.depth-o)}replace(e,t,r){return Fu(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return fr.resolveCached(this,e)}resolveNoCache(e){return fr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Jl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=C.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=s;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);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=ne.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ne.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=C.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};$t.prototype.text=void 0;class as extends $t{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Jl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new as(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new as(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Jl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class un{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new qu(e,t);if(r.next==null)return un.empty;let s=Gl(r);r.next&&r.err("Unexpected trailing text");let i=Qu(Yu(s));return Xu(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}
vendor: 12,537 bytes, lines 1-2
1matchFragment(e,t=0,r=e.childCount){let s=this;for(let i=t;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function i(o,a){let l=o.matchFragment(e,r);if(l&&(!t||l.validEnd))return C.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())&&s.indexOf(u)==-1){s.push(u);let h=i(u,a.concat(d));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let a=s;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:a,next:l}=i.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!s.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:s}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(` 2`)}}un.empty=new un(!0);class qu{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Gl(n){let e=[];do e.push(_u(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function _u(n){let e=[];do e.push(Uu(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Uu(n){let e=Gu(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Ku(n,e);else break;return e}function $o(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Ku(n,e){let t=$o(n),r=t;return n.eat(",")&&(n.next!="}"?r=$o(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Ju(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function Gu(n){if(n.eat("(")){let e=Gl(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Ju(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Yu(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,a,l){let c={term:l,to:a};return e[o].push(c),c}function s(o,a){o.forEach(l=>l.to=a)}function i(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(i(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=i(o.exprs[l],a);if(l==o.exprs.length-1)return c;s(c,a=t())}else if(o.type=="star"){let l=t();return r(a,l),s(i(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=t();return s(i(o.expr,a),l),s(i(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(i(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c<o.min;c++){let d=t();s(i(o.expr,l),d),l=d}if(o.max==-1)s(i(o.expr,l),l);else for(let c=o.min;c<o.max;c++){let d=t();r(l,d),s(i(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 Yl(n,e){return e-n}function Fo(n,e){let t=[];return r(e),t.sort(Yl);function r(s){let i=n[s];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(s);for(let o=0;o<i.length;o++){let{term:a,to:l}=i[o];!a&&t.indexOf(l)==-1&&r(l)}}}function Qu(n){let e=Object.create(null);return t(Fo(n,0));function t(r){let s=[];r.forEach(o=>{n[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<s.length;d++)s[d][0]==a&&(c=s[d][1]);Fo(n,l).forEach(d=>{c||s.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new un(r.indexOf(n.length-1)>-1);for(let o=0;o<s.length;o++){let a=s[o][1].sort(Yl);i.next.push({type:s[o][0],next:e[a.join(",")]||t(a)})}return i}}function Xu(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],i=!s.validEnd,o=[];for(let a=0;a<s.next.length;a++){let{type:l,next:c}=s.next[a];o.push(l.name),i&&!(l.isText||l.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ql(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Xl(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let i=n[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Zl(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function ec(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ef(n,r,e[r]);return t}let zo=class tc{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=ec(e,r.attrs),this.defaultAttrs=Ql(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==un.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:Xl(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new $t(this,this.computeAttrs(e),C.from(t),ne.setFrom(r))}createChecked(e=null,t,r){return t=C.from(t),this.checkContent(t),new $t(this,this.computeAttrs(e),t,ne.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=C.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(C.empty,!0);return i?new $t(this,e,t.append(i),ne.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Zl(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:ne.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,o)=>r[i]=new tc(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Zu(n,e,t){let r=t.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class ef{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Zu(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ys{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=ec(e,s.attrs),this.excluded=null;let i=Ql(this.attrs);this.instance=i?new ne(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ne(this,Xl(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new ys(i,s++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Zl(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class nc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=ke.from(e.nodes),t.marks=ke.from(e.marks||{}),this.nodes=zo.compile(this.spec.nodes,this),this.marks=ys.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",a=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=un.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=a=="_"?null:a?Vo(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Vo(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof zo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new as(r,r.defaultAttrs,e,ne.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return $t.fromJSON(this,e)}markFromJSON(e){return ne.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Vo(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],i=n.marks[s],o=i;if(i)t.push(i);else for(let a in n.marks){let l=n.marks[a];(s=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(s)>-1)&&t.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function tf(n){return n.tag!=null}function nf(n){return n.style!=null}let nr=class vi{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(tf(s))this.tags.push(s);else if(nf(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Ho(this,t,!1);return r.addAll(e,ne.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ho(this,t,!0);return r.addAll(e,ne.none,t.from,t.to),I.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(of(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs
vendor: 9,375 bytes, lines 2-4
2){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let a=t[o];if((a.priority==null?50:a.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=qo(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=qo(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new vi(e,vi.schemaRules(e)))}};const rc={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},rf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},sc={ol:!0,ul:!0},hr=1,wi=2,rr=4;function Wo(n,e,t){return e!=null?(e?hr:0)|(e==="full"?wi:0):n&&n.whitespace=="pre"?hr|wi:t&~rr}class $r{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=ne.none,this.match=i||(o&rr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(C.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&hr)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=C.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!rc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ho{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=Wo(null,t.preserveWhitespace,0)|(r?rr:0);s?i=new $r(s.type,s.attrs,ne.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new $r(null,null,ne.none,!0,null,o):i=new $r(e.schema.topNodeType,null,ne.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,i=s.options&wi?"full":this.localPreserveWS||(s.options&hr)>0;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,` 3`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=s.content[s.content.length-1],a=e.previousSibling;(!o||a&&a.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;sc.hasOwnProperty(o)&&this.parser.normalizeLists&&sf(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:rf.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(rc.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=l&&l.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` 4`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(i,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,r,s){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,t.attrs||null,r,t.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[t.mark];r=r.concat(l.create(t.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(a)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=s==null?null:e.childNodes[s];o!=a;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,r){let s,i;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(e);if(c&&(!s||s.length>c.length+a)&&(s=c,i=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)t=this.enterInner(s[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=ne.none;for(let a of s.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):_o(a.type,e.type))&&(o=a.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=Wo(e,i,o.options);o.options&rr&&o.content.length==0&&(a|=rr);let l=ne.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):_o(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new $r(e,t,l,s,null,a)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=hr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=i;l--)if(o(a-1,l))return!0;return!1}else{let d=l>0||l==0&&s?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];
vendor: 10,968 bytes, line 4
4if(r.isTextblock&&r.defaultAttrs)return r}}}function sf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&sc.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function of(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function qo(n){let e={};for(let t in n)e[t]=n[t];return e}function _o(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=a=>{i.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class yn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Bs(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let a=0,l=0;for(;a<i.length&&l<o.marks.length;){let c=o.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(i[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<i.length;)s=i.pop()[1];for(;l<o.marks.length;){let c=o.marks[l++],d=this.serializeMark(c,o.isInline,t);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Yr(Bs(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Yr(Bs(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Yr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new yn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Uo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Uo(e.marks)}}function Uo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Bs(n){return n.document||window.document}const Ko=new WeakMap;function af(n){let e=Ko.get(n);return e===void 0&&Ko.set(n,e=lf(n)),e}function lf(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Yr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=af(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+1));let a,l=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?l.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):l.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:m}=Yr(n,h,t,r);if(l.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const ic=65535,oc=Math.pow(2,16);function cf(n,e){return n+e*oc}function Jo(n){return n&ic}function df(n){return(n-(n&ic))/oc}const ac=1,lc=2,Qr=4,cc=8;class ki{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&cc)>0}get deletedBefore(){return(this.delInfo&(ac|Qr))>0}get deletedAfter(){return(this.delInfo&(lc|Qr))>0}get deletedAcross(){return(this.delInfo&Qr)>0}}class Ue{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ue.empty)return Ue.empty}recover(e){let t=0,r=Jo(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+df(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?s:0);if(l>e)break;let c=this.ranges[a+i],d=this.ranges[a+o],u=l+c;if(e<=u){let h=c?e==l?-1:e==u?1:t:t,p=l+s+(h<0?0:d);if(r)return p;let m=e==(t<0?l:u)?null:cf(a/3,e-l),g=e==l?lc:e==u?ac:Qr;return(t<0?e!=l:e!=u)&&(g|=cc),new ki(p,g,m)}s+=d-c}return r?e+s:new ki(e+s,0,null)}touches(e,t){let r=0,s=Jo(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+i],d=l+c;if(e<=d&&a==s*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],a=o-(this.inverted?i:0),l=o+(this.inverted?0:i),c=this.ranges[s+t],d=this.ranges[s+r];e(a,a+c,l,l+d),i+=d-c}}invert(){return new Ue(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ue.empty:new Ue(e<0?[0,-e,0]:[0,0,e])}}Ue.empty=new Ue([]);class pr{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new pr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new pr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],a=o.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(a.recover);continue}}s|=a.delInfo,e=a.pos}return r?e:new ki(e,s,null)}}const $s=Object.create(null);class je{getMap(){return Ue.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=$s[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in $s)throw new RangeError("Duplicate use of step JSON ID "+e);return $s[e]=t,t.prototype.jsonID=e,t}}class pe{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new pe(e,null)}static fail(e){return new pe(null,e)}static fromReplace(e,t,r,s){try{return pe.ok(e.replace(t,r,s))}catch(i){if(i instanceof rs)return pe.fail(i.message);throw i}}}function Ki(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(Ki(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return C.fromArray(r)}class Pt extends je{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new I(Ki(t.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,i)}invert(){return new mt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Pt(t.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:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Pt(t.from,t.to,e.markFromJSON(t.mark))}}je.jsonID("addMark",Pt);class mt extends je{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new I(Ki(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,r)}invert(){return new Pt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new mt(t.pos,r.pos,this.mark)}merge(e){return e instanceof mt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new mt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new mt(t.from,t.to,e.markFromJSON(t.mark))}}je.jsonID("removeMark",mt);class Lt extends je{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return pe.fromReplace(e,this.pos,this.pos+1,new I(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new Lt(this.pos,t.marks[s]);return new Lt(this.pos,this.mark)}}return new fn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Lt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Lt(t.pos,e.markFromJSON(t.mark))}}je.jsonID("addNodeMark",Lt);class fn extends je{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return pe.fromReplace(e,this.pos,this.pos+1,new I(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Lt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new fn(t.pos,this.mark)}
vendor: 2,303 bytes, line 4
4toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new fn(t.pos,e.markFromJSON(t.mark))}}je.jsonID("removeNodeMark",fn);class ge extends je{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Si(e,this.from,this.to)?pe.fail("Structure replace would overwrite content"):pe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ue([this.from,this.to-this.from,this.slice.size])}invert(e){return new ge(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new ge(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ge)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?I.empty:new I(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ge(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?I.empty:new I(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ge(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ge(t.from,t.to,I.fromJSON(e,t.slice),!!t.structure)}}je.jsonID("replace",ge);class xe extends je{constructor(e,t,r,s,i,o,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=a}apply(e){if(this.structure&&(Si(e,this.from,this.gapFrom)||Si(e,this.gapTo,this.to)))return pe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return pe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);
vendor: 18,931 bytes, lines 4-5
4return r?pe.fromReplace(e,this.from,this.to,r):pe.fail("Content does not fit in gap")}getMap(){return new Ue([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new xe(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new xe(t.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new xe(t.from,t.to,t.gapFrom,t.gapTo,I.fromJSON(e,t.slice),t.insert,!!t.structure)}}je.jsonID("replaceAround",xe);function Si(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function uf(n,e,t,r){let s=[],i=[],o,a;n.doc.nodesBetween(e,t,(l,c,d)=>{if(!l.isInline)return;let u=l.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+l.nodeSize,t),m=r.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(m)||(o&&o.to==h&&o.mark.eq(u[g])?o.to=p:s.push(o=new mt(h,p,u[g])));a&&a.to==h?a.to=p:i.push(a=new Pt(h,p,r))}}),s.forEach(l=>n.step(l)),i.forEach(l=>n.step(l))}function ff(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,a)=>{if(!o.isInline)return;i++;let l=null;if(r instanceof ys){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,t);for(let d=0;d<l.length;d++){let u=l[d],h;for(let p=0;p<s.length;p++){let m=s[p];m.step==i-1&&u.eq(s[p].style)&&(h=m)}h?(h.to=c,h.step=i):s.push({style:u,from:Math.max(a,e),to:c,step:i})}}}),s.forEach(o=>n.step(new mt(o.from,o.to,o.style)))}function Ji(n,e,t,r=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<i.childCount;l++){let c=i.child(l),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new ge(a,d,I.empty));else{r=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new mt(a,d,c.marks[h]));if(s&&c.isText&&t.whitespace!="pre"){let h,p=/\r?\n|\r/g,m;for(;h=p.exec(c.text);)m||(m=new I(C.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new ge(a+h.index,a+h.index+h[0].length,m))}}a=d}if(!r.validEnd){let l=r.fillBefore(C.empty,!0);n.replace(a,a,new I(l,0,0))}for(let l=o.length-1;l>=0;l--)n.step(o[l])}function hf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Wn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let s=n.$from.node(r),i=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&s.canReplace(i,o,t))return r;if(r==0||s.type.spec.isolating||!hf(s,i,o))break}return null}function pf(n,e,t){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),a=s.after(i+1),l=o,c=a,d=C.empty,u=0;for(let m=i,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,d=C.from(r.node(m).copy(d)),u++):l--;let h=C.empty,p=0;for(let m=i,g=!1;m>t;m--)g||s.after(m+1)<s.end(m)?(g=!0,h=C.from(s.node(m).copy(h)),p++):c++;n.step(new xe(l,c,o,a,new I(d.append(h),u,p),d.size-u,!0))}function Gi(n,e,t=null,r=n){let s=mf(n,e),i=s&&gf(r,e);return i?s.map(Go).concat({type:e,attrs:t}).concat(i.map(Go)):null}function Go(n){return{type:n,attrs:null}}function mf(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return t.canReplaceWith(r,s,o)?i:null}function gf(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;l&&c<s;c++)l=l.matchType(t.child(c).type);return!l||!l.validEnd?null:o}function xf(n,e,t){let r=C.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let a=t[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=C.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new xe(s,i,s,i,new I(r,0,0),t.length,!0))}function yf(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,a)=>{let l=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,l)&&bf(n.doc,n.mapping.slice(i).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?c=!1:!p&&m&&(c=!0)}c===!1&&uc(n,o,a,i),Ji(n,n.mapping.slice(i).map(a,1),r,void 0,c===null);let d=n.mapping.slice(i),u=d.map(a,1),h=d.map(a+o.nodeSize,1);return n.step(new xe(u,h,u+1,h-1,new I(C.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&dc(n,o,a,i),!1}})}function dc(n,e,t,r){e.forEach((s,i)=>{if(s.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(s.text);){let l=n.mapping.slice(r).map(t+1+i+o.index);n.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function uc(n,e,t,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+i);n.replaceWith(o,o+1,e.type.schema.text(` 5`))}})}function bf(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function vf(n,e,t,r,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let o=t.create(r,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,o);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new xe(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new I(C.from(o),0,0),1,!0))}function Et(n,e,t=1,r){let s=n.resolve(e),i=s.depth-t,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>i;c--,d--){let u=s.node(c),h=s.index(c);if(u.type.spec.isolating)return!1;let p=u.content.cutByIndex(h,u.childCount),m=r&&r[d+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!g.type.validContent(p))return!1}let a=s.indexAfter(i),l=r&&r[0];return s.node(i).canReplaceWith(a,a,l?l.type:s.node(i+1).type)}function wf(n,e,t=1,r){let s=n.doc.resolve(e),i=C.empty,o=C.empty;for(let a=s.depth,l=s.depth-t,c=t-1;a>l;a--,c--){i=C.from(s.node(a).copy(i));let d=r&&r[c];o=C.from(d?d.type.create(d.attrs,o):s.node(a).copy(o))}n.step(new ge(e,e,new I(i.append(o),t,t),!0))}function qt(n,e){let t=n.resolve(e),r=t.index();return fc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function kf(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function fc(n,e){return!!(n&&e&&!n.isLeaf&&kf(n,e))}function bs(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let i,o,a=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):t>0?(i=r.node(s+1),a++,o=r.node(s).maybeChild(a)):(i=r.node(s).maybeChild(a-1),o=r.node(s+1)),i&&!i.isTextblock&&fc(i,o)&&r.node(s).canReplace(a,a+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function Sf(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),o=i.node().type;if(s&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let a=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);uc(n,d.node(),d.before(),a)}o.inlineContent&&Ji(n,e+t-1,o,i.node().contentMatchAt(i.index()),r==null);let l=n.mapping.slice(a),c=l.map(e-t);if(n.step(new ge(c,l.map(e+t,-1),I.empty,!0)),r===!0){let d=n.doc.resolve(c);dc(n,d.node(),d.before(),n.steps.length)}return n}function Cf(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,t))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,t))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function hc(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let o=r.depth;o>=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),c=r.node(o),d=!1;if(i==1)d=c.canReplace(l,l,s);else{let u=c.contentMatchAt(l).findWrapping(s.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 vs(n,e,t=e,r=I.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),i=n.resolve(t);return pc(s,i,r)?new ge(e,t,r):new Nf(s,i,r).fit()}function pc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Nf{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=C.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=C.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,a=s.depth;for(;o&&a&&i.childCount==1;)i=i.firstChild.content,o--,a--;let l=new I(i,o,a);return e>-1?new xe(r.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||r.pos!=this.$to.pos?new ge(r.pos,s.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Fs(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(C.from(o),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:a,parent:i,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Fs(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new I(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Fs(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new I(Gn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new I(Gn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,a=r?r.content:o.content,l=o.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[t];if(s){for(let g=0;g<s.childCount;g++)d.push(s.child(g));u=u.matchFragment(s)}let p=a.size+e-(o.content.size-o.openEnd);for(;c<a.childCount;){let g=a.child(c),x=u.matchType(g.type);if(!x)break;c++,(c>1||l==0||g.content.size)&&(u=x,d.push(mc(g.mark(h.allowedMarks(g.marks)),c==1?l:0,c==a.childCount?p:-1)))}let m=c==a.childCount;m||(p=-1),this.placed=Yn(this.placed,t,C.from(d)),this.frontier[t].match=u,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,x=a;g<p;g++){let b=x.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),x=b.content}this.unplaced=m?e==0?I.empty:new I(Gn(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new I(Gn(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!zs(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=zs(e,t,s,r,i);if(o){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=zs(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Yn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Yn(this.placed,this.depth,C.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(C.empty,!0);t.childCount&&(this.placed=Yn(this.placed,this.frontier.length,t))}}function Gn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Gn(n.firstChild.content,e-1,t)))}function Yn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Yn(n.lastChild.content,e-1,t)))}function Fs(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function mc(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,mc(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),n.copy(r)}function zs(n,e,t,r,s){let i=n.node(e),o=s?n.indexAfter(e):n.index(e);if(o==i.childCount&&!t.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,o);return a&&!Mf(t,i.content,o)?a:null}function Mf(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Ef(n){return n.spec.defining||n.spec.definingForContent}function Tf(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(pc(s,i,r))return n.step(new ge(e,t,r));let o=xc(s,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let a=-(s.depth+1);o.unshift(a);for(let h=s.depth,p=s.pos-1;h>0;h--,p--){let m=s.node(h).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;o.indexOf(h)>-1?a=h:s.before(h)==p&&o.splice(1,0,-h)}let l=o.indexOf(a),c=[],d=r.openStart;for(let h=r.content,p=0;;p++){let m=h.firstChild;if(c.push(m),p==r.openStart)break;h=m.content}for(let h=d-1;h>=0;h--){let p=c[h],m=Ef(p.type);if(m&&!p.sameMarkup(s.node(Math.abs(a)-1)))d=h;else if(m||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+d+1)%(r.openStart+1),m=c[p];if(m)for(let g=0;g<o.length;g++){let x=o[(g+l)%o.length],b=!0;x<0&&(b=!1,x=-x);let w=s.node(x-1),S=s.index(x-1);if(w.canReplaceWith(S,S,m.type,m.marks))return n.replace(s.before(x),b?i.after(x):t,new I(gc(r.content,0,r.openStart,p),p,r.openEnd))}}let u=n.steps.length;for(let h=o.length-1;h>=0&&(n.replace(e,t,r),!(n.steps.length>u));h--){let p=o[h];p<0||(e=s.before(p),t=i.after(p))}}function gc(n,e,t,r,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(gc(i.content,e+1,t,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(n).append(n);n=o.append(i.matchFragment(o).fillBefore(C.empty,!0))}return n}function Of(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Cf(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new I(C.from(r),0,0))}function Af(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),i=xc(r,s);for(let o=0;o<i.length;o++){let a=i[o],l=o==i.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),s.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),s.indexAfter(a-1))))return n.delete(r.before(a),s.after(a))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&s.end(o)-t!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function xc(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class Dn extends je{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return pe.fromReplace(e,this.pos,this.pos+1,new I(C.from(s),0,t.isLeaf?0:1))}getMap(){return Ue.empty}invert(e){return new Dn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Dn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Dn(t.pos,t.attr,t.value)}}je.jsonID("attr",Dn);class mr extends je{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return pe.ok(r)}getMap(){return Ue.empty}invert(e){return new mr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new mr(t.attr,t.value)}}je.jsonID("docAttr",mr);
vendor: 3,246 bytes, line 5
5let Rn=class extends Error{};Rn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Rn.prototype=Object.create(Error.prototype);Rn.prototype.constructor=Rn;Rn.prototype.name="TransformError";class Df{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new pr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Rn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=I.empty){let s=vs(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new I(C.from(r),0,0))}delete(e,t){return this.replace(e,t,I.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Tf(this,e,t,r),this}replaceRangeWith(e,t,r){return Of(this,e,t,r),this}deleteRange(e,t){return Af(this,e,t),this}lift(e,t){return pf(this,e,t),this}join(e,t=1){return Sf(this,e,t),this}wrap(e,t){return xf(this,e,t),this}setBlockType(e,t=e,r,s=null){return yf(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return vf(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new Dn(e,t,r)),this}setDocAttribute(e,t){return this.step(new mr(e,t)),this}addNodeMark(e,t){return this.step(new Lt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof ne)t.isInSet(r.marks)&&this.step(new fn(e,t));else{let s=r.marks,i,o=[];for(;i=t.isInSet(s);)o.push(new fn(e,i)),s=i.removeFromSet(s);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(e,t=1,r){return wf(this,e,t,r),this}addMark(e,t,r){return uf(this,e,t,r),this}removeMark(e,t,r){return ff(this,e,t,r),this}clearIncompatible(e,t,r){return Ji(this,e,t,r),this}}const Vs=Object.create(null);class q{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new jf(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=I.empty){let r=t.content.lastChild,s=null;for(let a=0;a<t.openEnd;a++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:c}=o[a],d=e.mapping.slice(i);e.replaceRange(d.map(l.pos),d.map(c.pos),a?I.empty:t),a==0&&Xo(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:a}=s[i],l=e.mapping.slice(r),c=l.map(o.pos),d=l.map(a.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Xo(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new z(e):Cn(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=t<0?Cn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Cn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}
vendor: 7,451 bytes, line 5
5static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Je(e.node(0))}static atStart(e){return Cn(e,e,0,0,1)||new Je(e)}static atEnd(e){return Cn(e,e,e.content.size,e.childCount,-1)||new Je(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Vs[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Vs)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vs[e]=t,t.prototype.jsonID=e,t}getBookmark(){return z.between(this.$anchor,this.$head).getBookmark()}}q.prototype.visible=!0;class jf{constructor(e,t){this.$from=e,this.$to=t}}let Yo=!1;function Qo(n){!Yo&&!n.parent.inlineContent&&(Yo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class z extends q{constructor(e,t=e){Qo(e),Qo(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return q.near(r);let s=e.resolve(t.map(this.anchor));return new z(s.parent.inlineContent?s:r,r)}replace(e,t=I.empty){if(super.replace(e,t),t==I.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof z&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ws(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new z(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=q.findFrom(t,r,!0)||q.findFrom(t,-r,!0);if(i)t=i.$head;else return q.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new z(e,t)}}q.jsonID("text",z);class ws{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ws(e.map(this.anchor),e.map(this.head))}resolve(e){return z.between(e.resolve(this.anchor),e.resolve(this.head))}}class $ extends q{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?q.near(i):new $(i)}content(){return new I(C.from(this.node),0,0)}eq(e){return e instanceof $&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Yi(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new $(e.resolve(t.anchor))}static create(e,t){return new $(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}$.prototype.visible=!1;q.jsonID("node",$);class Yi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new ws(r,r):new Yi(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&$.isSelectable(r)?new $(t):q.near(t)}}class Je extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=I.empty){if(t==I.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,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Je(e)}map(e){return new Je(e)}eq(e){return e instanceof Je}getBookmark(){return If}}q.jsonID("all",Je);const If={map(){return this},resolve(n){return new Je(n)}};function Cn(n,e,t,r,s,i=!1){if(e.inlineContent)return z.create(n,t);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let a=e.child(o);if(a.isAtom){if(!i&&$.isSelectable(a))return $.create(n,t-(s<0?a.nodeSize:0))}else{let l=Cn(n,a,t+s,s<0?a.childCount:0,s,i);if(l)return l}t+=a.nodeSize*s}return null}function Xo(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof ge||s instanceof xe))return;let i=n.mapping.maps[r],o;i.forEach((a,l,c,d)=>{o==null&&(o=d)}),n.setSelection(q.near(n.doc.resolve(o),t))}const Zo=1,Fr=2,ea=4;class Rf extends Df{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|Zo)&~Fr,this.storedMarks=null,this}get selectionSet(){return(this.updated&Zo)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Fr,this}ensureMarks(e){return ne.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Fr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Fr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ne.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),this.selection.empty||this.setSelection(q.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ea,this}get scrolledIntoView(){return(this.updated&ea)>0}}function ta(n,e){return!e||!n?n:n.bind(e)}class Qn{constructor(e,t,r){this.name=e,this.init=ta(t.init,r),this.apply=ta(t.apply,r)}}const Pf=[new Qn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Qn("selection",{init(n,e){return n.selection||q.atStart(e.doc)},apply(n){return n.selection}}),new Qn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Qn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ws{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Pf.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Qn(r.key,r.spec.state,r))})}}class Tn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}
vendor: 4,601 bytes, line 5
5apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let a=this.config.plugins[o];if(a.spec.appendTransaction){let l=s?s[o].n:0,c=s?s[o].state:this,d=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<o?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),i=!0}s&&(s[o]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Tn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Rf(this)}static create(e){let t=new Ws(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Tn(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new Ws(this.schema,e.plugins),r=t.fields,s=new Tn(t);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Ws(e.schema,e.plugins),i=new Tn(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=$t.fromJSON(e.schema,t.doc);else if(o.name=="selection")i.selection=q.fromJSON(i.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){i[o.name]=c.fromJSON.call(l,e,t[a],i);return}}i[o.name]=o.init(e,i)}}),i}}function yc(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=yc(s,e,{})),t[r]=s}return t}class Me{constructor(e){this.spec=e,this.props={},e.props&&yc(e.props,this,this.props),this.key=e.key?e.key.key:bc("plugin")}getState(e){return e[this.key]}}const Hs=Object.create(null);function bc(n){return n in Hs?n+"$"+ ++Hs[n]:(Hs[n]=0,n+"$")}class Ye{constructor(e="key"){this.key=bc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Se=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Pn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Ci=null;const St=function(n,e,t){let r=Ci||(Ci=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Lf=function(){Ci=null},hn=function(n,e,t,r){return t&&(na(n,e,t,r,-1)||na(n,e,t,r,1))},Bf=/^(img|br|input|textarea|hr)$/i;function na(n,e,t,r,s){for(var i;;){if(n==t&&e==r)return!0;if(e==(s<0?0:et(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Cr(n)||Bf.test(n.nodeName)||n.contentEditable=="false")return!1;e=Se(n)+(s<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else n=o,e=s<0?et(n):0}else return!1}}function et(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function $f(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=et(n)}else if(n.parentNode&&!Cr(n))e=Se(n),n=n.parentNode;else return null}}function Ff(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Cr(n))e=Se(n)+1,n=n.parentNode;else return null}}function zf(n,e,t){for(let r=e==0,s=e==et(n);r||s;){if(n==t)return!0;let i=Se(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,s=s&&i==et(n)}}function Cr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);
vendor: 14,884 bytes, line 5
5t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const ks=function(n){return n.focusNode&&hn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function en(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Vf(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Wf(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(et(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(et(r.startContainer),r.startOffset)}}}const xt=typeof navigator<"u"?navigator:null,ra=typeof document<"u"?document:null,_t=xt&&xt.userAgent||"",Ni=/Edge\/(\d+)/.exec(_t),vc=/MSIE \d/.exec(_t),Mi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(_t),We=!!(vc||Mi||Ni),Ft=vc?document.documentMode:Mi?+Mi[1]:Ni?+Ni[1]:0,lt=!We&&/gecko\/(\d+)/i.test(_t);lt&&+(/Firefox\/(\d+)/.exec(_t)||[0,0])[1];const Ei=!We&&/Chrome\/(\d+)/.exec(_t),De=!!Ei,wc=Ei?+Ei[1]:0,Be=!We&&!!xt&&/Apple Computer/.test(xt.vendor),Ln=Be&&(/Mobile\/\w+/.test(_t)||!!xt&&xt.maxTouchPoints>2),Ze=Ln||(xt?/Mac/.test(xt.platform):!1),Hf=xt?/Win/.test(xt.platform):!1,Nt=/Android \d/.test(_t),Nr=!!ra&&"webkitFontSmoothing"in ra.documentElement.style,qf=Nr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function _f(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function kt(n,e){return typeof n=="number"?n:n[e]}function Uf(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function sa(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Pn(o);continue}let a=o,l=a==i.body,c=l?_f(i):Uf(a),d=0,u=0;if(e.top<c.top+kt(r,"top")?u=-(c.top-e.top+kt(s,"top")):e.bottom>c.bottom-kt(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+kt(s,"top")-c.top:e.bottom-c.bottom+kt(s,"bottom")),e.left<c.left+kt(r,"left")?d=-(c.left-e.left+kt(s,"left")):e.right>c.right-kt(r,"right")&&(d=e.right-c.right+kt(s,"right")),d||u)if(l)i.defaultView.scrollBy(d,u);else{let p=a.scrollLeft,m=a.scrollTop;u&&(a.scrollTop+=u),d&&(a.scrollLeft+=d);let g=a.scrollLeft-p,x=a.scrollTop-m;e={left:e.left-g,top:e.top-x,right:e.right-g,bottom:e.bottom-x}}let h=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:Pn(o)}}function Kf(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let a=n.root.elementFromPoint(i,o);if(!a||a==n.dom||!n.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){r=a,s=l.top;break}}return{refDOM:r,refTop:s,stack:kc(n.dom)}}function kc(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Pn(r));return e}function Jf({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Sc(t,r==0?0:r-e)}function Sc(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:i}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let kn=null;function Gf(n){if(n.setActive)return n.setActive();if(kn)return n.focus(kn);let e=kc(n);n.focus(kn==null?{get preventScroll(){return kn={preventScroll:!0},!0}}:void 0),kn||(kn=!1,Sc(e,0))}function Cc(n,e){let t,r=2e8,s,i=0,o=e.top,a=e.top,l,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=St(d).getClientRects();else continue;for(let p=0;p<h.length;p++){let m=h[p];if(m.top<=o&&m.bottom>=a){o=Math.max(m.bottom,o),a=Math.min(m.top,a);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<r){t=d,r=g,s=g&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,d.nodeType==1&&g&&(i=u+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=d,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(i=u+1)}}return!t&&l&&(t=l,s=c,r=0),t&&t.nodeType==3?Yf(t,s):!t||r&&t.nodeType==1?{node:n,offset:i}:Cc(t,s)}function Yf(n,e){let t=n.nodeValue.length,r=document.createRange();for(let s=0;s<t;s++){r.setEnd(n,s+1),r.setStart(n,s);let i=Dt(r,1);if(i.top!=i.bottom&&Qi(e,i))return{node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function Qi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Qf(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Xf(n,e,t){let{node:r,offset:s}=Cc(e,t),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,s,i)}function Zf(n,e,t,r){let s=-1;for(let i=e,o=!1;i!=n.dom;){let a=n.docView.nearestDesc(i,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&(!o&&l.left>r.left||l.top>r.top?s=a.posBefore:(!o&&l.right<r.left||l.bottom<r.top)&&(s=a.posAfter),o=!0),!a.contentDOM&&s<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;i=a.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function Nc(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let o=n.childNodes[i];if(o.nodeType==1){let a=o.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Qi(e,c))return Nc(o,e,c)}}if((i=(i+1)%r)==s)break}return n}function eh(n,e){let t=n.dom.ownerDocument,r,s=0,i=Wf(t,e.left,e.top);i&&({node:r,offset:s}=i);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!Qi(e,c)||(o=Nc(n.dom,e,c),!o))return null}if(Be)for(let c=o;r&&c;c=Pn(c))c.draggable&&(r=void 0);if(o=Qf(o,e),r){if(lt&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;Nr&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(a=Zf(n,r,s,e))}a==null&&(a=Xf(n,o,e));let l=n.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function ia(n){return n.top<n.bottom||n.left<n.right}function Dt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(ia(r))return r}return Array.prototype.find.call(t,ia)||n.getBoundingClientRect()}const th=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Mc(n,e,t){let{node:r,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),o=Nr||lt;if(r.nodeType==3)if(o&&(th.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let l=Dt(St(r,s,s),t);if(lt&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Dt(St(r,s-1,s-1),-1);if(c.top==l.top){let d=Dt(St(r,s,s+1),-1);if(d.top!=l.top)return qn(d,d.left<c.left)}}return l}else{let l=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==r.nodeValue.length?(l--,d=1):t<0?l--:c++,qn(Dt(St(r,l,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==et(r))){let l=r.childNodes[s-1];if(l.nodeType==1)return qs(l.getBoundingClientRect(),!1)}if(i==null&&s<et(r)){let l=r.childNodes[s];if(l.nodeType==1)return qs(l.getBoundingClientRect(),!0)}return qs(r.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==et(r))){let l=r.childNodes[s-1],c=l.nodeType==3?St(l,et(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return qn(Dt(c,1),!1)}if(i==null&&s<et(r)){let l=r.childNodes[s];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?St(l,0,o?0:1):l.nodeType==1?l:null:null;if(c)return qn(Dt(c,-1),!0)}return qn(Dt(r.nodeType==3?St(r):r,-t),t>=0)}function qn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function qs(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Ec(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function nh(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return Ec(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let o=Mc(n,s.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=St(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const rh=/[\u0590-\u08ac]/;function sh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,a=n.domSelection();return a?!rh.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?i:o:Ec(n,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),x=m&&!p.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==g;try{a.collapse(d,u),l&&(l!=d||c!=u)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),x}):r.pos==r.start()||r.pos==r.end()}let oa=null,aa=null,la=!1;function ih(n,e,t){return oa==e&&aa==t?la:(oa=e,aa=t,la=t=="up"||t=="down"?nh(n,e,t):sh(n,e,t))}const tt=0,ca=1,nn=2,yt=3;class Mr{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=tt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>Se(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!t||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let a=s.children[o];if(a.size){s=a;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],a=i+o.size;if(a>e||o instanceof Oc){s=e-i;break}i=a}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Tc&&i.side>=0;r--);if(t<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?Se(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?Se(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,a=0;;a++){let l=this.children[a],c=o+l.size;if(s==-1&&e<=c){let d=o+l.border;if(e>=d&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,d);e=o;for(let u=a;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=Se(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>t||a==this.children.length-1)){t=c;for(let d=a+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=Se(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);
vendor: 4,405 bytes, lines 5-6
5if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let p=0,m=0;p<this.children.length;p++){let g=this.children[p],x=m+g.size;if(i>m&&o<x)return g.setSelection(e-m-g.border,t-m-g.border,r,s);m=x}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((lt||Be)&&e==t){let{node:p,offset:m}=a;if(p.nodeType==3){if(u=!!(m&&p.nodeValue[m-1]==` 6`),u&&m==p.nodeValue.length)for(let g=p,x;g;g=g.parentNode){if(x=g.nextSibling){x.nodeName=="BR"&&(a=l={node:x.parentNode,offset:Se(x)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=p.childNodes[m-1];u=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(lt&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(s=!0)}if(!(s||u&&Be)&&hn(a.node,a.offset,d.anchorNode,d.anchorOffset)&&hn(l.node,l.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!u){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>t){let m=a;a=l,l=m}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let a=r+i.border,l=o-i.border;if(e>=a&&t<=l){this.dirty=e==r||t==o?nn:ca,e==a&&t==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=yt:i.markDirty(e-a,t-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?nn:yt}r=o}this.dirty=nn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?nn:ca;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Tc extends Mr{constructor(e,t,r,s){let i,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.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=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==tt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class oh extends Mr{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class pn extends Mr{constructor(e,t,r,s,i){super(e,[],r,s),this.mark=t,this.spec=i}static create(e,t,r,s){let i=s.nodeViews[t.type.name],o=i&&i(t,s,r);return(!o||!o.dom)&&(o=yn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new pn(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&yt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=yt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=tt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=tt}}slice(e,t,r){let s=pn.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;t<o&&(i=Oi(i,t,o,r)),e>0&&(i=Oi(i,0,e,r));for(let a=0;a<i.length;a++)i[a].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class zt extends Mr{constructor(e,t,r,s,i,o,a,l,c){super(e,[],i,o),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=a}
vendor: 23,273 bytes, line 6
6static create(e,t,r,s,i,o){let a=i.nodeViews[t.type.name],l,c=a&&a(t,i,()=>{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=yn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=jc(d,r,t),c?l=new ah(e,t,r,s,d,u||null,h,c,i,o+1):t.isText?new Ss(e,t,r,s,d,h,i):new zt(e,t,r,s,d,u||null,h,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>C.empty)}return e}matchesNode(e,t,r){return this.dirty==tt&&e.eq(this.node)&&ls(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new ch(this,o&&o.node,e);fh(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&l.syncToMarks(d==this.node.childCount?ne.none:this.node.child(d).marks,r,e),l.placeWidget(c,e,s)},(c,d,u,h)=>{l.syncToMarks(c.marks,r,e);let p;l.findNodeMatch(c,d,u,h)||a&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(p=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(c,d,u,p,e)||l.updateNextNode(c,d,u,e,h,s)||l.addNode(c,d,u,e,s),s+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==nn)&&(o&&this.protectLocalComposition(e,o),Ac(this.contentDOM,this.children,e),Ln&&hh(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof z)||r<t||s>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,a=ph(this.node.content,o,r-t,s-t);return a<0?null:{node:i,pos:a,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new oh(this,i,t,s);e.input.compositionNodes.push(o),this.children=Oi(this.children,r,r+s.length,e,o)}update(e,t,r,s){return this.dirty==yt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=tt}updateOuterDeco(e){if(ls(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Dc(this.dom,this.nodeDOM,Ti(this.outerDeco,this.node,t),Ti(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function da(n,e,t,r,s){jc(r,e,n);let i=new zt(void 0,n,e,t,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Ss extends zt{constructor(e,t,r,s,i,o,a){super(e,t,r,s,i,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==yt||this.dirty!=tt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=tt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=tt,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new Ss(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=yt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Oc extends Mr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==tt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ah extends zt{constructor(e,t,r,s,i,o,a,l,c,d){super(e,t,r,s,i,o,a,c,d),this.spec=l}update(e,t,r,s){if(this.dirty==yt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Ac(n,e,t){let r=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],a=o.dom;if(a.parentNode==n){for(;a!=r;)r=ua(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(a,r);if(o instanceof pn){let l=r?r.previousSibling:n.lastChild;Ac(o.contentDOM,o.children,t),r=l?l.nextSibling:n.firstChild}}for(;r;)r=ua(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const sr=function(n){n&&(this.nodeName=n)};sr.prototype=Object.create(null);const rn=[new sr];function Ti(n,e,t){if(n.length==0)return rn;let r=t?rn[0]:new sr,s=[r];for(let i=0;i<n.length;i++){let o=n[i].type.attrs;if(o){o.nodeName&&s.push(r=new sr(o.nodeName));for(let a in o){let l=o[a];l!=null&&(t&&s.length==1&&s.push(r=new sr(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return s}function Dc(n,e,t,r){if(t==rn&&r==rn)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],a=t[i];if(i){let l;a&&a.nodeName==o.nodeName&&s!=n&&(l=s.parentNode)&&l.nodeName.toLowerCase()==o.nodeName||(l=document.createElement(o.nodeName),l.pmIsDeco=!0,l.appendChild(s),a=rn[0]),s=l}lh(s,a||rn[0],o)}return s}function lh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function jc(n,e,t){return Dc(n,n,rn,Ti(e,t,n.nodeType!=1))}function ls(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function ua(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ch{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=dh(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let s=0,i=this.stack.length>>1,o=Math.min(i,e.length);for(;s<o&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=tt,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let a=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){a=l;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=pn.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))i=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=a;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,s,i){let o=this.top.children[s];return o.dirty==yt&&o.dom==o.contentDOM&&(o.dirty=nn),o.update(e,t,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,i,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof zt){let c=this.preMatch.matched.get(l);if(c!=null&&c!=i)return!1;let d=l.dom,u,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=yt&&ls(t,l.outerDeco));if(!h&&l.update(e,t,r,s))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(l,e,t,r,s,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=nn,u.updateChildren(s,o+1),u.dirty=tt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ls(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let a=zt.create(this.top,t,r,s,i,o);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,r,s,i){let o=zt.create(this.top,e,t,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Tc(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof pn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ss)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Be||De)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Oc(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function dh(n,e){let t=e,r=t.children.length,s=n.childCount,i=new Map,o=[];e:for(;s>0;){let a;for(;;)if(r){let c=t.children[r-1];if(c instanceof pn)t=c,r=c.children.length;else{a=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=n.child(s-1))break;--s,i.set(a,s),o.push(a)}}return{index:s,matched:i,matches:o.reverse()}}function uh(n,e){return n.type.side-e.type.side}function fh(n,e,t,r){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){let d,u;for(;o<s.length&&s[o].to==i;){let x=s[o++];x.widget&&(d?(u||(u=[d])).push(x):d=x)}if(d)if(u){u.sort(uh);for(let x=0;x<u.length;x++)t(u[x],c,!!l)}else t(d,c,!!l);let h,p;if(l)p=-1,h=l,l=null;else if(c<n.childCount)p=c,h=n.child(c++);else break;for(let x=0;x<a.length;x++)a[x].to<=i&&a.splice(x--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)a.push(s[o++]);let m=i+h.nodeSize;if(h.isText){let x=m;o<s.length&&s[o].from<x&&(x=s[o].from);for(let b=0;b<a.length;b++)a[b].to<x&&(x=a[b].to);x<m&&(l=h.cut(x-i),h=h.cut(0,x-i),m=x,p=-1)}else for(;o<s.length&&s[o].to<m;)o++;let g=h.isInline&&!h.isLeaf?a.filter(x=>!x.inline):a.slice();r(h,g,e.forChild(i,h),p),i=m}}function hh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function ph(n,e,t,r){for(let s=0,i=0;s<n.childCount&&i<=r;){let o=n.child(s++),a=i;if(i+=o.nodeSize,!o.isText)continue;let l=o.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;l+=c.text}if(i>=t){if(i>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Oi(n,e,t,r,s){let i=[];for(let o=0,a=0;o<n.length;o++){let l=n[o],c=a,d=a+=l.size;c>=t||d<=e?i.push(l):(c<e&&i.push(l.slice(0,e-c,r)),s&&(i.push(s),s=void 0),d>t&&i.push(l.slice(t-c,l.size,r)))}return i}function Xi(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if(ks(t)){for(l=o;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&$.isSelectable(u)&&s.parent&&!(u.isInline&&zf(t.focusNode,t.focusOffset,s.dom))){let h=s.posBefore;c=new $(o==h?a:r.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,h=o;for(let p=0;p<t.rangeCount;p++){let m=t.getRangeAt(p);u=Math.min(u,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(u<0)return null;[l,o]=h==n.state.selection.anchor?[h,u]:[u,h],a=r.resolve(o)}else l=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let u=e=="pointer"||n.state.selection.head<a.pos&&!i?1:-1;c=Zi(n,d,a,u)}return c}function Ic(n){return n.editable?n.hasFocus():Pc(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Tt(n,e=!1){let t=n.state.selection;if(Rc(n,t),!!Ic(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&De){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&hn(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)gh(n);else{let{anchor:r,head:s}=t,i,o;fa&&!(t instanceof z)&&(t.$from.parent.inlineContent||(i=ha(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=ha(n,t.to))),n.docView.setSelection(r,s,n,e),fa&&(i&&pa(i),o&&pa(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&mh(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const fa=Be||De&&wc<63;function ha(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(Be&&s&&s.contentEditable=="false")return _s(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return _s(s);if(i)return _s(i)}}function _s(n){return n.contentEditable="true",Be&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function pa(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function mh(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ic(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function gh(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,s=r.nodeName=="IMG";s?t.setStart(r.parentNode,Se(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&We&&Ft<=11&&(r.disabled=!0,r.disabled=!1)}function Rc(n,e){if(e instanceof $){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ma(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ma(n)}function ma(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Zi(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||z.between(e,t,r)}function ga(n){return n.editable&&!n.hasFocus()?!1:Pc(n)}function Pc(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function xh(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return hn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ai(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&q.findFrom(i,e)}function jt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function xa(n,e,t){let r=n.state.selection;if(r instanceof z)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return jt(n,new z(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Ai(n.state,e);return s&&s instanceof $?jt(n,s):!1}else if(!(Ze&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let a=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(a))&&!o.contentDOM?$.isSelectable(i)?jt(n,new $(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):Nr?jt(n,new z(n.state.doc.resolve(e<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof $&&r.node.isInline)return jt(n,new z(e>0?r.$to:r.$from));{let s=Ai(n.state,e);return s?jt(n,s):!1}}}function cs(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ir(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Sn(n,e){return e<0?yh(n):bh(n)}function yh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(lt&&t.nodeType==1&&r<cs(t)&&ir(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(ir(a,-1))s=t,i=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(Lc(t))break;{let a=t.previousSibling;for(;a&&ir(a,-1);)s=t.parentNode,i=Se(a),a=a.previousSibling;if(a)t=a,r=cs(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Di(n,t,r):s&&Di(n,s,i)}function bh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=cs(t),i,o;for(;;)if(r<s){if(t.nodeType!=1)break;let a=t.childNodes[r];if(ir(a,1))i=t,o=++r;else break}else{if(Lc(t))break;{let a=t.nextSibling;for(;a&&ir(a,1);)i=a.parentNode,o=Se(a)+1,a=a.nextSibling;if(a)t=a,r=0,s=cs(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}i&&Di(n,i,o)}function Lc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function vh(n,e){for(;n&&e==n.childNodes.length&&!Cr(n);)e=Se(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function wh(n,e){for(;n&&!e&&!Cr(n);)e=Se(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Di(n,e,t){if(e.nodeType!=3){let i,o;(o=vh(e,t))?(e=o,t=0):(i=wh(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(ks(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Tt(n)},50)}function ya(n,e){let t=n.state.doc.resolve(e);if(!(De||Hf)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ba(n,e,t){let r=n.state.selection;if(r instanceof z&&!r.empty||t.indexOf("s")>-1||Ze&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Ai(n.state,e);if(o&&o instanceof $)return jt(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,a=r instanceof Je?q.near(o,e):q.findFrom(o,e);return a?jt(n,a):!1}return!1}function va(n,e){if(!(n.state.selection instanceof z))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function wa(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function kh(n){if(!Be||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;wa(n,r,"true"),setTimeout(()=>wa(n,r,"false"),20)}return!1}function Sh(n){let e="";
vendor: 5,440 bytes, lines 6-9
6return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Ch(n,e){let t=e.keyCode,r=Sh(e);if(t==8||Ze&&t==72&&r=="c")return va(n,-1)||Sn(n,-1);if(t==46&&!e.shiftKey||Ze&&t==68&&r=="c")return va(n,1)||Sn(n,1);if(t==13||t==27)return!0;if(t==37||Ze&&t==66&&r=="c"){let s=t==37?ya(n,n.state.selection.from)=="ltr"?-1:1:-1;return xa(n,s,r)||Sn(n,s)}else if(t==39||Ze&&t==70&&r=="c"){let s=t==39?ya(n,n.state.selection.from)=="ltr"?1:-1:1;return xa(n,s,r)||Sn(n,s)}else{if(t==38||Ze&&t==80&&r=="c")return ba(n,-1,r)||Sn(n,-1);if(t==40||Ze&&t==78&&r=="c")return kh(n)||ba(n,1,r)||Sn(n,1);if(r==(Ze?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function eo(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=n.someProp("clipboardSerializer")||yn.fromSchema(n.state.schema),a=Wc(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Vc[c.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let m=a.createElement(d[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),u++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` 7 8`);return{dom:l,text:h,slice:e}}function Bc(n,e,t,r,s){let i=s.parent.type.spec.code,o,a;if(!t&&!e)return null;let l=e&&(r||i||!t);if(l){if(n.someProp("transformPastedText",h=>{e=h(e,i||r,n)}),i)return e?new I(C.from(n.state.schema.text(e.replace(/\r\n?/g,` 9`))),0,0):I.empty;let u=n.someProp("clipboardTextParser",h=>h(e,s,r,n));if(u)a=u;else{let h=s.marks(),{schema:p}=n.state,m=yn.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let x=o.appendChild(document.createElement("p"));g&&x.appendChild(m.serializeNode(p.text(g,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=Th(t),Nr&&Oh(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 h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||nr.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Nh.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)a=Ah(ka(a,+d[1],+d[2]),d[4]);else if(a=I.maxOpen(Mh(a.content,s),!0),a.openStart||a.openEnd){let u=0,h=0;for(let p=a.content.firstChild;u<a.openStart&&!p.type.spec.isolating;u++,p=p.firstChild);for(let p=a.content.lastChild;h<a.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);a=ka(a,u,h)}return n.someProp("transformPasted",u=>{a=u(a,n)}),a}const Nh=/^(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 Mh(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(a=>{if(!o)return;let l=s.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&i.length&&Fc(l,i,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=zc(o[o.length-1],i.length));let d=$c(a,l);o.push(d),s=s.matchType(d.type),i=l}}),o)return C.from(o)}return n}function $c(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function Fc(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=Fc(n,e,t,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(C.from($c(t,n,s+1))))}}function zc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,zc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function ji(n,e,t,r,s,i){let o=e<0?n.firstChild:n.lastChild,a=o.content;return n.childCount>1&&(i=0),s<r-1&&(a=ji(a,e,t,r,s+1,i)),s>=t&&(a=e<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(a))}function ka(n,e,t){return e<n.openStart&&(n=new I(ji(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new I(ji(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Vc={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 Sa=null;function Wc(){return Sa||(Sa=document.implementation.createHTMLDocument("title"))}let Us=null;function Eh(n){let e=window.trustedTypes;return e?(Us||(Us=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Us.createHTML(n)):n}function Th(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Wc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&Vc[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Eh(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function Oh(n){let e=n.querySelectorAll(De?"span:not([class]):not
9([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="Â "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Ah(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:o}=n;for(let a=r.length-2;a>=0;a-=2){let l=t.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;s=C.from(l.create(r[a+1],s)),i++,o++}return new I(s,i,o)}const $e={},Fe={},Dh={touchstart:!0,touchmove:!0};class jh{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ih(n){for(let e in $e){let t=$e[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Ph(n,r)&&!to(n,r)&&(n.editable||!(r.type in Fe))&&t(n,r)},Dh[e]?{passive:!0}:void 0)}Be&&n.dom.addEventListener("input",()=>null),Ii(n)}function Bt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Rh(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Ii(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>to(n,r))})}function to(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Ph(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Lh(n,e){!to(n,e)&&$e[e.type]&&(n.editable||!(e.type in Fe))&&$e[e.type](n,e)}Fe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!qc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Nt&&De&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Ln&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,en(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Ch(n,t)?t.preventDefault():Bt(n,"key")};Fe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Fe.keypress=(n,e)=>{let t=e;if(qc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ze&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof z)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,s,i))&&n.dispatch(i()),t.preventDefault()}};function Cs(n){return{left:n.clientX,top:n.clientY}}function Bh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function no(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,a=>o>i.depth?a(n,t,i.nodeAfter,i.before(o),s,!0):a(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function jn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function $h(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&$.isSelectable(r)?(jn(n,new $(t)),!0):!1}function Fh(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof $&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let a=o>i.depth?i.nodeAfter:i.node(o);if($.isSelectable(a)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(jn(n,$.create(n.state.doc,s)),!0):!1}function zh(n,e,t,r,s){return no(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?Fh(n,t):$h(n,t))}function Vh(n,e,t,r){return no(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",
vendor: 25,051 bytes, line 9
9s=>s(n,e,r))}function Wh(n,e,t,r){return no(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||Hh(n,t,r)}function Hh(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(jn(n,z.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),a=s.before(i);if(o.inlineContent)jn(n,z.create(r,a+1,a+1+o.content.size));else if($.isSelectable(o))jn(n,$.create(r,a));else continue;return!0}}function ro(n){return ds(n)}const Hc=Ze?"metaKey":"ctrlKey";$e.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=ro(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Bh(t,n.input.lastClick)&&!t[Hc]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i,button:t.button};let o=n.posAtCoords(Cs(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new qh(n,o,t,!!r)):(i=="doubleClick"?Vh:Wh)(n,o.pos,o.inside,t)?t.preventDefault():Bt(n,"pointer"))};class qh{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Hc],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,o=d.depth?d.before():0}const a=s?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.dom.nodeType==1?l.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof $&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&<&&!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)),Bt(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(()=>Tt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Cs(e))),this.updateAllowDefault(e),this.allowDefault||!t?Bt(this.view,"pointer"):zh(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Be&&this.mightDrag&&!this.mightDrag.node.isAtom||De&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(jn(this.view,q.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Bt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Bt(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)}}$e.touchstart=n=>{n.input.lastTouch=Date.now(),ro(n),Bt(n,"pointer")};$e.touchmove=n=>{n.input.lastTouch=Date.now(),Bt(n,"pointer")};$e.contextmenu=n=>ro(n);function qc(n,e){return n.composing?!0:Be&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const _h=Nt?5e3:-1;Fe.compositionstart=Fe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof z&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),ds(n,!0),n.markCursor=null;else if(ds(n,!e.selection.empty),lt&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let a=n.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}_c(n,_h)};Fe.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,_c(n,20))};function _c(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ds(n),e))}function Uc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Kh());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Uh(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=$f(e.focusNode,e.focusOffset),r=Ff(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Kh(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ds(n,e=!1){if(!(Nt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Uc(n),e||n.docView&&n.docView.dirty){let t=Xi(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Jh(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const gr=We&&Ft<15||Ln&&qf<604;$e.copy=Fe.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=gr?null:t.clipboardData,o=r.content(),{dom:a,text:l}=eo(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):Jh(n,a),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Gh(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Yh(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?xr(n,r.value,null,s,e):xr(n,r.textContent,r.innerHTML,s,e)},50)}function xr(n,e,t,r,s){let i=Bc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,s,i||I.empty)))return!0;if(!i)return!1;let o=Gh(i),a=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Kc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Fe.paste=(n,e)=>{let t=e;if(n.composing&&!Nt)return;let r=gr?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&xr(n,Kc(r),r.getData("text/html"),s,t)?t.preventDefault():Yh(n,t)};class Jc{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Qh=Ze?"altKey":"ctrlKey";function Gc(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Qh]}$e.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(Cs(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof $?s.to-1:s.to))){if(r&&r.mightDrag)o=$.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(o=$.create(n.state.doc,u.posBefore))}}let a=(o||n.state.selection).content(),{dom:l,text:c,slice:d}=eo(n,a);(!t.dataTransfer.files.length||!De||wc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(gr?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",gr||t.dataTransfer.setData("text/plain",c),n.dragging=new Jc(d,Gc(n,t),o)};$e.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Fe.dragover=Fe.dragenter=(n,e)=>e.preventDefault();Fe.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(Cs(t));if(!s)return;let i=n.state.doc.resolve(s.pos),o=r&&r.slice;o?n.someProp("transformPasted",m=>{o=m(o,n)}):o=Bc(n,Kc(t.dataTransfer),gr?null:t.dataTransfer.getData("text/html"),!1,i);let a=!!(r&&Gc(n,t));if(n.someProp("handleDrop",m=>m(n,t,o||I.empty,a))){t.preventDefault();return}if(!o)return;t.preventDefault();let l=o?hc(n.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(a){let{node:m}=r;m?m.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(h))return;let p=c.doc.resolve(d);if(u&&$.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new $(p));else{let m=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((g,x,b,w)=>m=w),c.setSelection(Zi(n,p,c.doc.resolve(m)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};$e.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Tt(n)},20))};$e.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};$e.beforeinput=(n,e)=>{if(De&&Nt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,en(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Fe)$e[n]=Fe[n];function yr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class us{constructor(e,t){this.toDOM=e,this.spec=t||an,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new Ke(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof us&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&yr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Vt{constructor(e,t){this.attrs=e,this.spec=t||an}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Ke(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Vt&&yr(this.attrs,e.attrs)&&yr(this.spec,e.spec)}static is(e){return e.type instanceof Vt}destroy(){}}class so{constructor(e,t){this.attrs=e,this.spec=t||an}map(e,t,r,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let o=e.mapResult(t.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Ke(i.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(r)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof so&&yr(this.attrs,e.attrs)&&yr(this.spec,e.spec)}destroy(){}}class Ke{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Ke(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Ke(e,e,new us(t,r))}static inline(e,t,r,s){return new Ke(e,t,new Vt(r,s))}static node(e,t,r,s){return new Ke(e,t,new so(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Vt}get widget(){return this.type instanceof us}}const Nn=[],an={};class he{constructor(e,t){this.local=e.length?e:Nn,this.children=t.length?t:Nn}static create(e,t){return t.length?fs(t,e,0,an):Oe}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,i){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=t&&a.to>=e&&(!i||i(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,t-a,r,s+a,i)}}map(e,t,r){return this==Oe||e.maps.length==0?this:this.mapInner(e,t,0,0,r||an)}mapInner(e,t,r,s,i){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,s);l&&l.type.valid(t,l)?(o||(o=[])).push(l):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?Xh(this.children,o||[],e,t,r,s,i):o?new he(o.sort(ln),Nn):Oe}add(e,t){return t.length?this==Oe?he.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,i=0;e.forEach((a,l)=>{let c=l+r,d;if(d=Qc(t,a,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<l;)i+=3;s[i]==l?s[i+2]=s[i+2].addInner(a,d,c+1):s.splice(i,0,l,l+a.nodeSize,fs(d,a,c+1,an)),i+=3}});let o=Yc(i?Xc(t):t,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new he(o.length?this.local.concat(o).sort(ln):this.local,s||this.children)}remove(e){return e.length==0||this==Oe?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,a=r[i]+t,l=r[i+1]+t;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[i+2].removeInner(o,a+1);c!=Oe?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let a=0;a<s.length;a++)s[a].eq(o,t)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new he(s,r):Oe}forChild(e,t){if(this==Oe)return this;if(t.isLeaf)return he.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let i=e+1,o=i+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>i&&l.type instanceof Vt){let c=Math.max(i,l.from)-i,d=Math.min(o,l.to)-i;c<d&&(s||(s=[])).push(l.copy(c,d))}}if(s){let a=new he(s.sort(ln),Nn);return r?new Rt([a,r]):a}return r||Oe}eq(e){if(this==e)return!0;if(!(e instanceof he)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return io(this.localsInner(e))}localsInner(e){if(this==Oe)return Nn;if(e.inlineContent||!this.local.some(Vt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Vt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}he.empty=new he([],[]);he.removeOverlap=io;const Oe=he.empty;class Rt{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,an));return Rt.from(r)}forChild(e,t){if(t.isLeaf)return he.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=Oe&&(i instanceof Rt?r=r.concat(i.members):r.push(i))}return Rt.from(r)}eq(e){if(!(e instanceof Rt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let o=0;o<i.length;o++)t.push(i[o])}}return t?io(r?t:t.sort(ln)):Nn}static from(e){switch(e.length){case 0:return Oe;case 1:return e[0];default:return new Rt(e.every(t=>t instanceof he)?e:e.reduce((t,r)=>t.concat(r instanceof he?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Xh(n,e,t,r,s,i,o){let a=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,p,m,g)=>{let x=g-m-(p-h);for(let b=0;b<a.length;b+=3){let w=a[b+1];if(w<0||h>w+d-u)continue;let S=a[b]+d-u;p>=S?a[b+1]=h<=S?-2:-1:h>=d&&x&&(a[b]+=x,a[b+1]+=x)}u+=x}),d=t.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=t.map(n[c]+i),u=d-s;if(u<0||u>=r.content.size){l=!0;continue}let h=t.map(n[c+1]+i,-1),p=h-s,{index:m,offset:g}=r.content.findIndex(u),x=r.maybeChild(m);if(x&&g==u&&g+x.nodeSize==p){let b=a[c+2].mapInner(t,x,d+1,n[c]+i+1,o);b!=Oe?(a[c]=u,a[c+1]=p,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Zh(a,n,e,t,s,i,o),d=fs(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,h=0;u<d.children.length;u+=3){let p=d.children[u];for(;h<a.length&&a[h]<p;)h+=3;a.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new he(e.sort(ln),a)}function Yc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new Ke(s.from+e,s.to+e,s.type))}return t}function Zh(n,e,t,r,s,i,o){function a(l,c){for(let d=0;d<l.local.length;d++){let u=l.local[d].map(r,s,c);u?t.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<n.length;l+=3)n[l+1]==-1&&a(n[l+2],e[l]+i+1);return t}function Qc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let i=0,o;i<n.length;i++)(o=n[i])&&o.from>t&&o.to<r&&((s||(s=[])).push(o),n[i]=null);return s}function Xc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function fs(n,e,t,r){let s=[],i=!1;e.forEach((a,l)=>{let c=Qc(n,a,l+t);if(c){i=!0;let d=fs(c,a,t+l+1,r);d!=Oe&&s.push(l,l+a.nodeSize,d)}});let o=Yc(i?Xc(n):n,-t).sort(ln);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1));return o.length||s.length?new he(o,s):Oe}function ln(n,e){return n.from-e.from||n.to-e.to}function io(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,r.to),Ca(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),Ca(e,s,r.copy(i.from,r.to)));break}}}return e}function Ca(n,e,t){for(;e<n.length&&ln(t,n[e])>0;)e++;n.splice(e,0,t)}function Ks(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Oe&&e.push(r)}),n.cursorWrapper&&e.push(he.create(n.state.doc,[n.cursorWrapper.deco])),Rt.from(e)}const ep={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},tp=We&&Ft<=11;class np{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 rp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new np,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);We&&Ft<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),tp&&(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,ep)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ga(this.view)){if(this.suppressingSelectionUpdates)return Tt(this.view);if(We&&Ft<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&hn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=Pn(i))t.add(i);for(let i=e.anchorNode;i;i=Pn(i))if(t.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ga(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,a=!1,l=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],l);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(a=!0))}if(lt&&l.length){let d=l.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let p=h.parentNode;p&&p.nodeName=="LI"&&(!u||op(e,u)!=p)&&h.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ks(r)&&(c=Xi(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Tt(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),sp(e)),this.handleDOMChange(i,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Tt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(We&&Ft<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let o=s&&s.parentNode==e.target?Se(s)+1:0,a=r.localPosFromDOM(e.target,o,-1),l=i&&i.parentNode==e.target?Se(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAt
vendor: 91,998 bytes, lines 9-89
9End+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Na=new WeakMap,Ma=!1;function sp(n){if(!Na.has(n)&&(Na.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=lt,Ma)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."),Ma=!0}}function Ea(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return hn(o.node,o.offset,s,i)&&([t,r,s,i]=[s,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:i}}function ip(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Ea(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ea(n,t):null}function op(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function ap(n,e,t){let{node:r,fromOffset:s,toOffset:i,from:o,to:a}=n.docView.parseRange(e,t),l=n.domSelectionRange(),c,d=l.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],ks(l)||c.push({node:l.focusNode,offset:l.focusOffset})),De&&n.input.lastKeyCode===8)for(let x=i;x>s;x--){let b=r.childNodes[x-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){i=x;break}if(!w||w.size)break}let u=n.state.doc,h=n.someProp("domParser")||nr.fromSchema(n.state.schema),p=u.resolve(o),m=null,g=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:lp,context:p});if(c&&c[0].pos!=null){let x=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=x),m={anchor:x+o,head:b+o}}return{doc:g,sel:m,from:o,to:a}}function lp(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Be&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Be&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const cp=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function dp(n,e,t,r,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,E=Xi(n,M);if(E&&!n.state.selection.eq(E)){if(De&&Nt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",L=>L(n,en(13,"Enter"))))return;let D=n.state.tr.setSelection(E);M=="pointer"?D.setMeta("pointer",!0):M=="key"&&D.scrollIntoView(),i&&D.setMeta("composition",i),n.dispatch(D)}return}let o=n.state.doc.resolve(e),a=o.sharedDepth(t);e=o.before(a+1),t=n.state.doc.resolve(t).after(a+1);let l=n.state.selection,c=ap(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),h,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,p="end"):(h=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let m=hp(u.content,c.doc.content,c.from,h,p);if(m&&n.input.domChangeCount++,(Ln&&n.input.lastIOSEnter>Date.now()-225||Nt)&&s.some(M=>M.nodeType==1&&!cp.test(M.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",M=>M(n,en(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof z&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let M=Ta(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let E=n.state.tr.setSelection(M);i&&E.setMeta("composition",i),n.dispatch(E)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof z&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),We&&Ft<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)=="  "&&(m.start--,m.endA--,m.endB--);let g=c.doc.resolveNoCache(m.start-c.from),x=c.doc.resolveNoCache(m.endB-c.from),b=d.resolve(m.start),w=g.sameParent(x)&&g.parent.inlineContent&&b.end()>=m.endA,S;if((Ln&&n.input.lastIOSEnter>Date.now()-225&&(!w||s.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!w&&g.pos<c.doc.content.size&&(!g.sameParent(x)||!g.parent.inlineContent)&&!/\S/.test(c.doc.textBetween(g.pos,x.pos,"",""))&&(S=q.findFrom(c.doc.resolve(g.pos+1),1,!0))&&S.head>g.pos)&&n.someProp("handleKeyDown",M=>M(n,en(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&fp(d,m.start,m.endA,g,x)&&n.someProp("handleKeyDown",M=>M(n,en(8,"Backspace")))){Nt&&De&&n.domObserver.suppressSelectionUpdates();return}De&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Nt&&!w&&g.start()!=x.start()&&x.parentOffset==0&&g.depth==x.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,x=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(M){return M(n,en(13,"Enter"))})},20));let y=m.start,O=m.endA,k=M=>{let E=M||n.state.tr.replace(y,O,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let D=Ta(n,E.doc,c.sel);D&&!(De&&n.composing&&D.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(D.head==y||D.head==E.mapping.map(O)-1)||We&&D.empty&&D.head==y)&&E.setSelection(D)}return i&&E.setMeta("composition",i),E.scrollIntoView()},R;if(w){if(g.pos==x.pos){We&&Ft<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Tt(n),20));let M=k(n.state.tr.delete(y,O)),E=d.resolve(m.start).marksAcross(d.resolve(m.endA));E&&M.ensureMarks(E),n.dispatch(M)}else if(m.endA==m.endB&&(R=up(g.parent.content.cut(g.parentOffset,x.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let M=k(n.state.tr);R.type=="add"?M.addMark(y,O,R.mark):M.removeMark(y,O,R.mark),n.dispatch(M)}else if(g.parent.child(g.index()).isText&&g.index()==x.index()-(x.textOffset?0:1)){let M=g.parent.textBetween(g.parentOffset,x.parentOffset),E=()=>k(n.state.tr.insertText(M,y,O));n.someProp("handleTextInput",D=>D(n,y,O,M,E))||n.dispatch(E())}}else n.dispatch(k())}function Ta(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Zi(n,e.resolve(t.anchor),e.resolve(t.head))}function up(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,i=r,o,a,l;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(s.length==1&&i.length==0)a=s[0],o="add",l=d=>d.mark(a.addToSet(d.marks));else if(s.length==0&&i.length==1)a=i[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(C.from(c).eq(n))return{mark:a,type:o}}function fp(n,e,t,r,s){if(t-e<=s.pos-r.pos||Js(r,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!r.parent.isTextblock){let a=i.nodeAfter;return a!=null&&t==e+a.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=n.resolve(Js(i,!0,!0));return!o.parent.isTextblock||o.pos>t||Js(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Js(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function hp(n,e,t,r,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:o,b:a}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let l=Math.max(0,i-Math.min(o,a));r-=o+l-i}if(o<i&&n.size<e.size){let l=r<=i&&r>=o?i-r:0;i-=l,i&&i<e.size&&Oa(e.textBetween(i-1,i+1))&&(i+=l?1:-1),a=i+(a-o),o=i}else if(a<i){let l=r<=i&&r>=a?i-r:0;i-=l,i&&i<n.size&&Oa(n.textBetween(i-1,i+1))&&(i+=l?1:-1),o=i+(o-a),a=i}return{start:i,endA:o,endB:a}}function Oa(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Zc{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new jh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ra),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=ja(this),Da(this),this.nodeViews=Ia(this),this.docView=da(this.state.doc,Aa(this),Ks(this),this.dom,this),this.domObserver=new rp(this,(r,s,i,o)=>dp(this,r,s,i,o)),this.domObserver.start(),Ih(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ii(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ra),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Uc(this),o=!0),this.state=e;let a=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Ia(this);mp(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ii(this),this.editable=ja(this),Da(this);let l=Ks(this),c=Aa(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,l);(u||!e.selection.eq(s.selection))&&(o=!0);let h=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Kf(this);if(o){this.domObserver.stop();let p=u&&(We||De)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&pp(s.selection,e.selection);if(u){let m=De?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Uh(this)),(i||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=da(e.doc,c,l,this.dom,this)),m&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&xh(this))?Tt(this,p):(Rc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&Jf(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof $){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&sa(this,t.getBoundingClientRect(),e)}else sa(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new Jc(e.slice,e.move,s<0?void 0:$.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let a=this.directPlugins[o].props[e];if(a!=null&&(s=t?t(a):a))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let a=i[o].props[e];if(a!=null&&(s=t?t(a):a))return s}}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&&Gf(this.dom),Tt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return eh(this,e)}coordsAtPos(e,t=1){return Mc(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return ih(this,t||this.state,e)}pasteHTML(e,t){return xr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return xr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return eo(this,e)}destroy(){this.docView&&(Rh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ks(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Lf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Lh(this,e)}domSelectionRange(){let e=this.domSelection();return e?Be&&this.root.nodeType===11&&Vf(this.dom.ownerDocument)==this.dom&&ip(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Zc.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Aa(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ke.node(0,n.state.doc.content.size,e)]}function Da(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ke.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ja(n){return!n.someProp("editable",e=>e(n.state)===!1)}function pp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ia(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function mp(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function Ra(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ht={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:"'"},hs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},gp=typeof navigator<"u"&&/Mac/.test(navigator.platform),xp=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ce=0;Ce<10;Ce++)Ht[48+Ce]=Ht[96+Ce]=String(Ce);for(var Ce=1;Ce<=24;Ce++)Ht[Ce+111]="F"+Ce;for(var Ce=65;Ce<=90;Ce++)Ht[Ce]=String.fromCharCode(Ce+32),hs[Ce]=String.fromCharCode(Ce);for(var Gs in Ht)hs.hasOwnProperty(Gs)||(hs[Gs]=Ht[Gs]);function yp(n){var e=gp&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||xp&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?hs:Ht)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const bp=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),vp=typeof navigator<"u"&&/Win/.test(navigator.platform);function wp(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))bp?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),o&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function kp(n){let e=Object.create(null);for(let t in n)e[wp(t)]=n[t];return e}function Ys(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Sp(n){return new Me({props:{handleKeyDown:ed(n)}})}function ed(n){let e=kp(n);return function(t,r){let s=yp(r),i,o=e[Ys(s,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[Ys(s,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(vp&&r.ctrlKey&&r.altKey)&&(i=Ht[r.keyCode])&&i!=s){let a=e[Ys(i,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}const oo=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function td(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const nd=(n,e,t)=>{let r=td(n,t);if(!r)return!1;let s=ao(r);if(!s){let o=r.blockRange(),a=o&&Wn(o);return a==null?!1:(e&&e(n.tr.lift(o,a).scrollIntoView()),!0)}let i=s.nodeBefore;if(ud(n,s,e,-1))return!0;if(r.parent.content.size==0&&(Bn(i,"end")||$.isSelectable(i)))for(let o=r.depth;;o--){let a=vs(n.doc,r.before(o),r.after(o),I.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(Bn(i,"end")?q.findFrom(l.doc.resolve(l.mapping.map(s.pos,-1)),-1):$.create(l.doc,s.pos-i.nodeSize)),e(l.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},Cp=(n,e,t)=>{let r=td(n,t);if(!r)return!1;let s=ao(r);return s?rd(n,s,e):!1},Np=(n,e,t)=>{let r=id(n,t);if(!r)return!1;let s=lo(r);return s?rd(n,s,e):!1};function rd(n,e,t){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=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=vs(n.doc,i,l,I.empty);if(!c||c.from!=i||c instanceof ge&&c.slice.size>=l-i)return!1;if(t){let d=n.tr.step(c);d.setSelection(z.create(d.doc,i)),t(d.scrollIntoView())}return!0}function Bn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const sd=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=ao(r)}let o=i&&i.nodeBefore;return!o||!$.isSelectable(o)?!1:(e&&e(n.tr.setSelection($.create(n.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function ao(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function id(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const od=(n,e,t)=>{let r=id(n,t);if(!r)return!1;let s=lo(r);if(!s)return!1;let i=s.nodeAfter;if(ud(n,s,e,1))return!0;if(r.parent.content.size==0&&(Bn(i,"start")||$.isSelectable(i))){let o=vs(n.doc,r.before(),r.after(),I.empty);if(o&&o.slice.size<o.to-o.from){if(e){let a=n.tr.step(o);a.setSelection(Bn(i,"start")?q.findFrom(a.doc.resolve(a.mapping.map(s.pos)),1):$.create(a.doc,a.mapping.map(s.pos))),e(a.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},ad=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=lo(r)}let o=i&&i.nodeAfter;return!o||!$.isSelectable(o)?!1:(e&&e(n.tr.setSelection($.create(n.doc,i.pos)).scrollIntoView()),!0)};function lo(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Mp=(n,e)=>{let t=n.selection,r=t instanceof $,s;if(r){if(t.node.isTextblock||!qt(n.doc,t.from))return!1;s=t.from}else if(s=bs(n.doc,t.from,-1),s==null)return!1;if(e){let i=n.tr.join(s);r&&i.setSelection($.create(i.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Ep=(n,e)=>{let t=n.selection,r;if(t instanceof $){if(t.node.isTextblock||!qt(n.doc,t.to))return!1;r=t.to}else if(r=bs(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Tp=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),i=s&&Wn(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)},ld=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` 10`).scrollIntoView()),!0)};function co(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Op=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),i=t.indexAfter(-1),o=co(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let a=t.after(),l=n.tr.replaceWith(a,a,o.createAndFill());l.setSelection(q.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},cd=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof Je||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=co(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,a=n.tr.insert(o,i.createAndFill());a.setSelection(z.create(a.doc,o+1)),e(a.scrollIntoView())}return!0},dd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(Et(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),s=r&&Wn(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function Ap(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof $&&e.selection.node.isBlock)return!r.parentOffset||!Et(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,a,l=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),a=co(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),i.unshift(l&&a?{type:a}:null),o=p;break}else{if(p==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof z||e.selection instanceof Je)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=Et(d.doc,u,i.length,i);if(h||(i[0]=a?{type:a}:null,h=Et(d.doc,u,i.length,i)),!h)return!1;if(d.split(u,i.length,i),!l&&c&&r.node(o).type!=a){let p=d.mapping.map(r.before(o)),m=d.doc.resolve(p);a&&r.node(o-1).canReplaceWith(m.index(),m.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(o)),a)}return t&&t(d.scrollIntoView()),!0}}const Dp=Ap(),jp=(n,e)=>{let{$from:t,to:r}=n.selection,s,i=t.sharedDepth(r);return i==0?!1:(s=t.before(i),e&&e(n.tr.setSelection($.create(n.doc,s))),!0)};function Ip(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||qt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function ud(n,e,t,r){let s=e.nodeBefore,i=e.nodeAfter,o,a,l=s.type.spec.isolating||i.type.spec.isolating;if(!l&&Ip(n,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(a=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&a.matchType(o[0]||i.type).validEnd){if(t){let p=e.pos+i.nodeSize,m=C.empty;for(let b=o.length-1;b>=0;b--)m=C.from(o[b].create(null,m));m=C.from(s.copy(m));let g=n.tr.step(new xe(e.pos-1,p,e.pos,p,new I(m,1,0),o.length,!0)),x=g.doc.resolve(p+2*o.length);x.nodeAfter&&x.nodeAfter.type==s.type&&qt(g.doc,x.pos)&&g.join(x.pos),t(g.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&l?null:q.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&Wn(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&Bn(i,"start",!0)&&Bn(s,"end")){let p=s,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let g=i,x=1;for(;!g.isTextblock;g=g.firstChild)x++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(t){let b=C.empty;for(let S=m.length-1;S>=0;S--)b=C.from(m[S].copy(b));let w=n.tr.step(new xe(e.pos-m.length,e.pos+i.nodeSize,e.pos+x,e.pos+i.nodeSize-x,new I(b,m.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function fd(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(z.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const Rp=fd(-1),Pp=fd(1);function Lp(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),a=o&&Gi(o,n,e);return a?(r&&r(t.tr.wrap(o,a).scrollIntoView()),!0):!1}}function Pa(n,e=null){return function(t,r){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:a}}=t.selection.ranges[i];t.doc.nodesBetween(o,a,(l,c)=>{if(s)return!1;if(!(!l.isTextblock||l.hasMarkup(n,e)))if(l.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(r){let i=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[o];i.setBlockType(a,l,n,e)}r(i.scrollIntoView())}return!0}}function uo(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}uo(oo,nd,sd);uo(oo,od,ad);uo(ld,cd,dd,Dp);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Bp(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i);if(!o)return!1;let a=r?t.tr:null;return $p(a,o,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function $p(n,e,t,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=o.resolve(e.start-2);i=new is(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new is(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let a=Gi(i,t,r,e);return a?(n&&Fp(n,e,a,s,t),!0):!1}function Fp(n,e,t,r,s){let i=C.empty;for(let d=t.length-1;d>=0;d--)i=C.from(t[d].type.create(t[d].attrs,i));n.step(new xe(e.start-(r?2:0),e.end,e.start,e.end,new I(i,0,0),t.length,!0));let o=0;for(let d=0;d<t.length;d++)t[d].type==s&&(o=d+1);let a=t.length-o,l=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&Et(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return n}function zp(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?Vp(e,t,n,i):Wp(e,t,i):!0:!1}}function Vp(n,e,t,r){let s=n.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new xe(i-1,o,i,o,new I(C.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new is(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const a=Wn(r);if(a==null)return!1;s.lift(r,a);let l=s.doc.resolve(s.mapping.map(i,-1)-1);return qt(s.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&s.join(l.pos),e(s.scrollIntoView()),!0}function Wp(n,e,t){let r=n.tr,s=t.parent;for(let p=t.end,m=t.endIndex-1,g=t.startIndex;m>g;m--)p-=s.child(m).nodeSize,r.delete(p-1,p+1);let i=r.doc.resolve(t.start),o=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,o.content.append(l?C.empty:C.from(s))))return!1;let u=i.pos,h=u+o.nodeSize;return r.step(new xe(u-(a?1:0),h+(l?1:0),u+1,h-1,new I((a?C.empty:C.from(s.copy(C.empty))).append(l?C.empty:C.from(s.copy(C.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function Hp(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let a=i.parent,l=a.child(o-1);if(l.type!=n)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,d=C.from(c?n.create():null),u=new I(C.from(n.create(null,C.from(a.type.create(null,d)))),c?3:1,0),h=i.start,p=i.end;t(e.tr.step(new xe(h-(c?3:1),p,h,p,u,1,!0)).scrollIntoView())}return!0}}function Ns(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,i=t.storedMarks,t}}}class Ms{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:s}=t,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...d)=>{const u=l(...d)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,a=[],l=!!e,c=e||i.tr,d=()=>(!l&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),a.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(r).map(([h,p])=>[h,(...g)=>{const x=this.buildProps(c,t),b=p(...g)(x);return a.push(b),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,a={tr:e,editor:s,view:o,state:Ns({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...d)=>c(...d)(a)]))}};return a}}class qp{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(s=>s.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(s=>s!==t):delete this.callbacks[e]),this}once(e,t){const r=(...s)=>{this.off(e,r),t.apply(this,s)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function P(n,e,t){return n.config[e]===void 0&&n.parent?P(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?P(n.parent,e,t):null}):n.config[e]}function Es(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function hd(n){const e=[],{nodeExtensions:t,markExtensions:r}=Es(n),s=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage,extensions:s},l=P(o,"addGlobalAttributes",a);if(!l)return;l().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([h,p])=>{e.push({type:u,name:h,attribute:{...i,...p}})})})})}),s.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=P(o,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([d,u])=>{const h={...i,...u};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,e.push({type:o.name,name:d,attribute:h})})}),e}function be(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function Ne(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const a=i?String(i).split(" "):[],l=r[s]?r[s].split(" "):[],c=a.filter(d=>!l.includes(d));r[s]=[...l,...c].join(" ")}else if(s==="style"){const a=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;l.forEach(d=>{const[u,h]=d.split(":").map(p=>p.trim());c.set(u,h)}),a.forEach(d=>{const[u,h]=d.split(":").map(p=>p.trim());c.set(u,h)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=i}),r},{})}function Ri(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>Ne(t,r),{})}function pd(n){return typeof n=="function"}function _(n,e=void 0,...t){return pd(n)?e?n.bind(e)(...t):n(...t):n}function _p(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Up(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function La(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(t):Up(t.getAttribute(o.name));return a==null?i:{...i,[o.name]:a}},{});return{...r,...s}}}}function Ba(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&_p(t)?!1:t!=null))}function Kp(n,e){var t;const r=hd(n),{nodeExtensions:s,markExtensions:i}=Es(n),o=(t=s.find(c=>P(c,"topNode")))===null||t===void 0?void 0:t.name,a=Object.fromEntries(s.map(c=>{const d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((b,w)=>{const S=P(w,"extendNodeSchema",u);return{...b,...S?S(c):{}}},{}),p=Ba({...h,content:_(P(c,"content",u)),marks:_(P(c,"marks",u)),group:_(P(c,"group",u)),inline:_(P(c,"inline",u)),atom:_(P(c,"atom",u)),selectable:_(P(c,"selectable",u)),draggable:_(P(c,"draggable",u)),code:_(P(c,"code",u)),whitespace:_(P(c,"whitespace",u)),linebreakReplacement:_(P(c,"linebreakReplacement",u)),defining:_(P(c,"defining",u)),isolating:_(P(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var w;return[b.name,{default:(w=b?.attribute)===null||w===void 0?void 0:w.default}]}))}),m=_(P(c,"parseHTML",u));m&&(p.parseDOM=m.map(b=>La(b,d)));const g=P(c,"renderHTML",u);g&&(p.toDOM=b=>g({node:b,HTMLAttributes:Ri(b,d)}));const x=P(c,"renderText",u);return x&&(p.toText=x),[c.name,p]})),l=Object.fromEntries(i.map(c=>{const d=r.filter(x=>x.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((x,b)=>{const w=P(b,"extendMarkSchema",u);return{...x,...w?w(c):{}}},{}),p=Ba({...h,inclusive:_(P(c,"inclusive",u)),excludes:_(P(c,"excludes",u)),group:_(P(c,"group",u)),spanning:_(P(c,"spanning",u)),code:_(P(c,"code",u)),attrs:Object.fromEntries(d.map(x=>{var b;return[x.name,{default:(b=x?.attribute)===null||b===void 0?void 0:b.default}]}))}),m=_(P(c,"parseHTML",u));m&&(p.parseDOM=m.map(x=>La(x,d)));const g=P(c,"renderHTML",u);return g&&(p.toDOM=x=>g({mark:x,HTMLAttributes:Ri(x,d)})),[c.name,p]}));return new nc({topNode:o,nodes:a,marks:l})}function Qs(n,e){return e.nodes[n]||e.marks[n]||null}function $a(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function fo(n,e){const t=yn.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}const Jp=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,a)=>{var l,c;const d=((c=(l=s.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:s,pos:i,parent:o,index:a}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-i))}),t};function ho(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Er{constructor(e){this.find=e.find,this.handler=e.handler}}const Gp=(n,e)=>{if(ho(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function zr(n){var e;const{editor:t,from:r,to:s,text:i,rules:o,plugin:a}=n,{view:l}=t;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(h=>h.type.spec.code))return!1;let d=!1;const u=Jp(c)+i;return o.forEach(h=>{if(d)return;const p=Gp(u,h.find);if(!p)return;const m=l.state.tr,g=Ns({state:l.state,transaction:m}),x={from:r-(p[0].length-i.length),to:s},{commands:b,chain:w,can:S}=new Ms({editor:t,state:g});h.handler({state:g,range:x,match:p,commands:b,chain:w,can:S})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:s,text:i}),l.dispatch(m),d=!0)}),d}function Yp(n){const{editor:e,rules:t}=n,r=new Me({state:{init(){return null},apply(s,i,o){const a=s.getMeta(r);if(a)return a;const l=s.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=fo(C.from(d),o.schema);const{from:u}=l,h=u+d.length;zr({editor:e,from:u,to:h,text:d,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,a){return zr({editor:e,from:i,to:o,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&zr({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?zr({editor:e,from:o.pos,to:o.pos,text:` 11`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Qp(n){return Object.prototype.toString.call(n).slice(8,-1)}function Vr(n){return Qp(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Ts(n,e){const t={...n};return Vr(n)&&Vr(e)&&Object.keys(e).forEach(r=>{Vr(e[r])&&Vr(n[r])?t[r]=Ts(n[r],e[r]):t[r]=e[r]}),t}class bt{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=_(P(this,"addOptions",{name:this.name}))),this.storage=_(P(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new bt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Ts(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new bt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=_(P(t,"addOptions",{name:t.name})),t.storage=_(P(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>c?.type.name===t.name))return!1;const l=o.find(c=>c?.type.name===t.name);return l&&r.removeStoredMark(l),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}}function Xp(n){return typeof n=="number"}class Zp{constructor(e){this.find=e.find,this.handler=e.handler}}const em=(n,e,t)=>{if(ho(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=n,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function tm(n){const{editor:e,state:t,from:r,to:s,rule:i,pasteEvent:o,dropEvent:a}=n,{commands:l,chain:c,can:d}=new Ms({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,s,(p,m)=>{if(!p.isTextblock||p.type.spec.code)return;const g=Math.max(r,m),x=Math.min(s,m+p.content.size),b=p.textBetween(g-m,x-m,void 0,"");em(b,i.find,o).forEach(S=>{if(S.index===void 0)return;const y=g+S.index+1,O=y+S[0].length,k={from:t.tr.mapping.map(y),to:t.tr.mapping.map(O)},R=i.handler({state:t,range:k,match:S,commands:l,chain:c,can:d,pasteEvent:o,dropEvent:a});u.push(R)})}),u.every(p=>p!==null)}let Wr=null;const nm=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function rm(n){const{editor:e,rules:t}=n;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:d,from:u,to:h,rule:p,pasteEvt:m})=>{const g=d.tr,x=Ns({state:d,transaction:g});if(!(!tm({editor:e,state:x,from:Math.max(u-1,0),to:h.b-1,rule:p,pasteEvent:m,dropEvent:a})||!g.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(d=>new Me({view(u){const h=m=>{var g;r=!((g=u.dom.parentElement)===null||g===void 0)&&g.contains(m.target)?u.dom.parentElement:null,r&&(Wr=e)},p=()=>{Wr&&(Wr=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(u,h)=>{if(i=r===u.dom.parentElement,a=h,!i){const p=Wr;p&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(u,h)=>{var p;const m=(p=h.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return o=h,s=!!m?.includes("data-pm-slice"),!1}}},appendTransaction:(u,h,p)=>{const m=u[0],g=m.getMeta("uiEvent")==="paste"&&!s,x=m.getMeta("uiEvent")==="drop"&&!i,b=m.getMeta("applyPasteRules"),w=!!b;if(!g&&!x&&!w)return;if(w){let{text:O}=b;typeof O=="string"?O=O:O=fo(C.from(O),p.schema);const{from:k}=b,R=k+O.length,M=nm(O);return l({rule:d,state:p,from:k,to:{b:R},pasteEvt:M})}const S=h.doc.content.findDiffStart(p.doc.content),y=h.doc.content.findDiffEnd(p.doc.content);if(!(!Xp(S)||!y||S===y.b))return l({rule:d,state:p,from:S,to:y,pasteEvt:o})}}))}function sm(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class On{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=On.resolve(e),this.schema=Kp(this.extensions,t),this.setupExtensions()}static resolve(e){const t=On.sort(On.flatten(e)),r=sm(t.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},s=P(t,"addExtensions",r);return s?[t,...this.flatten(s())]:t}).flat(10)}static sort(e){return e.sort((r,s)=>{const i=P(r,"priority")||100,o=P(s,"priority")||100;return i>o?-1:i<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Qs(t.name,this.schema)},s=P(t,"addCommands",r);return s?{...e,...s()}:e},{})}get plugins(){const{editor:e}=this,t=On.sort([...this.extensions].reverse()),r=[],s=[],i=t.map(o=>{const a={name:o.name,options:o.options,storage:o.storage,editor:e,type:Qs(o.name,this.schema)},l=[],c=P(o,"addKeyboardShortcuts",a);let d={};if(o.type==="mark"&&P(o,"exitable",a)&&(d.ArrowRight=()=>bt.handleExit({editor:e,mark:o})),c){const g=Object.fromEntries(Object.entries(c()).map(([x,b])=>[x,()=>b({editor:e})]));d={...d,...g}}const u=Sp(d);l.push(u);const h=P(o,"addInputRules",a);$a(o,e.options.enableInputRules)&&h&&r.push(...h());const p=P(o,"addPasteRules",a);$a(o,e.options.enablePasteRules)&&p&&s.push(...p());const m=P(o,"addProseMirrorPlugins",a);if(m){const g=m();l.push(...g)}return l}).flat();return[Yp({editor:e,rules:r}),...rm({editor:e,rules:s}),...i]}get attributes(){return hd(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Es(this.extensions);return Object.fromEntries(t.filter(r=>!!P(r,"addNodeView")).map(r=>{const s=this.attributes.filter(l=>l.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:be(r.name,this.schema)},o=P(r,"addNodeView",i);if(!o)return[];const a=(l,c,d,u,h)=>{const p=Ri(l,s);return o()({node:l,view:c,getPos:d,decorations:u,innerDecorations:h,editor:e,extension:r,HTMLAttributes:p})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Qs(e.name,this.schema)};e.type==="mark"&&(!((t=_(P(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const s=P(e,"onBeforeCreate",r),i=P(e,"onCreate",r),o=P(e,"onUpdate",r),a=P(e,"onSelectionUpdate",r),l=P(e,"onTransaction",r),c=P(e,"onFocus",r),d=P(e,"onBlur",r),u=P(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}}class me{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=_(P(this,"addOptions",{name:this.name}))),this.storage=_(P(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new me(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Ts(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new me({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=_(P(t,"addOptions",{name:t.name})),t.storage=_(P(t,"addStorage",{name:t.name,options:t.options})),t}}function md(n,e,t){const{from:r,to:s}=e,{blockSeparator:i=` 12 13`,textSerializers:o={}}=t||{};let a="";return n.nodesBetween(r,s,(l,c,d,u)=>{var h;l.isBlock&&c>r&&(a+=i);const p=o?.[l.type.name];if(p)return d&&(a+=p({node:l,pos:c,parent:d,index:u,range:e})),!1;l.isText&&(a+=(h=l?.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,s-c))}),a}function gd(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const im=me.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Me({key:new Ye("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(d=>d.$from.pos)),a=Math.max(...i.map(d=>d.$to.pos)),l=gd(t);return md(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),om=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),am=(n=!1)=>({commands:e})=>e.setContent("",n),lm=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:i,$to:o})=>{n.doc.nodesBetween(i.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(l)),h=c.resolve(d.map(l+a.nodeSize)),p=u.blockRange(h);if(!p)return;const m=Wn(p);if(a.type.isTextblock){const{defaultType:g}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(p.start,g)}(m||m===0)&&e.lift(p,m)})}),!0},cm=n=>e=>n(e),dm=()=>({state:n,dispatch:e})=>cd(n,e),um=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,i=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new z(r.doc.resolve(o-1))),!0},fm=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const a=s.before(i),l=s.after(i);n.delete(a,l).scrollIntoView()}return!0}return!1},hm=n=>({tr:e,state:t,dispatch:r})=>{const s=be(n,t.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const l=i.before(o),c=i.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},pm=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},mm=()=>({state:n,dispatch:e})=>oo(n,e),gm=()=>({commands:n})=>n.keyboardShortcut("Enter"),xm=()=>({state:n,dispatch:e})=>Op(n,e);function ps(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:ho(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function xd(n,e,t={}){return n.find(r=>r.type===e&&ps(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function Fa(n,e,t={}){return!!xd(n,e,t)}function po(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(t=t||((r=s.node.marks[0])===null||r===void 0?void 0:r.attrs),!xd([...s.node.marks],e,t)))return;let o=s.index,a=n.start()+s.offset,l=o+1,c=a+s.node.nodeSize;for(;o>0&&Fa([...n.parent.child(o-1).marks],e,t);)o-=1,a-=n.parent.child(o).nodeSize;for(;l<n.parent.childCount&&Fa([...n.parent.child(l).marks],e,t);)c+=n.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function Ut(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const ym=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const i=Ut(n,r.schema),{doc:o,selection:a}=t,{$from:l,from:c,to:d}=a;if(s){const u=po(l,i,e);if(u&&u.from<=c&&u.to>=d){const h=z.create(o,u.from,u.to);t.setSelection(h)}}return!0},bm=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function mo(n){return n instanceof z}function Mt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function yd(n,e=null){if(!e)return null;const t=q.atStart(n),r=q.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,i=r.to;return e==="all"?z.create(n,Mt(0,s,i),Mt(n.content.size,s,i)):z.create(n,Mt(e,s,i),Mt(e,s,i))}function vm(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function go(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const wm=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(go()||vm())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!mo(t.state.selection))return o(),!0;const a=yd(s.doc,n)||t.state.selection,l=t.state.selection.eq(a);return i&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},km=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),Sm=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),bd=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&bd(r)}return n};function Hr(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return bd(t)}function br(n,e,t){if(n instanceof $t||n instanceof C)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return C.fromArray(n.map(a=>e.nodeFromJSON(a)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),br("",e,t)}if(s){if(t.errorOnInvalidContent){let o=!1,a="";const l=new nc({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(t.slice?nr.fromSchema(l).parseSlice(Hr(n),t.parseOptions):nr.fromSchema(l).parse(Hr(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const i=nr.fromSchema(e);return t.slice?i.parseSlice(Hr(n),t.parseOptions).content:i.parse(Hr(n),t.parseOptions)}return br("",e,t)}function Cm(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof ge||s instanceof xe))return;const i=n.mapping.maps[r];let o=0;i.forEach((a,l,c,d)=>{o===0&&(o=d)}),n.setSelection(q.near(n.doc.resolve(o),t))}const Nm=n=>!("type"in n),Mm=(n,e,t)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;const l=x=>{i.emit("contentError",{editor:i,error:x,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{br(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(x){l(x)}try{a=br(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:i.options.enableContentCheck})}catch(x){return l(x),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,p=!0;if((Nm(a)?a:[a]).forEach(x=>{x.check(),h=h?x.isText&&x.marks.length===0:!1,p=p?x.isBlock:!1}),d===u&&p){const{parent:x}=r.doc.resolve(d);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(d-=1,u+=1)}let g;if(h){if(Array.isArray(e))g=e.map(x=>x.text||"").join("");else if(e instanceof C){let x="";e.forEach(b=>{b.text&&(x+=b.text)}),g=x}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,d,u)}else g=a,r.replaceWith(d,u,g);t.updateSelection&&Cm(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:g})}return!0},Em=()=>({state:n,dispatch:e})=>Mp(n,e),Tm=()=>({state:n,dispatch:e})=>Ep(n,e),Om=()=>({state:n,dispatch:e})=>nd(n,e),Am=()=>({state:n,dispatch:e})=>od(n,e),Dm=()=>({state:n,dispatch:e,tr:t})=>{try{const r=bs(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},jm=()=>({state:n,dispatch:e,tr:t})=>{try{const r=bs(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Im=()=>({state:n,dispatch:e})=>Cp(n,e),Rm=()=>({state:n,dispatch:e})=>Np(n,e);function vd(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Pm(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,i,o;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))go()||vd()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}const Lm=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const i=Pm(n).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,a))});return l?.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function vr(n,e,t={}){const{from:r,to:s,empty:i}=n.selection,o=e?be(e,n.schema):null,a=[];n.doc.nodesBetween(r,s,(u,h)=>{if(u.isText)return;const p=Math.max(r,h),m=Math.min(s,h+u.nodeSize);a.push({node:u,from:p,to:m})});const l=s-r,c=a.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>ps(u.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=l}const Bm=(n,e={})=>({state:t,dispatch:r})=>{const s=be(n,t.schema);return vr(t,s,e)?Tp(t,r):!1},$m=()=>({state:n,dispatch:e})=>dd(n,e),Fm=n=>({state:e,dispatch:t})=>{const r=be(n,e.schema);return zp(r)(e,t)},zm=()=>({state:n,dispatch:e})=>ld(n,e);function Os(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function za(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}const Vm=(n,e)=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const a=Os(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(i=be(n,r.schema)),a==="mark"&&(o=Ut(n,r.schema)),s&&t.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,d)=>{i&&i===c.type&&t.setNodeMarkup(d,void 0,za(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(za(u.attrs,e)))})})}),!0):!1},Wm=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Hm=()=>({tr:n,dispatch:e})=>{if(e){const t=new Je(n.doc);n.setSelection(t)}return!0},qm=()=>({state:n,dispatch:e})=>sd(n,e),_m=()=>({state:n,dispatch:e})=>ad(n,e),Um=()=>({state:n,dispatch:e})=>jp(n,e),Km=()=>({state:n,dispatch:e})=>Pp(n,e),Jm=()=>({state:n,dispatch:e})=>Rp(n,e);function Pi(n,e,t={},r={}){return br(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const Gm=(n,e=!1,t={},r={})=>({editor:s,tr:i,dispatch:o,commands:a})=>{var l,c;const{doc:d}=i;if(t.preserveWhitespace!=="full"){const u=Pi(n,s.schema,t,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:s.options.enableContentCheck});return o&&i.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return o&&i.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:d.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck})};function wd(n,e){const t=Ut(e,n.schema),{from:r,to:s,empty:i}=n.selection,o=[];i?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function Ym(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Qm(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function xo(n){return e=>Qm(e.$from,n)}function Xm(n,e){const t={from:0,to:n.content.size};return md(n,t,e)}function Zm(n,e){const t=be(e,n.schema),{from:r,to:s}=n.selection,i=[];n.doc.nodesBetween(r,s,a=>{i.push(a)});const o=i.reverse().find(a=>a.type.name===t.name);return o?{...o.attrs}:{}}function eg(n,e){const t=Os(typeof e=="string"?e:e.name,n.schema);return t==="node"?Zm(n,e):t==="mark"?wd(n,e):{}}function kd(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const i=t.resolve(n),o=po(i,s.type);o&&r.push({mark:s,...o})}):t.nodesBetween(n,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}function Xr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}function Li(n,e,t={}){const{empty:r,ranges:s}=n.selection,i=e?Ut(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>ps(u.attrs,t,{strict:!1}));let o=0;const a=[];if(s.forEach(({$from:u,$to:h})=>{const p=u.pos,m=h.pos;n.doc.nodesBetween(p,m,(g,x)=>{if(!g.isText&&!g.marks.length)return;const b=Math.max(p,x),w=Math.min(m,x+g.nodeSize),S=w-b;o+=S,a.push(...g.marks.map(y=>({mark:y,from:b,to:w})))})}),o===0)return!1;const l=a.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>ps(u.mark.attrs,t,{strict:!1})).reduce((u,h)=>u+h.to-h.from,0),c=a.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,h)=>u+h.to-h.from,0);return(l>0?l+c:l)>=o}function tg(n,e,t={}){if(!e)return vr(n,null,t)||Li(n,null,t);const r=Os(e,n.schema);return r==="node"?vr(n,e,t):r==="mark"?Li(n,e,t):!1}function Va(n,e){const{nodeExtensions:t}=Es(e),r=t.find(o=>o.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=_(P(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function As(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(i=>{s!==!1&&(As(i,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function Sd(n){return n instanceof $}function ng(n,e,t){const s=n.state.doc.content.size,i=Mt(e,0,s),o=Mt(t,0,s),a=n.coordsAtPos(i),l=n.coordsAtPos(o,-1),c=Math.min(a.top,l.top),d=Math.max(a.bottom,l.bottom),u=Math.min(a.left,l.left),h=Math.max(a.right,l.right),p=h-u,m=d-c,b={top:c,bottom:d,left:u,right:h,width:p,height:m,x:u,y:c};return{...b,toJSON:()=>b}}function rg(n,e,t){var r;const{selection:s}=e;let i=null;if(mo(s)&&(i=s.$cursor),i){const a=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(a)||!a.some(l=>l.type.excludes(t))}const{ranges:o}=s;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,l.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){const p=!h||h.type.allowsMarkType(t),m=!!t.isInSet(d.marks)||!d.marks.some(g=>g.type.excludes(t));c=p&&m}return!c}),c})}const sg=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=t,{empty:o,ranges:a}=i,l=Ut(n,r.schema);if(s)if(o){const c=wd(r,l);t.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,p)=>{const m=Math.max(p,d),g=Math.min(p+h.nodeSize,u);h.marks.find(b=>b.type===l)?h.marks.forEach(b=>{l===b.type&&t.addMark(m,g,l.create({...b.attrs,...e}))}):t.addMark(m,g,l.create(e))})});return rg(r,t,l)},ig=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),og=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const i=be(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:a})=>Pa(i,{...o,...e})(t)?!0:a.clearNodes()).command(({state:a})=>Pa(i,{...o,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ag=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=Mt(n,0,r.content.size),i=$.create(r,s);e.setSelection(i)}return!0},lg=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:i}=typeof n=="number"?{from:n,to:n}:n,o=z.atStart(r).from,a=z.atEnd(r).to,l=Mt(s,o,a),c=Mt(i,o,a),d=z.create(r,l,c);e.setSelection(d)}return!0},cg=n=>({state:e,dispatch:t})=>{const r=be(n,e.schema);return Hp(r)(e,t)};function Wa(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e?.includes(s.type.name));n.tr.ensureMarks(r)}}const dg=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:a,$to:l}=i,c=s.extensionManager.attributes,d=Xr(c,a.node().type.name,a.node().attrs);if(i instanceof $&&i.node.isBlock)return!a.parentOffset||!Et(o,a.pos)?!1:(r&&(n&&Wa(t,s.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:Ym(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=u&&h?[{type:h,attrs:d}]:void 0,m=Et(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&Et(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(m=!0,p=h?[{type:h,attrs:d}]:void 0),r){if(m&&(i instanceof z&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),h&&!u&&!a.parentOffset&&a.parent.type!==h)){const g=e.mapping.map(a.before()),x=e.doc.resolve(g);a.node(-1).canReplaceWith(x.index(),x.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}n&&Wa(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},ug=(n,e={})=>({tr:t,state:r,dispatch:s,editor:i})=>{var o;const a=be(n,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const u=l.node(-1);if(u.type!==a)return!1;const h=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let b=C.empty;const w=l.index(-1)?1:l.index(-2)?2:3;for(let M=l.depth-w;M>=l.depth-3;M-=1)b=C.from(l.node(M).copy(b));const S=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,y={...Xr(h,l.node().type.name,l.node().attrs),...e},O=((o=a.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(y))||void 0;b=b.append(C.from(a.createAndFill(null,O)||void 0));const k=l.before(l.depth-(w-1));t.replace(k,l.after(-S),new I(b,4-w,0));let R=-1;t.doc.nodesBetween(k,t.doc.content.size,(M,E)=>{if(R>-1)return!1;M.isTextblock&&M.content.size===0&&(R=E+1)}),R>-1&&t.setSelection(z.near(t.doc.resolve(R))),t.scrollIntoView()}return!0}const p=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,m={...Xr(h,u.type.name,u.attrs),...e},g={...Xr(h,l.node().type.name,l.node().attrs),...e};t.delete(l.pos,c.pos);const x=p?[{type:a,attrs:m},{type:p,attrs:g}]:[{type:a,attrs:m}];if(!Et(t.doc,l.pos,2))return!1;if(s){const{selection:b,storedMarks:w}=r,{splittableMarks:S}=i.extensionManager,y=w||b.$to.parentOffset&&b.$from.marks();if(t.split(l.pos,2,x).scrollIntoView(),!y||!s)return!0;const O=y.filter(k=>S.includes(k.type.name));t.ensureMarks(O)}return!0},Xs=(n,e)=>{const t=xo(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&qt(n.doc,t.pos)&&n.join(t.pos),!0},Zs=(n,e)=>{const t=xo(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&qt(n.doc,r)&&n.join(r),!0},fg=(n,e,t,r={})=>({editor:s,tr:i,state:o,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:u,splittableMarks:h}=s.extensionManager,p=be(n,o.schema),m=be(e,o.schema),{selection:g,storedMarks:x}=o,{$from:b,$to:w}=g,S=b.blockRange(w),y=x||g.$to.parentOffset&&g.$from.marks();if(!S)return!1;const O=xo(k=>Va(k.type.name,u))(g);if(S.depth>=1&&O&&S.depth-O.depth<=1){if(O.node.type===p)return c.liftListItem(m);if(Va(O.node.type.name,u)&&p.validContent(O.node.content)&&a)return l().command(()=>(i.setNodeMarkup(O.pos,p),!0)).command(()=>Xs(i,p)).command(()=>Zs(i,p)).run()}return!t||!y||!a?l().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>Xs(i,p)).command(()=>Zs(i,p)).run():l().command(()=>{const k=d().wrapInList(p,r),R=y.filter(M=>h.includes(M.type.name));return i.ensureMarks(R),k?!0:c.clearNodes()}).wrapInList(p,r).command(()=>Xs(i,p)).command(()=>Zs(i,p)).run()},hg=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=t,o=Ut(n,r.schema);return Li(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},pg=(n,e,t={})=>({state:r,commands:s})=>{const i=be(n,r.schema),o=be(e,r.schema),a=vr(r,i,t);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?s.setNode(o,l):s.setNode(i,{...l,...t})},mg=(n,e={})=>({state:t,commands:r})=>{const s=be(n,t.schema);return vr(t,s,e)?r.lift(s):r.wrapIn(s,e)},gg=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let i;if(s.spec.isInputRules&&(i=s.getState(n))){if(e){const o=n.tr,a=i.transform;for(let l=a.steps.length-1;l>=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(i.text){const l=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,n.schema.text(i.text,l))}else o.delete(i.from,i.to)}return!0}}return!1},xg=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},yg=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=t,l=Ut(n,r.schema),{$from:c,empty:d,ranges:u}=a;if(!s)return!0;if(d&&o){let{from:h,to:p}=a;const m=(i=c.marks().find(x=>x.type===l))===null||i===void 0?void 0:i.attrs,g=po(c,l,m);g&&(h=g.from,p=g.to),t.removeMark(h,p,l)}else u.forEach(h=>{t.removeMark(h.$from.pos,h.$to.pos,l)});return t.removeStoredMark(l),!0},bg=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const a=Os(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(i=be(n,r.schema)),a==="mark"&&(o=Ut(n,r.schema)),s&&t.selection.ranges.forEach(l=>{const c=l.$from.pos,d=l.$to.pos;let u,h,p,m;t.selection.empty?r.doc.nodesBetween(c,d,(g,x)=>{i&&i===g.type&&(p=Math.max(x,c),m=Math.min(x+g.nodeSize,d),u=x,h=g)}):r.doc.nodesBetween(c,d,(g,x)=>{x<c&&i&&i===g.type&&(p=Math.max(x,c),m=Math.min(x+g.nodeSize,d),u=x,h=g),x>=c&&x<=d&&(i&&i===g.type&&t.setNodeMarkup(x,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type){const w=Math.max(x,c),S=Math.min(x+g.nodeSize,d);t.addMark(w,S,o.create({...b.attrs,...e}))}}))}),h&&(u!==void 0&&t.setNodeMarkup(u,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&t.addMark(p,m,o.create({...g.attrs,...e}))}))}),!0):!1},vg=(n,e={})=>({state:t,dispatch:r})=>{const s=be(n,t.schema);return Lp(s,e)(t,r)},wg=(n,e={})=>({state:t,dispatch:r})=>{const s=be(n,t.schema);return Bp(s,e)(t,r)};var kg=Object.freeze({__proto__:null,blur:om,clearContent:am,clearNodes:lm,command:cm,createParagraphNear:dm,cut:um,deleteCurrentNode:fm,deleteNode:hm,deleteRange:pm,deleteSelection:mm,enter:gm,exitCode:xm,extendMarkRange:ym,first:bm,focus:wm,forEach:km,insertContent:Sm,insertContentAt:Mm,joinBackward:Om,joinDown:Tm,joinForward:Am,joinItemBackward:Dm,joinItemForward:jm,joinTextblockBackward:Im,joinTextblockForward:Rm,joinUp:Em,keyboardShortcut:Lm,lift:Bm,liftEmptyBlock:$m,liftListItem:Fm,newlineInCode:zm,resetAttributes:Vm,scrollIntoView:Wm,selectAll:Hm,selectNodeBackward:qm,selectNodeForward:_m,selectParentNode:Um,selectTextblockEnd:Km,selectTextblockStart:Jm,setContent:Gm,setMark:sg,setMeta:ig,setNode:og,setNodeSelection:ag,setTextSelection:lg,sinkListItem:cg,splitBlock:dg,splitListItem:ug,toggleList:fg,toggleMark:hg,toggleNode:pg,toggleWrap:mg,undoInputRule:gg,unsetAllMarks:xg,unsetMark:yg,updateAttributes:bg,wrapIn:vg,wrapInList:wg});const Sg=me.create({name:"commands",addCommands(){return{...kg}}}),Cg=me.create({name:"drop",addProseMirrorPlugins(){return[new Me({key:new Ye("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Ng=me.create({name:"editable",addProseMirrorPlugins(){return[new Me({key:new Ye("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Mg=new Ye("focusEvents"),Eg=me.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new Me({key:Mg,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Tg=me.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:d,$anchor:u}=l,{pos:h,parent:p}=u,m=u.parent.isTextblock&&h>0?a.doc.resolve(h-1):u,g=m.parent.type.spec.isolating,x=u.pos-u.parentOffset,b=g&&m.parent.childCount===1?x===u.pos:q.atStart(c).from===h;return!d||!p.type.isTextblock||p.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:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return go()||vd()?i:s},addProseMirrorPlugins(){return[new Me({key:new Ye("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),s=n.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:a}=e.selection,l=q.atStart(e.doc).from,c=q.atEnd(e.doc).to;if(i||!(o===l&&a===c)||!As(t.doc))return;const h=t.tr,p=Ns({state:t,transaction:h}),{commands:m}=new Ms({editor:this.editor,state:p});if(m.clearNodes(),!!h.steps.length)return h}})]}}),Og=me.create({name:"paste",addProseMirrorPlugins(){return[new Me({key:new Ye("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Ag=me.create({name:"tabindex",addProseMirrorPlugins(){return[new Me({key:new Ye("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class tn{get name(){return this.node.type.name}constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}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!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You canât set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new tn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new tn(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 tn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,o=this.pos+r+(i?0:1),a=this.resolvedPos.doc.resolve(o);if(!s&&a.depth<=this.depth)return;const l=new tn(a,this.editor,s,s?t:null);s&&(l.actualDepth=this.depth+1),e.push(new tn(a,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const i=s.node.attrs,o=Object.keys(t);for(let a=0;a<o.length;a+=1){const l=o[a];if(i[l]!==t[l])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(t);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(l=>t[l]===o.node.attrs[l])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const Dg=`.ProseMirror { 14 position: relative; 15} 16 17.ProseMirror { 18 word-wrap: break-word; 19 white-space: pre-wrap; 20 white-space: break-spaces; 21 -webkit-font-variant-ligatures: none; 22 font-variant-ligatures: none; 23 font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ 24} 25 26.ProseMirror [contenteditable="false"] { 27 white-space: normal; 28} 29 30.ProseMirror [contenteditable="false"] [contenteditable="true"] { 31 white-space: pre-wrap; 32} 33 34.ProseMirror pre { 35 white-space: pre-wrap; 36} 37 38img.ProseMirror-separator { 39 display: inline !important; 40 border: none !important; 41 margin: 0 !important; 42 width: 0 !important; 43 height: 0 !important; 44} 45 46.ProseMirror-gapcursor { 47 display: none; 48 pointer-events: none; 49 position: absolute; 50 margin: 0; 51} 52 53.ProseMirror-gapcursor:after { 54 content: ""; 55 display: block; 56 position: absolute; 57 top: -2px; 58 width: 20px; 59 border-top: 1px solid black; 60 animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; 61} 62 63@keyframes ProseMirror-cursor-blink { 64 to { 65 visibility: hidden; 66 } 67} 68 69.ProseMirror-hideselection *::selection { 70 background: transparent; 71} 72 73.ProseMirror-hideselection *::-moz-selection { 74 background: transparent; 75} 76 77.ProseMirror-hideselection * { 78 caret-color: transparent; 79} 80 81.ProseMirror-focused .ProseMirror-gapcursor { 82 display: block; 83} 84 85.tippy-box[data-animation=fade][data-state=hidden] { 86 opacity: 0 87}`;function jg(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}class Ig extends qp{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:s})=>this.options.onDrop(t,r,s)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=jg(Dg,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=pd(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;r=r.filter(a=>!a.key.startsWith(o))}),t.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[Ng,im.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),Sg,Eg,Tg,Ag,Cg,Og].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new On(s,this)}createCommandManager(){this.commandManager=new Ms({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=Pi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(o){if(!(o instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(o.message))throw o;this.emit("contentError",{editor:this,error:o,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),t=Pi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=yd(t,this.options.autofocus);this.view=new Zc(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:Tn.create({doc:t,selection:r||void 0})});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(o)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=e.getMeta("focus"),i=e.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return eg(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,s=typeof e=="string"?t:e;return tg(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return fo(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=` 88 89`,textSerializers:r={}}=e||{};return Xm(this.state.doc,{blockSeparator:t,textSerializers:{...gd(this.schema),...r}})}get isEmpty(){return As(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new tn(t,this)}get $doc(){return this.$pos(0)}}function mn(n){return new Er({find:n.find,handler:({state:e,range:t,match:r})=>{const s=_(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),c=t.from+a.indexOf(o),d=c+o.length;if(kd(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>c).length)return null;d<t.to&&i.delete(d,t.to),c>t.from&&i.delete(t.from+l,c);const h=t.from+l+o.length;i.addMark(t.from+l,h,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}function Rg(n){return new Er({find:n.find,handler:({state:e,range:t,match:r})=>{const s=_(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let a=t.to;const l=n.type.create(s);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];i.insertText(u,o+r[0].length-1),i.replaceWith(d,a,l)}else if(r[0]){const c=n.type.isInline?o:o-1;i.insert(c,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(a))}i.scrollIntoView()}})}function Bi(n){return new Er({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=_(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function le(n){return new Er({find:n.find,handler:({state:e,range:t,match:r})=>{let s=n.replace,i=t.from;const o=t.to;if(r[1]){const a=r[0].lastIndexOf(r[1]);s+=r[0].slice(a+r[1].length),i+=a;const l=i-o;l>0&&(s=r[0].slice(a-l,a)+s,i=o)}e.tr.insertText(s,i,o)}})}function wr(n){return new Er({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=_(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),c=l&&Gi(l,n.type,i);if(!c)return null;if(o.wrap(l,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:h}=e,{splittableMarks:p}=n.editor.extensionManager,m=h||u.$to.parentOffset&&u.$from.marks();if(m){const g=m.filter(x=>p.includes(x.type.name));o.ensureMarks(g)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,i).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&qt(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&o.join(t.from-1)}})}class _e{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=_(P(this,"addOptions",{name:this.name}))),this.storage=_(P(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new _e(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Ts(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new _e(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=_(P(t,"addOptions",{name:t.name})),t.storage=_(P(t,"addStorage",{name:t.name,options:t.options})),t}}function gn(n){return new Zp({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=_(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let c=t.to;if(a){const d=l.search(/\S/),u=t.from+l.indexOf(a),h=u+a.length;if(kd(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(x=>x===n.type&&x!==m.mark.type)).filter(m=>m.to>u).length)return null;h<t.to&&o.delete(h,t.to),u>
89t.from&&o.delete(t.from+d,u),c=t.from+d+a.length,o.addMark(t.from+d,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}var He="top",rt="bottom",st="right",qe="left",yo="auto",Tr=[He,rt,st,qe],$n="start",kr="end",Pg="clippingParents",Cd="viewport",_n="popper",Lg="reference",Ha=Tr.reduce(function(n,e){return n.concat([e+"-"+$n,e+"-"+kr])},[]),Nd=[].concat(Tr,[yo]).reduce(function(n,e){return n.concat([e,e+"-"+$n,e+"-"+kr])},[]),Bg="beforeRead",$g="read",Fg="afterRead",zg="beforeMain",Vg="main",Wg="afterMain",Hg="beforeWrite",qg="write",_g="afterWrite",Ug=[Bg,$g,Fg,zg,Vg,Wg,Hg,qg,_g];function vt(n){return n?(n.nodeName||"").toLowerCase():null}function Ge(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var e=n.ownerDocument;return e&&e.defaultView||window}return n}function xn(n){var e=Ge(n).Element;return n instanceof e||n instanceof Element}function nt(n){var e=Ge(n).HTMLElement;return n instanceof e||n instanceof HTMLElement}function bo(n){if(typeof ShadowRoot>"u")return!1;var e=Ge(n).ShadowRoot;return n instanceof e||n instanceof ShadowRoot}function Kg(n){var e=n.state;Object.keys(e.elements).forEach(function(t){var r=e.styles[t]||{},s=e.attributes[t]||{},i=e.elements[t];!nt(i)||!vt(i)||(Object.assign(i.style,r),Object.keys(s).forEach(function(o){var a=s[o];a===!1?i.removeAttribute(o):i.setAttribute(o,a===!0?"":a)}))})}function Jg(n){var e=n.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(r){var s=e.elements[r],i=e.attributes[r]||{},o=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:t[r]),a=o.reduce(function(l,c){return l[c]="",l},{});
vendor: 18,167 bytes, line 89
89!nt(s)||!vt(s)||(Object.assign(s.style,a),Object.keys(i).forEach(function(l){s.removeAttribute(l)}))})}}const Md={name:"applyStyles",enabled:!0,phase:"write",fn:Kg,effect:Jg,requires:["computeStyles"]};function gt(n){return n.split("-")[0]}var cn=Math.max,ms=Math.min,Fn=Math.round;function $i(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Ed(){return!/^((?!chrome|android).)*safari/i.test($i())}function zn(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var r=n.getBoundingClientRect(),s=1,i=1;e&&nt(n)&&(s=n.offsetWidth>0&&Fn(r.width)/n.offsetWidth||1,i=n.offsetHeight>0&&Fn(r.height)/n.offsetHeight||1);var o=xn(n)?Ge(n):window,a=o.visualViewport,l=!Ed()&&t,c=(r.left+(l&&a?a.offsetLeft:0))/s,d=(r.top+(l&&a?a.offsetTop:0))/i,u=r.width/s,h=r.height/i;return{width:u,height:h,top:d,right:c+u,bottom:d+h,left:c,x:c,y:d}}function vo(n){var e=zn(n),t=n.offsetWidth,r=n.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:n.offsetLeft,y:n.offsetTop,width:t,height:r}}function Td(n,e){var t=e.getRootNode&&e.getRootNode();if(n.contains(e))return!0;if(t&&bo(t)){var r=e;do{if(r&&n.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Ot(n){return Ge(n).getComputedStyle(n)}function Gg(n){return["table","td","th"].indexOf(vt(n))>=0}function Kt(n){return((xn(n)?n.ownerDocument:n.document)||window.document).documentElement}function Ds(n){return vt(n)==="html"?n:n.assignedSlot||n.parentNode||(bo(n)?n.host:null)||Kt(n)}function qa(n){return!nt(n)||Ot(n).position==="fixed"?null:n.offsetParent}function Yg(n){var e=/firefox/i.test($i()),t=/Trident/i.test($i());if(t&&nt(n)){var r=Ot(n);if(r.position==="fixed")return null}var s=Ds(n);for(bo(s)&&(s=s.host);nt(s)&&["html","body"].indexOf(vt(s))<0;){var i=Ot(s);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||e&&i.willChange==="filter"||e&&i.filter&&i.filter!=="none")return s;s=s.parentNode}return null}function Or(n){for(var e=Ge(n),t=qa(n);t&&Gg(t)&&Ot(t).position==="static";)t=qa(t);return t&&(vt(t)==="html"||vt(t)==="body"&&Ot(t).position==="static")?e:t||Yg(n)||e}function wo(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function or(n,e,t){return cn(n,ms(e,t))}function Qg(n,e,t){var r=or(n,e,t);return r>t?t:r}function Od(){return{top:0,right:0,bottom:0,left:0}}function Ad(n){return Object.assign({},Od(),n)}function Dd(n,e){return e.reduce(function(t,r){return t[r]=n,t},{})}var Xg=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,Ad(typeof e!="number"?e:Dd(e,Tr))};function Zg(n){var e,t=n.state,r=n.name,s=n.options,i=t.elements.arrow,o=t.modifiersData.popperOffsets,a=gt(t.placement),l=wo(a),c=[qe,st].indexOf(a)>=0,d=c?"height":"width";if(!(!i||!o)){var u=Xg(s.padding,t),h=vo(i),p=l==="y"?He:qe,m=l==="y"?rt:st,g=t.rects.reference[d]+t.rects.reference[l]-o[l]-t.rects.popper[d],x=o[l]-t.rects.reference[l],b=Or(i),w=b?l==="y"?b.clientHeight||0:b.clientWidth||0:0,S=g/2-x/2,y=u[p],O=w-h[d]-u[m],k=w/2-h[d]/2+S,R=or(y,k,O),M=l;t.modifiersData[r]=(e={},e[M]=R,e.centerOffset=R-k,e)}}function e0(n){var e=n.state,t=n.options,r=t.element,s=r===void 0?"[data-popper-arrow]":r;s!=null&&(typeof s=="string"&&(s=e.elements.popper.querySelector(s),!s)||Td(e.elements.popper,s)&&(e.elements.arrow=s))}const t0={name:"arrow",enabled:!0,phase:"main",fn:Zg,effect:e0,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Vn(n){return n.split("-")[1]}var n0={top:"auto",right:"auto",bottom:"auto",left:"auto"};function r0(n,e){var t=n.x,r=n.y,s=e.devicePixelRatio||1;return{x:Fn(t*s)/s||0,y:Fn(r*s)/s||0}}function _a(n){var e,t=n.popper,r=n.popperRect,s=n.placement,i=n.variation,o=n.offsets,a=n.position,l=n.gpuAcceleration,c=n.adaptive,d=n.roundOffsets,u=n.isFixed,h=o.x,p=h===void 0?0:h,m=o.y,g=m===void 0?0:m,x=typeof d=="function"?d({x:p,y:g}):{x:p,y:g};p=x.x,g=x.y;var b=o.hasOwnProperty("x"),w=o.hasOwnProperty("y"),S=qe,y=He,O=window;if(c){var k=Or(t),R="clientHeight",M="clientWidth";if(k===Ge(t)&&(k=Kt(t),Ot(k).position!=="static"&&a==="absolute"&&(R="scrollHeight",M="scrollWidth")),k=k,s===He||(s===qe||s===st)&&i===kr){y=rt;var E=u&&k===O&&O.visualViewport?O.visualViewport.height:k[R];g-=E-r.height,g*=l?1:-1}if(s===qe||(s===He||s===rt)&&i===kr){S=st;var D=u&&k===O&&O.visualViewport?O.visualViewport.width:k[M];p-=D-r.width,p*=l?1:-1}}var L=Object.assign({position:a},c&&n0),A=d===!0?r0({x:p,y:g},Ge(t)):{x:p,y:g};if(p=A.x,g=A.y,l){var T;return Object.assign({},L,(T={},T[y]=w?"0":"",T[S]=b?"0":"",T.transform=(O.devicePixelRatio||1)<=1?"translate("+p+"px, "+g+"px)":"translate3d("+p+"px, "+g+"px, 0)",T))}return Object.assign({},L,(e={},e[y]=w?g+"px":"",e[S]=b?p+"px":"",e.transform="",e))}function s0(n){var e=n.state,t=n.options,r=t.gpuAcceleration,s=r===void 0?!0:r,i=t.adaptive,o=i===void 0?!0:i,a=t.roundOffsets,l=a===void 0?!0:a,c={placement:gt(e.placement),variation:Vn(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:s,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,_a(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,_a(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 i0={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:s0,data:{}};var qr={passive:!0};function o0(n){var e=n.state,t=n.instance,r=n.options,s=r.scroll,i=s===void 0?!0:s,o=r.resize,a=o===void 0?!0:o,l=Ge(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return i&&c.forEach(function(d){d.addEventListener("scroll",t.update,qr)}),a&&l.addEventListener("resize",t.update,qr),function(){i&&c.forEach(function(d){d.removeEventListener("scroll",t.update,qr)}),a&&l.removeEventListener("resize",t.update,qr)}}const a0={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:o0,data:{}};var l0={left:"right",right:"left",bottom:"top",top:"bottom"};function Zr(n){return n.replace(/left|right|bottom|top/g,function(e){return l0[e]})}var c0={start:"end",end:"start"};function Ua(n){return n.replace(/start|end/g,function(e){return c0[e]})}function ko(n){var e=Ge(n),t=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:t,scrollTop:r}}function So(n){return zn(Kt(n)).left+ko(n).scrollLeft}function d0(n,e){var t=Ge(n),r=Kt(n),s=t.visualViewport,i=r.clientWidth,o=r.clientHeight,a=0,l=0;if(s){i=s.width,o=s.height;var c=Ed();(c||!c&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:i,height:o,x:a+So(n),y:l}}function u0(n){var e,t=Kt(n),r=ko(n),s=(e=n.ownerDocument)==null?void 0:e.body,i=cn(t.scrollWidth,t.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),o=cn(t.scrollHeight,t.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),a=-r.scrollLeft+So(n),l=-r.scrollTop;return Ot(s||t).direction==="rtl"&&(a+=cn(t.clientWidth,s?s.clientWidth:0)-i),{width:i,height:o,x:a,y:l}}function Co(n){var e=Ot(n),t=e.overflow,r=e.overflowX,s=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+s+r)}function jd(n){return["html","body","#document"].indexOf(vt(n))>=0?n.ownerDocument.body:nt(n)&&Co(n)?n:jd(Ds(n))}function ar(n,e){var t;e===void 0&&(e=[]);var r=jd(n),s=r===((t=n.ownerDocument)==null?void 0:t.body),i=Ge(r),o=s?[i].concat(i.visualViewport||[],Co(r)?r:[]):r,a=e.concat(o);return s?a:a.concat(ar(Ds(o)))}function Fi(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function f0(n,e){var t=zn(n,!1,e==="fixed");return t.top=t.top+n.clientTop,t.left=t.left+n.clientLeft,t.bottom=t.top+n.clientHeight,t.right=t.left+n.clientWidth,t.width=n.clientWidth,t.height=n.clientHeight,t.x=t.left,t.y=t.top,t}function Ka(n,e,t){return e===Cd?Fi(d0(n,t)):xn(e)?f0(e,t):Fi(u0(Kt(n)))}function h0(n){var e=ar(Ds(n)),t=["absolute","fixed"].indexOf(Ot(n).position)>=0,r=t&&nt(n)?Or(n):n;return xn(r)?e.filter(function(s){return xn(s)&&Td(s,r)&&vt(s)!=="body"}):[]}function p0(n,e,t,r){var s=e==="clippingParents"?h0(n):[].concat(e),i=[].concat(s,[t]),o=i[0],a=i.reduce(function(l,c){var d=Ka(n,c,r);return l.top=cn(d.top,l.top),l.right=ms(d.right,l.right),l.bottom=ms(d.bottom,l.bottom),l.left=cn(d.left,l.left),l},Ka(n,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 Id(n){var e=n.reference,t=n.element,r=n.placement,s=r?gt(r):null,i=r?Vn(r):null,o=e.x+e.width/2-t.width/2,a=e.y+e.height/2-t.height/2,l;switch(s){case He:l={x:o,y:e.y-t.height};break;case rt:l={x:o,y:e.y+e.height};break;case st:l={x:e.x+e.width,y:a};break;case qe:l={x:e.x-t.width,y:a};break;default:l={x:e.x,y:e.y}}var c=s?wo(s):null;if(c!=null){var d=c==="y"?"height":"width";switch(i){case $n:l[c]=l[c]-(e[d]/2-t[d]/2);break;case kr:l[c]=l[c]+(e[d]/2-t[d]/2);break}}return l}function Sr(n,e){e===void 0&&(e={});var t=e,r=t.placement,s=r===void 0?n.placement:r,i=t.strategy,o=i===void 0?n.strategy:i,a=t.boundary,l=a===void 0?Pg:a,c=t.rootBoundary,d=c===void 0?Cd:c,u=t.elementContext,h=u===void 0?_n:u,p=t.altBoundary,m=p===void 0?!1:p,g=t.padding,x=g===void 0?0:g,b=Ad(typeof x!="number"?x:Dd(x,Tr)),w=h===_n?Lg:_n,S=n.rects.popper,y=n.elements[m?w:h],O=p0(xn(y)?y:y.contextElement||Kt(n.elements.popper),l,d,o),k=zn(n.elements.reference),R=Id({reference:k,element:S,placement:s}),M=Fi(Object.assign({},S,R)),E=h===_n?M:k,D={top:O.top-E.top+b.top,bottom:E.bottom-O.bottom+b.bottom,left:O.left-E.left+b.left,right:E.right-O.right+b.right},L=n.modifiersData.offset;if(h===_n&&L){var A=L[s];Object.keys(D).forEach(function(T){var F=[st,rt].indexOf(T)>=0?1:-1,W=[He,rt].indexOf(T)>=0?"y":"x";D[T]+=A[W]*F})}return D}function m0(n,e){e===void 0&&(e={});var t=e,r=t.placement,s=t.boundary,i=t.rootBoundary,o=t.padding,a=t.flipVariations,l=t.allowedAutoPlacements,c=l===void 0?Nd:l,d=Vn(r),u=d?a?Ha:Ha.filter(function(m){return Vn(m)===d}):Tr,h=u.filter(function(m){return c.indexOf(m)>=0});h.length===0&&(h=u);var p=h.reduce(function(m,g){return m[g]=Sr(n,{placement:g,boundary:s,rootBoundary:i,padding:o})[gt(g)],m},{});return Object.keys(p).sort(function(m,g){return p[m]-p[g]})}function g0(n){if(gt(n)===yo)return[];var e=Zr(n);return[Ua(n),e,Ua(e)]}function x0(n){var e=n.state,t=n.options,r=n.name;if(!e.modifiersData[r]._skip){for(var s=t.mainAxis,i=s===void 0?!0:s,o=t.altAxis,a=o===void 0?!0:o,l=t.fallbackPlacements,c=t.padding,d=t.boundary,u=t.rootBoundary,h=t.altBoundary,p=t.flipVariations,m=p===void 0?!0:p,g=t.allowedAutoPlacements,x=e.options.placement,b=gt(x),w=b===x,S=l||(w||!m?[Zr(x)]:g0(x)),y=[x].concat(S).reduce(function(Ie,ve){return Ie.concat(gt(ve)===yo?m0(e,{placement:ve,boundary:d,rootBoundary:u,padding:c,flipVariations:m,allowedAutoPlacements:g}):ve)},[]),O=e.rects.reference,k=e.rects.popper,R=new Map,M=!0,E=y[0],D=0;D<y.length;D++){var L=y[D],A=gt(L),T=Vn(L)===$n,F=[He,rt].indexOf(A)>=0,W=F?"width":"height",de=Sr(e,{placement:L,boundary:d,rootBoundary:u,altBoundary:h,padding:c}),ie=F?T?st:qe:T?rt:He;O[W]>k[W]&&(ie=Zr(ie));var ee=Zr(ie),U=[];if(i&&U.push(de[A]<=0),a&&U.push(de[ie]<=0,de[ee]<=0),U.every(function(Ie){return Ie})){E=L,M=!1;break}R.set(L,U)}if(M)for(var ue=m?3:1,ze=function(ve){var K=y.find(function(se){var Ee=R.get(se);if(Ee)return Ee.slice(0,ve).every(function(Ve){return Ve})});if(K)return E=K,"break"},fe=ue;fe>0;fe--){var re=ze(fe);if(re==="break")break}e.placement!==E&&(e.modifiersData[r]._skip=!0,e.placement=E,e.reset=!0)}}const y0={name:"flip",enabled:!0,phase:"main",fn:x0,requiresIfExists:["offset"],data:{_skip:!1}};function Ja(n,e,t){return t===void 0&&(t={x:0,y:0}),{top:n.top-e.height-t.y,right:n.right-e.width+t.x,bottom:n.bottom-e.height+t.y,left:n.left-e.width-t.x}}function Ga(n){return[He,st,rt,qe].some(function(e){return n[e]>=0})}function b0(n){var e=n.state,t=n.name,r=e.rects.reference,s=e.rects.popper,i=e.modifiersData.preventOverflow,o=Sr(e,{elementContext:"reference"}),a=Sr(e,{altBoundary:!0}),l=Ja(o,r),c=Ja(a,s,i),d=Ga(l),u=Ga(c);e.modifiersData[t]={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 v0={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:b0};function w0(n,e,t){var r=gt(n),s=[qe,He].indexOf(r)>=0?-1:1,i=typeof t=="function"?t(Object.assign({},e,{placement:n})):t,o=i[0],a=i[1];return o=o||0,a=(a||0)*s,[qe,st].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}function k0(n){var e=n.state,t=n.options,r=n.name,s=t.offset,i=s===void 0?[0,0]:s,o=Nd.reduce(function(d,u){return d[u]=w0(u,e.rects,i),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 S0={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:k0};function C0(n){var e=n.state,t=n.name;e.modifiersData[t]=Id({reference:e.rects.reference,element:e.rects.popper,placement:e.placement})}const N0={name:"popperOffsets",enabled:!0,phase:"read",fn:C0,data:{}};function M0(n){return n==="x"?"y":"x"}function E0(n){var e=n.state,t=n.options,r=n.name,s=t.mainAxis,i=s===void 0?!0:s,o=t.altAxis,a=o===void 0?!1:o,l=t.boundary,c=t.rootBoundary,d=t.altBoundary,u=t.padding,h=t.tether,p=h===void 0?!0:h,m=t.tetherOffset,g=m===void 0?0:m,x=Sr(e,{boundary:l,rootBoundary:c,padding:u,altBoundary:d}),b=gt(e.placement),w=Vn(e.placement),S=!w,y=wo(b),O=M0(y),k=e.modifiersData.popperOffsets,R=e.rects.reference,M=e.rects.popper,E=typeof g=="function"?g(Object.assign({},e.rects,{placement:e.placement})):g,D=typeof E=="number"?{mainAxis:E,altAxis:E}:Object.assign({mainAxis:0,altAxis:0},E),L=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,A={x:0,y:0};if(k){if(i){var T,F=y==="y"?He:qe,W=y==="y"?rt:st,de=y==="y"?"height":"width",ie=k[y],ee=ie+x[F],U=ie-x[W],ue=p?-M[de]/2:0,ze=w===$n?R[de]:M[de],fe=w===$n?-M[de]:-R[de],re=e.elements.arrow,Ie=p&&re?vo(re):{width:0,height:0},ve=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Od(),K=ve[F],se=ve[W],Ee=or(0,R[de],Ie[de]),Ve=S?R[de]/2-ue-Ee-K-D.mainAxis:ze-Ee-K-D.mainAxis,Te=S?-R[de]/2+ue+Ee+se+D.mainAxis:fe+Ee+se+D.mainAxis,ct=e.elements.arrow&&Or(e.elements.arrow),dt=ct?y==="y"?ct.clientTop||0:ct.clientLeft||0:0,it=(T=L?.[y])!=null?T:0,wt=ie+Ve-it-dt,Qe=ie+Te-it,ut=or(p?ms(ee,wt):ee,ie,p?cn(U,Qe):U);k[y]=ut,A[y]=ut-ie}if(a){var J,ft=y==="x"?He:qe,te=y==="x"?rt:st,Re=k[O],ce=O==="y"?"height":"width",we=Re+x[ft],oe=Re-x[te],Jt=[He,qe].indexOf(b)!==-1,Gt=(J=L?.[O])!=null?J:0,Yt=Jt?we:Re-R[ce]-M[ce]-Gt+D.altAxis,bn=Jt?Re+R[ce]+M[ce]-Gt-D.altAxis:oe,Qt=p&&Jt?Qg(Yt,Re,bn):or(p?Yt:we,Re,p?bn:oe);k[O]=Qt,A[O]=Qt-Re}e.modifiersData[r]=A}}const T0={name:"preventOverflow",enabled:!0,phase:"main",fn:E0,requiresIfExists:["offset"]};function O0(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function A0(n){return n===Ge(n)||!nt(n)?ko(n):O0(n)}function D0(n){var e=n.getBoundingClientRect(),t=Fn(e.width)/n.offsetWidth||1,r=Fn(e.height)/n.offsetHeight||1;return t!==1||r!==1}function j0(n,e,t){t===void 0&&(t=!1);var r=nt(e),s=nt(e)&&D0(e),i=Kt(e),o=zn(n,s,t),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!t)&&((vt(e)!=="body"||Co(i))&&(a=A0(e)),nt(e)?(l=zn(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):i&&(l.x=So(i))),{x:o.left+a.scrollLeft-l.x,y:o.top+a.scrollTop-l.y,width:o.width,height:o.height}}function I0(n){var e=new Map,t=new Set,r=[];n.forEach(function(i){e.set(i.name,i)});function s(i){t.add(i.name);var o=[].concat(i.requires||[],i.requiresIfExists||[]);o.forEach(function(a){if(!t.has(a)){var l=e.get(a);l&&s(l)}}),r.push(i)}return n.forEach(function(i){t.has(i.name)||s(i)}),r}function R0(n){var e=I0(n);return Ug.reduce(function(t,r){return t.concat(e.filter(function(s){return s.phase===r}))},[])}function P0(n){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(n())})})),e}}function L0(n){var e=n.reduce(function(t,r){var s=t[r.name];return t[r.name]=s?Object.assign({},s,r,{options:Object.assign({},s.options,r.options),data:Object.assign({},s.data,r.data)}):r,t},{});return Object.keys(e).map(function(t){return e[t]})}var Ya={placement:"bottom",modifiers:[],strategy:"absolute"};function Qa(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return!e.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function B0(n){n===void 0&&(n={});var e=n,t=e.defaultModifiers,r=t===void 0?[]:t,s=e.defaultOptions,i=s===void 0?Ya:s;return function(a,l,c){c===void 0&&(c=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},Ya,i),modifiersData:{},elements:{reference:a,popper:l},attributes:{},styles:{}},u=[],h=!1,p={state:d,setOptions:function(b){var w=typeof b=="function"?b(d.options):b;g(),d.options=Object.assign({},i,d.options,w),d.scrollParents={reference:xn(a)?ar(a):a.contextElement?ar(a.contextElement):[],popper:ar(l)};var S=R0(L0([].concat(r,d.options.modifiers)));return d.orderedModifiers=S.filter(function(y){return y.enabled}),m(),p.update()},forceUpdate:function(){if(!h){var b=d.elements,w=b.reference,S=b.popper;if(Qa(w,S)){d.rects={reference:j0(w,Or(S),d.options.strategy==="fixed"),popper:vo(S)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(D){return d.modifiersData[D.name]=Object.assign({},D.data)});for(var y=0;y<d.orderedModifiers.length;y++){if(d.reset===!0){d.reset=!1,y=-1;continue}var O=d.orderedModifiers[y],k=O.fn,R=O.options,M=R===void 0?{}:R,E=O.name;typeof k=="function"&&(d=k({state:d,options:M,name:E,instance:p})||d)}}}},update:P0(function(){return new Promise(function(x){p.forceUpdate(),x(d)})}),destroy:function(){g(),h=!0}};if(!Qa(a,l))return p;p.setOptions(c).then(function(x){!h&&c.onFirstUpdate&&c.onFirstUpdate(x)});
vendor: 14,743 bytes, line 89
89function m(){d.orderedModifiers.forEach(function(x){var b=x.name,w=x.options,S=w===void 0?{}:w,y=x.effect;if(typeof y=="function"){var O=y({state:d,name:b,instance:p,options:S}),k=function(){};u.push(O||k)}})}function g(){u.forEach(function(x){return x()}),u=[]}return p}}var $0=[a0,N0,i0,Md,S0,y0,T0,t0,v0],F0=B0({defaultModifiers:$0}),z0="tippy-box",Rd="tippy-content",V0="tippy-backdrop",Pd="tippy-arrow",Ld="tippy-svg-arrow",Zt={passive:!0,capture:!0},Bd=function(){return document.body};function ei(n,e,t){if(Array.isArray(n)){var r=n[e];return r??(Array.isArray(t)?t[e]:t)}return n}function No(n,e){var t={}.toString.call(n);return t.indexOf("[object")===0&&t.indexOf(e+"]")>-1}function $d(n,e){return typeof n=="function"?n.apply(void 0,e):n}function Xa(n,e){if(e===0)return n;var t;return function(r){clearTimeout(t),t=setTimeout(function(){n(r)},e)}}function W0(n){return n.split(/\s+/).filter(Boolean)}function Mn(n){return[].concat(n)}function Za(n,e){n.indexOf(e)===-1&&n.push(e)}function H0(n){return n.filter(function(e,t){return n.indexOf(e)===t})}function q0(n){return n.split("-")[0]}function gs(n){return[].slice.call(n)}function el(n){return Object.keys(n).reduce(function(e,t){return n[t]!==void 0&&(e[t]=n[t]),e},{})}function lr(){return document.createElement("div")}function js(n){return["Element","Fragment"].some(function(e){return No(n,e)})}function _0(n){return No(n,"NodeList")}function U0(n){return No(n,"MouseEvent")}function K0(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function J0(n){return js(n)?[n]:_0(n)?gs(n):Array.isArray(n)?n:gs(document.querySelectorAll(n))}function ti(n,e){n.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function tl(n,e){n.forEach(function(t){t&&t.setAttribute("data-state",e)})}function G0(n){var e,t=Mn(n),r=t[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function Y0(n,e){var t=e.clientX,r=e.clientY;return n.every(function(s){var i=s.popperRect,o=s.popperState,a=s.props,l=a.interactiveBorder,c=q0(o.placement),d=o.modifiersData.offset;if(!d)return!0;var u=c==="bottom"?d.top.y:0,h=c==="top"?d.bottom.y:0,p=c==="right"?d.left.x:0,m=c==="left"?d.right.x:0,g=i.top-r+u>l,x=r-i.bottom-h>l,b=i.left-t+p>l,w=t-i.right-m>l;return g||x||b||w})}function ni(n,e,t){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){n[r](s,t)})}function nl(n,e){for(var t=e;t;){var r;if(n.contains(t))return!0;t=t.getRootNode==null||(r=t.getRootNode())==null?void 0:r.host}return!1}var pt={isTouch:!1},rl=0;function Q0(){pt.isTouch||(pt.isTouch=!0,window.performance&&document.addEventListener("mousemove",Fd))}function Fd(){var n=performance.now();n-rl<20&&(pt.isTouch=!1,document.removeEventListener("mousemove",Fd)),rl=n}function X0(){var n=document.activeElement;if(K0(n)){var e=n._tippy;n.blur&&!e.state.isVisible&&n.blur()}}function Z0(){document.addEventListener("touchstart",Q0,Zt),window.addEventListener("blur",X0)}var ex=typeof window<"u"&&typeof document<"u",tx=ex?!!window.msCrypto:!1,nx={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},rx={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},at=Object.assign({appendTo:Bd,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},nx,rx),sx=Object.keys(at),ix=function(e){var t=Object.keys(e);t.forEach(function(r){at[r]=e[r]})};function zd(n){var e=n.plugins||[],t=e.reduce(function(r,s){var i=s.name,o=s.defaultValue;if(i){var a;r[i]=n[i]!==void 0?n[i]:(a=at[i])!=null?a:o}return r},{});return Object.assign({},n,t)}function ox(n,e){var t=e?Object.keys(zd(Object.assign({},at,{plugins:e}))):sx,r=t.reduce(function(s,i){var o=(n.getAttribute("data-tippy-"+i)||"").trim();if(!o)return s;if(i==="content")s[i]=o;else try{s[i]=JSON.parse(o)}catch{s[i]=o}return s},{});return r}function sl(n,e){var t=Object.assign({},e,{content:$d(e.content,[n])},e.ignoreAttributes?{}:ox(n,e.plugins));return t.aria=Object.assign({},at.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}var ax=function(){return"innerHTML"};function zi(n,e){n[ax()]=e}function il(n){var e=lr();return n===!0?e.className=Pd:(e.className=Ld,js(n)?e.appendChild(n):zi(e,n)),e}function ol(n,e){js(e.content)?(zi(n,""),n.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?zi(n,e.content):n.textContent=e.content)}function Vi(n){var e=n.firstElementChild,t=gs(e.children);return{box:e,content:t.find(function(r){return r.classList.contains(Rd)}),arrow:t.find(function(r){return r.classList.contains(Pd)||r.classList.contains(Ld)}),backdrop:t.find(function(r){return r.classList.contains(V0)})}}function Vd(n){var e=lr(),t=lr();t.className=z0,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var r=lr();r.className=Rd,r.setAttribute("data-state","hidden"),ol(r,n.props),e.appendChild(t),t.appendChild(r),s(n.props,n.props);function s(i,o){var a=Vi(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"),(i.content!==o.content||i.allowHTML!==o.allowHTML)&&ol(c,n.props),o.arrow?d?i.arrow!==o.arrow&&(l.removeChild(d),l.appendChild(il(o.arrow))):l.appendChild(il(o.arrow)):d&&l.removeChild(d)}return{popper:e,onUpdate:s}}Vd.$$tippy=!0;var lx=1,_r=[],ri=[];function cx(n,e){var t=sl(n,Object.assign({},at,zd(el(e)))),r,s,i,o=!1,a=!1,l=!1,c=!1,d,u,h,p=[],m=Xa(wt,t.interactiveDebounce),g,x=lx++,b=null,w=H0(t.plugins),S={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:x,reference:n,popper:lr(),popperInstance:b,props:t,state:S,plugins:w,clearDelayTimeouts:Yt,setProps:bn,setContent:Qt,show:Hn,hide:V,hideWithInteractivity:H,enable:Jt,disable:Gt,unmount:Pe,destroy:X};if(!t.render)return y;var O=t.render(y),k=O.popper,R=O.onUpdate;k.setAttribute("data-tippy-root",""),k.id="tippy-"+y.id,y.popper=k,n._tippy=y,k._tippy=y;var M=w.map(function(v){return v.fn(y)}),E=n.hasAttribute("aria-expanded");return ct(),ue(),ie(),ee("onCreate",[y]),t.showOnCreate&&we(),k.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),k.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&F().addEventListener("mousemove",m)}),y;function D(){var v=y.props.touch;return Array.isArray(v)?v:[v,0]}function L(){return D()[0]==="hold"}function A(){var v;return!!((v=y.props.render)!=null&&v.$$tippy)}function T(){return g||n}function F(){var v=T().parentNode;return v?G0(v):document}function W(){return Vi(k)}function de(v){return y.state.isMounted&&!y.state.isVisible||pt.isTouch||d&&d.type==="focus"?0:ei(y.props.delay,v?0:1,at.delay)}function ie(v){v===void 0&&(v=!1),k.style.pointerEvents=y.props.interactive&&!v?"":"none",k.style.zIndex=""+y.props.zIndex}function ee(v,j,B){if(B===void 0&&(B=!0),M.forEach(function(Y){Y[v]&&Y[v].apply(Y,j)}),B){var G;(G=y.props)[v].apply(G,j)}}function U(){var v=y.props.aria;if(v.content){var j="aria-"+v.content,B=k.id,G=Mn(y.props.triggerTarget||n);G.forEach(function(Y){var Le=Y.getAttribute(j);if(y.state.isVisible)Y.setAttribute(j,Le?Le+" "+B:B);else{var Xe=Le&&Le.replace(B,"").trim();Xe?Y.setAttribute(j,Xe):Y.removeAttribute(j)}})}}function ue(){if(!(E||!y.props.aria.expanded)){var v=Mn(y.props.triggerTarget||n);v.forEach(function(j){y.props.interactive?j.setAttribute("aria-expanded",y.state.isVisible&&j===T()?"true":"false"):j.removeAttribute("aria-expanded")})}}function ze(){F().removeEventListener("mousemove",m),_r=_r.filter(function(v){return v!==m})}function fe(v){if(!(pt.isTouch&&(l||v.type==="mousedown"))){var j=v.composedPath&&v.composedPath()[0]||v.target;if(!(y.props.interactive&&nl(k,j))){if(Mn(y.props.triggerTarget||n).some(function(B){return nl(B,j)})){if(pt.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else ee("onClickOutside",[y,v]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),a=!0,setTimeout(function(){a=!1}),y.state.isMounted||K())}}}function re(){l=!0}function Ie(){l=!1}function ve(){var v=F();v.addEventListener("mousedown",fe,!0),v.addEventListener("touchend",fe,Zt),v.addEventListener("touchstart",Ie,Zt),v.addEventListener("touchmove",re,Zt)}function K(){var v=F();v.removeEventListener("mousedown",fe,!0),v.removeEventListener("touchend",fe,Zt),v.removeEventListener("touchstart",Ie,Zt),v.removeEventListener("touchmove",re,Zt)}function se(v,j){Ve(v,function(){!y.state.isVisible&&k.parentNode&&k.parentNode.contains(k)&&j()})}function Ee(v,j){Ve(v,j)}function Ve(v,j){var B=W().box;function G(Y){Y.target===B&&(ni(B,"remove",G),j())}if(v===0)return j();ni(B,"remove",u),ni(B,"add",G),u=G}function Te(v,j,B){B===void 0&&(B=!1);var G=Mn(y.props.triggerTarget||n);G.forEach(function(Y){Y.addEventListener(v,j,B),p.push({node:Y,eventType:v,handler:j,options:B})})}function ct(){L()&&(Te("touchstart",it,{passive:!0}),Te("touchend",Qe,{passive:!0})),W0(y.props.trigger).forEach(function(v){if(v!=="manual")switch(Te(v,it),v){case"mouseenter":Te("mouseleave",Qe);break;case"focus":Te(tx?"focusout":"blur",ut);break;case"focusin":Te("focusout",ut);break}})}function dt(){p.forEach(function(v){var j=v.node,B=v.eventType,G=v.handler,Y=v.options;j.removeEventListener(B,G,Y)}),p=[]}function it(v){var j,B=!1;if(!(!y.state.isEnabled||J(v)||a)){var G=((j=d)==null?void 0:j.type)==="focus";d=v,g=v.currentTarget,ue(),!y.state.isVisible&&U0(v)&&_r.forEach(function(Y){return Y(v)}),v.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||o)&&y.props.hideOnClick!==!1&&y.state.isVisible?B=!0:we(v),v.type==="click"&&(o=!B),B&&!G&&oe(v)}}function wt(v){var j=v.target,B=T().contains(j)||k.contains(j);if(!(v.type==="mousemove"&&B)){var G=ce().concat(k).map(function(Y){var Le,Xe=Y._tippy,vn=(Le=Xe.popperInstance)==null?void 0:Le.state;return vn?{popperRect:Y.getBoundingClientRect(),popperState:vn,props:t}:null}).filter(Boolean);Y0(G,v)&&(ze(),oe(v))}}function Qe(v){var j=J(v)||y.props.trigger.indexOf("click")>=0&&o;if(!j){if(y.props.interactive){y.hideWithInteractivity(v);return}oe(v)}}function ut(v){y.props.trigger.indexOf("focusin")<0&&v.target!==T()||y.props.interactive&&v.relatedTarget&&k.contains(v.relatedTarget)||oe(v)}function J(v){return pt.isTouch?L()!==v.type.indexOf("touch")>=0:!1}function ft(){te();var v=y.props,j=v.popperOptions,B=v.placement,G=v.offset,Y=v.getReferenceClientRect,Le=v.moveTransition,Xe=A()?Vi(k).arrow:null,vn=Y?{getBoundingClientRect:Y,contextElement:Y.contextElement||T()}:n,Oo={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Dr){var wn=Dr.state;if(A()){var Zd=W(),Rs=Zd.box;["placement","reference-hidden","escaped"].forEach(function(jr){jr==="placement"?Rs.setAttribute("data-placement",wn.placement):wn.attributes.popper["data-popper-"+jr]?Rs.setAttribute("data-"+jr,""):Rs.removeAttribute("data-"+jr)}),wn.attributes.popper={}}}},Xt=[{name:"offset",options:{offset:G}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!Le}},Oo];A()&&Xe&&Xt.push({name:"arrow",options:{element:Xe,padding:3}}),Xt.push.apply(Xt,j?.modifiers||[]),y.popperInstance=F0(vn,k,Object.assign({},j,{placement:B,onFirstUpdate:h,modifiers:Xt}))}function te(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function Re(){var v=y.props.appendTo,j,B=T();y.props.interactive&&v===Bd||v==="parent"?j=B.parentNode:j=$d(v,[B]),j.contains(k)||j.appendChild(k),y.state.isMounted=!0,ft()}function ce(){return gs(k.querySelectorAll("[data-tippy-root]"))}function we(v){y.clearDelayTimeouts(),v&&ee("onTrigger",[y,v]),ve();var j=de(!0),B=D(),G=B[0],Y=B[1];pt.isTouch&&G==="hold"&&Y&&(j=Y),j?r=setTimeout(function(){y.show()},j):y.show()}function oe(v){if(y.clearDelayTimeouts(),ee("onUntrigger",[y,v]),!y.state.isVisible){K();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(v.type)>=0&&o)){var j=de(!1);j?s=setTimeout(function(){y.state.isVisible&&y.hide()},j):i=requestAnimationFrame(function(){y.hide()})}}function Jt(){y.state.isEnabled=!0}function Gt(){y.hide(),y.state.isEnabled=!1}function Yt(){clearTimeout(r),clearTimeout(s),cancelAnimationFrame(i)}function bn(v){if(!y.state.isDestroyed){ee("onBeforeUpdate",[y,v]),dt();var j=y.props,B=sl(n,Object.assign({},j,el(v),{ignoreAttributes:!0}));y.props=B,ct(),j.interactiveDebounce!==B.interactiveDebounce&&(ze(),m=Xa(wt,B.interactiveDebounce)),j.triggerTarget&&!B.triggerTarget?Mn(j.triggerTarget).forEach(function(G){G.removeAttribute("aria-expanded")}):B.triggerTarget&&n.removeAttribute("aria-expanded"),ue(),ie(),R&&R(j,B),y.popperInstance&&(ft(),ce().forEach(function(G){requestAnimationFrame(G._tippy.popperInstance.forceUpdate)})),ee("onAfterUpdate",[y,v])}}function Qt(v){y.setProps({content:v})}function Hn(){var v=y.state.isVisible,j=y.state.isDestroyed,B=!y.state.isEnabled,G=pt.isTouch&&!y.props.touch,Y=ei(y.props.duration,0,at.duration);if(!(v||j||B||G)&&!T().hasAttribute("disabled")&&(ee("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,A()&&(k.style.visibility="visible"),ie(),ve(),y.state.isMounted||(k.style.transition="none"),A()){var Le=W(),Xe=Le.box,vn=Le.content;ti([Xe,vn],0)}h=function(){var Xt;if(!(!y.state.isVisible||c)){if(c=!0,k.offsetHeight,k.style.transition=y.props.moveTransition,A()&&y.props.animation){var Is=W(),Dr=Is.box,wn=Is.content;ti([Dr,wn],Y),tl([Dr,wn],"visible")}U(),ue(),Za(ri,y),(Xt=y.popperInstance)==null||Xt.forceUpdate(),ee("onMount",[y]),y.props.animation&&A()&&Ee(Y,function(){y.state.isShown=!0,ee("onShown",[y])})}},Re()}}function V(){var v=!y.state.isVisible,j=y.state.isDestroyed,B=!y.state.isEnabled,G=ei(y.props.duration,1,at.duration);
89if(!(v||j||B)&&(ee("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,c=!1,o=!1,A()&&(k.style.visibility="hidden"),ze(),K(),ie(!0),A()){var Y=W(),Le=Y.box,Xe=Y.content;y.props.animation&&(ti([Le,Xe],G),tl([Le,Xe],"hidden"))}U(),ue(),y.props.animation?A()&&se(G,y.unmount):y.unmount()}}function H(v){F().addEventListener("mousemove",m),Za(_r,m),m(v)}function Pe(){y.state.isVisible&&y.hide(),y.state.isMounted&&(te(),ce().forEach(function(v){v._tippy.unmount()}),k.parentNode&&k.parentNode.removeChild(k),ri=ri.filter(function(v){return v!==y}),y.state.isMounted=!1,ee("onHidden",[y]))}function X(){y.state.isDestroyed||(y.clearDelayTimeouts(),y.unmount(),dt(),delete n._tippy,y.state.isDestroyed=!0,ee("onDestroy",[y]))}}function Ar(n,e){e===void 0&&(e={});var t=at.plugins.concat(e.plugins||[]);Z0();var r=Object.assign({},e,{plugins:t}),s=J0(n),i=s.reduce(function(o,a){var l=a&&cx(a,r);return l&&o.push(l),o},[]);return js(n)?i[0]:i}Ar.defaultProps=at;Ar.setDefaultProps=ix;Ar.currentInput=pt;Object.assign({},Md,{effect:function(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow)}});Ar.setDefaultProps({render:Vd});class dx{constructor({editor:e,element:t,view:r,tippyOptions:s={},updateDelay:i=250,shouldShow:o}){this.preventHide=!1,this.shouldShow=({view:a,state:l,from:c,to:d})=>{const{doc:u,selection:h}=l,{empty:p}=h,m=!u.textBetween(c,d).length&&mo(l.selection),g=this.element.contains(document.activeElement);return!(!(a.hasFocus()||g)||p||m||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:a})=>{var l;if(this.preventHide){this.preventHide=!1;return}a?.relatedTarget&&(!((l=this.element.parentNode)===null||l===void 0)&&l.contains(a.relatedTarget))||a?.relatedTarget!==this.editor.view.dom&&this.hide()},this.tippyBlurHandler=a=>{this.blurHandler({event:a})},this.handleDebouncedUpdate=(a,l)=>{const c=!l?.selection.eq(a.state.selection),d=!l?.doc.eq(a.state.doc);!c&&!d||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(a,c,d,l)},this.updateDelay))},this.updateHandler=(a,l,c,d)=>{var u,h,p;const{state:m,composing:g}=a,{selection:x}=m;if(g||!l&&!c)return;this.createTooltip();const{ranges:w}=x,S=Math.min(...w.map(k=>k.$from.pos)),y=Math.max(...w.map(k=>k.$to.pos));if(!((u=this.shouldShow)===null||u===void 0?void 0:u.call(this,{editor:this.editor,element:this.element,view:a,state:m,oldState:d,from:S,to:y}))){this.hide();return}(h=this.tippy)===null||h===void 0||h.setProps({getReferenceClientRect:((p=this.tippyOptions)===null||p===void 0?void 0:p.getReferenceClientRect)||(()=>{if(Sd(m.selection)){let k=a.nodeDOM(S);if(k){const R=k.dataset.nodeViewWrapper?k:k.querySelector("[data-node-view-wrapper]");if(R&&(k=R.firstChild),k)return k.getBoundingClientRect()}}return ng(a,S,y)})}),this.show()},this.editor=e,this.element=t,this.view=r,this.updateDelay=i,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.tippyOptions=s,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;this.tippy||!t||(this.tippy=Ar(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,t){const{state:r}=e,s=r.selection.from!==r.selection.to;if(this.updateDelay>0&&s){this.handleDebouncedUpdate(e,t);return}const i=!t?.selection.eq(e.state.selection),o=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,o,t)}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Wd=n=>new Me({key:typeof n.pluginKey=="string"?new Ye(n.pluginKey):n.pluginKey,view:e=>
89new dx({view:e,...n})}),ux=me.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Wd({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});function fx(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Hd={exports:{}},si={};/** 90 * @license React 91 * use-sync-external-store-shim.production.min.js 92 * 93 * Copyright (c) Facebook, Inc. and its affiliates. 94 * 95 * This source code is licensed under the MIT license found in the 96 * LICENSE file in the root directory of this source tree. 97 */var al;function hx(){if(al)return si;al=1;var n=Ae;function e(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,s=n.useEffect,i=n.useLayoutEffect,o=n.useDebugValue;function a(u,h){var p=h(),m=r({inst:{value:p,getSnapshot:h}}),g=m[0].inst,x=m[1];return i(function(){g.value=p,g.getSnapshot=h,l(g)&&x({inst:g})},[u,p,h]),s(function(){return l(g)&&x({inst:g}),u(function(){l(g)&&x({inst:g})})},[u]),o(p),p}function l(u){var h=u.getSnapshot;u=u.value;try{var p=h();return!t(u,p)}catch{return!0}}function c(u,h){return h()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return si.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:d,si}Hd.exports=hx();var Mo=Hd.exports;const px=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},mx=({contentComponent:n})=>{const e=Mo.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return Ae.createElement(Ae.Fragment,null,Object.values(e))};function gx(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:nu.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}class xx extends Ae.Component{constructor(e){var t;super(e),this.editorContentRef=Ae.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((t=e.editor)===null||t===void 0)&&t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=gx(),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(){const e=this.props.editor;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!e.options.element.firstChild))return;const t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){const{editor:e,innerRef:t,...r}=this.props;return Ae.createElement(Ae.Fragment,null,Ae.createElement("div",{ref:px(t,this.editorContentRef),...r}),e?.contentComponent&&Ae.createElement(mx,{contentComponent:e.contentComponent}))}}const yx=N.forwardRef((n,e)=>{const t=Ae.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return Ae.createElement(xx,{key:t,innerRef:e,...n})}),bx=Ae.memo(yx);var vx=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(s=r;s--!==0;)if(!n(e[s],t[s]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(s of e.entries())if(!t.has(s[0]))return!1;for(s of e.entries())if(!n(s[1],t.get(s[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(s of e.entries())if(!t.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(s=r;s--!==0;)if(e[s]!==t[s])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[s]))return!1;for(s=r;s--!==0;){var o=i[s];if(!(o==="_owner"&&e.$$typeof)&&!n(e[o],t[o]))return!1}return!0}return e!==e&&t!==t},wx=fx(vx),qd={exports:{}},ii={};/** 98 * @license React 99 * use-sync-external-store-shim/with-selector.production.min.js 100 * 101 * Copyright (c) Facebook, Inc. and its affiliates. 102 * 103 * This source code is licensed under the MIT license found in the 104 * LICENSE file in the root directory of this source tree. 105 */var ll;function kx(){if(ll)return ii;ll=1;var n=Ae,e=Mo;
105function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:t,s=e.useSyncExternalStore,i=n.useRef,o=n.useEffect,a=n.useMemo,l=n.useDebugValue;return ii.useSyncExternalStoreWithSelector=function(c,d,u,h,p){var m=i(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=a(function(){function b(k){if(!w){if(w=!0,S=k,k=h(k),p!==void 0&&g.hasValue){var R=g.value;if(p(R,k))return y=R}return y=k}if(R=y,r(S,k))return R;var M=h(k);return p!==void 0&&p(R,M)?R:(S=k,y=M)}var w=!1,S,y,O=u===void 0?null:u;return[function(){return b(d())},O===null?void 0:function(){return b(O())}]},[d,u,h,p]);var x=s(c,m[0],m[1]);return o(function(){g.hasValue=!0,g.value=x},[x]),l(x),x},ii}qd.exports=kx();var Sx=qd.exports;const Cx=typeof window<"u"?N.useLayoutEffect:N.useEffect;class Nx{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}}function Mx(n){var e;const[t]=N.useState(()=>new Nx(n.editor)),r=Sx.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!==null&&e!==void 0?e:wx);return Cx(()=>t.watch(n.editor),[n.editor,t]),N.useDebugValue(r),r}const Ex=!1,Wi=typeof window>"u",Tx=Wi||!!(typeof window<"u"&&window.next);class Eo{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Wi||Tx?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)===null||i===void 0?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)===null||i===void 0?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)===null||i===void 0?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)===null||i===void 0?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)===null||i===void 0?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)===null||i===void 0?void 0:i.call(s,...r)}};return new Ig(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=t.extensions)===null||o===void 0?void 0:o[i])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Eo.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}
105):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,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function Ox(n={},e=[]){const t=N.useRef(n);t.current=n;const[r]=N.useState(()=>new Eo(t)),s=Mo.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return N.useDebugValue(s),N.useEffect(r.onRender(e)),Mx({editor:s,selector:({transactionNumber:i})=>n.shouldRerenderOnTransaction===!1?null:n.immediatelyRender&&i===0?0:i+1}),s}const _d=N.createContext({editor:null});_d.Consumer;const Ax=()=>N.useContext(_d),Dx=n=>{const[e,t]=N.useState(null),{editor:r}=Ax();return N.useEffect(()=>{var s;if(!e||!((s=n.editor)===null||s===void 0)&&s.isDestroyed||r?.isDestroyed)return;const{pluginKey:i="bubbleMenu",editor:o,tippyOptions:a={},updateDelay:l,shouldShow:c=null}=n,d=o||r;if(!d){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const u=Wd({updateDelay:l,editor:d,element:e,pluginKey:i,shouldShow:c,tippyOptions:a});return d.registerPlugin(u),()=>{d.unregisterPlugin(i)}},[n.editor,r,e]),Ae.createElement("div",{ref:t,className:n.className,style:{visibility:"hidden"}},n.children)},jx=N.createContext({onDragStart:void 0}),Ix=()=>N.useContext(jx);Ae.forwardRef((n,e)=>{const{onDragStart:t}=Ix(),r=n.as||"div";return Ae.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});const Rx=/^\s*>\s$/,Px=_e.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}}
vendor: 1,036 bytes, line 105
105,addInputRules(){return[wr({find:Rx,type:this.type})]}}),Lx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Bx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,$x=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Fx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,zx=bt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[mn({find:Lx,type:this.type}),mn({find:$x,type:this.t
vendor: 8,467 bytes, lines 105-108
105ype})]},addPasteRules(){return[gn({find:Bx,type:this.type}),gn({find:Fx,type:this.type})]}}),Vx="listItem",cl="textStyle",dl=/^\s*([-+*])\s$/,Wx=_e.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Vx,this.editor.getAttributes(cl)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=wr({find:dl,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=wr({find:dl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(cl),editor:this.editor})),[n]}}),Hx=/(^|[^`])`([^`]+)`(?!`)/,qx=/(^|[^`])`([^`]+)`(?!`)/g,_x=bt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[mn({find:Hx,type:this.type})]},addPasteRules(){return[gn({find:qx,type:this.type})]}}),Ux=/^```([a-z]+)?[\s\n]$/,Kx=/^~~~([a-z]+)?[\s\n]$/,Jx=_e.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",Ne(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` 106 107`);return!i||!o?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const a=s.after();return a===void 0?!1:r.nodeAt(a)?n.commands.command(({tr:c})=>(c.setSelection(q.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[Bi({find:Ux,type:this.type,getAttributes:n=>({language:n[1]})}),Bi({find:Kx,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new Me({key:new Ye("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!t||!i)return!1;const{tr:o,schema:a}=n.state,l=a.text(t.replace(/\r\n?/g,` 108`));return o.replaceSelectionWith(this.type.create({language:i},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(z.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),Gx=_e.create({name:"doc",topNode:!0,content:"block+"});function Yx(n={}){return new Me({view(e){return new Qx(e,n)}})}class Qx{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,a=i.height/s.offsetHeight;if(t){let u=e.nodeBefore,h=e.nodeAfter;if(u||h){let p=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(p){let m=p.getBoundingClientRect(),g=u?m.bottom:m.top;u&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*a;r={left:m.left,right:m.right,top:g-x,bottom:g+x}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=l.getBoundingClientRect(),h=u.width/l.offsetWidth,p=u.height/l.offsetHeight;c=u.left-l.scrollLeft*h,d=u.top-l.scrollTop*p}this.element.style.left=(r.left-c)/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 t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=hc(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)}}const Xx=me.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Yx(this.options)]}});class ae extends q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ae.valid(r)?new ae(r):q.near(r)}content(){return I.empty}eq(e){return e instanceof ae&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ae(e.resolve(t.pos))}getBookmark(){return new To(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Zx(e)||!ey(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ae.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let a=e.node(o);if(t>
vendor: 1,326 bytes, line 108
1080?e.indexAfter(o)<a.childCount:e.index(o)>0){i=a.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let l=e.doc.resolve(s);if(ae.valid(l))return l}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!$.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let a=e.doc.resolve(s);if(ae.valid(a))return a}return null}}}ae.prototype.visible=!1;ae.findFrom=ae.findGapCursorFrom;q.jsonID("gapcursor",ae);class To{constructor(e){this.pos=e}map(e){return new To(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ae.valid(t)?new ae(t):q.near(t)}}function Zx(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function ey(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function ty(){return new Me({props:{decorations:iy,createSelectionBetween(n,e,t){return e.pos==t.pos&&ae.valid(t)?new ae(t):null}
vendor: 3,508 bytes, lines 108-109
108,handleClick:ry,handleKeyDown:ny,handleDOMEvents:{beforeinput:sy}}})}const ny=ed({ArrowLeft:Ur("horiz",-1),ArrowRight:Ur("horiz",1),ArrowUp:Ur("vert",-1),ArrowDown:Ur("vert",1)});function Ur(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof z){if(!i.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=ae.findGapCursorFrom(a,e,l);return c?(s&&s(r.tr.setSelection(new ae(c))),!0):!1}}function ry(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ae.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&$.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ae(r))),!0)}function sy(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ae))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=C.empty;for(let o=r.length-1;o>=0;o--)s=C.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new I(s,0,0));return i.setSelection(z.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function iy(n){if(!(n.selection instanceof ae))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",he.create(n.doc,[Ke.widget(n.selection.head,e,{key:"gapcursor"})])}const oy=me.create({name:"gapCursor",addProseMirrorPlugins(){return[ty()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=_(P(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),ay=_e.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",Ne(this.options.HTMLAttributes,n)]},renderText(){return` 109`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&o){const u=l.filter(h=>a.includes(h.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),ly=_e.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Ne(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Bi({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}}
109)\\s$`),type:this.type,getAttributes:{level:n}}))}});var xs=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length<xs&&this.leafAppend(e)||this.length<xs&&e.leafPrepend(this)||this.appendInner(e)):this};ye.prototype.prepend=function(e){return e.length?ye.from(e).append(this):this};ye.prototype.appendInner=function(e){return new cy(this,e)};ye.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ye.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};ye.from=function(e){return e instanceof ye?e:e&&e.length?new Ud(e):ye.empty};var Ud=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,a){for(var l=i;l<o;l++)if(s(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,a){for(var l=i-1;l>=o;l--)if(s(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=xs)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=xs)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(ye);ye.empty=new Ud([]);var cy=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(i,a),o)===!1||i>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,i)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(i,a)-a,o+a)===!1||i<a&&this.left.forEachInvertedInner(r,Math.min(s,a),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(ye);const dy=500;class ot{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,a,l,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new ht(u.map));let p=u.step.map(s.slice(i)),m;p&&o.maybeStep(p).doc&&(m=o.mapping.maps[o.mapping.maps.length-1],c.push(new ht(m,void 0,void 0,c.length+d.length))),i--,m&&s.appendMap(m,i)}else o.maybeStep(u.step);if(u.selection)return a=s?u.selection.map(s.slice(i)):u.selection,l=new ot(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,t,r,s){let i=[],o=this.eventCount,a=this.items,l=!s&&a.length?a.get(a.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new ht(e.mapping.maps[d],u,t),p;(p=l&&l.merge(h))&&(h=p,d?i.pop():a=a.slice(0,a.length-1)),i.push(h),t&&(o++,t=void 0),s||(l=h)}let c=o-r.depth;return c>fy&&(a=uy(a,c),o-=c),new ot(a.append(i),o)}remapping(e,t){let r=new pr;
vendor: 10,003 bytes, line 109
109return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new ot(this.items.append(e.map(t=>new ht(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},s);let l=t;this.items.forEach(h=>{let p=i.getMirror(--l);if(p==null)return;o=Math.min(o,p);let m=i.maps[p];if(h.step){let g=e.steps[p].invert(e.docs[p]),x=h.selection&&h.selection.map(i.slice(l+1,p));x&&a++,r.push(new ht(m,g,x))}else r.push(new ht(m))},s);let c=[];for(let h=t;h<o;h++)c.push(new ht(i.maps[h]));let d=this.items.slice(0,s).append(c).append(r),u=new ot(d,a);return u.emptyItemCount()>dy&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],i=0;return this.items.forEach((o,a)=>{if(a>=e)s.push(o),o.selection&&i++;else if(o.step){let l=o.step.map(t.slice(r)),c=l&&l.getMap();if(r--,c&&t.appendMap(c,r),l){let d=o.selection&&o.selection.map(t.slice(r));d&&i++;let u=new ht(c.invert(),l,d),h,p=s.length-1;(h=s.length&&s[p].merge(u))?s[p]=h:s.push(u)}}else o.map&&r--},this.items.length,0),new ot(ye.from(s.reverse()),i)}}ot.empty=new ot(ye.empty,0);function uy(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class ht{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new ht(t.getMap().invert(),t,this.selection)}}}class It{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const fy=20;function hy(n,e,t,r){let s=t.getMeta(dn),i;if(s)return s.historyState;t.getMeta(gy)&&(n=new It(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(dn))return o.getMeta(dn).redo?new It(n.done.addTransform(t,void 0,r,es(e)),n.undone,ul(t.mapping.maps),n.prevTime,n.prevComposition):new It(n.done,n.undone.addTransform(t,void 0,r,es(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!o&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!py(t,n.prevRanges)),c=o?oi(n.prevRanges,t.mapping):ul(t.mapping.maps);return new It(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,es(e)),ot.empty,c,t.time,a??n.prevComposition)}else return(i=t.getMeta("rebased"))?new It(n.done.rebased(t,i),n.undone.rebased(t,i),oi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new It(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),oi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function py(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function ul(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function oi(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function my(n,e,t){let r=es(e),s=dn.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),a=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),l=new It(t?a:i.remaining,t?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(dn,{redo:t,historyState:l})}let ai=!1,fl=null;function es(n){let e=n.plugins;if(fl!=e){ai=!1,fl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){ai=!0;break}}return ai}const dn=new Ye("history"),gy=new Ye("closeHistory");function xy(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Me({key:dn,state:{init(){return new It(ot.empty,ot.empty,null,0,-1)},apply(e,t,r){return hy(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Jd:r=="historyRedo"?Gd:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function Kd(n,e){return(t,r)=>{let s=dn.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=my(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const Jd=Kd(!1,!0),Gd=Kd(!0,!0),yy=me.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Jd(n,e),redo:()=>({state:n,dispatch:e})=>Gd(n,e)}},addProseMirrorPlugins(){return[xy(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()}}}),by=_e.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",Ne(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{selection:t}=e,{$from:r,$to:s}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):Sd(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:a})=>{var l;if(a){const{$to:c}=o.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(z.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection($.create(o.doc,c.pos)):o.setSelection(z.create(o.doc,c.pos));else{const u=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();u&&(o.insert(d,u),o.setSelection(z.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Rg({find:/^(?:---|â-|___\s|\*\*\*\s)$/,type:this.type})]}}),vy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,wy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ky=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Sy=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Cy=bt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[mn({find:vy,type:this.type}),mn({find:ky,type:this.type})]},addPasteRules(){return[gn({find:wy,type:this.type}),gn({find:Sy,type:this.type})]}}),Ny=_e.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Ne(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),My="listItem",hl="textStyle",pl=/^(\d+)\.\s$/,Ey=_e.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",Ne(this.options.HTMLAttributes,t),0]:["ol",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(My,this.editor.getAttributes(hl)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=wr({find:pl,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=wr({find:pl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(hl)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Ty=_e.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Oy=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Ay=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Dy=bt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}}
109,addInputRules(){return[mn({find:Oy,type:this.type})]},addPasteRules(){return[gn({find:Ay,type:this.type})]}}),jy=_e.create({name:"text",group:"inline"}),Iy=me.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(zx.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(Px.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(Wx.configure(this.options.bulletList)),this.options.code!==!1&&n.push(_x.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(Jx.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(Gx.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(Xx.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(oy.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(ay.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(ly.configure(this.options.heading)),this.options.history!==!1&&n.push(yy.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(by.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(Cy.configure(this.options.italic)),this.options.listItem!==!1&&n.push(Ny.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(Ey.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(Ty.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(Dy.configure(this.options.strike)),this.options.text!==!1&&n.push(jy.configure(this.options.text)),n}}),Ry=me.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something â¦",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Me({key:new Ye("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const i=this.editor.isEmpty;return n.descendants((o,a)=>{const l=r>=a&&r<=a+o.nodeSize,c=!o.isLeaf&&As(o);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const u=Ke.node(a,a+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:a,hasAnchor:l}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),he.create(n,s)}}})]}}),Py=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Ly=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,By=bt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}}
109,addInputRules(){return[mn({find:Py,type:this.type})]},addPasteRules(){return[gn({find:Ly,type:this.type})]}}),$y=n=>le({find:/--$/,replace:n??"â"}),Fy=n=>le({find:/\.\.\.$/,replace:n??"â¦"}),zy=n=>le({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:n??"â"}),Vy=n=>le({find:/"$/,replace:n??"â"}),Wy=n=>le({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:n??"â"}),Hy=n=>le({find:/'$/,replace:n??"â"}),qy=n=>le({find:/<-$/,replace:n??"â"}),_y=n=>le({find:/->$/,replace:n??"â"}),Uy=n=>le({find:/\(c\)$/,replace:n??"©"}),Ky=n=>le({find:/\(tm\)$/,replace:n??"â¢"}),Jy=n=>le({find:/\(sm\)$/,replace:n??"â "}),Gy=n=>le({find:/\(r\)$/,replace:n??"®"}),Yy=n=>le({find:/(?:^|\s)(1\/2)\s$/,replace:n??"½"}),Qy=n=>le({find:/\+\/-$/,replace:n??"±"}),Xy=n=>le({find:/!=$/,replace:n??"â "}),Zy=n=>le({find:/<<$/,replace:n??"«"}),eb=n=>le({find:/>>$/,replace:n??"»"}),tb=n=>le({find:/\d+\s?([*x])\s?\d+$/,replace:n??"Ã"}),nb=n=>le({find:/\^2$/,replace:n??"²"}),rb=n=>le({find:/\^3$/,replace:n??"³"}),sb=n=>le({find:/(?:^|\s)(1\/4)\s$/,replace:n??"¼"}),ib=n=>le({find:/(?:^|\s)(3\/4)\s$/,replace:n??"¾"}),ob=me.create({name:"typography",addOptions(){return{closeDoubleQuote:"â",closeSingleQuote:"â",copyright:"©",ellipsis:"â¦",emDash:"â",laquo:"«",leftArrow:"â",multiplication:"Ã",notEqual:"â ",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"â",openSingleQuote:"â",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"â",servicemark:"â ",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"â¢"}},addInputRules(){const n=[];return this.options.emDash!==!1&&n.push($y(this.options.emDash)),this.options.ellipsis!==!1&&n.push(Fy(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&n.push(zy(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&n.push(Vy(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&n.push(Wy(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&n.push(Hy(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&n.push(qy(this.options.leftArrow)),this.options.rightArrow!==!1&&n.push(_y(this.options.rightArrow)),this.options.copyright!==!1&&n.push(Uy(this.options.copyright)),this.options.trademark!==!1&&n.push(Ky(this.options.trademark)),this.options.servicemark!==!1&&n.push(Jy(this.options.servicemark)),this.options.registeredTrademark!==!1&&n.push(Gy(this.options.registeredTrademark)),this.options.oneHalf!==!1&&n.push(Yy(this.options.oneHalf)),this.options.plusMinus!==!1&&n.push(Qy(this.options.plusMinus)),this.options.notEqual!==!1&&n.push(Xy(this.options.notEqual)),this.options.laquo!==!1&&n.push(Zy(this.options.laquo)),this.options.raquo!==!1&&n.push(eb(this.options.raquo)),this.options.multiplication!==!1&&n.push(tb(this.options.multiplication)),this.options.superscriptTwo!==!1&&n.push(nb(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&n.push(rb(this.options.superscriptThree)),this.options.oneQuarter!==!1&&n.push(sb(this.options.oneQuarter)),this.options.threeQuarters!==!1&&n.push(ib(this.options.threeQuarters)),n}}),ab=bt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),lb=me.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}
109return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new Me({key:new Ye("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,a=0,l=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(a,l);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=i-r,c=a-l,d=a;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}}),cb=({editor:n,spellCheck:e=!0})=>n?f.jsx("div",{className:"prose prose-lg dark:prose-invert max-w-none pb-0",children:f.jsx(bx,{editor:n,className:"min-h-[400px] focus:outline-none",spellCheck:e})}):null,Un=({className:n=""})=>f.jsx("div",{className:`w-px h-6 bg-gray-300 dark:bg-neutral-600 mx-0.5 md:mx-1 flex-shrink-0 ${n}`}),db=({editor:n,spellCheck:e=!0,onSpellCheckToggle:t,onToggleSidebar:r,onTextOperation:s,isProcessingAI:i=!1,disableSticky:o=!1,className:a,lastSaved:l,zoom:c=100,onZoomChange:d})=>{if(!n)return null;const u=n.getText(),h=u.trim()?u.trim().split(/\s+/).length:0,p=n.storage.characterCount?.characters?.()||u.length,m=l?l.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):null,g=x=>{if(!n)return;if(n.state.selection.empty){Q.error("Please select some text first");return}s?.(x)};return f.jsx("div",{className:er(o?"bg-white dark:bg-neutral-900 border-b border-gray-200 dark:border-neutral-700 px-2 sm:px-4 lg:px-8 py-1.5 md:py-2":"sticky top-[195px] sm:top-[175px] lg:top-[64px] z-10 bg-white dark:bg-neutral-900 border-b border-gray-200 dark:border-neutral-700 px-2 sm:px-4 lg:px-8 py-1.5 md:py-2",a),children:f.jsxs("div",{className:"flex items-center justify-between w-full",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),className:"gap-1.5 px-3 h-9",title:"Undo (Cmd+Z)",children:[f.jsx(Il,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden lg:inline",children:"Undo"})]}),f.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),className:"gap-1.5 px-3 h-9",title:"Redo (Cmd+Shift+Z)",children:[f.jsx(Rl,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden lg:inline",children:"Redo"})]}),f.jsx(Un,{}),f.jsxs(Z,{variant:e?"default":"outline",size:"sm",onClick:()=>t?.(),className:"gap-1.5 px-3 h-9",title:e?"Disable Spell Check":"Enable Spell Check",children:[f.jsx(Pl,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden lg:inline",children:"Spell Check"})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[n&&f.jsxs("div",{className:"hidden md:flex items-center gap-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-neutral-400 mr-1 hidden lg:inline",children:"AI Assistant:"}),f.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>g("expand"),disabled:i,className:"flex items-center gap-1.5 px-2.5 py-1.5 h-8 hover:bg-gray-100 dark:hover:bg-neutral-700",title:"Expand selected text",children:[f.jsx(Ll,{className:"h-3.5 w-3.5 text-blue-500"}),f.jsx("span",{className:"hidden lg:inline text-xs",children:"Expand"})]}),f.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>g("condense"),disabled:i,className:"flex items-center gap-1.5 px-2.5 py-1.5 h-8 hover:bg-gray-100 dark:hover:bg-neutral-700",title:"Condense selected text",children:[f.jsx(Bl,{className:"h-3.5 w-3.5 text-purple-500"}),f.jsx("span",{className:"hidden lg:inline text-xs",children:"Condense"})]}),f.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>g("rephrase"),disabled:i,className:"flex items-center gap-1.5 px-2.5 py-1.5 h-8 hover:bg-gray-100 dark:hover:bg-neutral-700",title:"Rephrase selected text",children:[f.jsx($l,{className:"h-3.5 w-3.5 text-green-500"}),f.jsx("span",{className:"hidden lg:inline text-xs",children:"Rephrase"})]}),f.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>g("improve"),disabled:i,className:"flex items-center gap-1.5 px-2.5 py-1.5 h-8 hover:bg-gray-100 dark:hover:bg-neutral-700",title:"Improve selected text",children:[f.jsx(cr,{className:"h-3.5 w-3.5 text-yellow-500"}),f.jsx("span",{className:"hidden lg:inline text-xs",children:"Improve"})]})]}),f.jsx(Un,{className:"hidden lg:block"}),f.jsxs("div",{className:"hidden lg:flex items-center gap-2 text-xs text-gray-500 dark:text-neutral-400",children:[f.jsxs("span",{children:[h," words"]}),f.jsx("span",{className:"text-gray-300 dark:text-neutral-600",children:"â¢"}),f.jsxs("span",{children:[p," characters"]})]}),m&&f.jsxs(f.Fragment,{children:[f.jsx(Un,{className:"hidden lg:block"}),f.jsxs("div",{className:"hidden lg:flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[f.jsx(fi,{className:"h-3.5 w-3.5"}),f.jsxs("span",{children:["Saved ",m]})]})]}),d&&f.jsxs(f.Fragment,{children:[f.jsx(Un,{className:"hidden lg:block"}),f.jsxs(ku,{children:[f.jsx(Su,{asChild:!0,children:f.jsxs(Z,{variant:"ghost",size:"sm",className:"hidden lg:flex h-8 gap-1 px-2",title:"Zoom level",children:[f.jsx(Nu,{className:"h-4 w-4"}),f.jsxs("span",{className:"text-xs",children:[c,"%"]}),f.jsx(hi,{className:"h-3 w-3"})]})}
109),f.jsx(Cu,{align:"end",className:"w-24 p-1",children:[100,110,125,150].map(x=>f.jsxs("button",{onClick:()=>d(x),className:er("flex w-full items-center justify-between rounded px-2 py-1.5 text-sm hover:bg-gray-100 dark:hover:bg-neutral-700",x===c&&"bg-gray-100 dark:bg-neutral-700"),children:[x,"%",x===c&&f.jsx(fi,{className:"h-4 w-4 text-blue-500"})]},x))})]})]}),r&&f.jsxs(f.Fragment,{children:[f.jsx(Un,{className:"hidden lg:block"}),f.jsx(Z,{variant:"ghost",size:"sm",onClick:r,className:"hidden lg:flex h-8 w-8 p-0",title:"Toggle AI Sidebar",children:f.jsx(Mu,{className:"h-4 w-4"})})]})]})]})})},ub=({title:n,score:e,maxScore:t,percentage:r,details:s,suggestions:i,isExpanded:o=!1})=>{const a=u=>u>=80?"text-green-600 dark:text-green-400":u>=60?"text-yellow-600 dark:text-yellow-400":u>=40?"text-orange-600 dark:text-orange-400":"text-red-600 dark:text-red-400",l=u=>u>=80?"bg-green-50 dark:bg-green-900/20":u>=60?"bg-yellow-50 dark:bg-yellow-900/20":u>=40?"bg-orange-50 dark:bg-orange-900/20":"bg-red-50 dark:bg-red-900/20",c=u=>u>=80?"border-green-200 dark:border-green-800":u>=60?"border-yellow-200 dark:border-yellow-800":u>=40?"border-orange-200 dark:border-orange-800":"border-red-200 dark:border-red-800",d=u=>u>=80?f.jsx(Ct,{className:"h-5 w-5 text-green-600 dark:text-green-400"}):u>=60?f.jsx(Eu,{className:"h-5 w-5 text-yellow-600 dark:text-yellow-400"}):f.jsx(In,{className:"h-5 w-5 text-red-600 dark:text-red-400"});return o?f.jsxs("div",{className:`p-4 rounded-lg ${l(r)} border ${c(r)}`,children:[f.jsx("div",{className:"flex items-start justify-between mb-3",children:f.jsxs("div",{className:"flex items-start gap-2",children:[d(r),f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-semibold text-foreground",children:n}),f.jsxs("p",{className:`text-xs ${a(r)} font-medium mt-0.5`,children:[r,"% (",e,"/",t," points)"]})]})]})}),s.filter(u=>u.startsWith("â")).length>0&&f.jsxs("div",{className:"mb-3",children:[f.jsxs("h4",{className:"text-xs font-semibold text-green-700 dark:text-green-400 mb-1 flex items-center gap-1",children:[f.jsx(Ct,{className:"h-3 w-3"}),"What's Working"]}),f.jsx("ul",{className:"space-y-0.5 list-disc list-inside",children:s.filter(u=>u.startsWith("â")).map((u,h)=>f.jsx("li",{className:"text-xs text-foreground pl-2",children:u.substring(2)},h))})]}),s.filter(u=>u.startsWith("â")).length>0&&f.jsxs("div",{className:"mb-3",children:[f.jsxs("h4",{className:"text-xs font-semibold text-red-700 dark:text-red-400 mb-1 flex items-center gap-1",children:[f.jsx(In,{className:"h-3 w-3"}),"Needs Attention"]}),f.jsx("ul",{className:"space-y-0.5 list-disc list-inside",children:s.filter(u=>u.startsWith("â")).map((u,h)=>f.jsx("li",{className:"text-xs text-foreground pl-2",children:u.substring(2)},h))})]}),i.length>0&&f.jsxs("div",{className:"bg-background/50 rounded-md p-3",children:[f.jsxs("h4",{className:"text-xs font-semibold text-foreground mb-1 flex items-center gap-1",children:[f.jsx(ts,{className:"h-3 w-3"}),"How to Improve"]}),f.jsx("ul",{className:"space-y-1 list-disc list-inside",children:i.map((u,h)=>f.jsx("li",{className:"text-xs text-foreground",children:u},h))})]})]}):f.jsxs("div",{className:`p-3 rounded-lg ${l(r)} border ${c(r)}`,children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[d(r),f.jsx("h3",{className:"text-sm font-semibold text-foreground",children:n})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:`text-sm font-bold ${a(r)}`,children:[r,"%"]}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",e,"/",t,")"]})]})]}),r<80&&i.length>0&&f.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[f.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Quick tip:"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:i[0]})]})]})};function An(n){return{contentQuality:"Description Quality",technicalMetrics:"Technical Metrics",seoMarketing:"SEO Marketing",engagementFactors:"Engagement Factors",compliance:"Compliance"}[n]||n.replace(/([A-Z])/g," $1").trim()}class fb{diff(e,t,r={}){let s;typeof r=="function"?(s=r,r={}):"callback"in r&&(s=r.callback);const i=this.castInput(e,r),o=this.castInput(t,r),a=this.removeEmpty(this.tokenize(i,r)),l=this.removeEmpty(this.tokenize(o,r));return this.diffWithOptionsObj(a,l,r,s)}diffWithOptionsObj(e,t,r,s){var i;const o=w=>{if(w=this.postProcess(w,r),s){setTimeout(function(){s(w)},0);return}else return w},a=t.length,l=e.length;let c=1,d=a+l;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));const u=(i=r.timeout)!==null&&i!==void 0?i:1/0,h=Date.now()+u,p=[{oldPos:-1,lastComponent:void 0}];let m=this.extractCommon(p[0],t,e,0,r);if(p[0].oldPos+1>=l&&m+1>=a)return o(this.buildValues(p[0].lastComponent,t,e));let g=-1/0,x=1/0;const b=()=>{for(let w=Math.max(g,-c);w<=Math.min(x,c);w+=2){let S;const y=p[w-1],O=p[w+1];y&&(p[w-1]=void 0);let k=!1;if(O){const M=O.oldPos-w;k=O&&0<=M&&M<a}const R=y&&y.oldPos+1<l;if(!k&&!R){p[w]=void 0;continue}if(!R||k&&y.oldPos<O.oldPos?S=this.addToPath(O,!0,!1,0,r):S=this.addToPath(y,!1,
109!0,1,r),m=this.extractCommon(S,t,e,w,r),S.oldPos+1>=l&&m+1>=a)return o(this.buildValues(S.lastComponent,t,e))||!0;p[w]=S,S.oldPos+1>=l&&(x=Math.min(x,w-1)),m+1>=a&&(g=Math.max(g,w+1))}c++};if(s)(function w(){setTimeout(function(){if(c>d||Date.now()>h)return s(void 0);b()||w()},0)})();else for(;c<=d&&Date.now()<=h;){const w=b();if(w)return w}}addToPath(e,t,r,s,i){const o=e.lastComponent;return o&&!i.oneChangePerToken&&o.added===t&&o.removed===r?{oldPos:e.oldPos+s,lastComponent:{count:o.count+1,added:t,removed:r,previousComponent:o.previousComponent}}:{oldPos:e.oldPos+s,lastComponent:{count:1,added:t,removed:r,previousComponent:o}}}extractCommon(e,t,r,s,i){const o=t.length,a=r.length;let l=e.oldPos,c=l-s,d=0;for(;c+1<o&&l+1<a&&this.equals(r[l+1],t[c+1],i);)c++,l++,d++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(e.lastComponent={count:d,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=l,c}equals(e,t,r){return r.comparator?r.comparator(e,t):e===t||!!r.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){const t=[];for(let r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join("")}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,r){const s=[];let i;for(;e;)s.push(e),i=e.previousComponent,delete e.previousComponent,e=i;s.reverse();const o=s.length;let a=0,l=0,c=0;for(;a<o;a++){const d=s[a];if(d.removed)d.value=this.join(r.slice(c,c+d.count)),c+=d.count;else{if(!d.added&&this.useLongestToken){let u=t.slice(l,l+d.count);u=u.map(function(h,p){const m=r[c+p];return m.length>h.length?m:h}),d.value=this.join(u)}else d.value=this.join(t.slice(l,l+d.count));l+=d.count,d.added||(c+=d.count)}}return s}}function ml(n,e){let t;for(t=0;t<n.length&&t<e.length;t++)if(n[t]!=e[t])return n.slice(0,t);return n.slice(0,t)}function gl(n,e){let t;if(!n||!e||n[n.length-1]!=e[e.length-1])return"";for(t=0;t<n.length&&t<e.length;t++)if(n[n.length-(t+1)]!=e[e.length-(t+1)])return n.slice(-t);return n.slice(-t)}function Hi(n,e,t){if(n.slice(0,e.length)!=e)throw Error(`string ${JSON.stringify(n)} doesn't start with prefix ${JSON.stringify(e)}; this is a bug`);return t+n.slice(e.length)}function qi(n,e,t){if(!e)return n+t;if(n.slice(-e.length)!=e)throw Error(`string ${JSON.stringify(n)} doesn't end with suffix ${JSON.stringify(e)}; this is a bug`);return n.slice(0,-e.length)+t}function Kn(n,e){return Hi(n,e,"")}function Kr(n,e){return qi(n,e,"")}function xl(n,e){return e.slice(0,hb(n,e))}function hb(n,e){let t=0;n.length>e.length&&(t=n.length-e.length);let r=e.length;n.length<e.length&&(r=n.length);const s=Array(r);let i=0;s[0]=0;for(let o=1;o<r;o++){for(e[o]==e[i]?s[o]=s[i]:s[o]=i;i>0&&e[o]!=e[i];)i=s[i];e[o]==e[i]&&i++}i=0;for(let o=t;o<n.length;o++){for(;i>0&&n[o]!=e[i];)i=s[i];n[o]==e[i]&&i++}return i}function Jn(n){let e;for(e=n.length-1;e>=0&&n[e].match(/\s/);e--);return n.substring(e+1)}function At(n){const e=n.match(/^\s*/);return e?e[0]:""}const yl="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",pb=new RegExp(`[${yl}]+|\\s+|[^${yl}]`,"ug");class mb extends fb{equals(e,t,r){return r.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let r;if(t.intlSegmenter){const o=t.intlSegmenter;if(o.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');r=[];for(const a of Array.from(o.segment(e))){const l=a.segment;r.length&&/\s/.test(r[r.length-1])&&/\s/.test(l)?r[r.length-1]+=l:r.push(l)}}else r=e.match(pb)||[];const s=[];let i=null;return r.forEach(o=>{/\s/.test(o)?i==null?s.push(o):s.push(s.pop()+o):i!=null&&/\s/.test(i)?s[s.length-1]==i?s.push(s.pop()+o):s.push(i+o):s.push(o),i=o}),s}join(e){return e.map((t,r)=>r==0?t:t.replace(/^\s+/,"")).join("")}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let r=null,s=null,i=null;return e.forEach(o=>{o.added?s=o:o.removed?i=o:((s||i)&&bl(r,i,s,o),r=o,s=null,i=null)}),(s||i)&&bl(r,i,s,null),e}}const gb=new mb;function xb(n,e,t){return gb.diff(n,e,t)}function bl(n,e,t,r){if(e&&t){const s=At(e.value),i=Jn(e.value),o=At(t.value),a=Jn(t.value);if(n){const l=ml(s,o);n.value=qi(n.value,o,l),e.value=Kn(e.value,l),t.value=Kn(t.value,l)}if(r){const l=gl(i,a);r.value=Hi(r.value,a,l),e.value=Kr(e.value,l),t.value=Kr(t.value,l)}}else if(t){if(n){const s=At(t.value);t.value=t.value.substring(s.length)}if(r){const s=At(r.value);r.value=r.value.substring(s.length)}}else if(n&&r){const s=At(r.value),i=At(e.value),o=Jn(e.value),a=ml(s,i);e.value=Kn(e.value,a);const l=gl(Kn(s,a),o);e.value=Kr(e.value,l),r.value=Hi(r.value,s,l),n.value=qi(n.value,s,s.slice(0,s.length-l.length))}else if(r){const s=At(r.value),i=Jn(e.value),o=xl(i,s);e.value=Kr(e.value,o)}else if(n){const s=Jn(n.value),i=At(e.value),o=xl(s,i);e.value=Kn(e.value,o)}}const yb=80;function li(n,e=yb){if(n.length<=e)return[n];const t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function ci(n){return n.replace(/\t+/g," ").match(/\S+|\n| +/g)??[]}function bb(n,e){if(!n&&!e)return{oldDiffs:[],newDiffs:[]};if(!n){const o=ci(e).flatMap(a=>li(a)).map(a=>({type:"added",text:a}));return{oldDiffs:[],newDiffs:o}}if(!e)return{oldDiffs:ci(n).flatMap(a=>li(a)).map(a=>({type:"removed",text:a})),newDiffs:[]};const t=xb(n,e),r=[],s=[];for(const i of t){const a=ci(i.value).flatMap(l=>li(l));i.added?a.forEach(l=>s.push({type:"added",text:l})):i.removed?a.forEach(l=>r.push({type:"removed",text:l}
109)):a.forEach(l=>{r.push({type:"unchanged",text:l}),s.push({type:"unchanged",text:l})})}return{oldDiffs:r,newDiffs:s}}const vb=({paragraphDiffs:n})=>f.jsx("div",{className:"space-y-4 text-sm leading-relaxed",children:n.map((e,t)=>f.jsx("p",{children:e.newDiffs.map((r,s)=>f.jsxs("span",{className:r.type==="added"?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 px-0.5 rounded":r.type==="removed"?"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 line-through px-0.5 rounded":"text-gray-800 dark:text-gray-200",children:[r.text," "]},s))},t))}),wb=({paragraphDiffs:n})=>f.jsx("div",{className:"space-y-4 text-sm leading-relaxed",children:n.map((e,t)=>f.jsx("p",{children:e.oldDiffs.map((r,s)=>f.jsxs("span",{className:r.type==="added"?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 px-0.5 rounded":r.type==="removed"?"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 line-through px-0.5 rounded":"text-gray-800 dark:text-gray-200",children:[r.text," "]},s))},t))}),Yd=({isOpen:n,onClose:e,oldContent:t,newContent:r,onAccept:s,onRevert:i,beforeScore:o,afterScore:a})=>{const l=N.useMemo(()=>{const u=Io(t),h=Io(r),p=u.split(/\n\n+/).filter(b=>b.trim()),m=h.split(/\n\n+/).filter(b=>b.trim()),g=Math.max(p.length,m.length),x=[];for(let b=0;b<g;b++){const w=p[b]||"",S=m[b]||"",{oldDiffs:y,newDiffs:O}=bb(w,S);x.push({oldDiffs:y,newDiffs:O})}return x},[t,r]),[c,d]=N.useState("after");return N.useEffect(()=>{n&&d("after")},[n]),f.jsx(El,{open:n,onOpenChange:u=>{u||e()},children:f.jsxs(Tl,{className:"max-w-[95vw] sm:max-w-2xl lg:max-w-4xl max-h-[90vh] sm:max-h-[85vh] overflow-hidden flex flex-col p-4 sm:p-6",children:[f.jsxs(Ol,{children:[f.jsx(Al,{className:"text-xl sm:text-2xl",children:"Review Changes"}),f.jsx("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 mt-2",children:"Compare your original description with the AI-improved version. Green highlights show additions, red shows removals."})]}),o&&a&&(()=>{const u=a.totalScore-o.totalScore,h=u>0,p=u<0,m=h?"text-green-600 dark:text-green-400":p?"text-red-600 dark:text-red-400":"text-gray-600 dark:text-gray-400",g=h?"text-green-600 dark:text-green-400":p?"text-red-600 dark:text-red-400":"text-gray-600 dark:text-gray-400",x=h?a.totalScore>=80?"⨠Outstanding score!":a.totalScore>=70?"â
Now publish-ready!":"ð Getting better!":p?"â ï¸ Score decreased":"â¡ï¸ No change",b=p?Tu:ts;return f.jsx("div",{className:"p-3 sm:p-4 bg-gradient-to-r from-blue-50 to-cyan-50 dark:from-blue-900/20 dark:to-cyan-900/20 rounded-lg border border-blue-200 dark:border-blue-800",children:f.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 sm:gap-0",children:[f.jsxs("div",{className:"flex items-center gap-3 sm:gap-4",children:[f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Before"}),f.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[f.jsx("span",{className:"text-xl sm:text-2xl font-bold",style:{color:Wt(o.totalScore)},children:o.totalScore}),f.jsx("span",{className:"text-xs sm:text-sm text-gray-600 dark:text-gray-400",children:"/100"})]})]}),f.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-2 sm:px-3",children:[f.jsx(b,{className:`h-4 w-4 sm:h-5 sm:w-5 ${m}`}),f.jsxs("div",{className:"text-center",children:[f.jsxs("div",{className:`text-base sm:text-lg font-bold ${g}`,children:[u>0?"+":"",u]}),f.jsx("div",{className:"text-[10px] sm:text-xs text-gray-500 dark:text-gray-400",children:"points"})]})]}),f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"After"}),f.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[f.jsx("span",{className:"text-xl sm:text-2xl font-bold",style:{color:Wt(a.totalScore)},children:a.totalScore}),f.jsx("span",{className:"text-xs sm:text-sm text-gray-600 dark:text-gray-400",children:"/100"})]})]})]}),f.jsx("div",{className:"text-xs sm:text-sm text-gray-700 dark:text-gray-300 font-medium",children:x})]})})})(),f.jsx("div",{className:"lg:hidden px-4 sm:px-6",children:f.jsxs("div",{className:"inline-flex rounded-lg bg-gray-100 dark:bg-gray-800 p-1 w-full",children:[f.jsx("button",{onClick:()=>d("after"),className:`flex-1 px-3 py-2 text-sm font-medium rounded-md transition-colors ${c==="after"?"bg-white dark:bg-neutral-900 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400"}`,children:"After (Improved)"}),f.jsx("button",{onClick:()=>d("before"),className:`flex-1 px-3 py-2 text-sm font-medium rounded-md transition-colors ${c==="before"?"bg-white dark:bg-neutral-900 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400"}`,children:"Before (Original)"})]})}),f.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 flex-1 overflow-auto p-2",children:[f.jsxs("div",{className:c==="before"?"block":"hidden lg:block",children:[f.jsx("h4",{className:"text-sm font-semibold mb-2 text-gray-700 dark:text-gray-300 sticky top-0 bg-white dark:bg-neutral-900 pb-2",children:"Before"}),f.jsx("div",{className:"p-3 lg:p-4 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700",children:f.jsx(wb,{paragraphDiffs:l})})]}),f.jsxs("div",{className:c==="after"?"block":"hidden lg:block",children:[f.jsx("h4",{className:"text-sm font-semibold mb-2 text-gray-700 dark:text-gray-300 sticky top-0 bg-white dark:bg-neutral-900 pb-2",children:"After"}),f.jsx("div",{className:"p-3 lg:p-4 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700",children:f.jsx(vb,{paragraphDiffs:l})})]})]}),f.jsxs(Dl,{className:"gap-2 flex-col sm:flex-row",children:[f.jsxs(Z,{variant:"outline",onClick:i,className:"w-full sm:w-auto min-h-[44px]",children:[f.jsx(Ui,{className:"h-4 w-4 mr-2"}),"Discard Changes"]}),f.jsxs(Z,{onClick:s,variant:"default",className:"w-full sm:w-auto min-h-[44px]",children:[f.jsx(fi,{className:"h-4 w-4 mr-2"}),"Accept Changes"]})]})]})})},vl=!1,kb=n=>n>=80?{label:"Outstanding",description:"Expect strong engagement with this draft.",badgeClasses:"bg-emerald-50 text-emerald-700 dark:bg-emerald-900/20 dark:text-emerald-300",dotColor:"bg-emerald-500"}:n>=70?{label:"Publish-ready",description:"Polish lifestyle and value cues to reach the 80s.",badgeClasses:"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300",dotColor:"bg-green-400"}:{label:"Needs polish",description:"Add location hooks, lifestyle scenes, and value language.",badgeClasses:"bg-amber-50 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",dotColor:"bg-
109amber-500"},Sb=n=>n>=80?"#10b981":n>=60?"#f59e0b":"#ef4444",Cb=({property:n,content:e="",mlsBoardId:t="generic",onMLSBoardChange:r,onOpenComplianceModal:s,insights:i})=>{const[o,a]=N.useState(new Set(["compliance","score"])),{complianceResult:l,isCheckingCompliance:c,scoreResult:d,isScoring:u,autoApplyImprovements:h,isApplying:p,boards:m,selectedBoard:g,showDiffModal:x,previousContent:b,newContentDraft:w,acceptChanges:S,revertChanges:y,closeDiffModal:O,showUndoButton:k,undoAutoApply:R,canUndo:M,beforeScore:E,afterScore:D}=i,L=A=>{const T=new Set(o);T.has(A)?T.delete(A):T.add(A),a(T)};return f.jsxs("div",{className:"w-96 border-l border-gray-200 dark:border-neutral-700 bg-gray-50 dark:bg-neutral-800 overflow-y-auto",children:[f.jsxs("div",{className:"p-4 space-y-4",children:[f.jsxs(Ps,{className:"p-3",children:[f.jsxs("button",{onClick:()=>L("score"),className:"flex items-center justify-between w-full text-sm font-medium mb-3 text-neutral-900 dark:text-neutral-100",children:[f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx(ts,{className:"h-4 w-4"}),"Description Score"]}),o.has("score")?f.jsx(hi,{className:"h-4 w-4"}):f.jsx(Lr,{className:"h-4 w-4"})]}),o.has("score")&&f.jsx("div",{className:"space-y-3",children:u?f.jsx("div",{className:"text-xs text-gray-500 dark:text-neutral-400 text-center py-4",children:"Analyzing description..."}):d?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsxs("div",{className:"relative w-28 h-28",children:[f.jsx("div",{className:"absolute inset-0 rounded-full",style:{background:`conic-gradient(${Wt(d.totalScore)} 0deg ${d.totalScore*3.6}deg, #e5e7eb ${d.totalScore*3.6}deg 360deg)`},"aria-hidden":"true"}),f.jsx("div",{className:"absolute inset-2 rounded-full bg-white dark:bg-neutral-900 shadow-inner flex items-center justify-center",children:f.jsx("span",{className:"text-4xl font-black tracking-tight",style:{color:Wt(d.totalScore)},children:d.totalScore})})]}),f.jsx("div",{className:"flex-1 space-y-2",children:(()=>{const A=kb(d.totalScore);return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:er("inline-flex items-center gap-2 rounded-full px-3 py-1 text-xs font-medium",A.badgeClasses),children:[f.jsx("span",{className:er("h-2 w-2 rounded-full",A.dotColor)}),A.label]}),f.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:A.description})]})})()})]}),f.jsx("div",{className:"space-y-2",children:Object.entries(d.categories).map(([A,T])=>f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-32 text-xs font-medium text-neutral-500 dark:text-neutral-400",children:An(A)}),f.jsx("div",{className:"flex-1",children:f.jsx("div",{className:"h-2 rounded-full bg-neutral-200 dark:bg-neutral-700 overflow-hidden",children:f.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${T.percentage}%`,backgroundColor:Sb(T.percentage)}})})}),f.jsxs("div",{className:"text-xs font-semibold text-neutral-600 dar
109k:text-neutral-200",children:[T.percentage,"%"]})]},A))}),d.totalScore>=80&&f.jsx("div",{className:"mt-3 p-2 bg-green-50 dark:bg-green-900/20 rounded-lg border border-green-200 dark:border-green-800",children:f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(Fl,{className:"h-4 w-4 text-green-600 dark:text-green-400 mt-0.5"}),f.jsxs("div",{className:"flex-1",children:[f.jsx("p",{className:"text-xs font-medium text-green-900 dark:text-green-100 mb-0.5",children:"Outstanding! This description is show-ready."}),f.jsxs("p",{className:"text-xs text-green-700 dark:text-green-300",children:[d.totalScore,"% exceeds the recommended 80+ benchmark."]})]})]})}),d.totalScore>=70&&d.totalScore<80&&f.jsx("div",{className:"mt-3 p-2 bg-emerald-50 dark:bg-emerald-900/20 rounded-lg border border-emerald-200 dark:border-emerald-800",children:f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(ts,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400 mt-0.5"}),f.jsxs("div",{className:"flex-1",children:[f.jsxs("p",{className:"text-xs font-medium text-emerald-900 dark:text-emerald-100 mb-0.5",children:["Publish-ready at ",d.totalScore,"%."]}),f.jsx("p",{className:"text-xs text-emerald-700 dark:text-emerald-300",children:"A few lifestyle or value tweaks could push it into the 80s."})]})]})}),d.totalScore<70&&f.jsxs("div",{className:"mt-3 rounded-2xl border border-amber-200/80 bg-amber-50 px-4 py-3 flex gap-3",children:[f.jsx("div",{className:"text-amber-500",children:f.jsx(dr,{className:"h-5 w-5"})}),f.jsxs("div",{className:"flex-1 text-sm text-amber-800 space-y-1",children:[f.jsx("p",{className:"font-semibold text-amber-900",children:"Quick improvements"}),f.jsx("ul",{className:"space-y-1 list-disc pl-4",children:d.overallSuggestions.slice(0,2).map((A,T)=>f.jsx("li",{children:A},T))}),vl]})]}),vl,Object.entries(d.categories).map(([A,T])=>T.percentage<80?f.jsxs("div",{className:"bg-gray-50 dark:bg-neutral-800/50 rounded-lg p-3 space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h6",{className:"text-xs font-semibold text-neutral-900 dark:text-neutral-100",children:An(A)}),f.jsxs("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${T.percentage>=80?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":T.percentage>=60?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400":T.percentage>=40?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}`,children:[T.percentage,"%"]})]}),T.details.filter(F=>F.startsWith("â")).length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-xs font-medium text-green-700 dark:text-green-400 mb-1",children:"â What's Working"}),f.jsx("ul",{className:"list-disc list-inside space-y-0.5",children:T.details.filter(F=>F.startsWith("â")).map((F,W)=>f.jsx("li",{className:"text-xs text-gray-600 dark:text-neutral-400 pl-2",children:F.substring(2)},W))})]}),T.details.filter(F=>F.startsWith("â")).length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-xs font-medium text-red-700 dark:text-red-400 mb-1",children:"â Needs Attention"}),f.jsx("ul",{className:"list-disc list-inside space-y-0.5",children:T.details.filter(F=>F.startsWith("â")).map((F,W)=>f.jsx("li",{className:"text-xs text-gray-600 dark:text-neutral-400 pl-2",children:F.substring(2)},W))})]}),T.suggestions.length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-400 mb-1",children:"â How to Improve"}),f.jsx("ul",{className:"list-disc list-inside space-y-0.5",children:T.suggestions.slice(0,2).map((F,W)=>f.jsx("li",{className:"text-xs text-gray-600 dark:text-neutral-400 pl-2",children:F},W))})]})]},A):null),d.totalScore>=80&&Object.entries(d.categories).some(([,A])=>A.percentage>=80&&A.percentage<100)&&f.jsxs("details",{className:"mt-3 group",children:[f.jsxs("summary",{className:"cursor-pointer text-xs font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-1",children:[f.jsx(Lr,{className:"h-3 w-3 group-open:rotate-90 transition-transform"}),"View category enhancements (",Object.entries(d.categories).filter(([,A])=>A.percentage>=80&&A.percentage<100).length," available)"]}),f.jsx("div",{className:"mt-3 space-y-3",children:Object.entries(d.categories).map(([A,T])=>T.percentage>=80&&T.percentage<100?f.jsxs("div",{className:"bg-blue-50/50 dark:bg-blue-900/10 rounded-lg p-3 space-y-2 border border-blue-100 dar
109k:border-blue-900",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("h6",{className:"text-xs font-semibold text-neutral-900 dark:text-neutral-100 flex items-center gap-1",children:[f.jsx(cr,{className:"h-3 w-3 text-blue-500"}),An(A)]}),f.jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",children:[T.percentage,"%"]})]}),T.suggestions.length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-gray-600 dark:text-neutral-400 mb-1",children:"Optional enhancements:"}),f.jsx("ul",{className:"space-y-0.5",children:T.suggestions.map((F,W)=>f.jsxs("li",{className:"text-xs text-gray-600 dark:text-neutral-400 flex items-start gap-1",children:[f.jsx("span",{className:"text-blue-400 mt-0.5",children:"â¢"}),f.jsx("span",{children:F})]},W))})]})]},A):null)})]}),f.jsxs("details",{className:"group",children:[f.jsxs("summary",{className:"cursor-pointer text-xs font-medium text-primary dark:text-primary hover:text-primary/90 dark:hover:text-primary/80 flex items-center gap-1",children:[f.jsx(Lr,{className:"h-3 w-3 group-open:rotate-90 transition-transform"}),"View all categories in detail"]}),f.jsx("div",{className:"mt-3 space-y-3",children:Object.entries(d.categories).map(([A,T])=>f.jsx(ub,{title:An(A),score:T.score,maxScore:T.maxScore,percentage:T.percentage,details:T.details,suggestions:T.suggestions,isExpanded:!0},A))})]})]}):f.jsx("div",{className:"text-xs text-gray-500 dark:text-neutral-400 text-center py-4",children:"Start typing to see your description score"})})]}),k&&f.jsx(Ps,{className:"p-3 bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ct,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),f.jsx("span",{className:"text-sm font-medium text-blue-900 dark:text-blue-100",children:"Changes applied"})]}),f.jsxs(Z,{size:"sm",variant:"ghost",onClick:R,disabled:!M,className:er("text-blue-600 hover:text-blue-700 hover:bg-blue-100 dark:hover:bg-blue-900/30",!M&&"opacity-50 cursor-not-allowed hover:bg-transparent hover:text-blue-600"),children:[f.jsx(Ui,{className:"h-3 w-3 mr-1"}),"Undo"]})]})}),f.jsxs(Ps,{className:"p-3",children:[f.jsxs("button",{onClick:()=>L("compliance"),className:"flex items-center justify-between w-full text-sm font-medium mb-3 text-neutral-900 dark:text-neutral-100",children:[f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx(pi,{className:"h-4 w-4"}),"MLS Compliance"]}),o.has("compliance")?f.jsx(hi,{className:"h-4 w-4"}):f.jsx(Lr,{className:"h-4 w-4"})]}),o.has("compliance")&&f.jsxs("div",{className:"space-y-3",children:[f.jsx("select",{value:t,onChange:A=>r?.(A.target.value),className:"w-full text-xs px-2 py-1 rounded border border-gray-200 dark:border-neutral-700 bg-white dark:bg-neutral-800",children:m.map(A=>f.jsxs("option",{value:A.id,children:[A.name," (",A.maxCharacters," chars)"]},A.id))}),c?f.jsx("div",{className:"text-xs text-gray-500 dark:text-neutral-400",children:"Checking compliance..."}):l?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center justify-between text-xs mb-2",children:[f.jsxs("span",{className:"text-gray-600 dark:text-neutral-400",children:[l.stats.characters,"/",g?.maxCharacters||5e3," chars"]}
109),l.isCompliant?f.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 font-medium",children:[f.jsx(Ct,{className:"h-3 w-3"}),"Compliant"]}):f.jsxs("span",{className:"flex items-center gap-1 text-red-600 dark:text-red-400 font-medium",children:[f.jsx(In,{className:"h-3 w-3"}),"Issues Found"]})]}),l.isCompliant?f.jsxs("div",{className:"text-xs text-gray-600 dark:text-neutral-400 space-y-1 bg-green-50 dark:bg-green-900/10 border border-green-200 dark:border-green-900/30 rounded-md p-2",children:[f.jsxs("div",{className:"flex items-start gap-1.5",children:[f.jsx(Ct,{className:"h-3 w-3 mt-0.5 text-green-600 dark:text-green-400 flex-shrink-0"}),f.jsx("span",{children:"Within character limit"})]}),f.jsxs("div",{className:"flex items-start gap-1.5",children:[f.jsx(Ct,{className:"h-3 w-3 mt-0.5 text-green-600 dark:text-green-400 flex-shrink-0"}),f.jsx("span",{children:"No prohibited terms"})]}),f.jsxs("div",{className:"flex items-start gap-1.5",children:[f.jsx(Ct,{className:"h-3 w-3 mt-0.5 text-green-600 dark:text-green-400 flex-shrink-0"}),f.jsx("span",{children:"Fair housing compliant"})]})]}):f.jsxs("div",{className:"space-y-2",children:[l.issues.slice(0,3).map(A=>f.jsx("div",{className:`text-xs p-2 rounded-md border ${A.severity==="error"?"bg-red-50 dark:bg-red-900/10 border-red-200 dark:border-red-900/30 text-red-700 dark:text-red-300":"bg-yellow-50 dark:bg-yellow-900/10 border-yellow-200 dark:border-yellow-900/30 text-yellow-700 dark:text-yellow-300"}`,children:f.jsxs("div",{className:"flex items-start gap-1.5",children:[A.severity==="error"?f.jsx(In,{className:"h-3 w-3 mt-0.5 flex-shrink-0"}):f.jsx(dr,{className:"h-3 w-3 mt-0.5 flex-shrink-0"}),f.jsxs("div",{className:"flex-1",children:[f.jsx("div",{className:"font-medium",children:A.message}),A.suggestion&&f.jsxs("div",{className:"mt-1 text-xs opacity-90",children:["â ",A.suggestion]})]})]})},A.id)),l.issues.length>3&&f.jsxs("button",{onClick:s,className:"w-full text-xs text-primary hover:text-primary/90 font-medium",children:["View ",l.issues.length-3," more issue",l.issues.length-3!==1?"s":""]})]})]}):f.jsx("div",{className:"text-xs text-gray-500 dark:text-neutral-400",children:"Start typing to check compliance"})]})]})]}),f.jsx(Yd,{isOpen:x,onClose:O,oldContent:b,newContent:w,onAccept:S,onRevert:y,beforeScore:E,afterScore:D})]})},Jr=({onClick:n,icon:e,title:t,disabled:r})=>f.jsx("button",{onClick:n,disabled:r,className:"p-2 hover:bg-gray-100 dark:hover:bg-neutral-700 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t,children:e}),Nb=({editor:n,onTextOperation:e,isProcessing:t=!1})=>{if(!n)return null;const r=s=>{const{from:i,to:o}=n.state.selection;if(!n.state.doc.textBetween(i,o).trim()){Q.error("Please select some text first");return}e(s)};return f.jsx(Dx,{editor:n,tippyOptions:{duration:100,placement:"top"},className:"bg-white dark:bg-neutral-800 shadow-lg rounded-lg border border-gray-200 dark:border-neutral-700 flex items-center p-1",children:t?f.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",children:[f.jsx(ur,{className:"h-4 w-4 animate-spin"}),f.jsx("span",{className:"text-sm",children:"Processing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(Jr,{onClick:()=>r("expand"),icon:f.jsx(Ll,{className:"h-4 w-4"}),title:`Expand text (${En.AI_WRITING} credits)`}),f.jsx(Jr,{onClick:()=>r("condense"),icon:f.jsx(Bl,{className:"h-4 w-4"}),title:`Condense text (${En.AI_WRITING} credits)`}),f.jsx(Jr,{onClick:()=>r("rephrase"),icon:f.jsx($l,{className:"h-4 w-4"}),title:`Rephrase text (${En.AI_WRITING} credits)`}),f.jsx(Jr,{onClick:()=>r("improve"),icon:f.jsx(cr,{className:"h-4 w-4"}),title:`Improve text (${En.AI_WRITING} credits)`})]})})},Mb=["no children","no kids","adults only","seniors only","no families","childless","child-free only","adult community","over 55","55+","no wheelchairs","no disabled","able-bodied only","physically fit required","no mental illness","no ESA","no emotional support animals","no service animals","must be able to climb stairs","no section 8","no vouchers","no housing assistance","no subsidized","christian only","muslim only","jewish only","catholic only","no muslims","no jews","no christians","white only","black only","asian only","hispanic only","no immigrants","citizens only","american born","legal residents only","english speakers only","no foreigners","english only","married couple","married couples only","couples only","single woman","single man","no couples","no single mothers","no single parents","traditional family","normal family","men only","women only"],Eb=["perfect for families","ideal for singles","great for young professionals","perfect for retirees","empty nesters welcome","no play area","quiet living","adult lifestyle","family-oriented","mature community","active adult","young couple","safe neighborhood","safe area","quiet neighborhood","exclusive community","prestigious area","executive neighborhood","professional community","select community","private community","low crime","crime-free","crime free","integrated neighborhood","diverse community","urban area","inner city","ethnic restaurants nearby","up and coming area","changing neighborhood","transitional neighborhood","gentrifying","walk to churches","near temple","near mosque","near synagogue","walking distance to church","near country club","exclusive area","upscale neighbors","affluent area","great schools","top-rated schools","best schools","good schools","top schools"],Tb=["handyman special","fixer upper","fixer-upper","tlc needed","needs work","as-is","as is","
109sold as-is","below market","priced to sell","won't last","wont last","best deal","steal","bargain","reduced","slashed","sacrifice","desperate","hurry","act now","urgent","cash only","no fha","no va","conventional only","investors only","motivated buyer","motivated seller","investor special","flip potential","investment opportunity","guaranteed return","guaranteed appreciation","best home","finest property","most beautiful","perfect home","one of a kind","unique opportunity","rare find"],_i={crmls:{id:"crmls",name:"California Regional MLS (CRMLS)",maxCharacters:2500,textCase:"none",restrictedWords:["motivated seller","must sell","bring all offers","owner financing","seller financing","commission","bonus","rebate","coming soon","pocket listing","pre-market","off-market"]},harmls:{id:"harmls",name:"Houston Association of REALTORS (HAR)",maxCharacters:3e3,textCase:"none",restrictedWords:["motivated","must sell","divorce","foreclosure","short sale","commission","bonus","rebate","gift card","coming soon"]},mred:{id:"mred",name:"Midwest Real Estate Data (MRED)",maxCharacters:1024,textCase:"uppercase",requiredEnding:"END OF DESCRIPTION",restrictedWords:["motivated seller","must sell","bring offers","make offer","obo","or best offer","commission","bonus","coming soon","pre-listing"]},ntreis:{id:"ntreis",name:"North Texas Real Estate Information Systems (NTREIS)",maxCharacters:2500,textCase:"none",restrictedWords:["motivated","must sell","divorce","illness","death","commission","bonus","rebate","coming soon","future listing"]},bright:{id:"bright",name:"Bright MLS",maxCharacters:1500,maxLines:50,textCase:"sentence",restrictedWords:["motivated seller","must sell quickly","bring all offers","owner will finance","seller financing available","commission","bonus to buyer agent","coming soon"]},stellar:{id:"stellar",name:"Stellar MLS",maxCharacters:4e3,textCase:"none",restrictedWords:["motivated","must go","bring offers","make an offer","owner financing","rent to own","lease purchase","commission","compensation","bonus","coming soon","future"]},generic:{id:"generic",name:"Generic MLS (Default)",maxCharacters:2500,textCase:"none",restrictedWords:["motivated seller","must sell","divorce","foreclosure","commission","bonus","rebate","coming soon","owner financing"]}},Ob={"master bedroom":"primary bedroom","master bathroom":"primary bathroom","master suite":"primary suite","master closet":"primary closet","his and hers":"dual","man cave":"bonus room","she shed":"studio shed","mother-in-law suite":"accessory dwelling unit","mother in law suite":"accessory dwelling unit","grandmother suite":"accessory dwelling unit","granny flat":"accessory dwelling unit","in-law apartment":"accessory dwelling unit","maid's quarters":"guest quarters","servants quarters":"guest quarters","bachelor pad":"studio apartment","bachelorette pad":"studio apartment","handicap accessible":"wheelchair accessible",handicapped:"accessible","invalid accessible":"wheelchair accessible",crippled:"accessibility features","safe neighborhood":"desirable location","perfect for families":"spacious layout","walking distance to church":"convenient location","exclusive area":"sought-after neighborhood","great schools":"nearby educational facilities","crime-free":"peaceful setting","ideal for retirees":"single-level living","no kids":"quiet environment","professionals only":"well-maintained property","won't last":"newly listed",hurry:"schedule your showing"},Ab=[/open\s+house\s+\d+\/\d+/gi,/open\s+house\s+(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/gi,/showing\s+on\s+\d+\/\d+/gi,/price\s+drop\s+soon/gi,/price\s+reduction\s+coming/gi,/auction\s+on\s+\d+\/\d+/gi,/bids\s+due\s+by/gi,/offers\s+due\s+by/gi,/coming\s+soon/gi,/pre[\s-]?market/gi,/pocket\s+listing/gi,/off[\s-]?market/gi,/future\s+listing/gi,/will\s+be\s+listed/gi,/to\s+be\s+listed/gi],Db=[/\$?\d+[,\d]*\s*(bonus|credit|rebate|gift|incentive)/gi,/buyer['s]?\s*(bonus|credit|rebate|gift|incentive)/gi,/seller\s*(pays?|paid|paying|will\s+pay)\s*(closing|buyer)/gi,/closing\s+cost\s+assistance/gi,/commission\s*\d*\.?\d*%?/gi,/\d*\.?\d*%?\s*commission/gi,/compensation\s+offered/gi,/co[\s-]?op\s*\d*\.?\d*%?/gi,/seller\s+financing/gi,/owner\s+financing/gi,/owner\s+will\s+carry/gi,/assumable\s+loan/gi,/rent\s+to\s+own/gi,/lease\s+purchase/gi,/contract\s+for\s+deed/gi];function jb(n){return _i[n]||_i.generic}function Qd(){return Object.values(_i)}const Ib=Tb,di={explicit:Mb,fuzzy:Eb,replacements:Ob},Rb=[/re\/max/gi,/remax/gi,/coldwell\s+banker/gi,/century\s+21/gi,/keller\s+williams/gi,/berkshire\s+hathaway/gi,/sotheby/gi,/christie/gi,/compass/gi,/exp\s+realty/gi,/call\s+[a-z]+\s+at/gi,/contact\s+[a-z]+\s+for/gi,/listed\s+by\s+[a-z]+/gi,/text\s+[a-z]+/gi,/email\s+[a-z]+/gi,/your\s+local\s+expert/gi,/trust\s+the\s+expert
109s/gi,/number\s+one\s+agent/gi,/top\s+producer/gi,/award\s+winning/gi];class Xd{constructor(e){Ao(this,"board");this.board=jb(e)}async checkCompliance(e,t){const r=[];let s=e;const i=gi(e);i.characters>this.board.maxCharacters&&r.push({id:"char-limit",severity:"error",category:"character-limit",message:`Description exceeds ${this.board.maxCharacters} character limit`,details:`Current: ${i.characters} characters, Limit: ${this.board.maxCharacters}`,suggestion:`Reduce description by ${i.characters-this.board.maxCharacters} characters`,autoFixable:!0}),this.board.maxLines&&i.lines>this.board.maxLines&&r.push({id:"line-limit",severity:"error",category:"character-limit",message:`Description exceeds ${this.board.maxLines} line limit`,details:`Current: ${i.lines} lines, Limit: ${this.board.maxLines}`,autoFixable:!0});const o=this.checkContactInfo(e);r.push(...o);const a=this.checkBranding(e);r.push(...a);const l=this.checkIncentives(e);r.push(...l);const c=this.checkTimeSensitive(e);r.push(...c);const d=this.checkFairHousing(e);r.push(...d);const u=this.checkRestrictedWords(e);r.push(...u);const h=this.checkFormatting(e);r.push(...h);const p=this.checkBoardSpecific(e);if(r.push(...p),t.checkDuplicates&&t.existingListings){const b=this.checkDuplicates(e,t.existingListings);r.push(...b)}const m=this.checkQuality(e);r.push(...m),t.autoFix&&(s=this.autoFix(e,r));const g=!r.some(b=>b.severity==="error"),x=r.some(b=>b.autoFixable);return{isCompliant:g,issues:r,stats:i,cleanedText:t.autoFix?s:void 0,autoFixAvailable:x}}checkContactInfo(e){const t=[],r=["ave","avenue","st","street","blvd","boulevard","rd","road","dr","drive","ct","court","pl","place","way","ln","lane","duplex","unit","suite","apt","apartment","floor","level","renovated","built","established","circa","year"];return Object.values(Iu).flat().forEach((i,o)=>{const a=e.match(i);if(a){let l=0;a.forEach((c,d)=>{const u=e.indexOf(c,l);l=u+c.length;let h=!1;u<10&&(h=!0);const p=Math.max(0,u-50),m=Math.min(e.length,u+c.length+50),g=e.substring(p,m).toLowerCase();r.some(x=>g.includes(x))&&(h=!0),/^\d{4}$/.test(c)&&(h=!0),h||t.push({id:`contact-${o}-${d}`,severity:"error",category:"contact-info",message:"Contact information not allowed",details:`Found: "${c}"`,suggestion:"Remove all contact information from description",position:{start:u,end:u+c.length},match:c,autoFixable:!0})})}}),t}checkPatterns(e,t,r,s,i,o){const a=[];return t.forEach((l,c)=>{const d=l.flags.includes("g")?l.flags:l.flags+"g",u=new RegExp(l.source,d);let h=0;for(const p of e.matchAll(u))p.index!==void 0&&(a.push({id:`${s}-${c}-${h}`,severity:r,category:s,message:i,details:`Found: "${p[0]}"`,suggestion:o,position:{start:p.index,end:p.index+p[0].length},match:p[0],autoFixable:!0}),h+=1)}),a}checkBranding(e){return this.checkPatterns(e,Rb,"error","branding","Branding or agent information not allowed","Remove all agent names, company names, and branding")}checkIncentives(e){return this.checkPatterns(e,Db,"error","compensation","Compensation or incentive language not allowed","Remove all references to commission, bonuses, or incentives")}checkTimeSensitive(e){return this.checkPatterns(e,Ab,"error","time-sensitive","Time-sensitive content not allowed","Remove dates, times, and time-sensitive phrases")}checkFairHousing(e){const t=[],r=e.toLowerCase();return di.explicit.forEach((s,i)=>{if(r.includes(s)){const o=r.indexOf(s);t.push({id:`fh-explicit-${i}`,severity:"error",category:"fair-housing",message:"Fair housing violation - discriminatory language",details:`Found: "${s}"`,suggestion:"Remove all discriminatory language",position:{start:o,end:o+s.length},match:s})}}),di.fuzzy.forEach((s,i)=>{if(r.includes(s)){const o=r.indexOf(s);t.push({id:`fh-fuzzy-${i}`,severity:"warning",category:"fair-housing",message:"Potential fair housing concern",details:`Found: "${s}" - This phrase may imply preference`,suggestion:"Consider rephrasing to be more inclusive",position:{start:o,end:o+s.length},match:s})}}),Object.entries(di.replacements).forEach(([s,i],o)=>{const a=new RegExp(s,"gi"),l=e.match(a);if(l){let c=0;l.forEach((d,u)=>{const h=e.toLowerCase().indexOf(d.toLowerCase(),c);c=h+d.length,t.push({id:`fh-replace-${o}-${u}`,severity:"warning",category:"fair-housing",message:"Outdated terminology",details:`Found: "${d}"`,suggestion:`Replace with "${i}"`,position:{start:h,end:h+d.length},match:d,autoFixable:!0})})}}),t}checkRestrictedWords(e){const t=[],r=new Set;return[...this.board.restrictedWords,...Ib].forEach((i,o)=>{const a=i.toLowerCase();if(r.has(a))return;const l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(`\\b${l}\\b`,"gi");let d,u=0;for(;(d=c.exec(e))!==null;)r.add(a),t.push({id:`restricted-${o}-${u}`,severity:"error",category:"restricted-words",message:`Restricted term: "${d[0]}"`,details:`"${d[0]}" is not allowed by ${this.board.name}`,suggestion:`Remove or replace "${d[0]}"`,position:{start:d.index,end:d.index+d[0].length},match:d[0],autoFixable:!0}),u++}),t}checkFormatting(e){const t=[];/<[^>
109]*>/.test(e)&&t.push({id:"html-tags",severity:"error",category:"text-formatting",message:"HTML tags found in description",suggestion:"Remove all HTML formatting",autoFixable:!0});const r=[...e].map((s,i)=>({char:s,code:s.charCodeAt(0),index:i})).filter(({code:s})=>s>127);if(r.length>0){const s=[...new Set(r.map(o=>o.char))],i=s.map(o=>{const a=o.charCodeAt(0);return o==="â"||o==="â"?`"${o}" (smart quote - use ")`:o==="â"||o==="â"?`"${o}" (smart apostrophe - use ')`:o==="â"?`"${o}" (em dash - use --)`:o==="â"?`"${o}" (en dash - use -)`:o==="â¦"?`"${o}" (ellipsis - use ...)`:o===" "?'" " (non-breaking space - use regular space)':`"${o}" (code ${a})`});t.push({id:"non-ascii",severity:"warning",category:"text-formatting",message:`Non-ASCII characters found: ${s.join(" ")}`,details:`Found: ${i.join(", ")}`,suggestion:"Replace these special characters with standard ASCII equivalents",match:s.join(""),autoFixable:!0})}return this.board.textCase==="uppercase"&&e!==e.toUpperCase()&&t.push({id:"text-case",severity:"error",category:"text-formatting",message:`Text must be in ${this.board.textCase} case`,suggestion:"Convert entire description to uppercase",autoFixable:!0}),t}checkBoardSpecific(e){const t=[];return this.board.requiredEnding&&!e.trim().endsWith(this.board.requiredEnding)&&t.push({id:"required-ending",severity:"error",category:"board-specific",message:"Missing required ending",details:`Description must end with "${this.board.requiredEnding}"`,suggestion:`Add "${this.board.requiredEnding}" to the end`,autoFixable:!0}),this.board.customRules&&this.board.customRules.forEach((r,s)=>{r.validate(e)||t.push({id:`custom-${r.id}-${s}`,severity:"error",category:"board-specific",message:r.message,details:r.description})}),t}checkDuplicates(e,t){const r=[];return t.forEach(i=>{const o=Ru(e,i.description);o>=.8&&r.push({id:`duplicate-${i.id}`,severity:"warning",category:"duplicate-content",message:"Description is very similar to another listing",details:`${Math.round(o*100)}% similar to listing ${i.id}`,suggestion:"Make description more unique to avoid duplicate content"})}),r}checkQuality(e){const t=[];if(this.board.textCase!=="uppercase"){const r=e.split(/\s+/);r.filter(i=>i.length>3&&i===i.toUpperCase()).length>r.length*.1&&t.push({id:"excessive-caps",severity:"info",category:"quality",message:"Excessive use of capital letters",suggestion:"Use normal capitalization for better readability"})}return e.trim().length<50&&t.push({id:"too-short",severity:"warning",category:"quality",message:"Description is very short",details:"Consider adding more details about the property",suggestion:"Expand description to highlight key features"}),/[!?]{2,}|\.{4,}/.test(e)&&t.push({id:"repeated-punctuation",severity:"info",category:"quality",message:"Excessive punctuation detected",suggestion:"Use standard punctuation",autoFixable:!0}),t}autoFix(e,t){let r=e;return t.filter(i=>i.autoFixable&&i.match).sort((i,o)=>(o.position?.start||0)-(i.position?.start||0)).forEach(i=>{switch(i.category){case"contact-info":case"branding":case"incentives":case"compensation":case"time-sensitive":case"restricted-words":i.match&&(r=r.replace(i.match,""));break;case"fair-housing":if(i.match&&i.suggestion?.includes("Replace with")){const o=i.suggestion.match(/"([^"]+)"$/)?.[1];o&&(r=r.replace(new RegExp(i.match,"gi"),o))}break}}),r=Pu(r,{stripHTML:t.some(i=>i.id==="html-tags"),convertToASCII:t.some(i=>i.id==="non-ascii"),normalizeLineBreaks:!0,textCase:this.board.textCase,requiredEnding:this.board.requiredEnding,maxCharacters:this.board.maxCharacters,maxLines:this.board.maxLines}),r=r.replace(/\s+/g," ").trim(),r}async getMLSReadyText(e,t){return(await this.checkCompliance(e,{boardId:t,autoFix:!0})).cleanedText||e}}const wl=!1,Pb={"character-limit":"Length & Limits","contact-info":"Contact Information",branding:"Branding",incentives:"Incentives","time-sensitive":"Time-Sensitive","fair-housing":"Fair Housing","text-formatting":"Formatting","restricted-words":"Restricted Words",compensation:"Compensation","duplicate-content":"Duplicates",quality:"Quality","board-specific":"Board Rules"},kl={error:{icon:In,color:"text-red-600 dark:text-red-400",bgColor:"bg-red-50 dark:bg-red-950/20",borderColor:"border-red-200 dark:border-red-800",label:"Must Fix"},warning:{icon:dr,color:"text-yellow-600 dark:text-yellow-400",bgColor:"bg-yellow-50 dark:bg-yellow-950/20",borderColor:"border-yellow-200 dark:border-yellow-800",label:"Should Fix"}
109,info:{icon:Ou,color:"text-blue-600 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950/20",borderColor:"border-blue-200 dark:border-blue-800",label:"Suggestion"}},Lb=({isOpen:n,onClose:e,description:t,boardId:r,onBoardChange:s,onExport:i,existingListings:o})=>{const[a,l]=N.useState(null),[c,d]=N.useState(r),[u,h]=N.useState(!1),[p]=N.useState(Qd()),m=N.useMemo(()=>new Xd(c),[c]),g=N.useCallback(async(E=!1,D)=>{try{const L=await m.checkCompliance(t,{boardId:c,checkDuplicates:!!o,existingListings:o,autoFix:E});(!D||!D.aborted)&&(l(L),E&&Q.success("Auto-fix applied successfully"))}catch(L){if(!D||!D.aborted){console.error("Compliance check error:",L);const A=L instanceof Error?L.message:"An unknown error occurred.";Q.error(`Failed to ${E?"apply auto-fix":"check compliance"}: ${A}`),E&&h(!1)}}},[c,t,o,m]),x=N.useRef(null);N.useEffect(()=>{if(!n)return;x.current&&clearTimeout(x.current);const E=new AbortController;return x.current=setTimeout(()=>{g(!1,E.signal)},300),()=>{x.current&&clearTimeout(x.current),E.abort()}},[n,c,t,g]);const b=()=>{if(!a)return;const E=a.cleanedText||t;i(E),Q.success("Description exported successfully"),e()},w=()=>{if(!a)return;const E=a.cleanedText||t;navigator.clipboard.writeText(E),Q.success("Clean description copied to clipboard")},S=E=>{const D={};return E.forEach(L=>{D[L.category]||(D[L.category]=[]),D[L.category].push(L)}),D},y=E=>{const D={error:[],warning:[],info:[]};return E.forEach(L=>{D[L.severity].push(L)}),D},O=E=>{const D=kl[E.severity],L=D.icon;return f.jsx("div",{className:`p-3 rounded-lg border ${D.bgColor} ${D.borderColor}`,children:f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(L,{className:`h-4 w-4 mt-0.5 ${D.color}`}),f.jsxs("div",{className:"flex-1",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("span",{className:`text-sm font-medium ${D.color}`,children:E.message}),wl]}
109),E.details&&f.jsx("p",{className:"text-xs text-neutral-600 dark:text-neutral-400 mb-1",children:E.details}),E.match&&f.jsxs("p",{className:"text-xs font-mono bg-neutral-100 dark:bg-neutral-800 p-1.5 rounded mt-1",children:['"',Lu(E.match,80),'"']}),E.suggestion&&f.jsxs("p",{className:"text-xs text-neutral-600 dark:text-neutral-400 mt-1",children:["ð¡ ",E.suggestion]})]})]})},E.id)};if(!a)return f.jsx(Ro,{isOpen:n,onClose:e,title:"Checking MLS Compliance...",children:f.jsx("div",{className:"flex items-center justify-center py-12",children:f.jsxs("div",{className:"text-center",children:[f.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"}),f.jsx("p",{className:"text-neutral-600 dark:text-neutral-400",children:"Analyzing description for compliance issues..."})]})})});const k=y(a.issues),R=S(a.issues),M=k.error.length>0;return f.jsx(Ro,{isOpen:n,onClose:e,title:"MLS Export Compliance Check",maxWidth:"lg",children:f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{className:"bg-neutral-50 dark:bg-neutral-800 rounded-lg p-3 text-center",children:[f.jsx("p",{className:"text-xs text-neutral-600 dar
109k:text-neutral-400 mb-1",children:"Characters"}),f.jsxs("p",{className:"text-xl font-bold",children:[a.stats.characters,f.jsxs("span",{className:"text-sm font-normal text-neutral-500",children:["/",p.find(E=>E.id===c)?.maxCharacters||5e3]})]})]}),f.jsxs("div",{className:"bg-neutral-50 dark:bg-neutral-800 rounded-lg p-3 text-center",children:[f.jsx("p",{className:"text-xs text-neutral-600 dark:text-neutral-400 mb-1",children:"Errors"}),f.jsxs("div",{className:"flex items-center justify-center gap-2",children:[f.jsx("p",{className:"text-xl font-bold text-red-600",children:k.error.length}),f.jsx(In,{className:"h-5 w-5 text-red-500"})]})]}),f.jsxs("div",{className:"bg-neutral-50 dark:bg-neutral-800 rounded-lg p-3 text-center",children:[f.jsx("p",{className:"text-xs text-neutral-600 dark:text-neutral-400 mb-1",children:"Warnings"}),f.jsxs("div",{className:"flex items-center justify-center gap-2",children:[f.jsx("p",{className:"text-xl font-bold text-yellow-600",children:k.warning.length}),f.jsx(dr,{className:"h-5 w-5 text-yellow-500"})]})]}),f.jsxs("div",{className:"bg-neutral-50 dark:bg-neutral-800 rounded-lg p-3 text-center",children:[f.jsx("p",{className:"text-xs text-neutral-600 dar
109k:text-neutral-400 mb-1",children:"Status"}),f.jsx("p",{className:`text-base font-bold ${a.isCompliant?"text-green-600":"text-red-600"}`,children:a.isCompliant?"Compliant":"Issues Found"})]})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("label",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300 whitespace-nowrap",children:"MLS Board:"}),f.jsxs("div",{className:"relative flex-1",children:[f.jsx("select",{value:c,onChange:E=>{const D=E.target.value;d(D),s(D),g(!1)},className:"w-full px-3 py-2 pr-8 border border-neutral-300 dark:border-neutral-600 rounded-lg bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 text-sm appearance-none cursor-pointer focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary",children:p.map(E=>f.jsxs("option",{value:E.id,children:[E.name," (",E.maxCharacters," chars)"]},E.id))}),f.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none",children:f.jsx("svg",{className:"h-4 w-4 text-neutral-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),a.issues.length>0?f.jsxs(Bu,{defaultValue:"severity",className:"w-full",children:[f.jsxs($u,{className:"grid w-full grid-cols-2",children:[f.jsx(Po,{value:"severity",children:"By Severity"}),f.jsx(Po,{value:"category",children:"By Category"})]}),f.jsx(Lo,{value:"severity",className:"space-y-3 mt-3",children:Object.entries(k).map(([E,D])=>{if(D.length===0)return null;const L=kl[E];return f.jsxs("div",{children:[f.jsxs("h3",{className:`text-sm font-medium mb-2 ${L.color}`,children:[L.label," (",D.length,")"]}),f.jsx("div",{className:"space-y-2",children:D.map(O)})]},E)})}),f.jsx(Lo,{value:"category",className:"space-y-3 mt-3",children:Object.entries(R).map(([E,D])=>f.jsxs("div",{children:[f.jsxs("h3",{className:"text-sm font-medium mb-2 text-neutral-900 dark:text-neutral-100",children:[Pb[E]," (",D.length,")"]}),f.jsx("div",{className:"space-y-2",children:D.map(O)})]},E))})]}):f.jsxs("div",{className:"text-center py-6",children:[f.jsx(Ct,{className:"h-12 w-12 text-green-500 mx-auto mb-3"}),f.jsx("h3",{className:"text-lg font-medium text-neutral-900 dark:text-neutral-100 mb-1",children:"All Compliance Checks Passed!"}
109),f.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Your description is ready for MLS export."})]}),f.jsxs("div",{className:"flex justify-between items-center border-t pt-4",children:[f.jsxs("div",{className:"flex gap-2",children:[wl,a.cleanedText&&f.jsx(Z,{size:"sm",variant:"outline",onClick:w,leftIcon:f.jsx(mi,{size:16}),children:"Copy Clean Text"})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Z,{size:"sm",variant:"outline",onClick:e,children:"Cancel"}),f.jsx(Z,{size:"sm",variant:"default",onClick:b,disabled:M&&!a.cleanedText,leftIcon:f.jsx(zl,{size:16}),children:M&&!a.cleanedText?"Fix Errors First":"Export Description"})]})]})]})})},Bb=!1,$b=n=>n>=80?{label:"Outstanding",badgeClasses:"bg-emerald-50 text-emerald-700",description:"Expect strong engagement with this draft."}:n>=70?{label:"Publish-ready",badgeClasses:"bg-green-50 text-green-700",description:"Add a lifestyle hook to push into the 80s."}:{label:"Needs polish",badgeClasses:"bg-amber-50 text-amber-700",description:"Add location anchors and lifestyle scenes to reach 70."},Fb=n=>n>=80?"#10b981":n>=60?"#f59e0b":"#ef4444",zb=({isOpen:n,onClose:e,scoreResult:t,isScoring:r,onAutoFix:s,isApplying:i,showDiffModal:o=!1,previousContent:a="",newContentDraft:l="",acceptChanges:c=()=>{},revertChanges:d=()=>{},beforeScore:u=null,afterScore:h=null,closeDiffModal:p=()=>{},showUndoButton:m=!1,undoAutoApply:g=()=>{},canUndo:x=!1})=>n?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:e}),f.jsxs("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-neutral-900 rounded-t-2xl shadow-2xl z-50 max-h-[85vh] overflow-y-auto lg:hidden safe-area-inset-bottom",children:[f.jsx("div",{className:"flex justify-center pt-2 pb-1",children:f.jsx("div",{className:"w-12 h-1 bg-gray-300 dark:bg-neutral-600 rounded-full"})}),f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-neutral-700",children:[r?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ur,{className:"h-5 w-5 animate-spin text-gray-400"}),f.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-neutral-400",children:"Analyzing..."})]}):t?f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsxs("div",{className:"relative h-14 w-14",children:[f.jsx("div",{className:"absolute inset-0 rounded-full",style:{background:`conic-gradient(${Wt(t.totalScore)} 0deg ${t.totalScore*3.6}deg, #e5e7eb ${t.totalScore*3.6}deg 360deg)`}}),f.jsx("div",{className:"absolute inset-1.5 rounded-full bg-white dark:bg-neutral-900 shadow-inner flex items-center justify-center",children:f.jsx("span",{className:"text-lg font-bold",style:{color:Wt(t.totalScore)},children:t.totalScore})})]}),f.jsx("div",{className:"flex-1 space-y-1.5",children:(()=>{const b=$b(t.totalScore);return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:`inline-flex items-center gap-2 rounded-full px-3 py-1 text-[11px] font-medium ${b.badgeClasses}`,children:b.label}),f.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400 leading-snug",children:b.description})]})})()})]}):f.jsx("h3",{className:"text-base font-semibold text-neutral-900 dark:text-neutral-100",children:"Description Score"}),f.jsx("button",{onClick:e,className:"p-1 hover:bg-gray-100 dark:hover:bg-neutral-800 rounded-lg transition-colors","aria-label":"Close",children:f.jsx(Au,{className:"h-5 w-5 text-gray-500 dark:text-neutral-400"})})]}),f.jsx("div",{className:"p-4 space-y-4",style:{paddingBottom:"calc(var(--app-combined-bottom-inset) + 16px)"},children:r?f.jsxs("div",{className:"flex items-center justify-center py-8 text-sm text-gray-500 dark:text-neutral-400",children:[f.jsx(ur,{className:"h-5 w-5 animate-spin mr-2"}),"Analyzing your description..."]}):t?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"space-y-3",children:[f.jsxs("h4",{className:"text-sm font-semibold text-neutral-900 dark:text-neutral-100 flex items-center gap-2",children:[f.jsx(Fl,{className:"h-4 w-4 text-amber-500"}),"Breakdown"]}),f.jsx("div",{className:"space-y-2",children:Object.entries(t.categories).map(([b,w])=>f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-28 text-xs font-medium text-neutral-500 dark:text-neutral-400",children:An(b)}),f.jsx("div",{className:"flex-1",children:f.jsx("div",{className:"h-2 rounded-full bg-neutral-200 dark:bg-neutral-700 overflow-hidden",children:f.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${w.percentage}%`,backgroundColor:Fb(w.percentage)}})})}),f.jsxs("div",{className:"text-xs font-semibold text-neutral-600 dar
109k:text-neutral-200",children:[w.percentage,"%"]})]},b))})]}),Bb,m&&x&&f.jsx("div",{className:"p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ct,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),f.jsx("span",{className:"text-sm font-medium text-blue-900 dark:text-blue-100",children:"Changes applied"})]}),f.jsxs(Z,{size:"sm",variant:"ghost",onClick:g,className:"text-blue-600 hover:text-blue-700 hover:bg-blue-100 dark:hover:bg-blue-900/30",children:[f.jsx(Ui,{className:"h-3 w-3 mr-1"}),"Undo"]})]})}),t.totalScore<70&&f.jsxs("div",{className:"rounded-2xl border border-amber-200/80 bg-amber-50 px-4 py-3 text-sm text-amber-800 space-y-1.5",children:[f.jsx("p",{className:"font-semibold text-amber-900",children:"Quick improvements"}),f.jsx("ul",{className:"space-y-1 list-disc pl-4",children:t.overallSuggestions.slice(0,3).map((b,w)=>f.jsx("li",{children:b},w))})]}),Object.entries(t.categories).filter(([,b])=>b.percentage<80).map(([b,w])=>f.jsxs("div",{className:"p-3 rounded-2xl border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-900/40 space-y-1",children:[f.jsxs("p",{className:"text-xs font-semibold text-neutral-900 dark:text-neutral-100",children:[An(b)," (",w.percentage,"%)"]}),f.jsx("ul",{className:"space-y-1",children:w.suggestions.slice(0,2).map((S,y)=>
109f.jsxs("li",{className:"text-xs text-neutral-600 dark:text-neutral-300 leading-relaxed",children:["⢠",S]},y))})]},b))]}):f.jsx("div",{className:"py-8 text-center",children:f.jsx("p",{className:"text-sm text-gray-500 dark:text-neutral-400",children:"Start typing to see your score"})})})]}),f.jsx(Yd,{isOpen:o,onClose:p,oldContent:a,newContent:l,onAccept:c,onRevert:d,beforeScore:u,afterScore:h})]}):null;class Vb{normalizeError(e){if(e instanceof Error){const t=typeof e.status=="number"?e.status:void 0;return{message:e.message,status:t}}if(typeof e=="object"&&e!==null){const t=e,r=typeof t.message=="string"?t.message:void 0,s=typeof t.status=="number"?t.status:void 0;return{message:r,status:s}}return typeof e=="string"?{message:e}:{}}async invokeProcessText(e){const r="live".toLowerCase()==="sandbox"?{"x-autumn-env":"sandbox"}:void 0,{data:s,error:i}=await Gr.functions.invoke("process-text",{body:{text:e.text,operation:e.operation,context:e.context,documentContext:e.documentContext,customPrompt:e.customPrompt,requestId:e.requestId},headers:r});if(i)throw i;if(s?.error)throw new Error(s.error);return s?.result||e.text}async invokeWithRetry(e,t=2){let r;const s=e.requestId??(typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2,10)}`),i={...e,requestId:s};for(let l=0;l<=t;l++)try{return await this.invokeProcessText(i)}catch(c){r=c;const{message:d,status:u}=this.normalizeError(c),h=d??(c instanceof Error?c.message:String(c));console.warn(`AI text processing attempt ${l+1} failed:`,h);const p=d?.toLowerCase()??"",m=/(no\s+.*credit|insufficient\s+credit|quota|upgrade\s+your\s+plan|billing|subscription|payment\s+required)/;if(u===401&&l===0)try{console.log("Got 401, attempting token refresh..."),await ou.forceRefresh();continue}catch(x){throw console.warn("Token refresh failed on 401:",x),c}if(u===401||u===403||m.test(p))throw c;const g=u===429||d?.includes("rate limit")||d?.includes("too many requests")||d?.includes("non-2xx status");if(l<t){const x=g?3e3:1e3,b=Math.pow(2,l)*x;await new Promise(w=>setTimeout(w,b)),console.log(`Retrying AI text processing after ${b}ms delay... (Rate limited: ${g})`)}}const{message:o,status:a}=this.normalizeError(r);throw new Error(o?.includes("timeout")?"The AI service is taking longer than expected. Please try again in a few seconds.":a===429||o?.includes("non-2xx status")?"The AI service is temporarily busy. Please wait a moment and try again.":"The AI service is experiencing high demand. Please try again in a moment.")}async processTextWithStatus(e){try{return{result:await this.invokeWithRetry(e),fallbackMode:!1}}catch(t){console.error("AI Text Processing Error:",t);const{message:r}=this.normalizeError(t);if(r?.includes("credits")||r?.includes("upgrade"))throw t;return Q.error(r||"AI service temporarily unavailable. Using basic text processing instead.",{duration:4e3,id:"ai-fallback-notification"}),{result:this.fallbackProcessing(e),fallbackMode:!0,statusMessage:"Operating in limited mode due to AI service unavailability"}}}async processText(e){try{return await this.invokeWithRetry(e)}catch(t){console.error("AI Text Processing Error:",t);const{message:r}=this.normalizeError(t);if(r?.includes("credits")||r?.includes("upgrade"))throw t;return Q.error(r||"AI service temporarily unavailable. Using basic text processing instead.",{duration:4e3,id:"ai-fallback-notification"}),this.fallbackProcessing(e)}}fallbackProcessing(e){const{text:t,operation:r}=e;switch(r){case"expand":return`${t} This property offers exceptional value with its thoughtfully designed spaces and modern amenities. The attention to detail throughout creates an inviting atmosphere perfect for comfortable living.`;case"condense":{const s=t.trim();if(!s)return"...";if(s.includes(".")){const o=s.split(".")[0].trim();return o.length>0?`${o}.`:s}if(s.length<=100)return s;const i=Math.max(1,Math.floor(s.length*.6));return`${s.substring(0,i).trim()}...`}case"rephrase":return t.replace(/beautiful/gi,"stunning").replace(/nice/gi,"excellent").replace(/good/gi,"outstanding").replace(/great/gi,"exceptional");case"improve":return`${t} The property showcases premium finishes and thoughtful design elements that elevate the living experience.`;default:return t}}async expandText(e,t,r){return this.processText({text:e,operation:"expand",context:t,documentContext:r})}async condenseText(e,t,r){return this.processText({text:e,operation:"condense",context:t,documentContext:r})}async rephraseText(e,t,r){return this.processText({text:e,operation:"rephrase",context:t,documentContext:r})}async improveText(e,t,r){return this.processText({text:e,operation:"improve",context:t,documentContext:r})}}const Xn=new Vb,Wb={pool:[{pattern:/no(?:\s+\w+){0,2}\s+(pool|swimming)/i,context:"negative",weight:1},{pattern:/lacks?(?:\s+\w+){0,2}\s+(pool|swimming)/i,context:"negative",weight:1},{pattern:/without(?:\s+\w+){0,2}\s+(pool|swimming)/i,context:"negative",weight:1},{pattern:/doesn'?t\s+have(?:\s+\w+){0,2}\s+pool/i,context:"negative",weight:1},{pattern:/(community|neighborhood|shared)\s+pool/i,context:"neutral",weight:.6},{pattern:/pool\s+(nearby|access|privileges)/i,context:"neutral",weight:.6},{pattern:/access\s+to.*pool/i,context:"neutral",weight:.5},{pattern:/(private|resort|heated|saltwater|infinity|olympic)\s+pool/i,context:"positive",weight:1},{pattern:/pool\s+(with|featuring)/i,context:"positive",weight:.8},{pattern:/(beautiful|stunning|gorgeous|sparkling)\s+pool/i,context:"positive",weight:.9},{pattern:/pool\s+(and|&)\s+spa/i,context:"positive",weight:1}
109,{pattern:/(in-ground|inground)\s+pool/i,context:"positive",weight:.8}],garage:[{pattern:/no(?:\s+\w+){0,2}\s+garage/i,context:"negative",weight:1},{pattern:/lacks?(?:\s+\w+){0,2}\s+garage/i,context:"negative",weight:1},{pattern:/without(?:\s+\w+){0,2}\s+garage/i,context:"negative",weight:1},{pattern:/(shared|assigned)\s+garage/i,context:"neutral",weight:.6},{pattern:/(carport|covered\s+parking)/i,context:"neutral",weight:.5},{pattern:/(2|3|4|two|three|four)[-\s]car\s+garage/i,context:"positive",weight:1},{pattern:/(attached|detached)\s+garage/i,context:"positive",weight:.9},{pattern:/garage\s+(with|featuring)/i,context:"positive",weight:.8},{pattern:/(finished|heated)\s+garage/i,context:"positive",weight:.9}],fireplace:[{pattern:/no(?:\s+\w+){0,2}\s+fireplace/i,context:"negative",weight:1},{pattern:/lacks?(?:\s+\w+){0,2}\s+fireplace/i,context:"negative",weight:1},{pattern:/without(?:\s+\w+){0,2}\s+fireplace/i,context:"negative",weight:1},{pattern:/(gas|wood|wood-burning|electric)\s+fireplace/i,context:"positive",weight:.9},{pattern:/(cozy|beautiful|stone|brick)\s+fireplace/i,context:"positive",weight:.9},{pattern:/fireplace\s+in/i,context:"positive",weight:.7},{pattern:/(double-sided|two-way)\s+fireplace/i,context:"positive",weight:1}],kitchen:[{pattern:/no(?:\s+\w+){0,2}\s+kitchen/i,context:"negative",weight:1},{pattern:/(dated|old|outdated)\s+kitchen/i,context:"negative",weight:.8},{pattern:/(gourmet|chef's?|modern|updated|renovated)\s+kitchen/i,context:"positive",weight:1},{pattern:/kitchen\s+(with|featuring)/i,context:"positive",weight:.8},{pattern:/\bkitchen(?:[\w\s]{0,30})?(granite|quartz|marble)\s+(counter|countertop)/i,context:"positive",weight:.9},{pattern:/\bkitchen(?:[\w\s]{0,50})?stainless\s+steel\s+appliance/i,context:"positive",weight:.9}],bathroom:[{pattern:/(dated|old|outdated)\s+bath/i,context:"negative",weight:.8},{pattern:/(luxury|spa|master|en-suite)\s+bath/i,context:"positive",weight:1},{pattern:/bath\s+(with|featuring)/i,context:"positive",weight:.8},{pattern:/(soaking|jetted)\s+tub/i,context:"positive",weight:.9},{pattern:/walk-in\s+shower/i,context:"positive",weight:.9}],yard:[{pattern:/no(?:\s+\w+){0,2}\s+yard/i,context:"negative",weight:1},{pattern:/(tiny|small|minimal)\s+yard/i,context:"negative",weight:.7},{pattern:/(shared|common)\s+yard/i,context:"neutral",weight:.6},{pattern:/(large|spacious|expansive|private|fenced)\s+yard/i,context:"positive",weight:1},{pattern:/(landscaped|manicured)\s+yard/i,context:"positive",weight:.9},{pattern:/yard\s+(with|featuring)/i,context:"positive",weight:.8}],patio:[{pattern:/no(?:\s+\w+){0,2}\s+patio/i,context:"negative",weight:1},{pattern:/(covered|enclosed|screened)\s+patio/i,context:"positive",weight:.9},{pattern:/(spacious|large)\s+patio/i,context:"positive",weight:.8},{pattern:/patio\s+(with|featuring)/i,context:"positive",weight:.8}],hardwood:[{pattern:/(worn|damaged|scratched)\s+hardwood/i,context:"negative",weight:.8},{pattern:/(original|refinished|beautiful)\s+hardwood/i,context:"positive",weight:.9},{pattern:/hardwood\s+(floor|throughout)/i,context:"positive",weight:.9}]};function Sl(n,e){const t=n.toLowerCase(),r=e.toLowerCase(),s=Wb[r]||[];if(s.length===0)return t.includes(r)?{context:"neutral",confidence:.5}:{context:"not_found",confidence:1};for(const{pattern:i,context:o,weight:a}of s)if(i.test(t))return{context:o,confidence:a,matchedPattern:i.source};return t.includes(r)?{context:"neutral",confidence:.4}:{context:"not_found",confidence:1}}const ui={pool:["pool","pools","poolside","swimming pool","outdoor pool","indoor pool","lap pool","heated pool"],spa:["spa","spas","hot tub","hot tubs","jacuzzi","whirlpool"],kitchen:["kitchen","kitchens","kitchenette","galley kitchen","chef kitchen","gourmet kitchen"],garage:["garage","garages","carport","parking garage","attached garage","detached garage"],fireplace:["fireplace","fireplaces","wood-burning","gas fireplace","wood fireplace","mantel"],patio:["patio","patios","courtyard","terrace","lanai"],deck:["deck","decks","balcony","balconies","veranda","sundeck"],yard:["yard","yards","backyard","front yard","lawn","fenced yard"],garden:["garden","gardens","landscaping","landscaped"],parking:["parking","parking space","parking space
109s","carport","driveway"],bathroom:["bathroom","bathrooms","bath","baths","powder room","half bath","full bath"],bedroom:["bedroom","bedrooms","bed","beds","master bedroom","guest bedroom"],"living room":["living room","living","family room","great room","den"],"dining room":["dining room","dining","dining area","formal dining"],hardwood:["hardwood","hardwood floors","hardwood flooring","wood floors","oak floors","maple floors"],granite:["granite","granite counters","granite countertops","stone counters"],"stainless steel":["stainless steel","stainless","stainless appliances","ss appliances"],marble:["marble","marble counters","marble countertops","marble floors"],"crown molding":["crown molding","crown moulding","molding","moulding"],"vaulted ceiling":["vaulted ceiling","vaulted ceilings","cathedral ceiling","high ceiling"],"walk-in closet":["walk-in closet","walk-in","walk in closet","walkin closet"],"master suite":["master suite","primary suite","master bedroom","primary bedroom"],"open floor plan":["open floor plan","open concept","open layout","flowing layout"],"natural light":["natural light","natural lighting","sunlight","sun-filled","bright"],storage:["storage","storage space","closet space","shelving","built-in storage"]},Cl=200,Nl=new Set;class Hb{scoreDescription(e,t=!0,r,s){const i=e.toLowerCase(),o=gi(e),a=jl(s),l=cu[a],c={...du};let d={...c};if(l?.categoryWeights){const L=Object.entries(l.categoryWeights).reduce((A,[T,F])=>{const W=T;return typeof F!="number"||!Number.isFinite(F)||F<0?(console.warn(`[DescriptionScoringService] Ignoring invalid weight override for "${W}":`,F),A):(A[W]=F,A)},{});Object.keys(L).length>0&&(d={...c,...L})}const u=Object.values(d).reduce((L,A)=>L+A,0);let h;u<=0?(console.error("[DescriptionScoringService] Category weight sum was non-positive after merging overrides; reverting to defaults."),h=c):Math.abs(u-1)>.001?(console.info(`[DescriptionScoringService] Normalizing category weights (pre-normalization sum: ${u.toFixed(3)}).`),h=Object.fromEntries(Object.entries(d).map(([L,A])=>[L,A/u]))):h=d;const p=l||uu,m=this.scoreContentQuality(e,i,r),g=this.scoreTechnicalMetrics(o,e,p),x=this.scoreSEOMarketing(i),b=this.scoreEngagementFactors(i,e),w=this.scoreCompliance(t),S=this.extractAvailableFeatures(r),y={...b,suggestions:this.filterSuggestionsByFeatures(b.suggestions,S)},O={...g,suggestions:this.filterSuggestionsByFeatures(g.suggestions,S)},k={...x,suggestions:this.filterSuggestionsByFeatures(x.suggestions,S)},R={contentQuality:m,technicalMetrics:O,seoMarketing:k,engagementFactors:y,compliance:w},M=this.applyCategoryCalibration(R,a),E=Math.round(M.contentQuality.percentage*h.contentQuality+M.technicalMetrics.percentage*h.technicalMetrics+M.seoMarketing.percentage*h.seoMarketing+M.engagementFactors.percentage*h.engagementFactors+M.compliance.percentage*h.compliance),D=this.compileOverallSuggestions(M);return{totalScore:E,categories:M,overallSuggestions:D}}applyCategoryCalibration(e,t){const r=fu[t];if(!r||Object.keys(r).length===0)return e;const s={...e};for(const[i,o]of Object.entries(r)){if(!o)continue;const a=i,l=e[a];if(!l||l.maxScore<=0)continue;const c=l.maxScore*o/100,d=Math.min(l.maxScore,Math.max(0,l.score+c)),u=Math.min(100,Math.max(0,Math.round(d/l.maxScore*100)));s[a]={...l,score:d,percentage:u}}return s}scoreContentQuality(e,t,r){let i=0;const o=[],a=[],l=this.extractAvailableFeatures(r),c=e.split(/[.!?]/)[0];let d=0;hu.some(T=>T.test(c))?(d=5,o.push("â Strong opening hook that captures attention")):pu.some(T=>T.test(c))?(d=1,o.push("â Generic opening that fails to engage"),a.push('Replace your opening with an engaging hook. Try: "Discover your dream home..." or "Experience luxury living..."')):(d=3,o.push("⢠Opening could be more compelling"),a.push('Start with action words like "Imagine," "Welcome to," or "Step into" to create immediate interest')),i+=d;let u=0;for(const T of Ir){const{context:F,confidence:W}=Sl(e,T);F==="positive"?u+=W:F==="neutral"&&(u+=W*.5)}const h=Math.min(5,u);i+=h;const m=["kitchen","bedroom","bathroom"].filter(T=>{const{context:F}=Sl(e,T);return F==="not_found"||F==="negative"});h>=4?o.push("â Comprehensive, positive feature coverage"):h>=2?(o.push("⢠Some features highlighted positively"),a.push('Highlight more features with descriptive language (e.g., "gourmet kitchen" not just "kitchen")')):(o.push("â Missing positive feature mentions"),a.push('Add specific features with descriptive words: "gourmet kitchen", "resort-style pool", "spa-like bathroom"')),m.length>0&&a.push(`Mention these key features: ${m.join(", ")}. Buyers specifically search for these terms`);const g=Rr.filter(T=>t.includes(T)),x=Math.min(5,g.length*2);if(i+=x,x>=4)o.push("â Creates emotional connection with buyers");else{o.push("â Lacks emotional appeal and lifestyle focus");const T=Rr.slice(0,5).join(", ");a.push(`Add lifestyle language: "${T}". Help buyers envision living there`)}const b=Pr.filter(T=>t.includes(T)),w=Math.min(5,b.length);if(i+=w,w>=4)o.push("â Strong descriptive language highlights uniqueness");else{o.push("â Generic language doesn't differentiate property");const T=Pr.slice(0,5).join(", ");a.push(`Use power words: "${T}". Make this property stand out from others`)}const S=["schedule","showing","tour","contact","call","visit","today","opportunity"],y=["don't miss","won't last","must see","now","soon"],O=e.split(/\n\n+/),k=O[O.length-1]?.toLowerCase()||"",R=S.some(T=>t.includes(T)),M=y.some(T=>t.includes(T));S.some(T=>k.includes(T))||R&&M?(i+=5,o.push("â Clear call to action motivates buyers")):R||M?(i+=3,o.push("⢠Has some action words but could be stronger"),a.push('End with a clear call-to-action like "Schedule your showing today!"')):(o.push("â No call to action to drive inquiries"),a.push(`End with urgency: "Schedule your private tour today" or "Don't miss this opportunity"`));const D=e.split(/[.!?]+/).filter(T=>T.trim().length>0),L=D.length>0?gi(e).words/D.length:0;if(L>=10&&L<=20)i+=5,o.push("â Easy to read with good sentence flow");else if(L>20){i+=2,o.push("â Sentences too long and complex");const T=D.reduce((F,W)=>F.split(" ").length>W.split(" ").length?F:W);a.push(`Break up long sentences. Your longest has ${T.split(" ").length} words - aim for 15-20`)}else i+=3,o.push("⢠Choppy flow from too many short sentences"),a.push('Combine related short sentences with connectors like "and," "while," or "featuring"');const A=this.filterSuggestionsByFeatures(a,l);return{score:i,maxScore:30,percentage:Math.round(i/30*100),details:o,suggestions:A}}scoreTechnicalMetrics(e,t,r){let i=0;const o=[],a=[],{minWords:l,maxWords:c,idealWords:d}=r,u=d-20,h=d+20;e.words>=l&&e.words<=c?e.words>=u&&e.words<=h?(i+=10,o.push(`â Perfect length at ${e.words} words`)):(i+=7,o.push(`â Good length at ${e.words} words`)):e.words<l?(i+=3,o.push(`â Too short at only ${e.words} words`),a.push(`Add ${l-e.words} more words. Expand on property features, neighborhood, and lifestyle benef
109its`)):(i+=5,o.push(`â Too long at ${e.words} words`),a.push(`Cut ${e.words-c} words. Remove redundant phrases and tighten your language`)),t.split(/\n\n+/).filter(g=>g.trim().length>0).length>=2?i+=1:(i+=0,o.push("â Wall of text without paragraph breaks"),a.push("Add paragraph breaks for easier editing and non-MLS platforms (Airbnb, etc.)"));const m=t.split(/[.!?]+/).filter(g=>g.trim().length>0);if(m.length===0)o.push("â No complete sentences detected"),a.push("Add at least one descriptive sentence highlighting property features and benefits");else{const g=m.map(w=>w.split(/\s+/).filter(Boolean).length),x=this.calculateVariance(g),b=g.reduce((w,S)=>w+S,0)/g.length;x>20?(i+=9,o.push("â Dynamic rhythm with varied sentence lengths")):x>10?(i+=5,o.push("⢠Some sentence variety present"),a.push(`Mix it up! Your sentences average ${Math.round(b)} words. Add some 5-10 word sentences for punch`)):(i+=2,o.push("â Repetitive sentence structure hurts readability"),a.push('Vary dramatically: "Stunning views. This meticulously maintained home features..." Mix short and long'))}return{score:i,maxScore:20,percentage:Math.round(i/20*100),details:o,suggestions:a}}scoreSEOMarketing(e){let r=0;const s=[],i=[],o=mu.filter(u=>e.includes(u)),a=Math.min(10,o.length*2);if(r+=a,a>=8)s.push(`â Excellent location SEO with ${o.length} keywords`);else if(a>=5){s.push("⢠Basic location info present");const u=["neighborhood","schools","shopping","transportation"].filter(h=>!e.includes(h));u.length>0&&i.push(`Add location details buyers search for: ${u.slice(0,3).join(", ")}`)}else s.push("â Missing location keywords hurts searchability"),i.push("Include: neighborhood name, nearby schools, shopping centers, commute times, local attractions");const l=Ir.filter(u=>e.includes(u)),c=Math.min(10,l.length*1.5);if(r+=c,c>=8)s.push(`â Feature-rich with ${l.length} searchable terms`);else{s.push("â Lacks searchable feature keywords");const u=Ir.filter(h=>!e.includes(h)).slice(0,5);i.push(`Add these high-search features if applicable: ${u.join(", ")}`)}return/\d+\s*(bed|bath|car|sqft|sq\.?\s*ft)/i.test(e)?s.push("â Includes specific numbers buyers search for"):i.push('Include specific numbers: "3 bedroom, 2 bathroom" instead of "multiple bedrooms"'),{score:r,maxScore:20,percentage:Math.round(r/20*100),details:s,suggestions:i}}scoreEngagementFactors(e,t){let s=0;const i=[],o=[],a=[...Pr,...Rr].filter(m=>e.includes(m)),l=Math.min(10,a.length);if(s+=l,l>=8)i.push(`â Vivid language with ${a.length} descriptive words`);else if(l>=5){i.push("⢠Some descriptive language present");const m=[...Pr.slice(0,3),...Rr.slice(0,2)];o.push(`Replace bland words with vivid ones: ${m.join(", ")}`)}else i.push("â Bland, generic language won't excite buyers"),o.push('Transform "nice kitchen" â "gourmet kitchen with granite counters"');const d=["lifestyle","enjoy","entertain","relax","gather","perfect for","ideal for","imagine"].filter(m=>e.includes(m));d.length>=2?(s+=5,i.push("â Paints lifestyle picture for buyers")):d.length===1?(s+=3,i.push("⢠Some lifestyle elements present"),o.push('Add lifestyle scenarios: "Perfect for entertaining" or "Relax by the fireplace"')):(i.push("â No lifestyle storytelling"),o.push('Help buyers imagine life here: "Gather with friends on the spacious deck" or "Enjoy morning coffee in the sun-drenched kitchen"'));const h=["value","investment","opportunity","potential","priced","competitive","rare","sought-after"].filter(m=>e.includes(m)),p=Math.min(5,h.length*2.5);return s+=p,p>=4?i.push("â Communicates strong value proposition"):(i.push("â Doesn't convey value or urgency"),o.push('Emphasize value: "Rare opportunity," "Exceptional value," "Priced to sell" or "Investment potential"')),{score:s,maxScore:20,percentage:Math.round(s/20*100),details:i,suggestions:o}}scoreCompliance(e){const r=e?10:0,s=e?["â MLS compliant"]:["â MLS compliance issues"],i=e?[]:["Fix MLS compliance issues first"];return{score:r,maxScore:10,percentage:Math.round(r/10*100),details:s,suggestions:i}}calculateVariance(e){if(e.length===0)return 0;const t=e.reduce((s,i)=>s+i,0)/e.length;return e.map(s=>Math.pow(s-t,2)).reduce((s,i)=>s+i,0)/e.length}compileOverallSuggestions(e){const t=[],r=[{name:"Description Quality",...e.contentQuality},{name:"Technical Metrics",...e.technicalMetrics},{name:"SEO & Marketing",...e.seoMarketing},{name:"Engagement",...e.engagementFactors},{name:"Compliance",...e.compliance}];r.sort((i,o)=>i.percentage-o.percentage);for(let i=0;i<2&&i<r.length;i++){const o=r[i];o.suggestions.length>0&&t.push(...o.suggestions.slice(0,2))}const s=new Map;for(const i of t){const o=i.toLowerCase().trim().replace(/[.,!?]/g,"");s.has(o)||s.set(o,i)}return Array.from(s.values()).slice(0,3)}extractAvailableFeatures(e){const t=new Set;if(!e)return t;const r=[...e.features??[]];e.interior&&(e.interior.interiorFeatures&&r.push(...e.interior.interiorFeatures),e.interior.kitchenFeatures&&r.push(...e.interior.kitchenFeatures),e.interior.fireplaceFeatures&&r.push(...e.interior.fireplaceFeatures),e.interior.appliances&&r.push(...e.interior.appliances)),e.exterior&&(e.exterior.exteriorFeatures&&r.push(...e.exterior.exteriorFeatures),e.exterior.patioPorchFeatures&&r.push(...e.exterior.patioPorchFeatures),e.exterior.poolFeatures&&r.push(...e.exterior.poolFeatures),e.exterior.spaFeatures&&r.push(...e.exterior.spaFeatures),e.exterior.lotFeatures&&r.push(...e.exterior.lotFeatures)),e.parking&&(e.parking.parkingFeatures&&r.push(...e.parking.parkingFeatures),e.parking.storageFeatures&&r.push(...e.parking.storageFeatures)),e.efficie
109ncy?.energyEfficientFeatures&&r.push(...e.efficiency.energyEfficientFeatures),e.community?.communityFeatures&&r.push(...e.community.communityFeatures);for(const s of r){if(typeof s!="string")continue;const i=s.trim();if(!i)continue;const o=i.toLowerCase();t.add(o),o.includes("pool")&&t.add("pool"),o.includes("garage")&&t.add("garage"),o.includes("fireplace")&&t.add("fireplace"),o.includes("kitchen")&&t.add("kitchen"),o.includes("bedroom")&&t.add("bedroom"),o.includes("bathroom")&&t.add("bathroom"),o.includes("patio")&&t.add("patio"),o.includes("deck")&&t.add("deck"),o.includes("yard")&&t.add("yard"),o.includes("garden")&&t.add("garden");for(const[a,l]of Object.entries(ui)){if(a===o)continue;l.some(d=>{const u=d.trim().toLowerCase();return u?u===o?!0:o.includes(u)||u.includes(o):!1})&&t.add(a)}}return t}filterSuggestionsByFeatures(e,t){return t.size===0?e:e.filter(r=>{const s=r.toLowerCase().replace(/[^\w\s]/g," ");return!Ir.some(o=>{const l=(ui[o]?[o,...ui[o]]:[o]).flatMap(d=>{if(typeof d!="string")return[];const u=d.trim();return u?u.length>Cl?(Nl.has(u)||(console.warn(`[DescriptionScoring] Skipping synonym exceeding ${Cl} characters for feature "${o}":`,`${u.slice(0,100)}${u.length>100?"â¦":""}`),Nl.add(u)),[]):[{original:u,normalized:u.toLowerCase()}]:[]});return l.length===0||l.some(({normalized:d})=>t.has(d))?!1:l.some(({original:d})=>{const h=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+");return new RegExp(`\\b${h}\\b`,"i").test(s)})})})}}const Zn=n=>{if(!n)return"";let e=n.trim();if(e=e.replace(/<\/?(html|body|head|style)[^>]*>/gi,"").trim(),/<p\b[^>]*>/i.test(e))return e;e=e.replace(/\r\n/g,` 110`);const t=e.split(/\n\s*\n+/).map(a=>a.trim()).filter(Boolean);if(t.length>1)return t.map(a=>`<p>${a}</p>`).join(` 111`);const r=e.split(/(?<=[.!?])\s+/).map(a=>a.trim()).filter(Boolean);if(r.length===0)return`<p>${e}</p>`;const s=Math.min(6,Math.max(3,Math.round(r.length/3))),i=Math.min(4,Math.max(2,Math.ceil(r.length/s))),o=[];for(let a=0;a<r.length;a+=i){const l=r.slice(a,a+i).join(" ");l&&o.push(`<p>${l}</p>`)}return o.join(` 112`)},qb=({editor:n,content:e,mlsBoardId:t,existingListings:r=[],property:s})=>{const i=N.useMemo(()=>Qd(),[]),o=N.useMemo(()=>i.find(K=>K.id===t),[i,t]),[a,l]=N.useState(null),[c,d]=N.useState(!1),[u,h]=N.useState(null),[p,m]=N.useState(!1),[g,x]=N.useState(!1),[b,w]=N.useState(!1),[S,y]=N.useState(""),[O,k]=N.useState(""),[R,M]=N.useState(null),[E,D]=N.useState(null),[L,A]=N.useState([]),[T,F]=N.useState(!1),W=N.useRef(null),de=L.length>0,ie=N.useMemo(()=>new Xd(t),[t]),ee=N.useMemo(()=>new Hb,[]),U=N.useCallback(async()=>{const K=e.trim();if(!K){l(null);return}d(!0);try{const se=await ie.checkCompliance(K,{boardId:t,checkDuplicates:r.length>0,existingListings:r,autoFix:!1});l(se)}catch(se){console.error("Compliance check error:",se)}finally{d(!1)}},[e,r,t,ie]),ue=N.useCallback(async()=>{const K=e.trim();if(!K){h(null);return}m(!0);try{const se=a?.isCompliant??!0,Ee=s?.enrichment_data||null,Ve=jl(s?.property_type),Te=ee.scoreDescription(K,se,Ee,Ve);h(Te)}catch(se){console.error("Scoring error:",se)}finally{m(!1)}},[a,e,ee,s]);N.useEffect(()=>{const K=window.setTimeout(()=>{U()},500);return()=>{window.clearTimeout(K)}},[U,e,t]),N.useEffect(()=>{const K=window.setTimeout(()=>{ue()},700);return()=>{window.clearTimeout(K)}},[ue,e,a]);const ze=N.useCallback(async()=>{if(!n){Q.error("Editor is not ready yet");return}const K=e.trim();if(!K){Q.error("Add some text before applying improvements");return}y(K),x(!0);try{const Ee=(await ie.checkCompliance(K,{boardId:t,checkDuplicates:r.length>0,existingListings:r,autoFix:!0})).cleanedText||K,Ve=u?[...u.overallSuggestions,...Object.values(u.categories).filter(oe=>oe.percentage<80).flatMap(oe=>oe.suggestions)]:[],Te=o?.maxCharacters??5e3,ct=s?`Property: ${s.property_type||"residential"} ⢠${s.city||""}, ${s.state||""} ⢠${s.bedrooms||"?"} bd ${s.bathrooms||"?"} ba ${s.square_feet||""} sf`:void 0,dt=u?.totalScore??0,it=dt>=80,wt=dt>=60&&dt<80;let Qe;it?Qe=`POLISH MODE - Fix ONLY objective errors. Preserve all original phrasing and flow. 113 114ALLOWED FIXES (make minimal changes only): 115- Fix grammar errors, typos, and punctuation mistakes 116- Fix MLS compliance violations (remove contact info, fair housing issues, time-sensitive language, branding) 117- If call-to-action is missing: append ONE final sentence only - do not touch any existing content 118- Replace vague terms with specific numbers (e.g., "multiple bedrooms" â "3 bedrooms") - make targeted replacements only in those specific spots 119 120CRITICAL: Do NOT make stylistic changes, restructure sentences, or "improve" phrasing that is already effective. The content is already good - only fix actual errors. 121 122Issues identified (fix only if they are objective errors): 123${Ve.map(oe=>`- ${oe}`).join(` 124`)} 125 126Keep under ${Te} characters.`:wt?Qe=`IMPROVE MODE - Make targeted, incremental improvements to address specific deficiencies. Preserve sentences and phrases that are already effective. Only change what's broken. 127 128GUIDELINES: 129- Identify weak sentences or phrases and improve ONLY those specific parts 130- Preserve sentences that already work well - don't rewrite for the sake of rewriting 131- If adding emotional appeal: add a few emotional words to existing sentences, don't restructure everything 132- If adding lifestyle focus: weave in 1-2 lifestyle phrases, don't rewrite entire paragraphs 133- Maintain natural flow - avoid creating choppy or monotone sentence patterns 134- Keep under ${Te} characters 135- Use specific numbers (e.g., "3 bedroom, 2 bathroom") instead of vague terms where suggested 136- End with a clear call-to-action if missing 137 138MLS COMPLIANCE: 139- Keep all facts; do not invent features or details 140- No contact info, incentives, time-sensitive language, branding, or fair-housing issues 141 142Issues to address with incremental improvements: 143${Ve.map(oe=>`- ${oe}`).join(` 144`)}`:Qe=`REWRITE MODE - Substantially improve the description to address the issues below. 145 146- Keep all facts; do not invent features or details 147- Stay MLS compliant: no contact info, incentives, time-sensitive language, branding, or fair-housing issues 148- Keep under ${Te} characters 149- Create natural flow with varied sentence structure - avoid choppy or monotone patterns 150- End with a clear call-to-action if missing 151- Use specific numbers (e.g., "3 bedroom, 2 bathroom") instead of vague terms 152 153Improvements to apply: 154${Ve.map(oe=>`- ${oe}`).join(` 155`)}`;const ut=await Xn.processText({text:Ee,operation:"improve",context:ct,documentContext:Ee,customPrompt:Qe}),J=Zn(ut),ft=oe=>oe.replace(/\s+/g," ").trim();if(ft(J)===ft(K)){Q.info("No improvements needed - content is already optimized");return}const te=s?.enrichment_data||null,Re=s?.property_type||"Single Family",ce=ee.scoreDescription(K,a?.isCompl
155iant??!0,te,Re),we=ee.scoreDescription(ut,!0,te,Re);M(ce),D(we),k(J),w(!0)}catch(se){console.error("Auto-apply improvements failed:",se),Q.error("Failed to apply improvements")}finally{x(!1)}},[n,e,r,ie,t,u,o,s,a?.isCompliant,ee]),fe=N.useCallback(()=>{n&&O&&(A(K=>[S,...K].slice(0,3)),n.chain().focus().setContent(O).run(),Q.success("Changes applied"),w(!1),F(!0),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{F(!1)},3e4))},[n,O,S]),re=N.useCallback(()=>{w(!1),k(""),Q("Changes discarded")},[]),Ie=N.useCallback(()=>{w(!1)},[]),ve=N.useCallback(()=>{if(L.length!==0&&n){const[K,...se]=L;n.chain().focus().setContent(K).run(),A(se),Q.success("Changes undone"),se.length===0&&F(!1)}},[n,L]);return N.useEffect(()=>()=>{W.current&&clearTimeout(W.current)},[]),{boards:i,selectedBoard:o,complianceResult:a,isCheckingCompliance:c,checkCompliance:U,scoreResult:u,isScoring:p,scoreDescription:ue,autoApplyImprovements:ze,isApplying:g,scorePercent:u?.totalScore??null,complianceSummary:a?{state:a.isCompliant?"compliant":"issues",errorCount:a.issues.filter(K=>K.severity==="error").length,warningCount:a.issues.filter(K=>K.severity==="warning").length}:c?{state:"checking",errorCount:0,warningCount:0}:e.trim().length===0?{state:"empty",errorCount:0,warningCount:0}:{state:"checking",errorCount:0,warningCount:0},showDiffModal:b,previousContent:S,newContentDraft:O,beforeScore:R,afterScore:E,acceptChanges:fe,revertChanges:re,closeDiffModal:Ie,showUndoButton:T,undoAutoApply:ve,canUndo:de}},Ml={expand:"Expanding selection...",condense:"Condensing selection...",rephrase:"Rephrasing selection...",improve:"Improving selection..."},_b={expand:"expand the selected text",condense:"condense the selected text",rephrase:"rephrase the selected text",improve:"improve the selected text"},Nv=()=>{const{id:n}=ru(),e=su(),t=iu(),{user:r}=au(),{refresh:s}=vu(),i=t.state?.generatedDescription,[o,a]=N.useState(null),[l,c]=N.useState([]),[d,u]=N.useState(!0),[,h]=N.useState(!1),[p,m]=N.useState(null),[g,x]=N.useState(!1),[b,w]=N.useState(i||""),[S,y]=N.useState(!0),[O,k]=N.useState(!1),[R,M]=N.useState("generic"),[E,D]=N.useState([]),[L,A]=N.useState(!0),[T,F]=N.useState(!1),[W,de]=N.useState(()=>{const V=localStorage.getItem("pl-editor-zoom");return V?Number(V):100}),[ie,ee]=N.useState(!1),[U,ue]=N.useState({operation:null,state:"idle",startedAt:null}),[ze,fe]=N.useState(0),re=N.useRef(null),Ie=N.useRef(new Set),ve=N.useRef(b),K=N.useRef({propertyId:null,appliedGenerated:!1,appliedInitialProperty:!1,lastAppliedHtml:null}),se=U.state==="running",Ee=N.useCallback(async()=>{try{await s()}catch(V){console.error("[DescriptionEditor] Failed to refresh credits:",V)}},[s]),Ve=N.useCallback(V=>{re.current&&(clearTimeout(re.current),re.current=null),fe(0),ue({operation:V,state:"running",startedAt:Date.now(),error:void 0})},[]),Te=N.useCallback(()=>{re.current&&(clearTimeout(re.current),re.current=null),fe(0),ue(V=>({...V,state:"success",error:void 0})),re.current=setTimeout(()=>{ue({operation:null,state:"idle",startedAt:null}),re.current=null},400)},[]),ct=N.useCallback((V,H)=>{re.current&&(clearTimeout(re.current),re.current=null),fe(0),ue({operation:V,state:"error",startedAt:null,error:H})},[]),dt=N.useCallback(()=>{re.current&&(clearTimeout(re.current),re.current=null),fe(0),ue({operation:null,state:"idle",startedAt:null})},[]);N.useEffect(()=>{if(U.state!=="running"){fe(0);return}fe(0);const V=window.setInterval(()=>{fe(H=>H+1)},1e3);return()=>window.clearInterval(V)},[U.state,U.startedAt]),N.useEffect(()=>()=>{re.current&&clearTimeout(re.current)},[]),N.useEffect(()=>{localStorage.setItem("pl-editor-zoom",String(W))},[W]);const it=N.useMemo(()=>U.state!=="running"||!U.operation?null:ze>=15?"ð¯ Finalizing improvements...":ze>=7?"â¡ Almost done...":ze>=3?"ð Working its magic...":Ml[U.operation],[U.state,U.operation,ze]),wt=N.useMemo(()=>{if(U.state!=="error")return null;const V=U.operation??"improve";return U.error?U.error:`We hit a snag while trying to ${_b[V]}.`},[U.state,U.operation,U.error]),Qe=N.useMemo(()=>U.state!=="running"?null:it||(U.operation?Ml[U.operation]:"AI is processing your text..."),[U.state,U.operation,it]),{images:ut}=bu(n,r?.id,l,{autoRefresh:!0,refreshBeforeExpiry:5}),J=Ox({extensions:[Iy.configure({heading:{levels:[1,2,3]}}),Ry.configure({placeholder:"Start writing your property description here..."}),By,ob,ab,lb.configure({limit:null}),ux],content:b,onUpdate:({editor:V})=>{w(V.getHTML())}});N.useEffect(()=>{ve.current=b},[b]);
155const ft=J?.getText()??"",te=qb({editor:J,content:ft,mlsBoardId:R,existingListings:E,property:o}),Re=p?p.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):null,ce=te.scorePercent,we=te.complianceSummary;N.useEffect(()=>{if(!n)return;(async()=>{try{u(!0);const{data:H,error:Pe}=await Gr.from("properties").select("*").eq("id",n).single();if(Pe)throw Pe;if(a(H),H.updated_at&&m(new Date(H.updated_at)),r)try{const v=await yu.getPropertyImages(n,r.id);c(v)}catch(v){console.error("Error fetching images:",v)}const{data:{user:X}}=await Gr.auth.getUser();if(X){const{data:v}=await Gr.from("properties").select("id, description").eq("user_id",X.id).neq("id",n).not("description","is",null);v&&D(v)}}catch(H){console.error("Error fetching property:",H),Q.error("Failed to load property"),e("/dashboard/properties")}finally{u(!1)}})()},[n,e,r]),N.useEffect(()=>{if(!J)return;const V=n??o?.id??null,H=K.current;H.propertyId!==V&&(H.propertyId=V,H.appliedGenerated=!1,H.appliedInitialProperty=!1,H.lastAppliedHtml=null);const Pe=X=>{H.lastAppliedHtml===X&&ve.current===X||(w(X),J.commands.setContent(X),H.lastAppliedHtml=X)};if(i&&!H.appliedGenerated){const X=Zn(i);Pe(X),H.appliedGenerated=!0,H.appliedInitialProperty=!0;return}if(!H.appliedInitialProperty&&o?.description){const X=Zn(o.description);if(ve.current===X){H.lastAppliedHtml=X,H.appliedInitialProperty=!0;return}Pe(X),H.appliedInitialProperty=!0}},[J,i,o,n]),N.useEffect(()=>{i&&!d&&Q.success("Generated description loaded! You can now edit it as needed.")},[i,d]),N.useEffect(()=>{if(!o||d||i||Ie.current.has(o.id))return;(async()=>{const H=o.description||"";if((()=>{try{return(new DOMParser().parseFromString(H,"text/html").body.textContent||"").trim().toLowerCase()}catch{return H.replace(/<[^>]+>/g," ").trim().toLowerCase()}})().includes("virtually staged")){Ie.current.add(o.id);return}try{const{exists:v,error:j}=await xu(o.id);if(j){console.error("[DescriptionEditor] Failed to check virtual staging:",j);return}if(Ie.current.add(o.id),!v)return;ee(!0)}catch(v){console.error("[DescriptionEditor] Failed to check virtual staging:",v);return}})()},[o,d,i]);const oe=N.useCallback(async(V=!1)=>{if(!(!o||!b)){h(!0);try{await Do(o.id,b),m(new Date),V||Q.success("Description saved successfully"),a({...o,description:b})}catch(H){console.error("Error saving description:",H),V||Q.error("Failed to save description")}finally{h(!1)}}},[o,b]);N.useEffect(()=>{if(!o||!b||b===o.description)return;const V=setTimeout(()=>{oe(!0)},2e3);return()=>clearTimeout(V)},[b,o,oe]);const Jt=async V=>{const H=Zn(V);w(H),J?.commands.setContent(H),x(!1),Q.success("Description generated! You can now edit it as needed.")},Gt=async V=>{if(!V||!o){ee(!1);return}const H=b,X=Zn("One or more photo(s) is virtually staged."),v=b+X;w(v),J?.commands.setContent(v);try{await Do(o.id,v),m(new Date),a({...o,description:v}),ee(!1),Q.success("Virtual staging disclaimer added")}catch(j){w(H),J?.commands.setContent(H),console.error("[DescriptionEditor] Failed to save disclaimer:",j),Q.error("Failed to save disclaimer. Please try again.")}},Yt=()=>{const V=J?.getText()||"";navigator.clipboard.writeText(V),Q.success("Description copied to clipboard")},bn=()=>{const V=te.complianceResult?.cleanedText||J?.getText()||"";if(!V.trim()){Q.error("Nothing to export yet");return}Qt(V),Q.success("Exported description text")},Qt=V=>{const H=new Blob([V],{type:"text/plain"}),Pe=URL.createObjectURL(H),X=document.createElement("a");X.href=Pe,X.download=`property-${o?.id}-mls-description.txt`,document.body.appendChild(X),X.click(),document.body.removeChild(X),URL.revokeObjectURL(Pe),Q.success("MLS-compliant description exported")},Hn=async V=>{if(!J)return;const{from:H,to:Pe}=J.state.selection,X=J.state.doc.textBetween(H,Pe);if(!X.trim()){Q.error("Please select some text first");return}Ve(V);const v="ai-processing";Q.loading("⨠AI is working on your text...",{id:v});try{let j="";const B=`Property: ${o?.property_type||"residential"} in ${o?.city}, ${o?.state}`,G=J.getText();switch(V){case"expand":j=await Xn.expandText(X,B,G);break;case"condense":j=await Xn.condenseText(X,B,G);break;case"rephrase":j=await Xn.rephraseText(X,B,G);break;case"improve":j=await Xn.improveText(X,B,G);break}J.chain().focus().deleteRange({from:H,to:Pe}).insertContent(j).run(),Q.dismiss(v),Q.success(`Text ${V}d successfully`),Te(),Ee()}catch(j){console.error("AI text operation error:",j);const B=j instanceof Error?j.message:"Failed to process text. Please try again.";Q.dismiss(v),Q.error(B),ct(V,B)}};return d?f.jsx("div",{className:"flex h-screen items-center justify-center",children:f.jsx(ur,{className:"h-8 w-8 animate-spin text-primary"})}):o?f.jsxs("div",{className:"flex h-screen bg-white dark:bg-neutral-900",children:[f.jsxs("div",{className:"fixed top-0 left-0 right-0 z-20 bg-white dark:bg-neutral-900",children:[f.jsx("div",{className:"mx-auto w-full max-w-5xl lg:max-w-none px-3 sm:px-6 lg:px-8 py-1.5 sm:py-2",children:f.jsxs("div",{className:"flex items-center justify-between gap-2 lg:gap-6",children:[f.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[f.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>e(`/dashboard/properties/${n}`),className:"gap-1 sm:gap-2 px-2 sm:px-3",children:[f.jsx(Du,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Back to Property"})]}),f.jsxs("div",{className:"border-l border-gray-200 dark:border-neutral-700 pl-2 sm:pl-4",children:[f.jsx("h1",{className:"text-base lg:text-lg font-semibold text-neutral-900 dark:text-neutral-100 font-display tracking-tight",children:"Description
155Editor"}),f.jsx("p",{className:"text-[11px] sm:text-xs lg:text-sm text-gray-600 dark:text-neutral-400 truncate max-w-[200px] sm:max-w-none",children:o.address||o.street_address})]}),f.jsx("div",{className:"hidden lg:block ml-4",children:f.jsx(wu,{align:"end"})})]}),f.jsxs("button",{onClick:()=>F(!0),className:"flex items-center gap-1.5 sm:gap-2 rounded-full px-2.5 sm:px-3 py-1.5 text-xs font-semibold shadow-sm lg:hidden bg-white dark:bg-neutral-800 border border-gray-200 dark:border-neutral-700",children:[f.jsxs("svg",{className:"h-5 w-5 -rotate-90",viewBox:"0 0 20 20",children:[f.jsx("circle",{cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-gray-200 dark:text-neutral-700"}),f.jsx("circle",{cx:"10",cy:"10",r:"8",fill:"none",strokeWidth:"2",strokeDasharray:`${2*Math.PI*8}`,strokeDashoffset:`${2*Math.PI*8*(1-(ce||0)/100)}`,className:"transition-all duration-500",style:{stroke:ce!==null?Wt(ce):"#94a3b8"},strokeLinecap:"round"})]}),f.jsx("span",{className:"text-sm font-semibold",style:{color:ce!==null?Wt(ce):void 0},children:ce!==null?`${ce}/100`:"Score"}),ce!==null&&f.jsx("span",{className:"hidden sm:inline text-gray-600 dark:text-neutral-400",children:ce>=80?"Outstanding":ce>=70?"Publish-ready":"Needs polish"})]}),f.jsx("div",{className:"hidden flex-1 items-center justify-end lg:flex",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(jo,{creditCost:En.DESCRIPTION,tooltipPosition:"bottom",children:f.jsxs(Z,{size:"sm",variant:"pl",onClick:()=>x(!0),className:"gap-1.5 px-3",children:[f.jsx(ju,{className:"h-4 w-4"}),"Generate Options"]})}),f.jsxs("button",{onClick:()=>k(!0),className:`flex items-center gap-1.5 rounded-md border px-3 py-2 text-sm font-medium transition-colors ${we.state==="issues"?"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 dark:border-red-900/40 dark:bg-red-900/30 dark:text-red-300 dark:hover:bg-red-900/40":we.state==="compliant"?"border-green-200 bg-green-50 text-green-700 hover:bg-green-100 dark:border-green-900/30 dark:bg-green-900/20 dark:text-green-300 dark:hover:bg-green-900/30":"border-gray-200 bg-gray-50 text-gray-600 hover:bg-gray-100 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700"}`,children:[f.jsx(pi,{className:"h-4 w-4"}),we.state==="issues"?`${we.errorCount} issues${we.warningCount?`, ${we.warningCount} warnings`:""}`:we.state==="compliant"?"Compliant":"Checkingâ¦"]}),f.jsxs(Z,{size:"sm",variant:"pl-outline",onClick:Yt,className:"gap-1.5 px-3",children:[f.jsx(mi,{className:"h-4 w-4"}),"Copy"]}),f.jsxs(Z,{size:"sm",variant:"pl-outline",onClick:bn,className:"gap-1.5 px-3",children:[f.jsx(zl,{className:"h-4 w-4"}),"Export"]})]})})]})}),f.jsx("div",{className:"lg:hidden border-t border-gray-200/80 dark:border-neutral-800/80",children:f.jsxs("div",{className:"mx-auto w-full max-w-5xl pt-2 pb-0 flex flex-col gap-2 px-3 sm:px-4 md:px-6",children:[f.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5 overflow-x-auto",children:[f.jsx(jo,{creditCost:En.DESCRIPTION,tooltipPosition:"top",showMobileInline:!1,children:f.jsxs(Z,{variant:"pl",size:"sm",onClick:()=>x(!0),className:"h-8 sm:h-9 rounded-full px-2.5 sm:px-3 flex-shrink-0 gap-1 sm:gap-1.5 text-xs",children:[f.jsx(cr,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}),f.jsx("span",{className:"whitespace-nowrap",children:"Generate"})]})}),f.jsxs("button",{onClick:()=>k(!0),className:`flex items-center gap-1 sm:gap-2 rounded-full border px-2.5 sm:px-3 h-8 sm:h-9 text-xs font-medium transition-colors flex-shrink-0 ${we.state==="issues"?"border-red-200 bg-red-50 text-red-600 dark:border-red-900/40 dark:bg-red-900/30 dark:text-red-200":"border-green-200 bg-green-50 text-green-600 dark:border-green-900/30 dark:bg-green-900/20 dark:text-green-200"}`,children:[f.jsx(pi,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}),f.jsx("span",{className:"whitespace-nowrap",children:we.state==="issues"?"Issues":"Compliant"})]}),f.jsx(Z,{variant:"outline",size:"sm",onClick:()=>J?.chain().focus().undo().run(),disabled:!J?.can().undo(),className:"h-8 w-8 sm:h-9 sm:w-9 rounded-full p-0 flex-shrink-0",title:"Undo",children:f.jsx(Il,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})}),f.jsx(Z,{variant:"outline",size:"sm",onClick:()=>J?.chain().focus().redo().run(),disabled:!J?.can().redo(),className:"h-8 w-8 sm:h-9 sm:w-9 rounded-full p-0 flex-shrink-0",title:"Redo",children:f.jsx(Rl,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})}),f.jsx(Z,{variant:S?"default":"outline",size:"sm",onClick:()=>y(!S),className:"h-8 w-8 sm:h-9 sm:w-9 rounded-full p-0 flex-shrink-0",title:S?"Disable Spell Check":"Enable Spell Check",children:f.jsx(Pl,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})}),f.jsx(Z,{variant:"outline",size:"sm",onClick:Yt,className:"h-8 w-8 sm:h-9 sm:w-9 rounded-full p-0 flex-shrink-0",title:"Copy",children:f.jsx(mi,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex-1 rounded-lg border border-dashed border-neutral-300 dark:border-neutral-700 bg-white/80 dark:bg-neutral-900/60 px-3 py-2 text-[11px] text-neutral-600 dar
155k:text-neutral-300 flex items-center gap-1.5",children:[f.jsx(cr,{className:"h-3 w-3 flex-shrink-0 text-blue-500 dark:text-blue-400"}),f.jsx("span",{className:"sm:hidden",children:"Select text for AI assistance"}),f.jsx("span",{className:"hidden sm:inline",children:"Select text to unlock AI actions"})]}),f.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-neutral-600 dark:text-neutral-400 flex-shrink-0",children:[f.jsxs("span",{className:"font-medium",children:[J?.getText().trim()?J.getText().trim().split(/\s+/).length:0," Words"]}),Re&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"block h-1 w-1 rounded-full bg-neutral-400"}),f.jsxs("span",{children:["Saved ",Re]})]})]})]})]})})]}),f.jsx("div",{className:"flex-1 flex pt-[144px] sm:pt-[140px] lg:pt-16",children:f.jsxs("div",{className:"flex-1 flex flex-col",children:[f.jsx("div",{className:"hidden lg:block",children:f.jsx(db,{editor:J,spellCheck:S,onSpellCheckToggle:()=>y(!S),onToggleSidebar:()=>A(!L),onTextOperation:Hn,isProcessingAI:se,lastSaved:p,zoom:W,onZoomChange:de})}),f.jsxs("div",{className:"flex-1 flex bg-gray-50 dark:bg-neutral-900",children:[f.jsx("div",{className:"flex-1 px-3 sm:px-6 lg:px-8 pt-2 pb-0 sm:pt-3 sm:pb-0 lg:py-6 overflow-auto",children:f.jsxs("div",{className:"mx-auto w-full",style:{maxWidth:`${Math.round(720*(W/100))}px`},children:[U.state==="running"&&Qe&&f.jsxs("div",{className:"sticky top-0 z-20 mb-3 flex items-center gap-2 rounded-md bg-blue-50 px-3 py-2 text-xs sm:text-sm font-medium text-blue-700 dark:bg-blue-900/20 dark:text-blue-200",role:"status","aria-live":"polite",children:[f.jsx(ur,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),f.jsx("span",{children:Qe})]}),U.state==="error"&&wt&&f.jsx("div",{className:"sticky top-0 z-20 mb-3",role:"alert","aria-live":"assertive",children:f.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs sm:text-sm text-red-700 dark:border-red-900/50 dark:bg-red-900/20 dark:text-red-200",children:[f.jsx(dr,{className:"mt-0.5 h-4 w-4","aria-hidden":"true"}),f.jsxs("div",{className:"flex-1",children:[f.jsx("p",{className:"font-medium",children:"We hit a snag while working on your text."}),f.jsx("p",{className:"mt-0.5 text-xs sm:text-sm",children:wt})]}),f.jsx(Z,{size:"sm",variant:"outline",onClick:dt,className:"ml-2 whitespace-nowrap",children:"Dismiss"})]})}),f.jsx("div",{className:`relative transition-opacity ${se?"pointer-events-none opacity-75":""} ${W!==100?`editor-zoom-${W}`:""}`,"aria-busy":se,children:f.jsx(cb,{editor:J,spellCheck:S})}),f.jsx(Nb,{editor:J,onTextOperation:Hn,isProcessing:se})]})}),L&&f.jsx("div",{className:"hidden lg:block",children:f.jsx(Cb,{property:o,onTextOperation:Hn,content:ft,mlsBoardId:R,onMLSBoardChange:M,onOpenComplianceModal:()=>k(!0),insights:te})})]})]})}),f.jsx(El,{open:ie,onOpenChange:ee,children:f.jsxs(Tl,{className:"max-w-md",children:[f.jsxs(Ol,{children:[f.jsx(Al,{children:"Virtual Staging Detected"}),f.jsxs(lu,{className:"space-y-3 pt-2",children:[f.jsx("p",{children:"We see you've used virtual staging for this property."}),f.jsx("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:'MLS rules require disclosure. Add "one or more photo(s) is virtually staged" to this description?'})]})]}),f.jsxs(Dl,{className:"flex-col sm:flex-row gap-2",children:[f.jsx(Z,{variant:"outline",onClick:()=>Gt(!1),className:"w-full sm:w-auto",children:"No, I'll Add Manually"}),f.jsx(Z,{variant:"pl",onClick:()=>Gt(!0),className:"w-full sm:w-auto",children:"Yes, Add Disclaimer"})]})]})}),g&&f.jsx(gu,{isOpen:g,onClose:()=>x(!1),property:o,images:ut,onDescriptionSaved:Jt}),f.jsx(Lb,{isOpen:O,onClose:()=>k(!1),description:J?.getText()||"",boardId:R,onBoardChange:M,onExport:Qt,existingListings:E}),f.jsx(zb,{isOpen:T,onClose:()=>F(!1),scoreResult:te.scoreResult,isScoring:te.isScoring,onAutoFix:te.autoApplyImprovements,isApplying:te.isApplying,showDiffModal:te.showDiffModal,previousContent:te.previousContent,newContentDraft:te.newContentDraft,acceptChanges:te.acceptChanges,revertChanges:te.revertChanges,beforeScore:te.beforeScore,afterScore:te.afterScore,closeDiffModal:te.closeDiffModal,showUndoButton:te.showUndoButton,undoAutoApply:te.undoAutoApply,canUndo:te.canUndo})]}):f.jsx("div",{className:"flex h-screen items-center justify-center",children:f.jsxs("div",{className:"text-center",children:[f.jsx("p",{className:"text-lg text-gray-600",children:"Property not found"}),f.jsx(Z,{onClick:()=>e("/dashboard/properties"),className:"mt-4",children:"Back to Properties"})]})})};export{Nv 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.