ariadne_view_components 0.0.49-arm64-darwin → 0.0.50-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,5 +4,5 @@ class t{constructor(t,e,n){this.eventTarget=t,this.eventName=e,this.eventOptions
4
4
  * Copyright 2017 Google LLC
5
5
  * SPDX-License-Identifier: BSD-3-Clause
6
6
  */
7
- var Z;X.blessings=[function(t){return O(t,"classes").reduce(((t,e)=>{return Object.assign(t,{[`${n=e}Class`]:{get(){const{classes:t}=this;if(t.has(n))return t.get(n);{const e=t.getAttributeName(n);throw new Error(`Missing attribute "${e}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${a(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(t){return O(t,"targets").reduce(((t,e)=>{return Object.assign(t,{[`${n=e}Target`]:{get(){const t=this.targets.find(n);if(t)return t;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${a(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(t){const e=M(t,"values"),n={valueDescriptorMap:{get(){return e.reduce(((t,e)=>{const n=W(e,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(t,{[r]:n})}),{})}}};return e.reduce(((t,e)=>Object.assign(t,function(t,e){const n=W(t,e),{key:r,name:i,reader:s,writer:o}=n;return{[i]:{get(){const t=this.data.get(r);return null!==t?s(t):n.defaultValue},set(t){void 0===t?this.data.delete(r):this.data.set(r,o(t))}},[`has${a(i)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(e))),n)},function(t){return O(t,"outlets").reduce(((t,e)=>Object.assign(t,function(t){const e=o(t);return{[`${e}Outlet`]:{get(){const e=this.outlets.find(t);if(e){const n=this.application.getControllerForElementAndIdentifier(e,t);if(n)return n;throw new Error(`Missing "data-controller=${t}" attribute on outlet element for "${this.identifier}" controller`)}throw new Error(`Missing outlet element "${t}" for "${this.identifier}" controller`)}},[`${e}Outlets`]:{get(){const e=this.outlets.findAll(t);return e.length>0?e.map((e=>{const n=this.application.getControllerForElementAndIdentifier(e,t);if(n)return n;console.warn(`The provided outlet element is missing the outlet controller "${t}" for "${this.identifier}"`,e)})).filter((t=>t)):[]}},[`${e}OutletElement`]:{get(){const e=this.outlets.find(t);if(e)return e;throw new Error(`Missing outlet element "${t}" for "${this.identifier}" controller`)}},[`${e}OutletElements`]:{get(){return this.outlets.findAll(t)}},[`has${a(e)}Outlet`]:{get(){return this.outlets.has(t)}}}}(e))),{})}],X.targets=[],X.outlets=[],X.values={};const Q=window,tt=Q.trustedTypes,et=tt?tt.createPolicy("lit-html",{createHTML:t=>t}):void 0,nt="$lit$",rt=`lit$${(Math.random()+"").slice(9)}$`,it="?"+rt,st=`<${it}>`,ot=document,at=()=>ot.createComment(""),lt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ct=Array.isArray,ht="[ \t\n\f\r]",dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ut=/-->/g,pt=/>/g,ft=RegExp(`>|${ht}(?:([^\\s"'>=/]+)(${ht}*=${ht}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),mt=/'/g,gt=/"/g,yt=/^(?:script|style|textarea|title)$/i,vt=(t=>(e,...n)=>({_$litType$:t,strings:e,values:n}))(1),bt=Symbol.for("lit-noChange"),wt=Symbol.for("lit-nothing"),xt=new WeakMap,kt=ot.createTreeWalker(ot,129,null,!1),St=(t,e)=>{const n=t.length-1,r=[];let i,s=2===e?"<svg>":"",o=dt;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,h=0;for(;h<n.length&&(o.lastIndex=h,l=o.exec(n),null!==l);)h=o.lastIndex,o===dt?"!--"===l[1]?o=ut:void 0!==l[1]?o=pt:void 0!==l[2]?(yt.test(l[2])&&(i=RegExp("</"+l[2],"g")),o=ft):void 0!==l[3]&&(o=ft):o===ft?">"===l[0]?(o=null!=i?i:dt,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?ft:'"'===l[3]?gt:mt):o===gt||o===mt?o=ft:o===ut||o===pt?o=dt:(o=ft,i=void 0);const d=o===ft&&t[e+1].startsWith("/>")?" ":"";s+=o===dt?n+st:c>=0?(r.push(a),n.slice(0,c)+nt+n.slice(c)+rt+d):n+rt+(-2===c?(r.push(void 0),e):d)}const a=s+(t[n]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==et?et.createHTML(a):a,r]};class Ot{constructor({strings:t,_$litType$:e},n){let r;this.parts=[];let i=0,s=0;const o=t.length-1,a=this.parts,[l,c]=St(t,e);if(this.el=Ot.createElement(l,n),kt.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(r=kt.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes()){const t=[];for(const e of r.getAttributeNames())if(e.endsWith(nt)||e.startsWith(rt)){const n=c[s++];if(t.push(e),void 0!==n){const t=r.getAttribute(n.toLowerCase()+nt).split(rt),e=/([.?@])?(.*)/.exec(n);a.push({type:1,index:i,name:e[2],strings:t,ctor:"."===e[1]?Tt:"?"===e[1]?Dt:"@"===e[1]?$t:Ct})}else a.push({type:6,index:i})}for(const e of t)r.removeAttribute(e)}if(yt.test(r.tagName)){const t=r.textContent.split(rt),e=t.length-1;if(e>0){r.textContent=tt?tt.emptyScript:"";for(let n=0;n<e;n++)r.append(t[n],at()),kt.nextNode(),a.push({type:2,index:++i});r.append(t[e],at())}}}else if(8===r.nodeType)if(r.data===it)a.push({type:2,index:i});else{let t=-1;for(;-1!==(t=r.data.indexOf(rt,t+1));)a.push({type:7,index:i}),t+=rt.length-1}i++}}static createElement(t,e){const n=ot.createElement("template");return n.innerHTML=t,n}}function Mt(t,e,n=t,r){var i,s,o,a;if(e===bt)return e;let l=void 0!==r?null===(i=n._$Co)||void 0===i?void 0:i[r]:n._$Cl;const c=lt(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(s=null==l?void 0:l._$AO)||void 0===s||s.call(l,!1),void 0===c?l=void 0:(l=new c(t),l._$AT(t,n,r)),void 0!==r?(null!==(o=(a=n)._$Co)&&void 0!==o?o:a._$Co=[])[r]=l:n._$Cl=l),void 0!==l&&(e=Mt(t,l._$AS(t,e.values),l,r)),e}class At{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:n},parts:r}=this._$AD,i=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:ot).importNode(n,!0);kt.currentNode=i;let s=kt.nextNode(),o=0,a=0,l=r[0];for(;void 0!==l;){if(o===l.index){let e;2===l.type?e=new Et(s,s.nextSibling,this,t):1===l.type?e=new l.ctor(s,l.name,l.strings,this,t):6===l.type&&(e=new It(s,this,t)),this._$AV.push(e),l=r[++a]}o!==(null==l?void 0:l.index)&&(s=kt.nextNode(),o++)}return kt.currentNode=ot,i}v(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class Et{constructor(t,e,n,r){var i;this.type=2,this._$AH=wt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=r,this._$Cp=null===(i=null==r?void 0:r.isConnected)||void 0===i||i}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Mt(this,t,e),lt(t)?t===wt||null==t||""===t?(this._$AH!==wt&&this._$AR(),this._$AH=wt):t!==this._$AH&&t!==bt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>ct(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==wt&&lt(this._$AH)?this._$AA.nextSibling.data=t:this.$(ot.createTextNode(t)),this._$AH=t}g(t){var e;const{values:n,_$litType$:r}=t,i="number"==typeof r?this._$AC(t):(void 0===r.el&&(r.el=Ot.createElement(r.h,this.options)),r);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.v(n);else{const t=new At(i,this),e=t.u(this.options);t.v(n),this.$(e),this._$AH=t}}_$AC(t){let e=xt.get(t.strings);return void 0===e&&xt.set(t.strings,e=new Ot(t)),e}T(t){ct(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,r=0;for(const i of t)r===e.length?e.push(n=new Et(this.k(at()),this.k(at()),this,this.options)):n=e[r],n._$AI(i),r++;r<e.length&&(this._$AR(n&&n._$AB.nextSibling,r),e.length=r)}_$AR(t=this._$AA.nextSibling,e){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class Ct{constructor(t,e,n,r,i){this.type=1,this._$AH=wt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=i,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=wt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,n,r){const i=this.strings;let s=!1;if(void 0===i)t=Mt(this,t,e,0),s=!lt(t)||t!==this._$AH&&t!==bt,s&&(this._$AH=t);else{const r=t;let o,a;for(t=i[0],o=0;o<i.length-1;o++)a=Mt(this,r[n+o],e,o),a===bt&&(a=this._$AH[o]),s||(s=!lt(a)||a!==this._$AH[o]),a===wt?t=wt:t!==wt&&(t+=(null!=a?a:"")+i[o+1]),this._$AH[o]=a}s&&!r&&this.j(t)}j(t){t===wt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Tt extends Ct{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===wt?void 0:t}}const Nt=tt?tt.emptyScript:"";class Dt extends Ct{constructor(){super(...arguments),this.type=4}j(t){t&&t!==wt?this.element.setAttribute(this.name,Nt):this.element.removeAttribute(this.name)}}class $t extends Ct{constructor(t,e,n,r,i){super(t,e,n,r,i),this.type=5}_$AI(t,e=this){var n;if((t=null!==(n=Mt(this,t,e,0))&&void 0!==n?n:wt)===bt)return;const r=this._$AH,i=t===wt&&r!==wt||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,s=t!==wt&&(r===wt||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==n?n:this.element,t):this._$AH.handleEvent(t)}}class It{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){Mt(this,t)}}const Rt=Q.litHtmlPolyfillSupport;null==Rt||Rt(Ot,Et),(null!==(Z=Q.litHtmlVersions)&&void 0!==Z?Z:Q.litHtmlVersions=[]).push("2.7.4");class Bt extends X{constructor(){super(...arguments),this.onBlur=t=>{this.validateField(t.target)},this.onSubmit=t=>{var e;this.validateForm()||(t.preventDefault(),null===(e=this.firstInvalidField)||void 0===e||e.focus())},this.getRenderString=t=>{const{strings:e,values:n}=t,r=[...n,""].map((t=>"object"==typeof t?this.getRenderString(t):t));return e.reduce(((t,e,n)=>t+e+r[n]),"")}}connect(){this.element.setAttribute("novalidate","true"),this.element.addEventListener("blur",this.onBlur,!0),this.element.addEventListener("submit",this.onSubmit),this.element.addEventListener("ajax:beforeSend",this.onSubmit)}disconnect(){this.element.removeEventListener("blur",this.onBlur),this.element.removeEventListener("submit",this.onSubmit),this.element.removeEventListener("ajax:beforeSend",this.onSubmit)}validateForm(){let t=!0;for(const e of this.formFields)this.shouldValidateField(e)&&!this.validateField(e)&&(t=!1);return t}validateField(t){if(!this.shouldValidateField(t))return!0;const e=t.checkValidity();return t.classList.toggle("invalid",!e),this.refreshErrorForInvalidField(t,e),e}shouldValidateField(t){return!t.disabled&&!t.classList.contains("ProseMirror")&&!["file","reset","submit","button"].includes(t.type)}refreshErrorForInvalidField(t,e){this.removeExistingErrorMessage(t),e||this.showErrorForInvalidField(t)}removeExistingErrorMessage(t){var e;const n=t.closest(".field");if(!n)return;const r=n.querySelector(".error");r&&(null===(e=null==r?void 0:r.parentNode)||void 0===e||e.removeChild(r))}showErrorForInvalidField(t){t.insertAdjacentHTML("afterend",this.buildFieldErrorHtml(t))}buildFieldErrorHtml(t){const e=vt`<p class="error">${t.validationMessage}</p>`;return this.getRenderString(e)}get formFields(){return Array.from(this.formFieldTargets)}get firstInvalidField(){return this.formFields.find((t=>!t.checkValidity()))}}function Ft(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}var Pt,Vt,Lt,zt,jt,_t,Kt,Wt,Ht,qt,Jt,Ut,Gt,Yt,Xt,Zt;Bt.targets=["formField"];class Qt extends X{constructor(){super(...arguments),Pt.add(this),this.outletEventsLookup=null,this.eventRecords=new Map}getOutlets(){return null}outletUpdate(t,e){}getState(){return null}connect(){this.syncOutlets()}syncOutlets(){const t=new Event("init");this.sendToOutlets(t,{data:this.getState(),eventKey:this.getEventKey(t)})}sendToOutlets(t,e={}){var n;const r=null!==(n=e.eventKey)&&void 0!==n?n:this.getEventKey(t),i=Ft(this,Pt,"a",Vt);if(null==i?void 0:i.length)for(const n in i){const s=i[n];if(s.isListeningForOutletEvent(r)&&!this.hasHeardEvent(t)){const n=this.identifier===s.identifier;s.outletUpdate(t,{eventKey:r,data:n?e.data:void 0})}}}isListeningForOutletEvent(t){const e=t.split("-");if(!e.length)return!1;let n=this.outletEvents;for(let t=0;t<e.length;t++){const r=e[t];if("boolean"==typeof n)return n;let i=r;if(void 0!==n["*"])i="*";else{const t=void 0!==n.domEvent;if(t&&!this.isDOMEventName(r))return!1;t&&(i="domEvent")}if(!n[i])return!1;n=n[i]}return!0}isDOMEventName(t){return Qt.domEvents[t]}getEventKey(t){const e=this.event_key_prefix,n=this.event_key_postfix,r=e?"-":"",i=null!=e?e:"",s=n?"-":"",o=null!=n?n:"";return`${this.identifier}-${i}${r}${t.type}${s}${o}`}hasHeardEvent(t){return!!this.eventRecords.has(t)||(this.eventRecords.set(t,!0),setTimeout((()=>this.eventRecords.delete(t))),!1)}get event_key_prefix(){return""}get event_key_postfix(){return""}get outletEvents(){return!this.outletEventsLookup&&this.hasOutletEventsValue?this.outletEventsLookup=this.outletEventsValue.reduce(((t,e)=>{let n=t;return e.split("-").forEach(((t,e,r)=>{"boolean"!=typeof n&&(e===r.length-1?n[t]=!0:void 0===n[t]&&(n[t]={}),n=n[t])})),t}),{}):this.outletEventsLookup||(this.outletEventsLookup={"*":!0}),this.outletEventsLookup}}Pt=new WeakSet,Vt=function(){const t=this.getOutlets();if(t)return t;const e=[];return this.hasToggleableOutlet&&e.push(...this.toggleableOutlets),this.hasOptionsOutlet&&e.push(...this.optionsOutlets),this.hasStringMatchOutlet&&e.push(...this.stringMatchOutlets),e},Qt.values={outletEvents:Array},Qt.outlets=["toggleable","options","string-match"],Qt.domEvents={abort:!0,afterprint:!0,animationend:!0,animationiteration:!0,animationstart:!0,beforeprint:!0,beforeunload:!0,blur:!0,canplay:!0,canplaythrough:!0,change:!0,click:!0,contextmenu:!0,copy:!0,cut:!0,dblclick:!0,drag:!0,dragend:!0,dragenter:!0,dragleave:!0,dragover:!0,dragstart:!0,drop:!0,durationchange:!0,ended:!0,error:!0,focus:!0,focusin:!0,focusout:!0,fullscreenchange:!0,fullscreenerror:!0,hashchange:!0,input:!0,invalid:!0,keydown:!0,keypress:!0,keyup:!0,load:!0,loadeddata:!0,loadedmetadata:!0,loadstart:!0,message:!0,mousedown:!0,mouseenter:!0,mouseleave:!0,mousemove:!0,mouseover:!0,mouseout:!0,mouseup:!0,mousewheel:!0,offline:!0,online:!0,open:!0,pagehide:!0,pageshow:!0,paste:!0,pause:!0,play:!0,playing:!0,popstate:!0,progress:!0,ratechange:!0,resize:!0,reset:!0,scroll:!0,search:!0,seeked:!0,seeking:!0,select:!0,show:!0,stalled:!0,storage:!0,submit:!0,suspend:!0,timeupdate:!0,toggle:!0,touchcancel:!0,touchend:!0,touchmove:!0,touchstart:!0,transitionend:!0,unload:!0,volumechange:!0,waiting:!0,wheel:!0};class te extends Qt{constructor(){super(...arguments),Lt.add(this),this.syncedAttrsLookup=null,this.antiAttrsLookup=null}getValueForElement(t){return null}getElementsToSync(){return[]}connect(){this.syncElementAttributes()}updateAttributesForElement(t,e){this.hasSyncedAttrsValue&&Ft(this,Lt,"m",Kt).call(this,t,this.syncedAttrsValue,e),this.hasAntiAttrsValue&&Ft(this,Lt,"m",Kt).call(this,t,this.antiAttrsValue,!e)}syncElementAttributes(){var t;this.syncOutlets();const e=this.getElementsToSync();if(null==e?void 0:e.length)for(let n in e){const r=e[n],i=null!==(t=this.getValueForElement(r))&&void 0!==t&&t;this.updateAttributesForElement(r,i)}}validateAttrChange(t){const{target:e,detail:n}=t;if(e&&n){null!==this.getValueForElement(e)&&this.protectAttrsValue&&Ft(this,Lt,"m",_t).call(this,n.attr)&&t.preventDefault()}}}Lt=new WeakSet,zt=function(t){var e;return null===this.syncedAttrsLookup&&(this.syncedAttrsLookup=Ft(this,Lt,"m",Wt).call(this,this.syncedAttrsValue)),null!==(e=this.syncedAttrsLookup[t])&&void 0!==e&&e},jt=function(t){var e;return null===this.antiAttrsLookup&&(this.antiAttrsLookup=Ft(this,Lt,"m",Wt).call(this,this.antiAttrsValue)),null!==(e=this.antiAttrsLookup[t])&&void 0!==e&&e},_t=function(t){return Ft(this,Lt,"m",jt).call(this,t)||Ft(this,Lt,"m",zt).call(this,t)},Kt=function(t,e,n){const r=JSON.stringify(n);for(let i in e){const s=e[i];this.dispatch("attrChange",{target:t,detail:{attr:s,value:n}}).defaultPrevented||("false"===r&&te.removeOnFalseAttrs[s]?t.removeAttribute(s):t.setAttribute(s,r))}},Wt=function(t){return(null==t?void 0:t.length)?t.reduce(((t,e)=>(t[e]=!0,t)),{}):{}},te.values=Object.assign(Object.assign({},Qt.values),{syncedAttrs:Array,antiAttrs:Array,protectAttrs:Boolean}),te.removeOnFalseAttrs={checked:!0};class ee extends te{constructor(){super(...arguments),Ht.add(this),this.outletUpdate=this.change}change(t,e={}){var n;const r=null!==(n=e.data)&&void 0!==n?n:t.currentTarget.value;this.keywordValue=r,Ft(this,Ht,"m",qt).call(this),this.sendToOutlets(t,Object.assign(Object.assign({},e),{data:this.keywordValue}))}getElementsToSync(){return this.matchTargets}getValueForElement(t){var e,n;return null!==(n=null===(e=t.innerText)||void 0===e?void 0:e.toLowerCase().includes(this.keywordValue.toLowerCase()))&&void 0!==n&&n}getState(){return this.keywordValue}}Ht=new WeakSet,qt=function(){if(this.hasMatchTarget){let t=!1;for(let e in this.matchTargets){const n=this.matchTargets[e],r=this.getValueForElement(n);this.updateAttributesForElement(n,r),r&&(t=!0)}this.hasEmptyTarget&&this.emptyTarget.setAttribute("aria-hidden",String(t))}},ee.outlets=te.outlets,ee.targets=["match","empty"],ee.values=Object.assign(Object.assign({},te.values),{keyword:String});class ne extends te{constructor(){super(...arguments),Jt.add(this),this.optionTargetLookup=new Map,this.outletUpdate=this.select}connect(){Ft(this,Jt,"m",Zt).call(this),this.syncElementAttributes()}select(t,e={}){var n;const r=e.data;for(let e in this.optionTargets){const i=this.optionTargets[e],s=i===t.currentTarget,o=null!==(n=this.getValueForElement(i))&&void 0!==n&&n,a=Ft(this,Jt,"m",Xt).call(this,i);if(void 0!==r?!!r[a]!==o:Ft(this,Jt,"m",Ut).call(this,o,s)){const t=!o;this.updateAttributesForElement(i,t),t?Ft(this,Jt,"m",Gt).call(this,a):Ft(this,Jt,"m",Yt).call(this,a)}}this.sendToOutlets(t,Object.assign(Object.assign({},e),{data:this.activeOptionsValue}))}getValueForElement(t){var e;if(!this.optionTargetLookup.has(t))return null;const n=Ft(this,Jt,"m",Xt).call(this,t);return null!==(e=this.activeOptionsValue[n])&&void 0!==e&&e}getState(){return this.activeOptionsValue}}Jt=new WeakSet,Ut=function(t,e){return!(!e&&!t)&&(!(!e&&t&&this.isMultiValue)&&!(e&&t&&!this.toggleableValue))},Gt=function(t){this.activeOptionsValue=Object.assign(Object.assign({},this.activeOptionsValue),{[t]:!0})},Yt=function(t){const e=Object.assign({},this.activeOptionsValue);delete e[t],this.activeOptionsValue=e},Xt=function(t){const e=t.getAttribute("data-option-value");return e||t.innerText.trim()},Zt=function(){this.optionTargetLookup=new Map;for(let t in this.optionTargets){const e=this.optionTargets[t],n=Ft(this,Jt,"m",Xt).call(this,e);this.optionTargetLookup.set(e,n);if(!!this.syncedAttrsValue.find((t=>"true"===e.getAttribute(t))))Ft(this,Jt,"m",Gt).call(this,n);else{!!this.antiAttrsValue.find((t=>"false"===e.getAttribute(t)))&&Ft(this,Jt,"m",Gt).call(this,n)}}},ne.outlets=te.outlets,ne.targets=["option"],ne.values=Object.assign(Object.assign({},te.values),{activeOptions:Object,isMulti:{type:Boolean,default:!1},toggleable:{type:Boolean,default:!1}});class re extends X{connect(){this.accumulate()}accumulate(){let t=0;for(let e in this.sumTargets){const n=this.sumTargets[e],r=Number(n.getAttribute(this.sumAttrValue));isNaN(r)||(t+=r)}this.setAttributesTo(t)}setAttributesTo(t){for(let e in this.syncAttrsValue){const n=this.syncAttrsValue[e];this.accumulator.setAttribute(n,t.toString())}}get accumulator(){var t;return null!==(t=this.accumulatorTarget)&&void 0!==t?t:this.element}}re.targets=["sum","accumulator"],re.values={syncAttrs:{type:Array,default:["aria-valuenow"]},sumAttr:{type:"string",default:"data-value"}};const ie={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},se=(t,e={})=>{const n=t,{onlyVisible:r,dispatchEvent:i,events:s,eventPrefix:o}=Object.assign({},ie,e),a=t=>{const s=(null==e?void 0:e.element)||n.element;if(!(s.contains(t.target)||!function(t){const e=t.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,r=window.innerWidth||document.documentElement.clientWidth,i=e.top<=n&&e.top+e.height>0,s=e.left<=r&&e.left+e.width>0;return i&&s}(s)&&r)&&(n.clickOutside&&n.clickOutside(t),i)){const e=((t,e,n)=>{let r=t;return!0===n?r=`${e.identifier}:${t}`:"string"==typeof n&&(r=`${n}:${t}`),r})("click:outside",n,o),r=((t,e,n)=>{const{bubbles:r,cancelable:i,composed:s}=e||{bubbles:!0,cancelable:!0,composed:!0};return e&&Object.assign(n,{originalEvent:e}),new CustomEvent(t,{bubbles:r,cancelable:i,composed:s,detail:n})})(e,t,{controller:n});s.dispatchEvent(r)}},l=()=>{null==s||s.forEach((t=>{window.addEventListener(t,a,!0)}))},c=()=>{null==s||s.forEach((t=>{window.removeEventListener(t,a,!0)}))},h=n.disconnect.bind(n);return Object.assign(n,{disconnect(){c(),h()}}),l(),[l,c]};(class extends X{}).debounces=[];(class extends X{}).throttles=[];class oe extends te{constructor(){super(...arguments),this.outletUpdate=this.toggle}connect(){this.syncElementAttributes(),se(this,{dispatchEvent:this.closeOnOutsideClickValue&&this.stateValue})}toggle(t,e={}){var n;const r=null!==(n=e.data)&&void 0!==n?n:!this.stateValue;this.updateAttributesForElement(this.element,r),this.stateValue=r,this.sendToOutlets(t,Object.assign(Object.assign({},e),{data:r}))}on(t){this.toggle(t,{data:!0})}off(t){this.toggle(t,{data:!1})}clickOutside(t){this.closeOnOutsideClickValue&&this.stateValue&&this.toggle(t,{data:!1})}getValueForElement(t){return t!==this.element?null:this.stateValue}getElementsToSync(){return[this.element]}getState(){return this.stateValue}get event_key_postfix(){return this.stateValue?"on":"off"}}oe.outlets=te.outlets,oe.values=Object.assign(Object.assign({},te.values),{state:{type:Boolean,default:!1},closeOnOutsideClick:{type:Boolean,default:!1}});function ae(t){this.content=t}function le(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let t=0;i.text[t]==s.text[t];t++)n++;return n}if(i.content.size||s.content.size){let t=le(i.content,s.content,n+1);if(null!=t)return t}n+=i.nodeSize}else n+=i.nodeSize}}function ce(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o!=a){if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let t=0,e=Math.min(o.text.length,a.text.length);for(;t<e&&o.text[o.text.length-t-1]==a.text[a.text.length-t-1];)t++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let t=ce(o.content,a.content,n-1,r-1);if(t)return t}n-=l,r-=l}else n-=l,r-=l}}ae.prototype={constructor:ae,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return-1==i?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new ae(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new ae(n)},addToStart:function(t,e){return new ae([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ae(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(-1==s?i.length:s,0,e,n),new ae(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=ae.from(t)).size?new ae(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=ae.from(t)).size?new ae(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ae.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},get size(){return this.content.length>>1}},ae.from=function(t){if(t instanceof ae)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ae(e)};class he{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,r=0,i){for(let s=0,o=0;o<e;s++){let a=this.content[s],l=o+a.nodeSize;if(l>t&&!1!==n(a,r+o,i||null,s)&&a.content.size){let i=o+1;a.nodesBetween(Math.max(0,t-i),Math.min(a.content.size,e-i),n,r+i)}o=l}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let i="",s=!0;return this.nodesBetween(t,e,((o,a)=>{o.isText?(i+=o.text.slice(Math.max(t,a)-a,e-a),s=!n):o.isLeaf?(r?i+="function"==typeof r?r(o):r:o.type.spec.leafText&&(i+=o.type.spec.leafText(o)),s=!n):!s&&o.isBlock&&(i+=n,s=!0)}),0),i}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),i=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),i=1);i<t.content.length;i++)r.push(t.content[i]);return new he(r,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],r=0;if(e>t)for(let i=0,s=0;s<e;i++){let o=this.content[i],a=s+o.nodeSize;a>t&&((s<t||a>e)&&(o=o.isText?o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s)):o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))),n.push(o),r+=o.nodeSize),s=a}return new he(n,r)}cutByIndex(t,e){return t==e?he.empty:0==t&&e==this.content.length?this:new he(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice(),i=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new he(r,i)}addToStart(t){return new he([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new he(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))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(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return le(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return ce(this,t,e,n)}findIndex(t,e=-1){if(0==t)return ue(0,t);if(t==this.size)return ue(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=r+this.child(n).nodeSize;if(i>=t)return i==t||e>0?ue(n+1,i):ue(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return he.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new he(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return he.empty;let e,n=0;for(let r=0;r<t.length;r++){let i=t[r];n+=i.nodeSize,r&&i.isText&&t[r-1].sameMarkup(i)?(e||(e=t.slice(0,r)),e[e.length-1]=i.withText(e[e.length-1].text+i.text)):e&&e.push(i)}return new he(e||t,n)}static from(t){if(!t)return he.empty;if(t instanceof he)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new he([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}he.empty=new he([],0);const de={index:0,offset:0};function ue(t,e){return de.index=t,de.offset=e,de}function pe(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!pe(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!pe(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}class fe{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(this.eq(i))return t;if(this.type.excludes(i.type))e||(e=t.slice(0,r));else{if(i.type.excludes(this.type))return t;!n&&i.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(i)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&pe(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);return n.create(e.attrs)}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return fe.none;if(t instanceof fe)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}fe.none=[];class me extends Error{}class ge{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=ve(this.content,t+this.openStart,e);return n&&new ge(n,this.openStart,this.openEnd)}removeBetween(t,e){return new ge(ye(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return ge.empty;let n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new ge(he.fromJSON(t,e.content),n,r)}static maxOpen(t,e=!0){let n=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)r++;return new ge(t,n,r)}}function ye(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(ye(s.content,e-i-1,n-i-1)))}function ve(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=ve(o.content,e-s-1,n);return a&&t.replaceChild(i,o.copy(a))}function be(t,e,n){if(n.openStart>t.depth)throw new me("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new me("Inconsistent open depths");return we(t,e,n,0)}function we(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=we(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){let{start:i,end:o}=function(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)r=e.node(t).copy(he.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return Me(s,Ae(t,i,o,e,r))}{let r=t.parent,i=r.content;return Me(r,i.cut(0,t.parentOffset).append(n.content).append(i.cut(e.parentOffset)))}}return Me(s,Ee(t,e,r))}function xe(t,e){if(!e.type.compatibleContent(t.type))throw new me("Cannot join "+e.type.name+" onto "+t.type.name)}function ke(t,e,n){let r=t.node(n);return xe(r,e.node(n)),r}function Se(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Oe(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Se(t.nodeAfter,r),s++));for(let t=s;t<o;t++)Se(i.child(t),r);e&&e.depth==n&&e.textOffset&&Se(e.nodeBefore,r)}function Me(t,e){return t.type.checkContent(e),t.copy(e)}function Ae(t,e,n,r,i){let s=t.depth>i&&ke(t,e,i+1),o=r.depth>i&&ke(n,r,i+1),a=[];return Oe(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(xe(s,o),Se(Me(s,Ae(t,e,n,r,i+1)),a)):(s&&Se(Me(s,Ee(t,e,i+1)),a),Oe(e,n,i,a),o&&Se(Me(o,Ee(n,r,i+1)),a)),Oe(r,null,i,a),new he(a)}function Ee(t,e,n){let r=[];if(Oe(null,t,n,r),t.depth>n){Se(Me(ke(t,e,n+1),Ee(t,e,n+1)),r)}return Oe(e,null,n,r),new he(r)}ge.empty=new ge(he.empty,0,0);class Ce{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)r+=n.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return fe.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){let t=n;n=r,r=t}let i=n.marks;for(var s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,r=t.parent.maybeChild(t.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new $e(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],r=0,i=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(i),o=i-s;if(n.push(e,t,r+s),!o)break;if(e=e.child(t),e.isText)break;i=o-1,r+=s+1}return new Ce(e,n,i)}static resolveCached(t,e){for(let n=0;n<Te.length;n++){let r=Te[n];if(r.pos==e&&r.doc==t)return r}let n=Te[Ne]=Ce.resolve(t,e);return Ne=(Ne+1)%De,n}}let Te=[],Ne=0,De=12;class $e{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Ie=Object.create(null);class Re{constructor(t,e,n,r=fe.none){this.type=t,this.attrs=e,this.marks=r,this.content=n||he.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,r=0){this.content.nodesBetween(t,e,n,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,r){return this.content.textBetween(t,e,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&pe(this.attrs,e||t.defaultAttrs||Ie)&&fe.sameSet(this.marks,n||fe.none)}copy(t=null){return t==this.content?this:new Re(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Re(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return ge.empty;let r=this.resolve(t),i=this.resolve(e),s=n?0:r.sharedDepth(e),o=r.start(s),a=r.node(s).content.cut(r.pos-o,i.pos-o);return new ge(a,r.depth-s,i.depth-s)}replace(t,e,n){return be(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:r}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let r=this.content.child(e-1);return{node:r,index:e-1,offset:n-r.nodeSize}}resolve(t){return Ce.resolveCached(this,t)}resolveNoCache(t){return Ce.resolve(this,t)}rangeHasMark(t,e,n){let r=!1;return e>t&&this.nodesBetween(t,e,(t=>(n.isInSet(t.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Fe(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=he.empty,r=0,i=n.childCount){let s=this.contentMatchAt(t).matchFragment(n,r,i),o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let t=r;t<i;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(t).matchType(n),s=i&&i.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);let t=fe.none;for(let e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!fe.sameSet(t,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 t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let r=he.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)}}Re.prototype.text=void 0;class Be extends Re{constructor(t,e,n,r){if(super(t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Fe(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new Be(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new Be(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function Fe(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Pe{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new Ve(t,e);if(null==n.next)return Pe.empty;let r=Le(n);n.next&&n.err("Unexpected trailing text");let i=function(t){let e=Object.create(null);return n(He(t,0));function n(r){let i=[];r.forEach((e=>{t[e].forEach((({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);He(t,n).forEach((t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)}))}))}));let s=e[r.join(",")]=new Pe(r.indexOf(t.length-1)>-1);for(let t=0;t<i.length;t++){let r=i[t][1].sort(We);s.next.push({type:i[t][0],next:e[r.join(",")]||n(r)})}return s}}(function(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){let i={term:r,to:n};return e[t].push(i),i}function i(t,e){t.forEach((t=>t.to=e))}function s(t,e){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(s(n,e))),[]);if("seq"!=t.type){if("star"==t.type){let o=n();return r(e,o),i(s(t.expr,o),o),[r(o)]}if("plus"==t.type){let o=n();return i(s(t.expr,e),o),i(s(t.expr,o),o),[r(o)]}if("opt"==t.type)return[r(e)].concat(s(t.expr,e));if("range"==t.type){let o=e;for(let e=0;e<t.min;e++){let e=n();i(s(t.expr,o),e),o=e}if(-1==t.max)i(s(t.expr,o),o);else for(let e=t.min;e<t.max;e++){let e=n();r(o,e),i(s(t.expr,o),e),o=e}return[r(o)]}if("name"==t.type)return[r(e,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=s(t.exprs[r],e);if(r==t.exprs.length-1)return o;i(o,e=n())}}}(r));return function(t,e){for(let n=0,r=[t];n<r.length;n++){let t=r[n],i=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:n,next:o}=t.next[e];s.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,n),i}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let i=e;r&&i<n;i++)r=r.matchType(t.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];return function i(s,o){let a=s.matchFragment(t,n);if(a&&(!e||a.validEnd))return he.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:n}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let t=i(n,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<i.next.length;t++){let{type:s,next:o}=i.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let r=0;r<n.next.length;r++)-1==t.indexOf(n.next[r].next)&&e(n.next[r].next)}(this),t.map(((e,n)=>{let r=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)r+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return r})).join("\n")}}Pe.empty=new Pe(!0);class Ve{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Le(t){let e=[];do{e.push(ze(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function ze(t){let e=[];do{e.push(je(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function je(t){let e=function(t){if(t.eat("(")){let e=Le(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let t in n){let r=n[t];r.groups.indexOf(e)>-1&&i.push(r)}0==i.length&&t.err("No node type or group '"+e+"' found");return i}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=Ke(t,e)}return e}function _e(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Ke(t,e){let n=_e(t),r=n;return t.eat(",")&&(r="}"!=t.next?_e(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function We(t,e){return e-t}function He(t,e){let n=[];return function e(r){let i=t[r];if(1==i.length&&!i[0].term)return e(i[0].to);n.push(r);for(let t=0;t<i.length;t++){let{term:r,to:s}=i[t];r||-1!=n.indexOf(s)||e(s)}}(e),n.sort(We)}function qe(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Je(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(void 0===i){let e=t[r];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=e.default}n[r]=i}return n}function Ue(t){let e=Object.create(null);if(t)for(let n in t)e[n]=new Ye(t[n]);return e}class Ge{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Ue(n.attrs),this.defaultAttrs=qe(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Pe.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Je(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Re(this,this.computeAttrs(t),he.from(e),fe.setFrom(n))}createChecked(t=null,e,n){return e=he.from(e),this.checkContent(e),new Re(this,this.computeAttrs(t),e,fe.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=he.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e),i=r&&r.fillBefore(he.empty,!0);return i?new Re(this,t,e.append(i),fe.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:fe.none:t}static compile(t,e){let n=Object.create(null);t.forEach(((t,r)=>n[t]=new Ge(t,e,r)));let r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let t in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class Ye{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default}get isRequired(){return!this.hasDefault}}class Xe{constructor(t,e,n,r){this.name=t,this.rank=e,this.schema=n,this.spec=r,this.attrs=Ue(r.attrs),this.excluded=null;let i=qe(this.attrs);this.instance=i?new fe(this,i):null}create(t=null){return!t&&this.instance?this.instance:new fe(this,Je(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;return t.forEach(((t,i)=>n[t]=new Xe(t,r++,e,i))),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}excludes(t){return this.excluded.indexOf(t)>-1}}class Ze{constructor(t){this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=ae.from(t.nodes),e.marks=ae.from(t.marks||{}),this.nodes=Ge.compile(this.spec.nodes,this),this.marks=Xe.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",i=e.spec.marks;e.contentMatch=n[r]||(n[r]=Pe.parse(r,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.markSet="_"==i?null:i?Qe(this,i.split(" ")):""!=i&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:Qe(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof Ge))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)}text(t,e){let n=this.nodes.text;return new Be(n,n.defaultAttrs,t,fe.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return Re.fromJSON(this,t)}markFromJSON(t){return fe.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function Qe(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let e in t.marks){let r=t.marks[e];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=r)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class tn{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((t=>{t.tag?this.tags.push(t):t.style&&this.styles.push(t)})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new an(this,e,!1);return n.addAll(t,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new an(this,e,!0);return n.addAll(t,e.from,e.to),ge.maxOpen(n.finish())}matchTag(t,e,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(ln(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],s=r.style;if(!(0!=s.indexOf(t)||r.context&&!n.matchesContext(r.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(r.getAttrs){let t=r.getAttrs(e);if(!1===t)continue;r.attrs=t||void 0}return r}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r];if((null==t.priority?50:t.priority)<n)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;r&&r.forEach((t=>{n(t=cn(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;r&&r.forEach((t=>{n(t=cn(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new tn(t,tn.schemaRules(t)))}}const en={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},nn={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},rn={ol:!0,ul:!0};function sn(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class on{constructor(t,e,n,r,i,s,o){this.type=t,this.attrs=e,this.marks=n,this.pendingMarks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=fe.none,this.stashMarks=[],this.match=s||(4&o?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(he.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=he.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(he.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}popFromStashMark(t){for(let e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]}applyPending(t){for(let e=0,n=this.pendingMarks;e<n.length;e++){let r=n[e];(this.type?this.type.allowsMarkType(r.type):hn(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!en.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class an{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0;let r,i=e.topNode,s=sn(null,e.preserveWhitespace,0)|(n?4:0);r=i?new on(i.type,i.attrs,fe.none,fe.none,!0,e.topMatch||i.type.contentMatch,s):new on(n?null:t.schema.topNodeType,null,fe.none,fe.none,!0,null,s),this.nodes=[r],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){let e=t.getAttribute("style");if(e){let n=this.readStyles(function(t){let e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e));if(!n)return;let[r,i]=n,s=this.top;for(let t=0;t<i.length;t++)this.removePendingMark(i[t],s);for(let t=0;t<r.length;t++)this.addPendingMark(r[t]);this.addElement(t);for(let t=0;t<r.length;t++)this.removePendingMark(r[t],s);for(let t=0;t<i.length;t++)this.addPendingMark(i[t])}else this.addElement(t)}}addTextNode(t){let e=t.nodeValue,n=this.top;if(2&n.options||n.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){let r=n.content[n.content.length-1],i=t.previousSibling;(!r||i&&"BR"==i.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)}addElement(t,e){let n,r=t.nodeName.toLowerCase();rn.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&rn.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let i=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(i?i.ignore:nn.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(t=i.skip);let e,n=this.top,s=this.needsBlock;if(en.hasOwnProperty(r))n.content.length&&n.content[0].isInline&&this.open&&(this.open--,n=this.top),e=!0,n.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),e&&this.sync(n),this.needsBlock=s}else this.addElementByRule(t,i,!1===i.consuming?n:void 0)}leafFallback(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))}ignoreFallback(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(t){let e=fe.none,n=fe.none;t:for(let r=0;r<t.length;r+=2)for(let i;;){let s=this.parser.matchStyle(t[r],t[r+1],this,i);if(!s)continue t;if(s.ignore)return null;if(s.clearMark?this.top.pendingMarks.forEach((t=>{s.clearMark(t)&&(n=t.addToSet(n))})):e=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(e),!1!==s.consuming)break;i=s}return[e,n]}addElementByRule(t,e,n){let r,i,s;if(e.node)i=this.parser.schema.nodes[e.node],i.isLeaf?this.insertNode(i.create(e.attrs))||this.leafFallback(t):r=this.enter(i,e.attrs||null,e.preserveWhitespace);else{s=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(s)}let o=this.top;if(i&&i.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t)));else{let n=t;"string"==typeof e.contentElement?n=t.querySelector(e.contentElement):"function"==typeof e.contentElement?n=e.contentElement(t):e.contentElement&&(n=e.contentElement),this.findAround(t,n,!0),this.addAll(n)}r&&this.sync(o)&&this.open--,s&&this.removePendingMark(s,o)}addAll(t,e,n){let r=e||0;for(let i=e?t.childNodes[e]:t.firstChild,s=null==n?null:t.childNodes[n];i!=s;i=i.nextSibling,++r)this.findAtPoint(t,r),this.addDOM(i);this.findAtPoint(t,r)}findPlace(t){let e,n;for(let r=this.open;r>=0;r--){let i=this.nodes[r],s=i.findWrapping(t);if(s&&(!e||e.length>s.length)&&(e=s,n=i,!s.length))break;if(i.solid)break}if(!e)return!1;this.sync(n);for(let t=0;t<e.length;t++)this.enterInner(e[t],null,!1);return!0}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(t)){this.closeExtra();let e=this.top;e.applyPending(t.type),e.match&&(e.match=e.match.matchType(t.type));let n=e.activeMarks;for(let r=0;r<t.marks.length;r++)e.type&&!e.type.allowsMarkType(t.marks[r].type)||(n=t.marks[r].addToSet(n));return e.content.push(t.mark(n)),!0}return!1}enter(t,e,n){let r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r}enterInner(t,e=null,n=!1,r){this.closeExtra();let i=this.top;i.applyPending(t),i.match=i.match&&i.match.matchType(t);let s=sn(t,r,i.options);4&i.options&&0==i.content.length&&(s|=4),this.nodes.push(new on(t,e,i.activeMarks,i.pendingMarks,n,null,s)),this.open++}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));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(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)){e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),s=(t,o)=>{for(;t>=0;t--){let a=e[t];if(""==a){if(t==e.length-1||0==t)continue;for(;o>=i;o--)if(s(t-1,o))return!0;return!1}{let t=o>0||0==o&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!t||t.name!=a&&-1==t.groups.indexOf(a))return!1;o--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}addPendingMark(t){let e=function(t,e){for(let n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,e){for(let n=this.open;n>=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);let e=r.popFromStashMark(t);e&&r.type&&r.type.allowsMarkType(e.type)&&(r.activeMarks=e.addToSet(r.activeMarks))}if(r==e)break}}}function ln(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function cn(t){let e={};for(let n in t)e[n]=t[n];return e}function hn(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let n=0;n<t.edgeCount;n++){let{type:r,next:i}=t.edge(n);if(r==e)return!0;if(s.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}class dn{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=pn(e).createDocumentFragment());let r=n,i=[];return t.forEach((t=>{if(i.length||t.marks.length){let n=0,s=0;for(;n<i.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(i[n][0])||!1===e.type.spec.spanning)break;n++,s++}else s++}for(;n<i.length;)r=i.pop()[1];for(;s<t.marks.length;){let n=t.marks[s++],o=this.serializeMark(n,t.isInline,e);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(t,e))})),n}serializeNodeInner(t,e){let{dom:n,contentDOM:r}=dn.renderSpec(pn(e),this.nodes[t.type.name](t));if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let i=this.serializeMark(t.marks[r],t.isInline,e);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(t,e,n={}){let r=this.marks[t.type.name];return r&&dn.renderSpec(pn(n),r(t,e))}static renderSpec(t,e,n=null){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let r,i=e[0],s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o=n?t.createElementNS(n,i):t.createElement(i),a=e[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let t in a)if(null!=a[t]){let e=t.indexOf(" ");e>0?o.setAttributeNS(t.slice(0,e),t.slice(e+1),a[t]):o.setAttribute(t,a[t])}}for(let i=l;i<e.length;i++){let s=e[i];if(0===s){if(i<e.length-1||i>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}{let{dom:e,contentDOM:i}=dn.renderSpec(t,s,n);if(o.appendChild(e),i){if(r)throw new RangeError("Multiple content holes");r=i}}}return{dom:o,contentDOM:r}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new dn(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=un(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return un(t.marks)}}function un(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function pn(t){return t.document||window.document}const fn=Math.pow(2,16);function mn(t,e){return t+e*fn}function gn(t){return 65535&t}class yn{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class vn{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&vn.empty)return vn.empty}recover(t){let e=0,n=gn(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/fn}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let a=this.ranges[o]-(this.inverted?r:0);if(a>t)break;let l=this.ranges[o+i],c=this.ranges[o+s],h=a+l;if(t<=h){let i=a+r+((l?t==a?-1:t==h?1:e:e)<0?0:c);if(n)return i;let s=t==(e<0?a:h)?null:mn(o/3,t-a),d=t==a?2:t==h?1:4;return(e<0?t!=a:t!=h)&&(d|=8),new yn(i,d,s)}r+=c-l}return n?t+r:new yn(t+r,0,null)}touches(t,e){let n=0,r=gn(e),i=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?n:0);if(o>t)break;let a=this.ranges[e+i];if(t<=o+a&&e==3*r)return!0;n+=this.ranges[e+s]-a}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),a=s+(this.inverted?0:i),l=this.ranges[r+e],c=this.ranges[r+n];t(o,o+l,a,a+c),i+=c-l}}invert(){return new vn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?vn.empty:new vn(t<0?[0,-t,0]:[0,0,t])}}vn.empty=new vn([]);class bn{constructor(t=[],e,n=0,r=t.length){this.maps=t,this.mirror=e,this.from=n,this.to=r}slice(t=0,e=this.maps.length){return new bn(this.maps,this.mirror,t,e)}copy(){return new bn(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,n=this.maps.length;e<t.maps.length;e++){let r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:void 0)}}invert(){let t=new bn;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this.maps[n].mapResult(t,e);if(null!=i.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this.maps[e].recover(i.recover);continue}}r|=i.delInfo,t=i.pos}return n?t:new yn(t,r,null)}}const wn=Object.create(null);class xn{getMap(){return vn.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=wn[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in wn)throw new RangeError("Duplicate use of step JSON ID "+t);return wn[t]=e,e.prototype.jsonID=t,e}}class kn{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new kn(t,null)}static fail(t){return new kn(null,t)}static fromReplace(t,e,n,r){try{return kn.ok(t.replace(e,n,r))}catch(t){if(t instanceof me)return kn.fail(t.message);throw t}}}function Sn(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Sn(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return he.fromArray(r)}class On extends xn{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new ge(Sn(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),r),e.openStart,e.openEnd);return kn.fromReplace(t,this.from,this.to,i)}invert(){return new Mn(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new On(e.pos,n.pos,this.mark)}merge(t){return t instanceof On&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new On(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new On(e.from,e.to,t.markFromJSON(e.mark))}}xn.jsonID("addMark",On);class Mn extends xn{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new ge(Sn(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return kn.fromReplace(t,this.from,this.to,n)}invert(){return new On(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Mn(e.pos,n.pos,this.mark)}merge(t){return t instanceof Mn&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Mn(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Mn(e.from,e.to,t.markFromJSON(e.mark))}}xn.jsonID("removeMark",Mn);class An extends xn{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kn.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return kn.fromReplace(t,this.pos,this.pos+1,new ge(he.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new An(this.pos,e.marks[n]);return new An(this.pos,this.mark)}}return new En(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new An(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new An(e.pos,t.markFromJSON(e.mark))}}xn.jsonID("addNodeMark",An);class En extends xn{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kn.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return kn.fromReplace(t,this.pos,this.pos+1,new ge(he.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new An(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new En(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new En(e.pos,t.markFromJSON(e.mark))}}xn.jsonID("removeNodeMark",En);class Cn extends xn{constructor(t,e,n,r=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=r}apply(t){return this.structure&&Nn(t,this.from,this.to)?kn.fail("Structure replace would overwrite content"):kn.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new vn([this.from,this.to-this.from,this.slice.size])}invert(t){return new Cn(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deletedAcross&&n.deletedAcross?null:new Cn(e.pos,Math.max(e.pos,n.pos),this.slice)}merge(t){if(!(t instanceof Cn)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?ge.empty:new ge(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Cn(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?ge.empty:new ge(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Cn(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Cn(e.from,e.to,ge.fromJSON(t,e.slice),!!e.structure)}}xn.jsonID("replace",Cn);class Tn extends xn{constructor(t,e,n,r,i,s,o=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(t){if(this.structure&&(Nn(t,this.from,this.gapFrom)||Nn(t,this.gapTo,this.to)))return kn.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return kn.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?kn.fromReplace(t,this.from,this.to,n):kn.fail("Content does not fit in gap")}getMap(){return new vn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Tn(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),r=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||r<e.pos||i>n.pos?null:new Tn(e.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Tn(e.from,e.to,e.gapFrom,e.gapTo,ge.fromJSON(t,e.slice),e.insert,!!e.structure)}}function Nn(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let t=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,i--}}return!1}function Dn(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function $n(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth;;--n){let r=t.$from.node(n),i=t.$from.index(n),s=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(i,s,e))return n;if(0==n||r.type.spec.isolating||!Dn(r,i,s))break}return null}function In(t,e,n=null,r=t){let i=function(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}(t,e),s=i&&function(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let t=r;a&&t<i;t++)a=a.matchType(n.child(t).type);return a&&a.validEnd?o:null}(r,e);return s?i.map(Rn).concat({type:e,attrs:n}).concat(s.map(Rn)):null}function Rn(t){return{type:t,attrs:null}}function Bn(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let t=i.depth-1,e=n-2;t>s;t--,e--){let n=i.node(t),s=i.index(t);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(s,n.childCount),a=r&&r[e]||n;if(a!=n&&(o=o.replaceChild(0,a.type.create(a.attrs))),!n.canReplace(s+1,n.childCount)||!a.type.validContent(o))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function Fn(t,e){let n=t.resolve(e),r=n.index();return Pn(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Pn(t,e){return!(!t||!e||t.isLeaf||!t.canAppend(e))}function Vn(t,e,n=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let i,s,o=r.index(t);if(t==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(t+1),o++,s=r.node(t).maybeChild(o)):(i=r.node(t).maybeChild(o-1),s=r.node(t+1)),i&&!i.isTextblock&&Pn(i,s)&&r.node(t).canReplace(o,o+1))return e;if(0==t)break;e=n<0?r.before(t):r.after(t)}}function Ln(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let t=0;t<n.openStart;t++)i=i.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=r.depth;e>=0;e--){let n=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,s=r.index(e)+(n>0?1:0),o=r.node(e),a=!1;if(1==t)a=o.canReplace(s,s,i);else{let t=o.contentMatchAt(s).findWrapping(i.firstChild.type);a=t&&o.canReplaceWith(s,s,t[0])}if(a)return 0==n?r.pos:n<0?r.before(e+1):r.after(e+1)}return null}function zn(t,e,n=e,r=ge.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return jn(i,s,r)?new Cn(e,n,r):new _n(i,s,r).fit()}function jn(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}xn.jsonID("replaceAround",Tn);class _n{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=he.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=he.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(t<0?this.$to:n.doc.resolve(t));if(!r)return null;let i=this.placed,s=n.depth,o=r.depth;for(;s&&o&&1==i.childCount;)i=i.firstChild.content,s--,o--;let a=new ge(i,s,o);return t>-1?new Tn(n.pos,t,this.$to.pos,this.$to.end(),a,e):a.size||n.pos!=this.$to.pos?new Cn(n.pos,r.pos,a):null}findFittable(){for(let t=1;t<=2;t++)for(let e=this.unplaced.openStart;e>=0;e--){let n,r=null;e?(r=Hn(this.unplaced.content,e-1).firstChild,n=r.content):n=this.unplaced.content;let i=n.firstChild;for(let n=this.depth;n>=0;n--){let s,{type:o,match:a}=this.frontier[n],l=null;if(1==t&&(i?a.matchType(i.type)||(l=a.fillBefore(he.from(i),!1)):r&&o.compatibleContent(r.type)))return{sliceDepth:e,frontierDepth:n,parent:r,inject:l};if(2==t&&i&&(s=a.findWrapping(i.type)))return{sliceDepth:e,frontierDepth:n,parent:r,wrap:s};if(r&&a.matchType(r.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=Hn(t,e);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new ge(t,e+1,Math.max(n,r.size+e>=t.size-n?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=Hn(t,e);if(r.childCount<=1&&e>0){let i=t.size-e<=e+r.size;this.unplaced=new ge(Kn(t,e-1,1),e-1,i?e-1:n)}else this.unplaced=new ge(Kn(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:r,wrap:i}){for(;this.depth>e;)this.closeFrontierNode();if(i)for(let t=0;t<i.length;t++)this.openFrontierNode(i[t]);let s=this.unplaced,o=n?n.content:s.content,a=s.openStart-t,l=0,c=[],{match:h,type:d}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)c.push(r.child(t));h=h.matchFragment(r)}let u=o.size+t-(s.content.size-s.openEnd);for(;l<o.childCount;){let t=o.child(l),e=h.matchType(t.type);if(!e)break;l++,(l>1||0==a||t.content.size)&&(h=e,c.push(qn(t.mark(d.allowedMarks(t.marks)),1==l?a:0,l==o.childCount?u:-1)))}let p=l==o.childCount;p||(u=-1),this.placed=Wn(this.placed,e,he.from(c)),this.frontier[e].match=h,p&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=o;t<u;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=p?0==t?ge.empty:new ge(Kn(s.content,t-1,1),t-1,u<0?s.openEnd:t-1):new ge(Kn(s.content,t,l),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Jn(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:r}=this.frontier[e],i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Jn(t,e,r,n,i);if(s){for(let n=e-1;n>=0;n--){let{match:e,type:r}=this.frontier[n],i=Jn(t,n,r,e,!0);if(!i||i.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Wn(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),r=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=Wn(this.placed,this.depth,he.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(he.empty,!0);t.childCount&&(this.placed=Wn(this.placed,this.frontier.length,t))}}function Kn(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Kn(t.firstChild.content,e-1,n)))}function Wn(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Wn(t.lastChild.content,e-1,n)))}function Hn(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function qn(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,qn(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(he.empty,!0)))),t.copy(r)}function Jn(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!function(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,s.content,o)?a:null}function Un(t){return t.spec.defining||t.spec.definingForContent}function Gn(t,e,n,r,i){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Gn(i.content,e+1,n,r,i)))}if(e>r){let e=i.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(he.empty,!0))}return t}function Yn(t,e){let n=[];for(let r=Math.min(t.depth,e.depth);r>=0;r--){let i=t.start(r);if(i<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(i==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==i-1)&&n.push(r)}return n}class Xn extends xn{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return kn.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return kn.fromReplace(t,this.pos,this.pos+1,new ge(he.from(r),0,e.isLeaf?0:1))}getMap(){return vn.empty}invert(t){return new Xn(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Xn(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Xn(e.pos,e.attr,e.value)}}xn.jsonID("attr",Xn);let Zn=class extends Error{};Zn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(Zn.prototype=Object.create(Error.prototype)).constructor=Zn,Zn.prototype.name="TransformError";const Qn=Object.create(null);class tr{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new er(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=ge.empty){let n=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++)r=n,n=n.lastChild;let i=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=t.mapping.slice(i);t.replaceRange(c.map(a.pos),c.map(l.pos),o?ge.empty:e),0==o&&dr(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],a=t.mapping.slice(n),l=a.map(s.pos),c=a.map(o.pos);i?t.deleteRange(l,c):(t.replaceRangeWith(l,c,e),dr(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new ir(t):hr(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let r=t.depth-1;r>=0;r--){let i=e<0?hr(t.node(0),t.node(r),t.before(r+1),t.index(r),e,n):hr(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,n);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new lr(t.node(0))}static atStart(t){return hr(t,t,0,0,1)||new lr(t)}static atEnd(t){return hr(t,t,t.content.size,t.childCount,-1)||new lr(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Qn[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Qn)throw new RangeError("Duplicate use of selection JSON ID "+t);return Qn[t]=e,e.prototype.jsonID=t,e}getBookmark(){return ir.between(this.$anchor,this.$head).getBookmark()}}tr.prototype.visible=!0;class er{constructor(t,e){this.$from=t,this.$to=e}}let nr=!1;function rr(t){nr||t.parent.inlineContent||(nr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ir extends tr{constructor(t,e=t){rr(t),rr(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return tr.near(n);let r=t.resolve(e.map(this.anchor));return new ir(r.parent.inlineContent?r:n,n)}replace(t,e=ge.empty){if(super.replace(t,e),e==ge.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof ir&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new sr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new ir(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(t,e,n){let r=t.pos-e.pos;if(n&&!r||(n=r>=0?1:-1),!e.parent.inlineContent){let t=tr.findFrom(e,n,!0)||tr.findFrom(e,-n,!0);if(!t)return tr.near(e,n);e=t.$head}return t.parent.inlineContent||(0==r||(t=(tr.findFrom(t,-n,!0)||tr.findFrom(t,n,!0)).$anchor).pos<e.pos!=r<0)&&(t=e),new ir(t,e)}}tr.jsonID("text",ir);class sr{constructor(t,e){this.anchor=t,this.head=e}map(t){return new sr(t.map(this.anchor),t.map(this.head))}resolve(t){return ir.between(t.resolve(this.anchor),t.resolve(this.head))}}class or extends tr{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:r}=e.mapResult(this.anchor),i=t.resolve(r);return n?tr.near(i):new or(i)}content(){return new ge(he.from(this.node),0,0)}eq(t){return t instanceof or&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ar(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new or(t.resolve(e.anchor))}static create(t,e){return new or(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}or.prototype.visible=!1,tr.jsonID("node",or);class ar{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new sr(n,n):new ar(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&or.isSelectable(n)?new or(e):tr.near(e)}}class lr extends tr{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=ge.empty){if(e==ge.empty){t.delete(0,t.doc.content.size);let e=tr.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new lr(t)}map(t){return new lr(t)}eq(t){return t instanceof lr}getBookmark(){return cr}}tr.jsonID("all",lr);const cr={map(){return this},resolve:t=>new lr(t)};function hr(t,e,n,r,i,s=!1){if(e.inlineContent)return ir.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let r=e.child(o);if(r.isAtom){if(!s&&or.isSelectable(r))return or.create(t,n-(i<0?r.nodeSize:0))}else{let e=hr(t,r,n+i,i<0?r.childCount:0,i,s);if(e)return e}n+=r.nodeSize*i}return null}function dr(t,e,n){let r=t.steps.length-1;if(r<e)return;let i,s=t.steps[r];(s instanceof Cn||s instanceof Tn)&&(t.mapping.maps[r].forEach(((t,e,n,r)=>{null==i&&(i=r)})),t.setSelection(tr.near(t.doc.resolve(i),n)))}class ur extends class{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new bn}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Zn(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=ge.empty){let r=zn(this.doc,t,e,n);return r&&this.step(r),this}replaceWith(t,e,n){return this.replace(t,e,new ge(he.from(n),0,0))}delete(t,e){return this.replace(t,e,ge.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(jn(i,s,r))return t.step(new Cn(e,n,r));let o=Yn(i,t.doc.resolve(n));0==o[o.length-1]&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let t=i.depth,e=i.pos-1;t>0;t--,e--){let n=i.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(t)>-1?a=t:i.before(t)==e&&o.splice(1,0,-t)}let l=o.indexOf(a),c=[],h=r.openStart;for(let t=r.content,e=0;;e++){let n=t.firstChild;if(c.push(n),e==r.openStart)break;t=n.content}for(let t=h-1;t>=0;t--){let e=c[t].type,n=Un(e);if(n&&i.node(l).type!=e)h=t;else if(n||!e.isTextblock)break}for(let e=r.openStart;e>=0;e--){let a=(e+h+1)%(r.openStart+1),d=c[a];if(d)for(let e=0;e<o.length;e++){let c=o[(e+l)%o.length],h=!0;c<0&&(h=!1,c=-c);let u=i.node(c-1),p=i.index(c-1);if(u.canReplaceWith(p,p,d.type,d.marks))return t.replace(i.before(c),h?s.after(c):n,new ge(Gn(r.content,0,r.openStart,a),a,r.openEnd))}}let d=t.steps.length;for(let a=o.length-1;a>=0&&(t.replace(e,n,r),!(t.steps.length>d));a--){let t=o[a];t<0||(e=i.before(t),n=s.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=function(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,n))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,n))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}(t.doc,e,r.type);null!=i&&(e=n=i)}t.replaceRange(e,n,new ge(he.from(r),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=Yn(r,i);for(let e=0;e<s.length;e++){let n=s[e],o=e==s.length-1;if(o&&0==n||r.node(n).type.contentMatch.validEnd)return t.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return t.delete(r.before(n),i.after(n))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),a=i.after(s+1),l=o,c=a,h=he.empty,d=0;for(let t=s,e=!1;t>n;t--)e||r.index(t)>0?(e=!0,h=he.from(r.node(t).copy(h)),d++):l--;let u=he.empty,p=0;for(let t=s,e=!1;t>n;t--)e||i.after(t+1)<i.end(t)?(e=!0,u=he.from(i.node(t).copy(u)),p++):c++;t.step(new Tn(l,c,o,a,new ge(h.append(u),d,p),h.size-d,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let r=new Cn(e-n,e+n,ge.empty,!0);t.step(r)}(this,t,e),this}wrap(t,e){return function(t,e,n){let r=he.empty;for(let t=n.length-1;t>=0;t--){if(r.size){let e=n[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=he.from(n[t].type.create(n[t].attrs,r))}let i=e.start,s=e.end;t.step(new Tn(i,s,i,s,new ge(r,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,r=null){return function(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{if(e.isTextblock&&!e.hasMarkup(r,i)&&function(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(t.doc,t.mapping.slice(s).map(n),r)){t.clearIncompatible(t.mapping.slice(s).map(n,1),r);let o=t.mapping.slice(s),a=o.map(n,1),l=o.map(n+e.nodeSize,1);return t.step(new Tn(a,l,a+1,l-1,new ge(he.from(r.create(i,null,e.marks)),0,0),1,!0)),!1}}))}(this,t,e,n,r),this}setNodeMarkup(t,e,n=null,r=[]){return function(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Tn(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new ge(he.from(o),0,0),1,!0))}(this,t,e,n,r),this}setNodeAttribute(t,e,n){return this.step(new Xn(t,e,n)),this}addNodeMark(t,e){return this.step(new An(t,e)),this}removeNodeMark(t,e){if(!(e instanceof fe)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(n.marks)))return this}return this.step(new En(t,e)),this}split(t,e=1,n){return function(t,e,n=1,r){let i=t.doc.resolve(e),s=he.empty,o=he.empty;for(let t=i.depth,e=i.depth-n,a=n-1;t>e;t--,a--){s=he.from(i.node(t).copy(s));let e=r&&r[a];o=he.from(e?e.type.create(e.attrs,o):i.node(t).copy(o))}t.step(new Cn(e,e,new ge(s.append(o),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,r){let i,s,o=[],a=[];t.doc.nodesBetween(e,n,((t,l,c)=>{if(!t.isInline)return;let h=t.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,e),d=Math.min(l+t.nodeSize,n),u=r.addToSet(h);for(let t=0;t<h.length;t++)h[t].isInSet(u)||(i&&i.to==c&&i.mark.eq(h[t])?i.to=d:o.push(i=new Mn(c,d,h[t])));s&&s.to==c?s.to=d:a.push(s=new On(c,d,r))}})),o.forEach((e=>t.step(e))),a.forEach((e=>t.step(e)))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,((t,o)=>{if(!t.isInline)return;s++;let a=null;if(r instanceof Xe){let e,n=t.marks;for(;e=r.isInSet(n);)(a||(a=[])).push(e),n=e.removeFromSet(n)}else r?r.isInSet(t.marks)&&(a=[r]):a=t.marks;if(a&&a.length){let r=Math.min(o+t.nodeSize,n);for(let t=0;t<a.length;t++){let n,l=a[t];for(let t=0;t<i.length;t++){let e=i[t];e.step==s-1&&l.eq(i[t].style)&&(n=e)}n?(n.to=r,n.step=s):i.push({style:l,from:Math.max(o,e),to:r,step:s})}}})),i.forEach((e=>t.step(new Mn(e.from,e.to,e.style))))}(this,t,e,n),this}clearIncompatible(t,e,n){return function(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),s=[],o=e+1;for(let e=0;e<i.childCount;e++){let a=i.child(e),l=o+a.nodeSize,c=r.matchType(a.type);if(c){r=c;for(let e=0;e<a.marks.length;e++)n.allowsMarkType(a.marks[e].type)||t.step(new Mn(o,l,a.marks[e]))}else s.push(new Cn(o,l,ge.empty));o=l}if(!r.validEnd){let e=r.fillBefore(he.empty,!0);t.replace(o,o,new ge(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}(this,t,e,n),this}}{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.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(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return fe.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||fe.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=null==n?e:n,!t)return this.deleteRange(e,n);let i=this.storedMarks;if(!i){let t=this.doc.resolve(e);i=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,i)),this.selection.empty||this.setSelection(tr.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function pr(t,e){return e&&t?t.bind(e):t}class fr{constructor(t,e,n){this.name=t,this.init=pr(e.init,n),this.apply=pr(e.apply,n)}}const mr=[new fr("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new fr("selection",{init:(t,e)=>t.selection||tr.atStart(e.doc),apply:t=>t.selection}),new fr("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,r)=>r.selection.$cursor?t.storedMarks:null}),new fr("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class gr{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=mr.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new fr(t.key,t.spec.state,t))}))}}class yr{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),r=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let a=r?r[s].n:0,l=r?r[s].state:this,c=a<e.length&&o.spec.appendTransaction.call(o,a?e.slice(a):e,l,n);if(c&&n.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",t),!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<s?{state:n,n:e.length}:{state:this,n:0})}e.push(c),n=n.applyInner(c),i=!0}r&&(r[s]={state:n,n:e.length})}}if(!i)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new yr(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];e[i.name]=i.apply(t,this[i.name],this,e)}return e}get tr(){return new ur(this)}static create(t){let e=new gr(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new yr(e);for(let r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n}reconfigure(t){let e=new gr(this.schema,t.plugins),n=e.fields,r=new yr(e);for(let e=0;e<n.length;e++){let i=n[e].name;r[i]=this.hasOwnProperty(i)?this[i]:n[e].init(t,r)}return r}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[n],i=r.spec.state;i&&i.toJSON&&(e[n]=i.toJSON.call(r,this[r.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new gr(t.schema,t.plugins),i=new yr(r);return r.fields.forEach((r=>{if("doc"==r.name)i.doc=Re.fromJSON(t.schema,e.doc);else if("selection"==r.name)i.selection=tr.fromJSON(i.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(i.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let s in n){let o=n[s],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(e,s))return void(i[r.name]=a.fromJSON.call(o,t,e[s],i))}i[r.name]=r.init(t,i)}})),i}}function vr(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):"handleDOMEvents"==r&&(i=vr(i,e,{})),n[r]=i}return n}class br{constructor(t){this.spec=t,this.props={},t.props&&vr(t.props,this,this.props),this.key=t.key?t.key.key:xr("plugin")}getState(t){return t[this.key]}}const wr=Object.create(null);function xr(t){return t in wr?t+"$"+ ++wr[t]:(wr[t]=0,t+"$")}class kr{constructor(t="key"){this.key=xr(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Sr=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Or=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let Mr=null;const Ar=function(t,e,n){let r=Mr||(Mr=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},Er=function(t,e,n,r){return n&&(Tr(t,e,n,r,-1)||Tr(t,e,n,r,1))},Cr=/^(img|br|input|textarea|hr)$/i;function Tr(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Nr(t))){let n=t.parentNode;if(!n||1!=n.nodeType||Dr(t)||Cr.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Sr(t)+(i<0?0:1),t=n}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(i<0?-1:0)]).contentEditable)return!1;e=i<0?Nr(t):0}}}function Nr(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Dr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const $r=function(t){return t.focusNode&&Er(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ir(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Rr="undefined"!=typeof navigator?navigator:null,Br="undefined"!=typeof document?document:null,Fr=Rr&&Rr.userAgent||"",Pr=/Edge\/(\d+)/.exec(Fr),Vr=/MSIE \d/.exec(Fr),Lr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fr),zr=!!(Vr||Lr||Pr),jr=Vr?document.documentMode:Lr?+Lr[1]:Pr?+Pr[1]:0,_r=!zr&&/gecko\/(\d+)/i.test(Fr);_r&&(/Firefox\/(\d+)/.exec(Fr)||[0,0])[1];const Kr=!zr&&/Chrome\/(\d+)/.exec(Fr),Wr=!!Kr,Hr=Kr?+Kr[1]:0,qr=!zr&&!!Rr&&/Apple Computer/.test(Rr.vendor),Jr=qr&&(/Mobile\/\w+/.test(Fr)||!!Rr&&Rr.maxTouchPoints>2),Ur=Jr||!!Rr&&/Mac/.test(Rr.platform),Gr=/Android \d/.test(Fr),Yr=!!Br&&"webkitFontSmoothing"in Br.documentElement.style,Xr=Yr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Zr(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Qr(t,e){return"number"==typeof t?t:t[e]}function ti(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function ei(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;o=Or(o)){if(1!=o.nodeType)continue;let t=o,n=t==s.body,a=n?Zr(s):ti(t),l=0,c=0;if(e.top<a.top+Qr(r,"top")?c=-(a.top-e.top+Qr(i,"top")):e.bottom>a.bottom-Qr(r,"bottom")&&(c=e.bottom-a.bottom+Qr(i,"bottom")),e.left<a.left+Qr(r,"left")?l=-(a.left-e.left+Qr(i,"left")):e.right>a.right-Qr(r,"right")&&(l=e.right-a.right+Qr(i,"right")),l||c)if(n)s.defaultView.scrollBy(l,c);else{let n=t.scrollLeft,r=t.scrollTop;c&&(t.scrollTop+=c),l&&(t.scrollLeft+=l);let i=t.scrollLeft-n,s=t.scrollTop-r;e={left:e.left-i,top:e.top-s,right:e.right-i,bottom:e.bottom-s}}if(n)break}}function ni(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Or(r));return e}function ri(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ii=null;function si(t,e){let n,r,i=2e8,s=0,o=e.top,a=e.top;for(let l=t.firstChild,c=0;l;l=l.nextSibling,c++){let t;if(1==l.nodeType)t=l.getClientRects();else{if(3!=l.nodeType)continue;t=Ar(l).getClientRects()}for(let h=0;h<t.length;h++){let d=t[h];if(d.top<=o&&d.bottom>=a){o=Math.max(d.bottom,o),a=Math.min(d.top,a);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<i){n=l,i=t,r=t&&3==n.nodeType?{left:d.right<e.left?d.right:d.left,top:e.top}:e,1==l.nodeType&&t&&(s=c+(e.left>=(d.left+d.right)/2?1:0));continue}}!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(s=c+1)}}return n&&3==n.nodeType?function(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let n=ci(r,1);if(n.top!=n.bottom&&oi(e,n))return{node:t,offset:i+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||i&&1==n.nodeType?{node:t,offset:s}:si(n,r)}function oi(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ai(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let n=t.childNodes[s];if(1==n.nodeType){let t=n.getClientRects();for(let r=0;r<t.length;r++){let i=t[r];if(oi(e,i))return ai(n,e,i)}}if((s=(s+1)%r)==i)break}return t}function li(t,e){let n,r=t.dom.ownerDocument,i=0;if(r.caretPositionFromPoint)try{let t=r.caretPositionFromPoint(e.left,e.top);t&&({offsetNode:n,offset:i}=t)}catch(t){}if(!n&&r.caretRangeFromPoint){let t=r.caretRangeFromPoint(e.left,e.top);t&&({startContainer:n,startOffset:i}=t)}let s,o=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);if(!o||!t.dom.contains(1!=o.nodeType?o.parentNode:o)){let n=t.dom.getBoundingClientRect();if(!oi(e,n))return null;if(o=ai(t.dom,e,n),!o)return null}if(qr)for(let t=o;n&&t;t=Or(t))t.draggable&&(n=void 0);if(o=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(o,e),n){if(_r&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let t,r=n.childNodes[i];"IMG"==r.nodeName&&(t=r.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&i++}n==t.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(s=function(t,e,n,r){let i=-1;for(let n=e;n!=t.dom;){let e=t.docView.nearestDesc(n,!0);if(!e)return null;if(e.node.isBlock&&e.parent){let t=e.dom.getBoundingClientRect();if(t.left>r.left||t.top>r.top)i=e.posBefore;else{if(!(t.right<r.left||t.bottom<r.top))break;i=e.posAfter}}n=e.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,1)}(t,n,i,e))}null==s&&(s=function(t,e,n){let{node:r,offset:i}=si(e,n),s=-1;if(1==r.nodeType&&!r.firstChild){let t=r.getBoundingClientRect();s=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function ci(t,e){let n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}const hi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function di(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Yr||_r;if(3==r.nodeType){if(!o||!hi.test(r.nodeValue)&&(n<0?i:i!=r.nodeValue.length)){let t=i,e=i,s=n<0?1:-1;return n<0&&!i?(e++,s=-1):n>=0&&i==r.nodeValue.length?(t--,s=1):n<0?t--:e++,ui(ci(Ar(r,t,e),1),s<0)}{let t=ci(Ar(r,i,i),n);if(_r&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let e=ci(Ar(r,i-1,i-1),-1);if(e.top==t.top){let n=ci(Ar(r,i,i+1),-1);if(n.top!=t.top)return ui(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(null==s&&i&&(n<0||i==Nr(r))){let t=r.childNodes[i-1];if(1==t.nodeType)return pi(t.getBoundingClientRect(),!1)}if(null==s&&i<Nr(r)){let t=r.childNodes[i];if(1==t.nodeType)return pi(t.getBoundingClientRect(),!0)}return pi(r.getBoundingClientRect(),n>=0)}if(null==s&&i&&(n<0||i==Nr(r))){let t=r.childNodes[i-1],e=3==t.nodeType?Ar(t,Nr(t)-(o?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return ui(ci(e,1),!1)}if(null==s&&i<Nr(r)){let t=r.childNodes[i];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?Ar(t,0,o?0:1):1==t.nodeType?t:null:null;if(e)return ui(ci(e,-1),!0)}return ui(ci(3==r.nodeType?Ar(r):r,-n),n>=0)}function ui(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function pi(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function fi(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}const mi=/[\u0590-\u08ac]/;let gi=null,yi=null,vi=!1;function bi(t,e,n){return gi==e&&yi==n?vi:(gi=e,yi=n,vi="up"==n||"down"==n?function(t,e,n){let r=e.selection,i="up"==n?r.$from:r.$to;return fi(t,e,(()=>{let{node:e}=t.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.dom;break}e=n.dom.parentNode}let r=di(t,i.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=Ar(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let i=e[t];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>2*(i.bottom-r.top):i.bottom-r.bottom>2*(r.bottom-i.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=t.domSelection();return mi.test(r.parent.textContent)&&a.modify?fi(t,e,(()=>{let{focusNode:e,focusOffset:i,anchorNode:s,anchorOffset:o}=t.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:d}=t.domSelectionRange(),u=h&&!c.contains(1==h.nodeType?h:h.parentNode)||e==h&&i==d;try{a.collapse(s,o),e&&(e!=s||i!=o)&&a.extend&&a.extend(e,i)}catch(t){}return null!=l&&(a.caretBidiLevel=l),u})):"left"==n||"backward"==n?s:o}(t,e,n))}class wi{constructor(t,e,n,r){this.parent=t,this.children=e,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let r=this.children[e];if(r==t)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,r;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM)r=e>Sr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!1;break}if(e.previousSibling)break}if(null==r&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!0;break}if(e.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,r=t;r;r=r.parentNode){let i,s=this.getDesc(r);if(s&&(!e||s.node)){if(!n||!(i=s.nodeDOM)||(1==i.nodeType?i.contains(1==t.nodeType?t:t.parentNode):i==t))return s;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let r=t;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let r=this.children[e],i=n+r.size;if(n==t&&i!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<i)return r.descAt(t-n-r.border);n=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n,r=0,i=0;for(let e=0;r<this.children.length;r++){let n=this.children[r],s=e+n.size;if(s>t||n instanceof Ei){i=t-e;break}e=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(;r&&!(n=this.children[r-1]).size&&n instanceof xi&&n.side>=0;r--);if(e<=0){let t,n=!0;for(;t=r?this.children[r-1]:null,t&&t.dom.parentNode!=this.contentDOM;r--,n=!1);return t&&e&&n&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?Sr(t.dom)+1:0}}{let t,n=!0;for(;t=r<this.children.length?this.children[r]:null,t&&t.dom.parentNode!=this.contentDOM;r++,n=!1);return t&&n&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?Sr(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=n,o=0;;o++){let n=this.children[o],a=s+n.size;if(-1==r&&t<=a){let i=s+n.border;if(t>=i&&e<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,i);t=s;for(let e=o;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Sr(n.dom)+1;break}t-=n.size}-1==r&&(r=0)}if(r>-1&&(a>e||o==this.children.length-1)){e=a;for(let t=o+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=Sr(n.dom);break}e+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,r=!1){let i=Math.min(t,e),s=Math.max(t,e);for(let o=0,a=0;o<this.children.length;o++){let l=this.children[o],c=a+l.size;if(i>a&&s<c)return l.setSelection(t-a-l.border,e-a-l.border,n,r);a=c}let o=this.domFromPos(t,t?-1:1),a=e==t?o:this.domFromPos(e,e?-1:1),l=n.getSelection(),c=!1;if((_r||qr)&&t==e){let{node:t,offset:e}=o;if(3==t.nodeType){if(c=!(!e||"\n"!=t.nodeValue[e-1]),c&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(o=a={node:e.parentNode,offset:Sr(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(_r&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let t=l.focusNode.childNodes[l.focusOffset];t&&"false"==t.contentEditable&&(r=!0)}if(!(r||c&&qr)&&Er(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Er(a.node,a.offset,l.focusNode,l.focusOffset))return;let h=!1;if((l.extend||t==e)&&!c){l.collapse(o.node,o.offset);try{t!=e&&l.extend(a.node,a.offset),h=!0}catch(t){}}if(!h){if(t>e){let t=o;o=a,a=t}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],s=n+i.size;if(n==s?t<=s&&e>=n:t<s&&e>n){let r=n+i.border,o=s-i.border;if(t>=r&&e<=o)return this.dirty=t==n||e==s?2:1,void(t!=r||e!=o||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(t-r,e-r):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=s}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class xi extends wi{constructor(t,e,n,r){let i,s=e.type.toDOM;if("function"==typeof s&&(s=s(n,(()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r))),!e.type.spec.raw){if(1!=s.nodeType){let t=document.createElement("span");t.appendChild(s),s=t}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,i=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class ki extends wi{constructor(t,e,n,r){super(t,[],e,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class Si extends wi{constructor(t,e,n,r){super(t,[],n,r),this.mark=e}static create(t,e,n,r){let i=r.nodeViews[e.type.name],s=i&&i(e,r,n);return s&&s.dom||(s=dn.renderSpec(document,e.type.spec.toDOM(e,n))),new Si(t,e,s.dom,s.contentDOM||s.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let r=Si.create(this.parent,this.mark,!0,n),i=this.children,s=this.size;e<s&&(i=zi(i,e,s,n)),t>0&&(i=zi(i,0,t,n));for(let t=0;t<i.length;t++)i[t].parent=r;return r.children=i,r}}class Oi extends wi{constructor(t,e,n,r,i,s,o,a,l){super(t,[],i,s),this.node=e,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o,s&&this.updateChildren(a,l)}static create(t,e,n,r,i,s){let o,a=i.nodeViews[e.type.name],l=a&&a(e,i,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),n,r),c=l&&l.dom,h=l&&l.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else c||({dom:c,contentDOM:h}=dn.renderSpec(document,e.type.spec.toDOM(e)));h||e.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let d=c;return c=Bi(c,n,e),l?o=new Ci(t,e,n,r,c,h||null,d,l,i,s+1):e.isText?new Ai(t,e,n,r,c,d,i):new Oi(t,e,n,r,c,h||null,d,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>he.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&Fi(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,r=e,i=t.composing?this.localCompositionInfo(t,e):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,a=new Vi(this,s&&s.node,t);!function(t,e,n,r){let i=e.locals(t),s=0;if(0==i.length){for(let n=0;n<t.childCount;n++){let o=t.child(n);r(o,i,e.forChild(s,o),n),s+=o.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){if(o<i.length&&i[o].to==s){let t,e=i[o++];for(;o<i.length&&i[o].to==s;)(t||(t=[e])).push(i[o++]);if(t){t.sort(Li);for(let e=0;e<t.length;e++)n(t[e],c,!!l)}else n(e,c,!!l)}let h,d;if(l)d=-1,h=l,l=null;else{if(!(c<t.childCount))break;d=c,h=t.child(c++)}for(let t=0;t<a.length;t++)a[t].to<=s&&a.splice(t--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let u=s+h.nodeSize;if(h.isText){let t=u;o<i.length&&i[o].from<t&&(t=i[o].from);for(let e=0;e<a.length;e++)a[e].to<t&&(t=a[e].to);t<u&&(l=h.cut(t-s),h=h.cut(0,t-s),u=t,d=-1)}let p=h.isInline&&!h.isLeaf?a.filter((t=>!t.inline)):a.slice();r(h,p,e.forChild(s,h),d),s=u}}(this.node,this.innerDeco,((e,i,s)=>{e.spec.marks?a.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?fe.none:this.node.child(i).marks,n,t),a.placeWidget(e,t,r)}),((e,s,l,c)=>{let h;a.syncToMarks(e.marks,n,t),a.findNodeMatch(e,s,l,c)||o&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(e,s,l,h,t)||a.updateNextNode(e,s,l,t,c)||a.addNode(e,s,l,t,r),r+=e.nodeSize})),a.syncToMarks([],n,t),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),Ti(this.contentDOM,this.children,t),Jr&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:r}=t.state.selection;if(!(t.state.selection instanceof ir)||n<e||r>e+this.node.content.size)return null;let i=t.domSelectionRange(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];e=Nr(t=t.childNodes[e-1])}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let t=s.nodeValue,i=function(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<t.childCount;){let e=t.child(i++);if(s+=e.nodeSize,!e.isText)break;l+=e.text}if(s>=n){let t=a<r?l.lastIndexOf(e,r-a-1):-1;if(t>=0&&t+e.length+a>=n)return a+t;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}(this.node.content,t,n-e,r-e);return i<0?null:{node:s,pos:i,text:t}}return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:r}){if(this.getDesc(e))return;let i=e;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 s=new ki(this,i,e,r);t.input.compositionNodes.push(s),this.children=zi(this.children,n,n+r.length,t,s)}update(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)}updateInner(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(Fi(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Ii(this.dom,this.nodeDOM,$i(this.outerDeco,this.node,e),$i(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function Mi(t,e,n,r,i){return Bi(r,e,t),new Oi(void 0,t,e,n,r,r,r,i,0)}class Ai extends Oi{constructor(t,e,n,r,i,s,o){super(t,e,n,r,i,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,!0)}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let r=this.node.cut(t,e),i=document.createTextNode(r.text);return new Ai(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}}class Ei extends wi{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Ci extends Oi{constructor(t,e,n,r,i,s,o,a,l,c){super(t,e,n,r,i,s,o,l,c),this.spec=a}update(t,e,n,r){if(3==this.dirty)return!1;if(this.spec.update){let i=this.spec.update(t,e,n);return i&&this.updateInner(t,e,n,r),i}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n):super.setSelection(t,e,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Ti(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],a=o.dom;if(a.parentNode==t){for(;a!=r;)r=Pi(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(o instanceof Si){let e=r?r.previousSibling:t.lastChild;Ti(o.contentDOM,o.children,n),r=e?e.nextSibling:t.firstChild}}for(;r;)r=Pi(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Ni=function(t){t&&(this.nodeName=t)};Ni.prototype=Object.create(null);const Di=[new Ni];function $i(t,e,n){if(0==t.length)return Di;let r=n?Di[0]:new Ni,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new Ni(o.nodeName));for(let t in o){let s=o[t];null!=s&&(n&&1==i.length&&i.push(r=new Ni(e.isInline?"span":"div")),"class"==t?r.class=(r.class?r.class+" ":"")+s:"style"==t?r.style=(r.style?r.style+";":"")+s:"nodeName"!=t&&(r[t]=s))}}}return i}function Ii(t,e,n,r){if(n==Di&&r==Di)return e;let i=e;for(let e=0;e<r.length;e++){let s=r[e],o=n[e];if(e){let e;o&&o.nodeName==s.nodeName&&i!=t&&(e=i.parentNode)&&e.nodeName.toLowerCase()==s.nodeName||(e=document.createElement(s.nodeName),e.pmIsDeco=!0,e.appendChild(i),o=Di[0]),i=e}Ri(i,o||Di[0],s)}return i}function Ri(t,e,n){for(let r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)-1==i.indexOf(r[e])&&t.classList.remove(r[e]);for(let e=0;e<i.length;e++)-1==r.indexOf(i[e])&&t.classList.add(i[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function Bi(t,e,n){return Ii(t,t,Di,$i(e,n,1!=t.nodeType))}function Fi(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Pi(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Vi{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];t:for(;i>0;){let a;for(;;)if(r){let t=n.children[r-1];if(!(t instanceof Si)){a=t,r--;break}n=t,r=t.children.length}else{if(n==e)break t;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let r=0,i=this.stack.length>>1,s=Math.min(i,t.length);for(;r<s&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<t.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++)if(this.top.children[e].matchesMark(t[i])){r=e;break}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Si.create(this.top,t[i],e,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(t,e,n,r){let i,s=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(t,e,n))s=this.top.children.indexOf(i,this.index);else for(let r=this.index,i=Math.min(this.top.children.length,r+5);r<i;r++){let i=this.top.children[r];if(i.matchesNode(t,e,n)&&!this.preMatch.matched.has(i)){s=r;break}}return!(s<0)&&(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(t,e,n,r,i){let s=this.top.children[r];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(t,e,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,r,i){for(let s=this.index;s<this.top.children.length;s++){let o=this.top.children[s];if(o instanceof Oi){let a=this.preMatch.matched.get(o);if(null!=a&&a!=i)return!1;let l=o.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(t.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==t.text&&3!=o.dirty&&Fi(e,o.outerDeco)))&&o.update(t,e,n,r))return this.destroyBetween(this.index,s),o.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1}addNode(t,e,n,r,i){this.top.children.splice(this.index++,0,Oi.create(this.top,t,e,n,r,i)),this.changed=!0}placeWidget(t,e,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){let r=new xi(this.top,t,e,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof Si;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Ai)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((qr||Wr)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let r=new Ei(this.top,[],n,null);e!=this.top?e.children.push(r):e.children.splice(this.index++,0,r),this.changed=!0}}}function Li(t,e){return t.type.side-e.type.side}function zi(t,e,n,r,i){let s=[];for(let o=0,a=0;o<t.length;o++){let l=t[o],c=a,h=a+=l.size;c>=n||h<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),i&&(s.push(i),i=void 0),h>n&&s.push(l.slice(n-c,l.size,r)))}return s}function ji(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&0==i.size,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a,l,c=r.resolve(o);if($r(n)){for(a=c;i&&!i.node;)i=i.parent;let t=i.node;if(i&&t.isAtom&&or.isSelectable(t)&&i.parent&&(!t.isInline||!function(t,e,n){for(let r=0==e,i=e==Nr(t);r||i;){if(t==n)return!0;let e=Sr(t);if(!(t=t.parentNode))return!1;r=r&&0==e,i=i&&e==Nr(t)}}(n.focusNode,n.focusOffset,i.dom))){let t=i.posBefore;l=new or(o==t?c:r.resolve(t))}}else{let e=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(e<0)return null;a=r.resolve(e)}if(!l){l=Yi(t,a,c,"pointer"==e||t.state.selection.head<c.pos&&!s?1:-1)}return l}function _i(t){return t.editable?t.hasFocus():Zi(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ki(t,e=!1){let n=t.state.selection;if(Ui(t,n),_i(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Wr){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&Er(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i="IMG"==r.nodeName;i?n.setEnd(r.parentNode,Sr(r)+1):n.setEnd(r,0);n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&zr&&jr<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{let r,i,{anchor:s,head:o}=n;!Wi||n instanceof ir||(n.$from.parent.inlineContent||(r=Hi(t,n.from)),n.empty||n.$from.parent.inlineContent||(i=Hi(t,n.to))),t.docView.setSelection(s,o,t.root,e),Wi&&(r&&Ji(r),i&&Ji(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==i||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{_i(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Wi=qr||Wr&&Hr<63;function Hi(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(qr&&i&&"false"==i.contentEditable)return qi(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return qi(i);if(s)return qi(s)}}function qi(t){return t.contentEditable="true",qr&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ji(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Ui(t,e){if(e instanceof or){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Gi(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Gi(t)}function Gi(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Yi(t,e,n,r){return t.someProp("createSelectionBetween",(r=>r(t,e,n)))||ir.between(e,n,r)}function Xi(t){return!(t.editable&&!t.hasFocus())&&Zi(t)}function Zi(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Qi(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&tr.findFrom(s,e)}function ts(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function es(t,e,n){let r=t.state.selection;if(!(r instanceof ir)){if(r instanceof or&&r.node.isInline)return ts(t,new ir(e>0?r.$to:r.$from));{let n=Qi(t.state,e);return!!n&&ts(t,n)}}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){let n=Qi(t.state,e);return!!(n&&n instanceof or)&&ts(t,n)}if(!(Ur&&n.indexOf("m")>-1)){let n,i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let o=e<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=t.docView.descAt(o))&&!n.contentDOM)&&(or.isSelectable(s)?ts(t,new or(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):!!Yr&&ts(t,new ir(t.state.doc.resolve(e<0?o:o+s.nodeSize))))}}function ns(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function rs(t){let e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function is(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(_r&&1==n.nodeType&&r<ns(n)&&rs(n.childNodes[r])&&(o=!0);;)if(r>0){if(1!=n.nodeType)break;{let t=n.childNodes[r-1];if(rs(t))i=n,s=--r;else{if(3!=t.nodeType)break;n=t,r=n.nodeValue.length}}}else{if(as(n))break;{let e=n.previousSibling;for(;e&&rs(e);)i=n.parentNode,s=Sr(e),e=e.previousSibling;if(e)n=e,r=ns(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?ls(t,n,r):i&&ls(t,i,s)}function ss(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=ns(n);for(;;)if(r<o){if(1!=n.nodeType)break;if(!rs(n.childNodes[r]))break;i=n,s=++r}else{if(as(n))break;{let e=n.nextSibling;for(;e&&rs(e);)i=e.parentNode,s=Sr(e)+1,e=e.nextSibling;if(e)n=e,r=0,o=ns(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&ls(t,i,s)}function as(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function ls(t,e,n){let r=t.domSelection();if($r(r)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),r.removeAllRanges(),r.addRange(t)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout((()=>{t.state==i&&Ki(t)}),50)}function cs(t,e,n){let r=t.state.selection;if(r instanceof ir&&!r.empty||n.indexOf("s")>-1)return!1;if(Ur&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=Qi(t.state,e);if(n&&n instanceof or)return ts(t,n)}if(!i.parent.inlineContent){let n=e<0?i:s,o=r instanceof lr?tr.near(n,e):tr.findFrom(n,e);return!!o&&ts(t,o)}return!1}function hs(t,e){if(!(t.state.selection instanceof ir))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=t.state.tr;return e<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),t.dispatch(r),!0}return!1}function ds(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function us(t,e){let n=e.keyCode,r=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||Ur&&72==n&&"c"==r?hs(t,-1)||is(t):46==n||Ur&&68==n&&"c"==r?hs(t,1)||ss(t):13==n||27==n||(37==n||Ur&&66==n&&"c"==r?es(t,-1,r)||is(t):39==n||Ur&&70==n&&"c"==r?es(t,1,r)||ss(t):38==n||Ur&&80==n&&"c"==r?cs(t,-1,r)||is(t):40==n||Ur&&78==n&&"c"==r?function(t){if(!qr||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;ds(t,n,"true"),setTimeout((()=>ds(t,n,"false")),20)}return!1}(t)||cs(t,1,r)||ss(t):r==(Ur?"m":"c")&&(66==n||73==n||89==n||90==n))}function ps(t,e){t.someProp("transformCopied",(t=>{e=t(e)}));let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let t=r.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),r=t.content}let o=t.someProp("clipboardSerializer")||dn.fromSchema(t.state.schema),a=Ss(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c,h=l.firstChild,d=0;for(;h&&1==h.nodeType&&(c=xs[h.nodeName.toLowerCase()]);){for(let t=c.length-1;t>=0;t--){let e=a.createElement(c[t]);for(;l.firstChild;)e.appendChild(l.firstChild);l.appendChild(e),d++}h=l.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let u=t.someProp("clipboardTextSerializer",(t=>t(e)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:l,text:u}}function fs(t,e,n,r,i){let s,o,a=i.parent.type.spec.code;if(!n&&!e)return null;let l=e&&(r||a||!n);if(l){if(t.someProp("transformPastedText",(t=>{e=t(e,a||r)})),a)return e?new ge(he.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):ge.empty;let n=t.someProp("clipboardTextParser",(t=>t(e,i,r)));if(n)o=n;else{let n=i.marks(),{schema:r}=t.state,o=dn.fromSchema(r);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=s.appendChild(document.createElement("p"));t&&e.appendChild(o.serializeNode(r.text(t,n)))}))}}else t.someProp("transformPastedHTML",(t=>{n=t(n)})),s=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,r=Ss().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(t);(n=i&&xs[i[1].toLowerCase()])&&(t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join(""));if(r.innerHTML=t,n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}(n),Yr&&function(t){let e=t.querySelectorAll(Wr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(s);let c=s&&s.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let t=+h[3];t>0&&s.firstChild;t--)s=s.firstChild;if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||tn.fromSchema(t.state.schema);o=e.parseSlice(s,{preserveWhitespace:!(!l&&!h),context:i,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||ms.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(h)o=function(t,e){if(!t.size)return t;let n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}let{content:i,openStart:s,openEnd:o}=t;for(let t=n.length-2;t>=0;t-=2){let e=r.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;i=he.from(e.create(n[t+1],i)),s++,o++}return new ge(i,s,o)}(ws(o,+h[1],+h[2]),h[4]);else if(o=ge.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r,i=e.node(n).contentMatchAt(e.index(n)),s=[];if(t.forEach((t=>{if(!s)return;let e,n=i.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&r.length&&ys(n,r,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=vs(s[s.length-1],r.length));let e=gs(t,n);s.push(e),i=i.matchType(e.type),r=n}})),s)return he.from(s)}return t}(o.content,i),!0),o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);o=ws(o,t,e)}return t.someProp("transformPasted",(t=>{o=t(o)})),o}const ms=/^(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 gs(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,he.from(t));return t}function ys(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=ys(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(he.from(gs(n,t,i+1))))}}function vs(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,vs(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(he.empty,!0);return t.copy(n.append(r))}function bs(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,a=o.content;return i<r-1&&(a=bs(a,e,n,r,i+1,s)),i>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,t.childCount>1||s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(he.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function ws(t,e,n){return e<t.openStart&&(t=new ge(bs(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new ge(bs(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const xs={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 ks=null;function Ss(){return ks||(ks=document.implementation.createHTMLDocument("title"))}const Os={},Ms={},As={touchstart:!0,touchmove:!0};class Es{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Cs(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Ts(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>Ns(t,e))}))}function Ns(t,e){return t.someProp("handleDOMEvents",(n=>{let r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function Ds(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function $s(t){return{left:t.clientX,top:t.clientY}}function Is(t,e,n,r,i){if(-1==r)return!1;let s=t.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--)if(t.someProp(e,(e=>r>s.depth?e(t,n,s.nodeAfter,s.before(r),i,!0):e(t,n,s.node(r),s.before(r),i,!1))))return!0;return!1}function Rs(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Bs(t,e,n,r,i){return Is(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(n=>n(t,e,r)))||(i?function(t,e){if(-1==e)return!1;let n,r,i=t.state.selection;i instanceof or&&(n=i.node);let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(or.isSelectable(e)){r=n&&i.$from.depth>0&&t>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(t);break}}return null!=r&&(Rs(t,or.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&or.isSelectable(r))&&(Rs(t,new or(n),"pointer"),!0)}(t,n))}function Fs(t,e,n,r){return Is(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(n=>n(t,e,r)))}function Ps(t,e,n,r){return Is(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(n=>n(t,e,r)))||function(t,e,n){if(0!=n.button)return!1;let r=t.state.doc;if(-1==e)return!!r.inlineContent&&(Rs(t,ir.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(e);for(let e=i.depth+1;e>0;e--){let n=e>i.depth?i.nodeAfter:i.node(e),s=i.before(e);if(n.inlineContent)Rs(t,ir.create(r,s+1,s+1+n.content.size),"pointer");else{if(!or.isSelectable(n))continue;Rs(t,or.create(r,s),"pointer")}return!0}}(t,n,r)}function Vs(t){return Hs(t)}Ms.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!js(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!Gr||!Wr||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!Jr||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",(e=>e(t,n)))||us(t,n)?n.preventDefault():Cs(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,Ir(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},Ms.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},Ms.keypress=(t,e)=>{let n=e;if(js(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ur&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n))))return void n.preventDefault();let r=t.state.selection;if(!(r instanceof ir&&r.$from.sameParent(r.$to))){let e=String.fromCharCode(n.charCode);t.someProp("handleTextInput",(n=>n(t,r.$from.pos,r.$to.pos,e)))||t.dispatch(t.state.tr.insertText(e).scrollIntoView()),n.preventDefault()}};const Ls=Ur?"metaKey":"ctrlKey";Os.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Vs(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(n,t.input.lastClick)&&!n[Ls]&&("singleClick"==t.input.lastClick.type?s="doubleClick":"doubleClick"==t.input.lastClick.type&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=t.posAtCoords($s(n));o&&("singleClick"==s?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new zs(t,o,n,!!r)):("doubleClick"==s?Fs:Ps)(t,o.pos,o.inside,n)?n.preventDefault():Cs(t,"pointer"))};class zs{constructor(t,e,n,r){let i,s;if(this.view=t,this.pos=e,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[Ls],this.allowDefault=n.shiftKey,e.inside>-1)i=t.state.doc.nodeAt(e.inside),s=e.inside;else{let n=t.state.doc.resolve(e.pos);i=n.parent,s=n.depth?n.before():0}const o=r?null:n.target,a=o?t.docView.nearestDesc(o,!0):null;this.target=a?a.dom:null;let{selection:l}=t.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof or&&l.from<=s&&l.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!_r||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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Cs(t,"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((()=>Ki(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords($s(t))),this.updateAllowDefault(t),this.allowDefault||!e?Cs(this.view,"pointer"):Bs(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||qr&&this.mightDrag&&!this.mightDrag.node.isAtom||Wr&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Rs(this.view,tr.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):Cs(this.view,"pointer")}move(t){this.updateAllowDefault(t),Cs(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function js(t,e){return!!t.composing||!!(qr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}Os.touchstart=t=>{t.input.lastTouch=Date.now(),Vs(t),Cs(t,"pointer")},Os.touchmove=t=>{t.input.lastTouch=Date.now(),Cs(t,"pointer")},Os.contextmenu=t=>Vs(t);const _s=Gr?5e3:-1;function Ks(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>Hs(t)),e))}function Ws(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Hs(t,e=!1){if(!(Gr&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Ws(t),e||t.docView&&t.docView.dirty){let e=ji(t);return e&&!e.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(e)):t.updateState(t.state),!0}return!1}}Ms.compositionstart=Ms.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||n.marks(),Hs(t,!0),t.markCursor=null;else if(Hs(t),_r&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,r=e.focusOffset;n&&1==n.nodeType&&0!=r;){let e=r<0?n.lastChild:n.childNodes[r-1];if(!e)break;if(3==e.nodeType){t.domSelection().collapse(e,e.nodeValue.length);break}n=e,r=-1}}t.input.composing=!0}Ks(t,_s)},Ms.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,Ks(t,20))};const qs=zr&&jr<15||Jr&&Xr<604;function Js(t,e,n,r){let i=fs(t,e,n,t.input.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,r,i||ge.empty))))return!0;if(!i)return!1;let s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),o=s?t.state.tr.replaceSelectionWith(s,t.input.shiftKey):t.state.tr.replaceSelection(i);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Os.copy=Ms.cut=(t,e)=>{let n=e,r=t.state.selection,i="cut"==n.type;if(r.empty)return;let s=qs?null:n.clipboardData,o=r.content(),{dom:a,text:l}=ps(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Ms.paste=(t,e)=>{let n=e;if(t.composing&&!Gr)return;let r=qs?null:n.clipboardData;r&&Js(t,r.getData("text/plain"),r.getData("text/html"),n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Js(t,r.value,null,e):Js(t,r.textContent,r.innerHTML,e)}),50)}(t,n)};class Us{constructor(t,e){this.slice=t,this.move=e}}const Gs=Ur?"altKey":"ctrlKey";Os.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords($s(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof or?i.to-1:i.to));else if(r&&r.mightDrag)t.dispatch(t.state.tr.setSelection(or.create(t.state.doc,r.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&t.dispatch(t.state.tr.setSelection(or.create(t.state.doc,e.posBefore)))}let o=t.state.selection.content(),{dom:a,text:l}=ps(t,o);n.dataTransfer.clearData(),n.dataTransfer.setData(qs?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",qs||n.dataTransfer.setData("text/plain",l),t.dragging=new Us(o,!n[Gs])},Os.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},Ms.dragover=Ms.dragenter=(t,e)=>e.preventDefault(),Ms.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords($s(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",(t=>{o=t(o)})):o=fs(t,n.dataTransfer.getData(qs?"Text":"text/plain"),qs?null:n.dataTransfer.getData("text/html"),!1,s);let a=!(!r||n[Gs]);if(t.someProp("handleDrop",(e=>e(t,n,o||ge.empty,a))))return void n.preventDefault();if(!o)return;n.preventDefault();let l=o?Ln(t.state.doc,s.pos,o):s.pos;null==l&&(l=s.pos);let c=t.state.tr;a&&c.deleteSelection();let h=c.mapping.map(l),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=c.doc;if(d?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(u))return;let p=c.doc.resolve(h);if(d&&or.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new or(p));else{let e=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((t,n,r,i)=>e=i)),c.setSelection(Yi(t,p,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},Os.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Ki(t)}),20))},Os.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},Os.beforeinput=(t,e)=>{if(Wr&&Gr&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,Ir(8,"Backspace")))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let t in Ms)Os[t]=Ms[t];function Ys(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Xs{constructor(t,e){this.toDOM=t,this.spec=e||no,this.side=this.spec.side||0}map(t,e,n,r){let{pos:i,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new to(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof Xs&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ys(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Zs{constructor(t,e){this.attrs=t,this.spec=e||no}map(t,e,n,r){let i=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new to(i,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Zs&&Ys(this.attrs,t.attrs)&&Ys(this.spec,t.spec)}static is(t){return t.type instanceof Zs}destroy(){}}class Qs{constructor(t,e){this.attrs=t,this.spec=e||no}map(t,e,n,r){let i=t.mapResult(e.from+r,1);if(i.deleted)return null;let s=t.mapResult(e.to+r,-1);return s.deleted||s.pos<=i.pos?null:new to(i.pos-n,s.pos-n,this)}valid(t,e){let n,{index:r,offset:i}=t.content.findIndex(e.from);return i==e.from&&!(n=t.child(r)).isText&&i+n.nodeSize==e.to}eq(t){return this==t||t instanceof Qs&&Ys(this.attrs,t.attrs)&&Ys(this.spec,t.spec)}destroy(){}}class to{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new to(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new to(t,t,new Xs(e,n))}static inline(t,e,n,r){return new to(t,e,new Zs(n,r))}static node(t,e,n,r){return new to(t,e,new Qs(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Zs}}const eo=[],no={};class ro{constructor(t,e){this.local=t.length?t:eo,this.children=e.length?e:eo}static create(t,e){return e.length?co(e,t,0,no):io}find(t,e,n){let r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r}findInner(t,e,n,r,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=e&&o.to>=t&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,n,r+o,i)}}map(t,e,n){return this==io||0==t.maps.length?this:this.mapInner(t,e,0,0,n||no)}mapInner(t,e,n,r,i){let s;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(t,n,r);a&&a.type.valid(e,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?function(t,e,n,r,i,s,o){let a=t.slice();for(let t=0,e=s;t<n.maps.length;t++){let r=0;n.maps[t].forEach(((t,n,s,o)=>{let l=o-s-(n-t);for(let o=0;o<a.length;o+=3){let c=a[o+1];if(c<0||t>c+e-r)continue;let h=a[o]+e-r;n>=h?a[o+1]=t<=h?-2:-1:s>=i&&l&&(a[o]+=l,a[o+1]+=l)}r+=l})),e=n.maps[t].map(e,-1)}let l=!1;for(let e=0;e<a.length;e+=3)if(a[e+1]<0){if(-2==a[e+1]){l=!0,a[e+1]=-1;continue}let c=n.map(t[e]+s),h=c-i;if(h<0||h>=r.content.size){l=!0;continue}let d=n.map(t[e+1]+s,-1)-i,{index:u,offset:p}=r.content.findIndex(h),f=r.maybeChild(u);if(f&&p==h&&p+f.nodeSize==d){let r=a[e+2].mapInner(n,f,c+1,t[e]+s+1,o);r!=io?(a[e]=h,a[e+1]=d,a[e+2]=r):(a[e+1]=-2,l=!0)}else l=!0}if(l){let l=function(t,e,n,r,i,s,o){function a(t,e){for(let s=0;s<t.local.length;s++){let a=t.local[s].map(r,i,e);a?n.push(a):o.onRemove&&o.onRemove(t.local[s].spec)}for(let n=0;n<t.children.length;n+=3)a(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&a(t[n+2],e[n]+s+1);return n}(a,t,e,n,i,s,o),c=co(l,r,0,o);e=c.local;for(let t=0;t<a.length;t+=3)a[t+1]<0&&(a.splice(t,3),t-=3);for(let t=0,e=0;t<c.children.length;t+=3){let n=c.children[t];for(;e<a.length&&a[e]<n;)e+=3;a.splice(e,0,c.children[t],c.children[t+1],c.children[t+2])}}return new ro(e.sort(ho),a)}(this.children,s||[],t,e,n,r,i):s?new ro(s.sort(ho),eo):io}add(t,e){return e.length?this==io?ro.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let r,i=0;t.forEach(((t,s)=>{let o,a=s+n;if(o=ao(e,t,a)){for(r||(r=this.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,o,a+1):r.splice(i,0,s,s+t.nodeSize,co(o,t,a+1,no)),i+=3}}));let s=oo(i?lo(e):e,-n);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||s.splice(e--,1);return new ro(s.length?this.local.concat(s).sort(ho):this.local,r||this.children)}remove(t){return 0==t.length||this==io?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,s=n[r]+e,o=n[r+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>s&&e.to<o&&(t[n]=null,(i||(i=[])).push(e));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,s+1);a!=io?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,i=0;i<t.length;i++)if(n=t[i])for(let t=0;t<r.length;t++)r[t].eq(n,e)&&(r==this.local&&(r=this.local.slice()),r.splice(t--,1));return n==this.children&&r==this.local?this:r.length||n.length?new ro(r,n):io}forChild(t,e){if(this==io)return this;if(e.isLeaf)return ro.empty;let n,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let i=t+1,s=i+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>i&&e.type instanceof Zs){let t=Math.max(i,e.from)-i,n=Math.min(s,e.to)-i;t<n&&(r||(r=[])).push(e.copy(t,n))}}if(r){let t=new ro(r.sort(ho),eo);return n?new so([t,n]):t}return n||io}eq(t){if(this==t)return!0;if(!(t instanceof ro)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return uo(this.localsInner(t))}localsInner(t){if(this==io)return eo;if(t.inlineContent||!this.local.some(Zs.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof Zs||e.push(this.local[t]);return e}}ro.empty=new ro([],[]),ro.removeOverlap=uo;const io=ro.empty;class so{constructor(t){this.members=t}map(t,e){const n=this.members.map((n=>n.map(t,e,no)));return so.from(n)}forChild(t,e){if(e.isLeaf)return ro.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(t,e);i!=io&&(i instanceof so?n=n.concat(i.members):n.push(i))}return so.from(n)}eq(t){if(!(t instanceof so)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(t);if(i.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<i.length;t++)e.push(i[t])}else e=i}return e?uo(n?e:e.sort(ho)):eo}static from(t){switch(t.length){case 0:return io;case 1:return t[0];default:return new so(t)}}}function oo(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new to(i.from+e,i.to+e,i.type))}return n}function ao(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let e,s=0;s<t.length;s++)(e=t[s])&&e.from>n&&e.to<r&&((i||(i=[])).push(e),t[s]=null);return i}function lo(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function co(t,e,n,r){let i=[],s=!1;e.forEach(((e,o)=>{let a=ao(t,e,o+n);if(a){s=!0;let t=co(a,e,n+o+1,r);t!=io&&i.push(o,o+e.nodeSize,t)}}));let o=oo(s?lo(t):t,-n).sort(ho);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||(r.onRemove&&r.onRemove(o[t].spec),o.splice(t--,1));return o.length||i.length?new ro(o,i):io}function ho(t,e){return t.from-e.from||t.to-e.to}function uo(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from!=r.from){s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),po(e,i,r.copy(s.from,r.to)));break}s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),po(e,i+1,s.copy(r.to,s.to)))}}return e}function po(t,e,n){for(;e<t.length&&ho(n,t[e])>0;)e++;t.splice(e,0,n)}function fo(t){let e=[];return t.someProp("decorations",(n=>{let r=n(t.state);r&&r!=io&&e.push(r)})),t.cursorWrapper&&e.push(ro.create(t.state.doc,[t.cursorWrapper.deco])),so.from(e)}const mo={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},go=zr&&jr<=11;class yo{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class vo{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yo,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);zr&&jr<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),go&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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,mo)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);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(Xi(this.view)){if(this.suppressingSelectionUpdates)return Ki(this.view);if(zr&&jr<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Er(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=Or(e))n.add(e);for(let r=t.anchorNode;r;r=Or(r))if(n.has(r)){e=r;break}let r=e&&this.view.docView.nearestDesc(e);return r&&r.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.observer?this.observer.takeRecords():[];this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);let n=t.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Xi(t)&&!this.ignoreSelectionChange(n),i=-1,s=-1,o=!1,a=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],a);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(o=!0))}if(_r&&a.length>1){let t=a.filter((t=>"BR"==t.nodeName));if(2==t.length){let e=t[0],n=t[1];e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}}let l=null;i<0&&r&&t.input.lastFocus>Date.now()-200&&t.input.lastTouch<Date.now()-300&&$r(n)&&(l=ji(t))&&l.eq(tr.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Ki(t),this.currentSelection.set(n),t.scrollToSelection()):(i>-1||r)&&(i>-1&&(t.docView.markDirty(i,s),function(t){if(bo.has(t))return;if(bo.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)){if(t.requiresGeckoHackNode=_r,wo)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."),wo=!0}}(t)),this.handleDOMChange(i,s,o,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||Ki(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++)e.push(t.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let r=t.previousSibling,i=t.nextSibling;if(zr&&jr<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:s}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(r=n),(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)&&(i=s)}let s=r&&r.parentNode==t.target?Sr(r)+1:0,o=n.localPosFromDOM(t.target,s,-1),a=i&&i.parentNode==t.target?Sr(i):t.target.childNodes.length;return{from:o,to:n.localPosFromDOM(t.target,a,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}let bo=new WeakMap,wo=!1;function xo(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(qr&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||qr&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}function ko(t,e,n,r,i){if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=ji(t,e);if(n&&!t.state.selection.eq(n)){let r=t.state.tr.setSelection(n);"pointer"==e?r.setMeta("pointer",!0):"key"==e&&r.scrollIntoView(),t.dispatch(r)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let a,l,c=t.state.selection,h=function(t,e,n){let r,{node:i,fromOffset:s,toOffset:o,from:a,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),h=c.anchorNode;if(h&&t.dom.contains(1==h.nodeType?h:h.parentNode)&&(r=[{node:h,offset:c.anchorOffset}],$r(c)||r.push({node:c.focusNode,offset:c.focusOffset})),Wr&&8===t.input.lastKeyCode)for(let t=o;t>s;t--){let e=i.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){o=t;break}if(!n||n.size)break}let d=t.state.doc,u=t.someProp("domParser")||tn.fromSchema(t.state.schema),p=d.resolve(a),f=null,m=u.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:xo,context:p});if(r&&null!=r[0].pos){let t=r[0].pos,e=r[1]&&r[1].pos;null==e&&(e=t),f={anchor:t+a,head:e+a}}return{doc:m,sel:f,from:a,to:l}}(t,e,n),d=t.state.doc,u=d.slice(h.from,h.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(a=t.state.selection.to,l="end"):(a=t.state.selection.from,l="start"),t.input.lastKeyCode=null;let p=function(t,e,n,r,i){let s=t.findDiffStart(e,n);if(null==s)return null;let{a:o,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==i){r-=o+Math.max(0,s-Math.min(o,a))-s}if(o<s&&t.size<e.size){s-=r<=s&&r>=o?s-r:0,a=s+(a-o),o=s}else if(a<s){s-=r<=s&&r>=a?s-r:0,o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}(u.content,h.doc.content,h.from,a,l);if((Jr&&t.input.lastIOSEnter>Date.now()-225||Gr)&&i.some((t=>"DIV"==t.nodeName||"P"==t.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,Ir(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!p){if(!(r&&c instanceof ir&&!c.empty&&c.$head.sameParent(c.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let e=So(t,t.state.doc,h.sel);e&&!e.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(e))}return}p={start:c.from,endA:c.to,endB:c.to}}if(Wr&&t.cursorWrapper&&h.sel&&h.sel.anchor==t.cursorWrapper.deco.from&&h.sel.head==h.sel.anchor){let t=p.endB-p.start;h.sel={anchor:h.sel.anchor+t,head:h.sel.anchor+t}}t.input.domChangeCount++,t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ir&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),zr&&jr<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&"  "==h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)&&(p.start--,p.endA--,p.endB--);let f,m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=d.resolve(p.start),v=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Jr&&t.input.lastIOSEnter>Date.now()-225&&(!v||i.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!v&&m.pos<h.doc.content.size&&(f=tr.findFrom(h.doc.resolve(m.pos+1),1,!0))&&f.head==g.pos)&&t.someProp("handleKeyDown",(e=>e(t,Ir(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>p.start&&function(t,e,n,r,i){if(!r.parent.isTextblock||n-e<=i.pos-r.pos||Oo(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Oo(s,!0,!0));return!(!o.parent.isTextblock||o.pos>n||Oo(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(d,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",(e=>e(t,Ir(8,"Backspace")))))return void(Gr&&Wr&&t.domObserver.suppressSelectionUpdates());Wr&&Gr&&p.endB==p.start&&(t.input.lastAndroidDelete=Date.now()),Gr&&!v&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Ir(13,"Enter"))}))}),20));let b,w,x,k=p.start,S=p.endA;if(v)if(m.pos==g.pos)zr&&jr<=11&&0==m.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>Ki(t)),20)),b=t.state.tr.delete(k,S),w=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(x=function(t,e){let n,r,i,s=t.firstChild.marks,o=e.firstChild.marks,a=s,l=o;for(let t=0;t<o.length;t++)a=o[t].removeFromSet(a);for(let t=0;t<s.length;t++)l=s[t].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",i=t=>t.mark(r.addToSet(t.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",i=t=>t.mark(r.removeFromSet(t.marks))}let c=[];for(let t=0;t<e.childCount;t++)c.push(i(e.child(t)));if(he.from(c).eq(t))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))b=t.state.tr,"add"==x.type?b.addMark(k,S,x.mark):b.removeMark(k,S,x.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,g.parentOffset);if(t.someProp("handleTextInput",(n=>n(t,k,S,e))))return;b=t.state.tr.insertText(e,k,S)}if(b||(b=t.state.tr.replace(k,S,h.doc.slice(p.start-h.from,p.endB-h.from))),h.sel){let e=So(t,b.doc,h.sel);e&&!(Wr&&Gr&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastAndroidDelete<Date.now()-100)&&(e.head==k||e.head==b.mapping.map(S)-1)||zr&&e.empty&&e.head==k)&&b.setSelection(e)}w&&b.ensureMarks(w),t.dispatch(b.scrollIntoView())}function So(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Yi(t,e.resolve(n.anchor),e.resolve(n.head))}function Oo(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let e=t.node(r).maybeChild(t.indexAfter(r));for(;e&&!e.isLeaf;)e=e.firstChild,i++}return i}class Mo{constructor(t,e){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 Es,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(No),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Co(this),Eo(this),this.nodeViews=To(this),this.docView=Mi(this.state.doc,Ao(this),fo(this),this.dom,this),this.domObserver=new vo(this,((t,e,n,r)=>ko(this,t,e,n,r))),this.domObserver.start(),function(t){for(let e in Os){let n=Os[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Ds(t,e)||Ns(t,e)||!t.editable&&e.type in Ms||n(t,e)},As[e]?{passive:!0}:void 0)}qr&&t.dom.addEventListener("input",(()=>null)),Ts(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Ts(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(No),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){let n=this.state,r=!1,i=!1;t.storedMarks&&this.composing&&(Ws(this),i=!0),this.state=t;let s=n.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=To(this);(function(t,e){let n=0,r=0;for(let r in t){if(t[r]!=e[r])return!0;n++}for(let t in e)r++;return n!=r})(t,this.nodeViews)&&(this.nodeViews=t,r=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&Ts(this),this.editable=Co(this),Eo(this);let o=fo(this),a=Ao(this),l=n.plugins==t.plugins||n.doc.eq(t.doc)?t.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=r||!this.docView.matchesNode(t.doc,a,o);!c&&t.selection.eq(n.selection)||(i=!0);let h="preserve"==l&&i&&null==this.dom.style.overflowAnchor&&function(t){let e,n,r=t.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let s=(r.left+r.right)/2,o=i+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=t.root.elementFromPoint(s,o);if(!r||r==t.dom||!t.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){e=r,n=a.top;break}}return{refDOM:e,refTop:n,stack:ni(t.dom)}}(this);if(i){this.domObserver.stop();let e=c&&(zr||Wr)&&!this.composing&&!n.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(n.selection,t.selection);if(c){let n=Wr?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(t.doc,a,o,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Mi(t.doc,a,o,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Er(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?Ki(this,e):(Ui(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():h&&function({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;ri(n,0==r?0:r-e)}(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof or){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&ei(this,e.getBoundingClientRect(),t)}else ei(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}someProp(t,e){let n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[t];if(null!=i&&(n=e?e(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let s=i[r].props[t];if(null!=s&&(n=e?e(s):s))return n}}hasFocus(){if(zr){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(ii)return t.focus(ii);let e=ni(t);t.focus(null==ii?{get preventScroll(){return ii={preventScroll:!0},!0}}:void 0),ii||(ii=!1,ri(e,0))}(this.dom),Ki(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}posAtCoords(t){return li(this,t)}coordsAtPos(t,e=1){return di(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return bi(this,e||this.state,t)}destroy(){this.docView&&(!function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],fo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Ns(t,e)||!Os[e.type]||!t.editable&&e.type in Ms||Os[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){return qr&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom?function(t){let e;function n(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",n,!0);let r=e.startContainer,i=e.startOffset,s=e.endContainer,o=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return Er(a.node,a.offset,s,o)&&([r,i,s,o]=[s,o,r,i]),{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:o}}(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function Ao(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),e.translate="no",t.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t&&(e.class+=" "+n[t]),"style"==t?e.style=(e.style?e.style+";":"")+n[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(n[t]))})),[to.node(0,t.state.doc.content.size,e)]}function Eo(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:to.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Co(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function To(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function No(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Do={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:"'"},$o={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Io="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent);"undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent);for(var Ro="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Bo="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Fo=Ro||Io&&+Io[1]<57,Po=0;Po<10;Po++)Do[48+Po]=Do[96+Po]=String(Po);for(Po=1;Po<=24;Po++)Do[Po+111]="F"+Po;for(Po=65;Po<=90;Po++)Do[Po]=String.fromCharCode(Po+32),$o[Po]=String.fromCharCode(Po);for(var Vo in Do)$o.hasOwnProperty(Vo)||($o[Vo]=Do[Vo]);const Lo="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function zo(t){let e,n,r,i,s=t.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let t=0;t<s.length-1;t++){let o=s[t];if(/^(cmd|meta|m)$/i.test(o))i=!0;else if(/^a(lt)?$/i.test(o))e=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);Lo?i=!0:n=!0}}return e&&(o="Alt-"+o),n&&(o="Ctrl-"+o),i&&(o="Meta-"+o),r&&(o="Shift-"+o),o}function jo(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}function _o(t){let e=function(t){let e=Object.create(null);for(let n in t)e[zo(n)]=t[n];return e}(t);return function(t,n){let r,i=function(t){var e=!(Fo&&(t.ctrlKey||t.altKey||t.metaKey)||Bo&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?$o:Do)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),s=1==i.length&&" "!=i,o=e[jo(i,n,!s)];if(o&&o(t.state,t.dispatch,t))return!0;if(s&&(n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(r=Do[n.keyCode])&&r!=i){let i=e[jo(r,n,!0)];if(i&&i(t.state,t.dispatch,t))return!0}else if(s&&n.shiftKey){let r=e[jo(i,n,!0)];if(r&&r(t.state,t.dispatch,t))return!0}return!1}}function Ko(t,e,n=!1){for(let r=t;r;r="start"==e?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function Wo(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Ho(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}function qo(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Jo(t,e,n){let r,i,s=e.nodeBefore,o=e.nodeAfter;if(s.type.spec.isolating||o.type.spec.isolating)return!1;if(function(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(s,s+1)||!i.isTextblock&&!Fn(t.doc,e.pos)||(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let a=e.parent.canReplace(e.index(),e.index()+1);if(a&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&i.matchType(r[0]||o.type).validEnd){if(n){let i=e.pos+o.nodeSize,a=he.empty;for(let t=r.length-1;t>=0;t--)a=he.from(r[t].create(null,a));a=he.from(s.copy(a));let l=t.tr.step(new Tn(e.pos-1,i,e.pos,i,new ge(a,1,0),r.length,!0)),c=i+2*r.length;Fn(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=tr.findFrom(e,1),c=l&&l.$from.blockRange(l.$to),h=c&&$n(c);if(null!=h&&h>=e.depth)return n&&n(t.tr.lift(c,h).scrollIntoView()),!0;if(a&&Ko(o,"start",!0)&&Ko(s,"end")){let r=s,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let a=o,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,a.content)){if(n){let r=he.empty;for(let t=i.length-1;t>=0;t--)r=he.from(i[t].copy(r));n(t.tr.step(new Tn(e.pos-i.length,e.pos+o.nodeSize,e.pos+l,e.pos+o.nodeSize-l,new ge(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Uo(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return!!i.node(s).isTextblock&&(n&&n(e.tr.setSelection(ir.create(e.doc,t<0?i.start(s):i.end(s)))),!0)}}const Go=Uo(-1),Yo=Uo(1);function Xo(t,e=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(s,o,((r,s)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(t,e))if(r.type==t)i=!0;else{let e=n.doc.resolve(s),r=e.index();i=e.parent.canReplaceWith(r,r+1,t)}}))}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(s,o,t,e)}r(i.scrollIntoView())}return!0}}function Zo(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=!1,l=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(t)&&0==o.startIndex){if(0==i.index(o.depth-1))return!1;let t=n.doc.resolve(o.start-2);l=new $e(t,t,o.depth),o.endIndex<o.parent.childCount&&(o=new $e(i,n.doc.resolve(s.end(o.depth)),o.depth)),a=!0}let c=In(l,t,e,o);return!!c&&(r&&r(function(t,e,n,r,i){let s=he.empty;for(let t=n.length-1;t>=0;t--)s=he.from(n[t].type.create(n[t].attrs,s));t.step(new Tn(e.start-(r?2:0),e.end,e.start,e.end,new ge(s,0,0),n.length,!0));let o=0;for(let t=0;t<n.length;t++)n[t].type==i&&(o=t+1);let a=n.length-o,l=e.start+n.length-(r?2:0),c=e.parent;for(let n=e.startIndex,r=e.endIndex,i=!0;n<r;n++,i=!1)!i&&Bn(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return t}(n.tr,o,c,a,t).scrollIntoView()),!0)}}function Qo(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));return!!s&&(!n||(r.node(s.depth-1).type==t?function(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Tn(s-1,o,s,o,new ge(he.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new $e(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const a=$n(r);if(null==a)return!1;i.lift(r,a);let l=i.mapping.map(s,-1)-1;Fn(i.doc,l)&&i.join(l);return e(i.scrollIntoView()),!0}(e,n,t,s):function(t,e,n){let r=t.tr,i=n.parent;for(let t=n.end,e=n.endIndex-1,s=n.startIndex;e>s;e--)t-=i.child(e).nodeSize,r.delete(t-1,t+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=s.node(-1),h=s.index(-1);if(!c.canReplace(h+(a?0:1),h+1,o.content.append(l?he.empty:he.from(i))))return!1;let d=s.pos,u=d+o.nodeSize;return r.step(new Tn(d-(a?1:0),u+(l?1:0),d+1,u-1,new ge((a?he.empty:he.from(i.copy(he.empty))).append(l?he.empty:he.from(i.copy(he.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}(e,n,s)))}}function ta(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),filterTransaction:e.filterTransaction,plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class ea{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(...t)=>{const n=e(...t)(s);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],a=!!t,l=t||i.tr,c={...Object.fromEntries(Object.entries(n).map((([t,n])=>[t,(...t)=>{const r=this.buildProps(l,e),i=n(...t)(r);return o.push(i),c}]))),run:()=>(a||!e||l.getMeta("preventDispatch")||this.hasCustomState||s.dispatch(l),o.every((t=>!0===t)))};return c}createCan(t){const{rawCommands:e,state:n}=this,r=t||n.tr,i=this.buildProps(r,false),s=Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...i,dispatch:void 0})])));return{...s,chain:()=>this.createChain(r,false)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r;i.storedMarks&&t.setStoredMarks(i.storedMarks);const o={tr:t,editor:r,view:s,state:ta({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map((([t,e])=>[t,(...t)=>e(...t)(o)])))}};return o}}function na(t,e,n){if(void 0===t.config[e]&&t.parent)return na(t.parent,e,n);if("function"==typeof t.config[e]){return t.config[e].bind({...n,parent:t.parent?na(t.parent,e,n):null})}return t.config[e]}function ra(t){return{baseExtensions:t.filter((t=>"extension"===t.type)),nodeExtensions:t.filter((t=>"node"===t.type)),markExtensions:t.filter((t=>"mark"===t.type))}}function ia(t){const e=[],{nodeExtensions:n,markExtensions:r}=ra(t),i=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach((t=>{const n=na(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage});if(!n)return;n().forEach((t=>{t.types.forEach((n=>{Object.entries(t.attributes).forEach((([t,r])=>{e.push({type:n,name:t,attribute:{...s,...r}})}))}))}))})),i.forEach((t=>{const n={name:t.name,options:t.options,storage:t.storage},r=na(t,"addAttributes",n);if(!r)return;const i=r();Object.entries(i).forEach((([n,r])=>{const i={...s,...r};"function"==typeof(null==i?void 0:i.default)&&(i.default=i.default()),(null==i?void 0:i.isRequired)&&void 0===(null==i?void 0:i.default)&&delete i.default,e.push({type:t.name,name:n,attribute:i})}))})),e}function sa(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function oa(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};return Object.entries(e).forEach((([t,e])=>{n[t]?n[t]="class"===t?[n[t],e].join(" "):"style"===t?[n[t],e].join("; "):e:n[t]=e})),n}),{})}function aa(t,e){return e.filter((t=>t.attribute.rendered)).map((e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]})).reduce(((t,e)=>oa(t,e)),{})}function la(t){return"function"==typeof t}function ca(t,e,...n){return la(t)?e?t.bind(e)(...n):t(...n):t}function ha(t,e){return t.style?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===r)return!1;const i=e.reduce(((t,e)=>{const r=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==r?t:{...t,[e.name]:r}}),{});return{...r,...i}}}}function da(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e)))}function ua(t,e){return e.nodes[t]||e.marks[t]||null}function pa(t,e){return Array.isArray(e)?e.some((e=>("string"==typeof e?e:e.name)===t.name)):e}function fa(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function ma(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null===(e=c.nodeBefore||c.nodeAfter)||void 0===e?void 0:e.marks.find((t=>t.type.spec.code))))return!1;let h=!1;const d=((t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,((t,e,i,s)=>{var o,a;const l=(null===(a=(o=t.type.spec).toText)||void 0===a?void 0:a.call(o,{node:t,pos:e,parent:i,index:s}))||t.textContent||"%leaf%";n+=l.slice(0,Math.max(0,r-e))})),n})(c)+s;return o.forEach((t=>{if(h)return;const e=((t,e)=>{if(fa(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(d,t.find);if(!e)return;const o=l.state.tr,c=ta({state:l.state,transaction:o}),u={from:r-(e[0].length-s.length),to:i},{commands:p,chain:f,can:m}=new ea({editor:n,state:c});null!==t.handler({state:c,range:u,match:e,commands:p,chain:f,can:m})&&o.steps.length&&(o.setMeta(a,{transform:o,from:r,to:i,text:s}),l.dispatch(o),h=!0)})),h}function ga(t){const{editor:e,rules:n}=t,r=new br({state:{init:()=>null,apply(t,e){const n=t.getMeta(r);return n||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:(t,i,s,o)=>ma({editor:e,from:i,to:s,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:t=>(setTimeout((()=>{const{$cursor:i}=t.state.selection;i&&ma({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(t,i){if("Enter"!==i.key)return!1;const{$cursor:s}=t.state.selection;return!!s&&ma({editor:e,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function ya(t){const{editor:e,state:n,from:r,to:i,rule:s}=t,{commands:o,chain:a,can:l}=new ea({editor:e,state:n}),c=[];n.doc.nodesBetween(r,i,((t,e)=>{if(!t.isTextblock||t.type.spec.code)return;const h=Math.max(r,e),d=Math.min(i,e+t.content.size);((t,e)=>{if(fa(e))return[...t.matchAll(e)];const n=e(t);return n?n.map((e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n})):[]})(t.textBetween(h-e,d-e,void 0,""),s.find).forEach((t=>{if(void 0===t.index)return;const e=h+t.index+1,r=e+t[0].length,i={from:n.tr.mapping.map(e),to:n.tr.mapping.map(r)},d=s.handler({state:n,range:i,match:t,commands:o,chain:a,can:l});c.push(d)}))}));return c.every((t=>null!==t))}function va(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1;return n.map((t=>new br({view(t){const e=e=>{var n;r=(null===(n=t.dom.parentElement)||void 0===n?void 0:n.contains(e.target))?t.dom.parentElement:null};return window.addEventListener("dragstart",e),{destroy(){window.removeEventListener("dragstart",e)}}},props:{handleDOMEvents:{drop:t=>(s=r===t.dom.parentElement,!1),paste:(t,e)=>{var n;const r=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/html");return i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(n,r,o)=>{const a=n[0],l="paste"===a.getMeta("uiEvent")&&!i,c="drop"===a.getMeta("uiEvent")&&!s;if(!l&&!c)return;const h=r.doc.content.findDiffStart(o.doc.content),d=r.doc.content.findDiffEnd(o.doc.content);if("number"!=typeof h||!d||h===d.b)return;const u=o.tr,p=ta({state:o,transaction:u});return ya({editor:e,state:p,from:Math.max(h-1,0),to:d.b-1,rule:t})&&u.steps.length?u:void 0}})))}class ba{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=ba.resolve(t),this.schema=function(t,e){var n;const r=ia(t),{nodeExtensions:i,markExtensions:s}=ra(t),o=null===(n=i.find((t=>na(t,"topNode"))))||void 0===n?void 0:n.name,a=Object.fromEntries(i.map((n=>{const i=r.filter((t=>t.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:e},o=t.reduce(((t,e)=>{const r=na(e,"extendNodeSchema",s);return{...t,...r?r(n):{}}}),{}),a=da({...o,content:ca(na(n,"content",s)),marks:ca(na(n,"marks",s)),group:ca(na(n,"group",s)),inline:ca(na(n,"inline",s)),atom:ca(na(n,"atom",s)),selectable:ca(na(n,"selectable",s)),draggable:ca(na(n,"draggable",s)),code:ca(na(n,"code",s)),defining:ca(na(n,"defining",s)),isolating:ca(na(n,"isolating",s)),attrs:Object.fromEntries(i.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=ca(na(n,"parseHTML",s));l&&(a.parseDOM=l.map((t=>ha(t,i))));const c=na(n,"renderHTML",s);c&&(a.toDOM=t=>c({node:t,HTMLAttributes:aa(t,i)}));const h=na(n,"renderText",s);return h&&(a.toText=h),[n.name,a]}))),l=Object.fromEntries(s.map((n=>{const i=r.filter((t=>t.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:e},o=t.reduce(((t,e)=>{const r=na(e,"extendMarkSchema",s);return{...t,...r?r(n):{}}}),{}),a=da({...o,inclusive:ca(na(n,"inclusive",s)),excludes:ca(na(n,"excludes",s)),group:ca(na(n,"group",s)),spanning:ca(na(n,"spanning",s)),code:ca(na(n,"code",s)),attrs:Object.fromEntries(i.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=ca(na(n,"parseHTML",s));l&&(a.parseDOM=l.map((t=>ha(t,i))));const c=na(n,"renderHTML",s);return c&&(a.toDOM=t=>c({mark:t,HTMLAttributes:aa(t,i)})),[n.name,a]})));return new Ze({topNode:o,nodes:a,marks:l})}(this.extensions,e),this.extensions.forEach((t=>{var e;this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:ua(t.name,this.schema)};if("mark"===t.type){(null===(e=ca(na(t,"keepOnSplit",n)))||void 0===e||e)&&this.splittableMarks.push(t.name)}const r=na(t,"onBeforeCreate",n);r&&this.editor.on("beforeCreate",r);const i=na(t,"onCreate",n);i&&this.editor.on("create",i);const s=na(t,"onUpdate",n);s&&this.editor.on("update",s);const o=na(t,"onSelectionUpdate",n);o&&this.editor.on("selectionUpdate",o);const a=na(t,"onTransaction",n);a&&this.editor.on("transaction",a);const l=na(t,"onFocus",n);l&&this.editor.on("focus",l);const c=na(t,"onBlur",n);c&&this.editor.on("blur",c);const h=na(t,"onDestroy",n);h&&this.editor.on("destroy",h)}))}static resolve(t){const e=ba.sort(ba.flatten(t)),n=function(t){const e=t.filter(((e,n)=>t.indexOf(e)!==n));return[...new Set(e)]}(e.map((t=>t.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`),e}static flatten(t){return t.map((t=>{const e=na(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...this.flatten(e())]:t})).flat(10)}static sort(t){return t.sort(((t,e)=>{const n=na(t,"priority")||100,r=na(e,"priority")||100;return n>r?-1:n<r?1:0}))}get commands(){return this.extensions.reduce(((t,e)=>{const n=na(e,"addCommands",{name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:ua(e.name,this.schema)});return n?{...t,...n()}:t}),{})}get plugins(){const{editor:t}=this,e=ba.sort([...this.extensions].reverse()),n=[],r=[],i=e.map((e=>{const i={name:e.name,options:e.options,storage:e.storage,editor:t,type:ua(e.name,this.schema)},s=[],o=na(e,"addKeyboardShortcuts",i);let a={};if("mark"===e.type&&e.config.exitable&&(a.ArrowRight=()=>sl.handleExit({editor:t,mark:e})),o){const e=Object.fromEntries(Object.entries(o()).map((([e,n])=>[e,()=>n({editor:t})])));a={...a,...e}}const l=new br({props:{handleKeyDown:_o(a)}});s.push(l);const c=na(e,"addInputRules",i);pa(e,t.options.enableInputRules)&&c&&n.push(...c());const h=na(e,"addPasteRules",i);pa(e,t.options.enablePasteRules)&&h&&r.push(...h());const d=na(e,"addProseMirrorPlugins",i);if(d){const t=d();s.push(...t)}return s})).flat();return[ga({editor:t,rules:n}),...va({editor:t,rules:r}),...i]}get attributes(){return ia(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ra(this.extensions);return Object.fromEntries(e.filter((t=>!!na(t,"addNodeView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name)),r={name:e.name,options:e.options,storage:e.storage,editor:t,type:sa(e.name,this.schema)},i=na(e,"addNodeView",r);if(!i)return[];return[e.name,(r,s,o,a)=>{const l=aa(r,n);return i()({editor:t,node:r,getPos:o,decorations:a,HTMLAttributes:l,extension:e})}]})))}}function wa(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&(t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype)}function xa(t,e){const n={...t};return wa(t)&&wa(e)&&Object.keys(e).forEach((r=>{wa(e[r])?r in t?n[r]=xa(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})})),n}class ka{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ca(na(this,"addOptions",{name:this.name}))),this.storage=ca(na(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ka(t)}configure(t={}){const e=this.extend();return e.options=xa(this.options,t),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}extend(t={}){const e=new ka(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=ca(na(e,"addOptions",{name:e.name})),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}}function Sa(t,e,n){const{from:r,to:i}=e,{blockSeparator:s="\n\n",textSerializers:o={}}=n||{};let a="",l=!0;return t.nodesBetween(r,i,((t,n,c,h)=>{var d;const u=null==o?void 0:o[t.type.name];u?(t.isBlock&&!l&&(a+=s,l=!0),c&&(a+=u({node:t,pos:n,parent:c,index:h,range:e}))):t.isText?(a+=null===(d=null==t?void 0:t.text)||void 0===d?void 0:d.slice(Math.max(r,n)-n,i-n),l=!1):t.isBlock&&!l&&(a+=s,l=!0)})),a}function Oa(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}const Ma=ka.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new br({key:new kr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map((t=>t.$from.pos))),a=Math.max(...s.map((t=>t.$to.pos)));return Sa(r,{from:o,to:a},{textSerializers:Oa(n)})}}})]}});function Aa(t,e,n={strict:!0}){const r=Object.keys(e);return!r.length||r.every((r=>n.strict?e[r]===t[r]:fa(e[r])?e[r].test(t[r]):e[r]===t[r]))}function Ea(t,e,n={}){return t.find((t=>t.type===e&&Aa(t.attrs,n)))}function Ca(t,e,n={}){return!!Ea(t,e,n)}function Ta(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&0!==r.offset&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const i=Ea([...r.node.marks],e,n);if(!i)return;let s=r.index,o=t.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(Ea([...r.node.marks],e,n);s>0&&i.isInSet(t.parent.child(s-1).marks);)s-=1,o-=t.parent.child(s).nodeSize;for(;a<t.parent.childCount&&Ca([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function Na(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function Da(t){return t instanceof ir}function $a(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ia(t,e=null){if(!e)return null;const n=tr.atStart(t),r=tr.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return r;const i=n.from,s=r.to;return"all"===e?ir.create(t,$a(0,i,s),$a(t.content.size,i,s)):ir.create(t,$a(e,i,s),$a(e,i,s))}function Ra(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Ba(t){const e=`<body>${t}</body>`;return(new window.DOMParser).parseFromString(e,"text/html").body}function Fa(t,e,n){if(n={slice:!0,parseOptions:{},...n},"object"==typeof t&&null!==t)try{return Array.isArray(t)&&t.length>0?he.fromArray(t.map((t=>e.nodeFromJSON(t)))):e.nodeFromJSON(t)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),Fa("",e,n)}if("string"==typeof t){const r=tn.fromSchema(e);return n.slice?r.parseSlice(Ba(t),n.parseOptions).content:r.parse(Ba(t),n.parseOptions)}return Fa("",e,n)}function Pa(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function Va(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?sa(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,((t,e)=>{if(t.isText)return;const n=Math.max(r,e),s=Math.min(i,e+t.nodeSize);a.push({node:t,from:n,to:s})}));const l=i-r,c=a.filter((t=>!o||o.name===t.node.type.name)).filter((t=>Aa(t.node.attrs,n,{strict:!1})));if(s)return!!c.length;return c.reduce(((t,e)=>t+e.to-e.from),0)>=l}function La(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function za(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce(((e,r)=>(n.includes(r)||(e[r]=t[r]),e)),{})}function ja(t,e,n={}){return Fa(t,e,{slice:!1,parseOptions:n})}function _a(t){return e=>function(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}(e.$from,t)}function Ka(t,e){const n=Na(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,(t=>{o.push(...t.marks)}));const a=o.find((t=>t.type.name===n.name));return a?{...a.attrs}:{}}function Wa(t,e){const n=La("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=sa(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,(t=>{s.push(t)}));const o=s.reverse().find((t=>t.type.name===n.name));return o?{...o.attrs}:{}}(t,e):"mark"===n?Ka(t,e):{}}function Ha(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=t.find((t=>t.type===e&&t.name===n));return!!r&&r.attribute.keepOnSplit})))}function qa(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Na(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>!s||s.name===t.type.name)).find((t=>Aa(t.attrs,n,{strict:!1})));let o=0;const a=[];if(i.forEach((({$from:e,$to:n})=>{const r=e.pos,i=n.pos;t.doc.nodesBetween(r,i,((t,e)=>{if(!t.isText&&!t.marks.length)return;const n=Math.max(r,e),s=Math.min(i,e+t.nodeSize);o+=s-n,a.push(...t.marks.map((t=>({mark:t,from:n,to:s}))))}))})),0===o)return!1;const l=a.filter((t=>!s||s.name===t.mark.type.name)).filter((t=>Aa(t.mark.attrs,n,{strict:!1}))).reduce(((t,e)=>t+e.to-e.from),0),c=a.filter((t=>!s||t.mark.type!==s&&t.mark.type.excludes(s))).reduce(((t,e)=>t+e.to-e.from),0);return(l>0?l+c:l)>=o}function Ja(t,e){const{nodeExtensions:n}=ra(e),r=n.find((e=>e.name===t));if(!r)return!1;const i=ca(na(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function Ua(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter((t=>null==e?void 0:e.includes(t.type.name)));t.tr.ensureMarks(r)}}const Ga=(t,e)=>{const n=_a((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=t.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!Fn(t.doc,n.pos)||(t.join(n.pos),!0)},Ya=(t,e)=>{const n=_a((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=t.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!Fn(t.doc,r)||(t.join(r),!0)};var Xa=Object.freeze({__proto__:null,blur:()=>({editor:t,view:e})=>(requestAnimationFrame((()=>{var n;t.isDestroyed||(e.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(t=!1)=>({commands:e})=>e.setContent("",t),clearNodes:()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return!n||(i.forEach((({$from:n,$to:r})=>{t.doc.nodesBetween(n.pos,r.pos,((t,n)=>{if(t.type.isText)return;const{doc:r,mapping:i}=e,s=r.resolve(i.map(n)),o=r.resolve(i.map(n+t.nodeSize)),a=s.blockRange(o);if(!a)return;const l=$n(a);if(t.type.isTextblock){const{defaultType:t}=s.parent.contentMatchAt(s.index());e.setNodeMarkup(a.start,t)}(l||0===l)&&e.lift(a,l)}))})),!0)},command:t=>e=>t(e),createParagraphNear:()=>({state:t,dispatch:e})=>((t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof lr||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=qo(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(n,s.createAndFill());o.setSelection(ir.create(o.doc,n+1)),e(o.scrollIntoView())}return!0})(t,e),deleteCurrentNode:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let n=i.depth;n>0;n-=1){if(i.node(n).type===r.type){if(e){const e=i.before(n),r=i.after(n);t.delete(e,r).scrollIntoView()}return!0}}return!1},deleteNode:t=>({tr:e,state:n,dispatch:r})=>{const i=sa(t,n.schema),s=e.selection.$anchor;for(let t=s.depth;t>0;t-=1){if(s.node(t).type===i){if(r){const n=s.before(t),r=s.after(t);e.delete(n,r).scrollIntoView()}return!0}}return!1},deleteRange:t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},deleteSelection:()=>({state:t,dispatch:e})=>((t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0))(t,e),enter:()=>({commands:t})=>t.keyboardShortcut("Enter"),exitCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=qo(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let r=n.after(),i=t.tr.replaceWith(r,r,o.createAndFill());i.setSelection(tr.near(i.doc.resolve(r),1)),e(i.scrollIntoView())}return!0})(t,e),extendMarkRange:(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Na(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:h}=a;if(i){const t=Ta(l,s,e);if(t&&t.from<=c&&t.to>=h){const e=ir.create(o,t.from,t.to);n.setSelection(e)}}return!0},first:t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1},focus:(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{Ra()&&r.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())}))};if(r.hasFocus()&&null===t||!1===t)return!0;if(s&&null===t&&!Da(n.state.selection))return o(),!0;const a=Ia(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},forEach:(t,e)=>n=>t.every(((t,r)=>e(t,{...n,index:r}))),insertContent:(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),insertContentAt:(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const i=Fa(e,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if("<>"===i.toString())return!0;let{from:o,to:a}="number"==typeof t?{from:t,to:t}:t,l=!0,c=!0;if((i.toString().startsWith("<")?i:[i]).forEach((t=>{t.check(),l=!!l&&(t.isText&&0===t.marks.length),c=!!c&&t.isBlock})),o===a&&c){const{parent:t}=r.doc.resolve(o);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(o-=1,a+=1)}l?Array.isArray(e)?r.insertText(e.map((t=>t.text||"")).join(""),o,a):"object"==typeof e&&e&&e.text?r.insertText(e.text,o,a):r.insertText(e,o,a):r.replaceWith(o,a,i),n.updateSelection&&function(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Cn||i instanceof Tn))return;const s=t.mapping.maps[r];let o=0;s.forEach(((t,e,n,r)=>{0===o&&(o=r)})),t.setSelection(tr.near(t.doc.resolve(o),n))}(r,r.steps.length-1,-1)}return!0},joinUp:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection,i=r instanceof or;if(i){if(r.node.isTextblock||!Fn(t.doc,r.from))return!1;n=r.from}else if(n=Vn(t.doc,r.from,-1),null==n)return!1;if(e){let r=t.tr.join(n);i&&r.setSelection(or.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(r.scrollIntoView())}return!0})(t,e),joinDown:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection;if(r instanceof or){if(r.node.isTextblock||!Fn(t.doc,r.to))return!1;n=r.to}else if(n=Vn(t.doc,r.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),joinBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=function(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}(t,n);if(!r)return!1;let i=Wo(r);if(!i){let n=r.blockRange(),i=n&&$n(n);return null!=i&&(e&&e(t.tr.lift(n,i).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&Jo(t,i,e))return!0;if(0==r.parent.content.size&&(Ko(s,"end")||or.isSelectable(s))){let n=zn(t.doc,r.before(),r.after(),ge.empty);if(n&&n.slice.size<n.to-n.from){if(e){let r=t.tr.step(n);r.setSelection(Ko(s,"end")?tr.findFrom(r.doc.resolve(r.mapping.map(i.pos,-1)),-1):or.create(r.doc,i.pos-s.nodeSize)),e(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),0))})(t,e),joinForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=function(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}(t,n);if(!r)return!1;let i=Ho(r);if(!i)return!1;let s=i.nodeAfter;if(Jo(t,i,e))return!0;if(0==r.parent.content.size&&(Ko(s,"start")||or.isSelectable(s))){let n=zn(t.doc,r.before(),r.after(),ge.empty);if(n&&n.slice.size<n.to-n.from){if(e){let r=t.tr.step(n);r.setSelection(Ko(s,"start")?tr.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):or.create(r.doc,r.mapping.map(i.pos))),e(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),0))})(t,e),keyboardShortcut:t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=function(t){const e=t.split(/-(?!$)/);let n,r,i,s,o=e[e.length-1];"Space"===o&&(o=" ");for(let t=0;t<e.length-1;t+=1){const o=e[t];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))n=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error(`Unrecognized modifier name: ${o}`);Ra()||Pa()?s=!0:r=!0}}return n&&(o=`Alt-${o}`),r&&(o=`Ctrl-${o}`),s&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o}(t).split(/-(?!$)/),o=s.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t))),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,a)))}));return null==l||l.steps.forEach((t=>{const e=t.map(r.mapping);e&&i&&r.maybeStep(e)})),!0},lift:(t,e={})=>({state:n,dispatch:r})=>!!Va(n,sa(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&$n(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)})(n,r),liftEmptyBlock:()=>({state:t,dispatch:e})=>((t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Bn(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&$n(r);return null!=i&&(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)})(t,e),liftListItem:t=>({state:e,dispatch:n})=>Qo(sa(t,e.schema))(e,n),newlineInCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))})(t,e),resetAttributes:(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=La("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(s=sa(t,r.schema)),"mark"===a&&(o=Na(t,r.schema)),i&&n.selection.ranges.forEach((t=>{r.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,r)=>{s&&s===t.type&&n.setNodeMarkup(r,void 0,za(t.attrs,e)),o&&t.marks.length&&t.marks.forEach((i=>{o===i.type&&n.addMark(r,r+t.nodeSize,o.create(za(i.attrs,e)))}))}))})),!0)},scrollIntoView:()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),selectAll:()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),selectNodeBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Wo(r)}let o=s&&s.nodeBefore;return!(!o||!or.isSelectable(o)||(e&&e(t.tr.setSelection(or.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),0))})(t,e),selectNodeForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Ho(r)}let o=s&&s.nodeAfter;return!(!o||!or.isSelectable(o)||(e&&e(t.tr.setSelection(or.create(t.doc,s.pos)).scrollIntoView()),0))})(t,e),selectParentNode:()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:r,to:i}=t.selection,s=r.sharedDepth(i);return 0!=s&&(n=r.before(s),e&&e(t.tr.setSelection(or.create(t.doc,n))),!0)})(t,e),selectTextblockEnd:()=>({state:t,dispatch:e})=>Yo(t,e),selectTextblockStart:()=>({state:t,dispatch:e})=>Go(t,e),setContent:(t,e=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,a=ja(t,i.schema,n);return s&&r.replaceWith(0,o.content.size,a).setMeta("preventUpdate",!e),!0},setMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:a}=s,l=Na(t,r.schema);if(i)if(o){const t=Ka(r,l);n.addStoredMark(l.create({...t,...e}))}else a.forEach((t=>{const i=t.$from.pos,s=t.$to.pos;r.doc.nodesBetween(i,s,((t,r)=>{const o=Math.max(r,i),a=Math.min(r+t.nodeSize,s);t.marks.find((t=>t.type===l))?t.marks.forEach((t=>{l===t.type&&n.addMark(o,a,l.create({...t.attrs,...e}))})):n.addMark(o,a,l.create(e))}))}));return function(t,e,n){var r;const{selection:i}=e;let s=null;if(Da(i)&&(s=i.$cursor),s){const e=null!==(r=t.storedMarks)&&void 0!==r?r:s.marks();return!!n.isInSet(e)||!e.some((t=>t.type.excludes(n)))}const{ranges:o}=i;return o.some((({$from:e,$to:r})=>{let i=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,r.pos,((t,e,r)=>{if(i)return!1;if(t.isInline){const e=!r||r.type.allowsMarkType(n),s=!!n.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(n)));i=e&&s}return!i})),i}))}(r,n,l)},setMeta:(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),setNode:(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=sa(t,n.schema);return s.isTextblock?i().command((({commands:t})=>!!Xo(s,e)(n)||t.clearNodes())).command((({state:t})=>Xo(s,e)(t,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,r=$a(t,0,n.content.size),i=or.create(n,r);e.setSelection(i)}return!0},setTextSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:r,to:i}="number"==typeof t?{from:t,to:t}:t,s=ir.atStart(n).from,o=ir.atEnd(n).to,a=$a(r,s,o),l=$a(i,s,o),c=ir.create(n,a,l);e.setSelection(c)}return!0},sinkListItem:t=>({state:e,dispatch:n})=>{const r=sa(t,e.schema);return(i=r,function(t,e){let{$from:n,$to:r}=t.selection,s=n.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==i));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=i)return!1;if(e){let n=l.lastChild&&l.lastChild.type==a.type,r=he.from(n?i.create():null),o=new ge(he.from(i.create(null,he.from(a.type.create(null,r)))),n?3:1,0),c=s.start,h=s.end;e(t.tr.step(new Tn(c-(n?3:1),h,c,h,o,1,!0)).scrollIntoView())}return!0})(e,n);var i},splitBlock:({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:a,$to:l}=s,c=Ha(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(s instanceof or&&s.node.isBlock)return!(!a.parentOffset||!Bn(o,a.pos))&&(r&&(t&&Ua(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){const r=l.parentOffset===l.parent.content.size;s instanceof ir&&e.deleteSelection();const o=0===a.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=r&&o?[{type:o,attrs:c}]:void 0,d=Bn(e.doc,e.mapping.map(a.pos),1,h);if(h||d||!Bn(e.doc,e.mapping.map(a.pos),1,o?[{type:o}]:void 0)||(d=!0,h=o?[{type:o,attrs:c}]:void 0),d&&(e.split(e.mapping.map(a.pos),1,h),o&&!r&&!a.parentOffset&&a.parent.type!==o)){const t=e.mapping.map(a.before()),n=e.doc.resolve(t);a.node(-1).canReplaceWith(n.index(),n.index()+1,o)&&e.setNodeMarkup(e.mapping.map(a.before()),o)}t&&Ua(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},splitListItem:t=>({tr:e,state:n,dispatch:r,editor:i})=>{var s;const o=sa(t,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const h=a.node(-1);if(h.type!==o)return!1;const d=i.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==o||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let t=he.empty;const n=a.index(-1)?1:a.index(-2)?2:3;for(let e=a.depth-n;e>=a.depth-3;e-=1)t=he.from(a.node(e).copy(t));const r=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,i=Ha(d,a.node().type.name,a.node().attrs),l=(null===(s=o.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;t=t.append(he.from(o.createAndFill(null,l)||void 0));const c=a.before(a.depth-(n-1));e.replace(c,a.after(-r),new ge(t,4-n,0));let h=-1;e.doc.nodesBetween(c,e.doc.content.size,((t,e)=>{if(h>-1)return!1;t.isTextblock&&0===t.content.size&&(h=e+1)})),h>-1&&e.setSelection(ir.near(e.doc.resolve(h))),e.scrollIntoView()}return!0}const u=l.pos===a.end()?h.contentMatchAt(0).defaultType:null,p=Ha(d,h.type.name,h.attrs),f=Ha(d,a.node().type.name,a.node().attrs);e.delete(a.pos,l.pos);const m=u?[{type:o,attrs:p},{type:u,attrs:f}]:[{type:o,attrs:p}];if(!Bn(e.doc,a.pos,2))return!1;if(r){const{selection:t,storedMarks:s}=n,{splittableMarks:o}=i.extensionManager,l=s||t.$to.parentOffset&&t.$from.marks();if(e.split(a.pos,2,m).scrollIntoView(),!l||!r)return!0;const c=l.filter((t=>o.includes(t.type.name)));e.ensureMarks(c)}return!0},toggleList:(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:h})=>{const{extensions:d,splittableMarks:u}=i.extensionManager,p=sa(t,o.schema),f=sa(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:v}=m,b=y.blockRange(v),w=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const x=_a((t=>Ja(t.type.name,d)))(m);if(b.depth>=1&&x&&b.depth-x.depth<=1){if(x.node.type===p)return c.liftListItem(f);if(Ja(x.node.type.name,d)&&p.validContent(x.node.content)&&a)return l().command((()=>(s.setNodeMarkup(x.pos,p),!0))).command((()=>Ga(s,p))).command((()=>Ya(s,p))).run()}return n&&w&&a?l().command((()=>{const t=h().wrapInList(p,r),e=w.filter((t=>u.includes(t.type.name)));return s.ensureMarks(e),!!t||c.clearNodes()})).wrapInList(p,r).command((()=>Ga(s,p))).command((()=>Ya(s,p))).run():l().command((()=>!!h().wrapInList(p,r)||c.clearNodes())).wrapInList(p,r).command((()=>Ga(s,p))).command((()=>Ya(s,p))).run()},toggleMark:(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Na(t,r.schema);return qa(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},toggleNode:(t,e,n={})=>({state:r,commands:i})=>{const s=sa(t,r.schema),o=sa(e,r.schema);return Va(r,s,n)?i.setNode(o):i.setNode(s,n)},toggleWrap:(t,e={})=>({state:n,commands:r})=>{const i=sa(t,n.schema);return Va(n,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const e=t.tr,n=s.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(s.text){const n=e.doc.resolve(s.from).marks();e.replaceWith(s.from,s.to,t.schema.text(s.text,n))}else e.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)})),!0},unsetMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=Na(t,r.schema),{$from:c,empty:h,ranges:d}=a;if(!i)return!0;if(h&&o){let{from:t,to:e}=a;const r=null===(s=c.marks().find((t=>t.type===l)))||void 0===s?void 0:s.attrs,i=Ta(c,l,r);i&&(t=i.from,e=i.to),n.removeMark(t,e,l)}else d.forEach((t=>{n.removeMark(t.$from.pos,t.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=La("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(s=sa(t,r.schema)),"mark"===a&&(o=Na(t,r.schema)),i&&n.selection.ranges.forEach((t=>{const i=t.$from.pos,a=t.$to.pos;r.doc.nodesBetween(i,a,((t,r)=>{s&&s===t.type&&n.setNodeMarkup(r,void 0,{...t.attrs,...e}),o&&t.marks.length&&t.marks.forEach((s=>{if(o===s.type){const l=Math.max(r,i),c=Math.min(r+t.nodeSize,a);n.addMark(l,c,o.create({...s.attrs,...e}))}}))}))})),!0)},wrapIn:(t,e={})=>({state:n,dispatch:r})=>function(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&In(o,t,e);return!!a&&(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0)}}(sa(t,n.schema),e)(n,r),wrapInList:(t,e={})=>({state:n,dispatch:r})=>Zo(sa(t,n.schema),e)(n,r)});const Za=ka.create({name:"commands",addCommands:()=>({...Xa})}),Qa=ka.create({name:"editable",addProseMirrorPlugins(){return[new br({key:new kr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),tl=ka.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new br({key:new kr("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),el=ka.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:n,doc:r}=e,{empty:i,$anchor:s}=n,{pos:o,parent:a}=s,l=tr.atStart(r).from===o;return!(!(i&&l&&a.type.isTextblock)||a.textContent.length)&&t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()])),e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ra()||Pa()?i:r},addProseMirrorPlugins(){return[new br({key:new kr("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some((t=>t.docChanged))&&!e.doc.eq(n.doc)))return;const{empty:r,from:i,to:s}=e.selection,o=tr.atStart(e.doc).from,a=tr.atEnd(e.doc).to;if(r||!(i===o&&s===a))return;if(!(0===n.doc.textBetween(0,n.doc.content.size," "," ").length))return;const l=n.tr,c=ta({state:n,transaction:l}),{commands:h}=new ea({editor:this.editor,state:c});return h.clearNodes(),l.steps.length?l:void 0}})]}}),nl=ka.create({name:"tabindex",addProseMirrorPlugins(){return[new br({key:new kr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var rl=Object.freeze({__proto__:null,ClipboardTextSerializer:Ma,Commands:Za,Editable:Qa,FocusEvents:tl,Keymap:el,Tabindex:nl});class il extends class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}{constructor(t={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(t,e){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute("data-tiptap-style",""),r.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(r),r}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,e){const n=la(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});this.view.updateState(r)}unregisterPlugin(t){if(this.isDestroyed)return;const e="string"==typeof t?`${t}$`:t.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((t=>!t.key.startsWith(e)))});this.view.updateState(n)}createExtensionManager(){const t=[...this.options.enableCoreExtensions?Object.values(rl):[],...this.options.extensions].filter((t=>["extension","node","mark"].includes(null==t?void 0:t.type)));this.extensionManager=new ba(t,this)}createCommandManager(){this.commandManager=new ea({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const t=ja(this.options.content,this.schema,this.options.parseOptions),e=Ia(t,this.options.autofocus);this.view=new Mo(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:yr.create({doc:t,selection:e||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews();this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach((t=>{var e;return null===(e=this.capturedTransaction)||void 0===e?void 0:e.step(t)})):void(this.capturedTransaction=t);const e=this.state.apply(t),n=!this.state.selection.eq(e.selection);this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t}),n&&this.emit("selectionUpdate",{editor:this,transaction:t});const r=t.getMeta("focus"),i=t.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:t}),i&&this.emit("blur",{editor:this,event:i.event,transaction:t}),t.docChanged&&!t.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return Wa(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,r="string"==typeof t?e:t;return function(t,e,n={}){if(!e)return Va(t,null,n)||qa(t,null,n);const r=La(e,t.schema);return"node"===r?Va(t,e,n):"mark"===r&&qa(t,e,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(t,e){const n=dn.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return Sa(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...Oa(this.schema),...n}})}get isEmpty(){return function(t){var e;const n=null===(e=t.type.createAndFill())||void 0===e?void 0:e.toJSON(),r=t.toJSON();return JSON.stringify(n)===JSON.stringify(r)}(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var t;return!(null===(t=this.view)||void 0===t?void 0:t.docView)}}class sl{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ca(na(this,"addOptions",{name:this.name}))),this.storage=ca(na(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new sl(t)}configure(t={}){const e=this.extend();return e.options=xa(this.options,t),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}extend(t={}){const e=new sl(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=ca(na(e,"addOptions",{name:e.name})),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,r=t.state.selection.$from;if(r.pos===r.end()){const i=r.marks(),s=!!i.find((t=>(null==t?void 0:t.type.name)===e.name));if(!s)return!1;const o=i.find((t=>(null==t?void 0:t.type.name)===e.name));return o&&n.removeStoredMark(o),n.insertText(" ",r.pos),t.view.dispatch(n),!0}return!1}}class ol{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ca(na(this,"addOptions",{name:this.name}))),this.storage=ca(na(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ol(t)}configure(t={}){const e=this.extend();return e.options=xa(this.options,t),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}extend(t={}){const e=new ol(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=ca(na(e,"addOptions",{name:e.name})),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}}const al=ol.create({name:"doc",topNode:!0,content:"block+"}),ll=ol.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",oa(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),cl=ol.create({name:"text",group:"inline"});function hl(t={}){return new br({view:e=>new dl(e,t)})}class dl{constructor(t,e){this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=e.width||1,this.color=e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let n=t=>{this[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos);if(!e.parent.inlineContent){let n=e.nodeBefore,r=e.nodeAfter;if(n||r){let e=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(e){let i=e.getBoundingClientRect(),s=n?i.bottom:i.top;n&&r&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:i.left,right:i.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos);t={left:e.left-this.width/2,right:e.left+this.width/2,top:e.top,bottom:e.bottom}}let n,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color),!i||i==document.body&&"static"==getComputedStyle(i).position)n=-pageXOffset,r=-pageYOffset;else{let t=i.getBoundingClientRect();n=t.left-i.scrollLeft,r=t.top-i.scrollTop}this.element.style.left=t.left-n+"px",this.element.style.top=t.top-r+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,e,t):r;if(e&&!i){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice&&(t=Ln(this.editorView.state.doc,t,this.editorView.dragging.slice),null==t))return this.setCursor(null);this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const ul=ka.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[hl(this.options)]}});class pl extends tr{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return pl.valid(n)?new pl(n):tr.near(n)}content(){return ge.empty}eq(t){return t instanceof pl&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new pl(t.resolve(e.pos))}getBookmark(){return new fl(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(0!=n)for(let t=r.child(n-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n!=r.childCount)for(let t=r.child(n);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(t))return!1;let n=e.type.spec.allowGapCursor;if(null!=n)return n;let r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,e,n=!1){t:for(;;){if(!n&&pl.valid(t))return t;let r=t.pos,i=null;for(let n=t.depth;;n--){let s=t.node(n);if(e>0?t.indexAfter(n)<s.childCount:t.index(n)>0){i=s.child(e>0?t.indexAfter(n):t.index(n)-1);break}if(0==n)return null;r+=e;let o=t.doc.resolve(r);if(pl.valid(o))return o}for(;;){let s=e>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!or.isSelectable(i)){t=t.doc.resolve(r+i.nodeSize*e),n=!1;continue t}break}i=s,r+=e;let o=t.doc.resolve(r);if(pl.valid(o))return o}return null}}}pl.prototype.visible=!1,pl.findFrom=pl.findGapCursorFrom,tr.jsonID("gapcursor",pl);class fl{constructor(t){this.pos=t}map(t){return new fl(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return pl.valid(e)?new pl(e):tr.near(e)}}const ml=_o({ArrowLeft:gl("horiz",-1),ArrowRight:gl("horiz",1),ArrowUp:gl("vert",-1),ArrowDown:gl("vert",1)});function gl(t,e){const n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,r,i){let s=t.selection,o=e>0?s.$to:s.$from,a=s.empty;if(s instanceof ir){if(!i.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=t.doc.resolve(e>0?o.after():o.before())}let l=pl.findGapCursorFrom(o,e,a);return!!l&&(r&&r(t.tr.setSelection(new pl(l))),!0)}}function yl(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!pl.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&or.isSelectable(t.state.doc.nodeAt(i.inside)))&&(t.dispatch(t.state.tr.setSelection(new pl(r))),!0)}function vl(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof pl))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=he.empty;for(let t=r.length-1;t>=0;t--)i=he.from(r[t].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new ge(i,0,0));return s.setSelection(ir.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function bl(t){if(!(t.selection instanceof pl))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ro.create(t.doc,[to.widget(t.selection.head,e,{key:"gapcursor"})])}const wl=ka.create({name:"gapCursor",addProseMirrorPlugins:()=>[new br({props:{decorations:bl,createSelectionBetween:(t,e,n)=>e.pos==n.pos&&pl.valid(n)?new pl(n):null,handleClick:yl,handleKeyDown:ml,handleDOMEvents:{beforeinput:vl}}})],extendNodeSchema(t){var e;return{allowGapCursor:null!==(e=ca(na(t,"allowGapCursor",{name:t.name,options:t.options,storage:t.storage})))&&void 0!==e?e:null}}});var xl=function(){};xl.prototype.append=function(t){return t.length?(t=xl.from(t),!this.length&&t||t.length<200&&this.leafAppend(t)||this.length<200&&t.leafPrepend(this)||this.appendInner(t)):this},xl.prototype.prepend=function(t){return t.length?xl.from(t).append(this):this},xl.prototype.appendInner=function(t){return new Sl(this,t)},xl.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?xl.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},xl.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},xl.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},xl.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(e,n){return r.push(t(e,n))}),e,n),r},xl.from=function(t){return t instanceof xl?t:t&&t.length?new kl(t):xl.empty};var kl=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var i=e;i<n;i++)if(!1===t(this.values[i],r+i))return!1},e.prototype.forEachInvertedInner=function(t,e,n,r){for(var i=e-1;i>=n;i--)if(!1===t(this.values[i],r+i))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=200)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=200)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(xl);xl.empty=new kl([]);var Sl=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,r){var i=this.left.length;return!(e<i&&!1===this.left.forEachInner(t,e,Math.min(n,i),r))&&(!(n>i&&!1===this.right.forEachInner(t,Math.max(e-i,0),Math.min(this.length,n)-i,r+i))&&void 0)},e.prototype.forEachInvertedInner=function(t,e,n,r){var i=this.left.length;return!(e>i&&!1===this.right.forEachInvertedInner(t,e-i,Math.max(n,i)-i,r+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(t,Math.min(e,i),n,r))&&void 0)},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(xl),Ol=xl;class Ml{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let n,r,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}e&&(n=this.remapping(i,this.items.length),r=n.maps.length);let s,o,a=t.tr,l=[],c=[];return this.items.forEach(((t,e)=>{if(!t.step)return n||(n=this.remapping(i,e+1),r=n.maps.length),r--,void c.push(t);if(n){c.push(new Al(t.map));let e,i=t.step.map(n.slice(r));i&&a.maybeStep(i).doc&&(e=a.mapping.maps[a.mapping.maps.length-1],l.push(new Al(e,void 0,void 0,l.length+c.length))),r--,e&&n.appendMap(e,r)}else a.maybeStep(t.step);return t.selection?(s=n?t.selection.map(n.slice(r)):t.selection,o=new Ml(this.items.slice(0,i).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:a,selection:s}}addTransform(t,e,n,r){let i=[],s=this.eventCount,o=this.items,a=!r&&o.length?o.get(o.length-1):null;for(let n=0;n<t.steps.length;n++){let l,c=t.steps[n].invert(t.docs[n]),h=new Al(t.mapping.maps[n],c,e);(l=a&&a.merge(h))&&(h=l,n?i.pop():o=o.slice(0,o.length-1)),i.push(h),e&&(s++,e=void 0),r||(a=h)}let l=s-n.depth;return l>Cl&&(o=function(t,e){let n;return t.forEach(((t,r)=>{if(t.selection&&0==e--)return n=r,!1})),t.slice(n)}(o,l),s-=l),new Ml(o.append(i),s)}remapping(t,e){let n=new bn;return this.items.forEach(((e,r)=>{let i=null!=e.mirrorOffset&&r-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0;n.appendMap(e.map,i)}),t,e),n}addMaps(t){return 0==this.eventCount?this:new Ml(this.items.append(t.map((t=>new Al(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-e),i=t.mapping,s=t.steps.length,o=this.eventCount;this.items.forEach((t=>{t.selection&&o--}),r);let a=e;this.items.forEach((e=>{let r=i.getMirror(--a);if(null==r)return;s=Math.min(s,r);let l=i.maps[r];if(e.step){let s=t.steps[r].invert(t.docs[r]),c=e.selection&&e.selection.map(i.slice(a+1,r));c&&o++,n.push(new Al(l,s,c))}else n.push(new Al(l))}),r);let l=[];for(let t=e;t<s;t++)l.push(new Al(i.maps[t]));let c=this.items.slice(0,r).append(l).append(n),h=new Ml(c,o);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,r=[],i=0;return this.items.forEach(((s,o)=>{if(o>=t)r.push(s),s.selection&&i++;else if(s.step){let t=s.step.map(e.slice(n)),o=t&&t.getMap();if(n--,o&&e.appendMap(o,n),t){let a=s.selection&&s.selection.map(e.slice(n));a&&i++;let l,c=new Al(o.invert(),t,a),h=r.length-1;(l=r.length&&r[h].merge(c))?r[h]=l:r.push(c)}}else s.map&&n--}),this.items.length,0),new Ml(Ol.from(r.reverse()),i)}}Ml.empty=new Ml(Ol.empty,0);class Al{constructor(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new Al(e.getMap().invert(),e,this.selection)}}}class El{constructor(t,e,n,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=r}}const Cl=20;function Tl(t){let e=[];return t.forEach(((t,n,r,i)=>e.push(r,i))),e}function Nl(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function Dl(t,e,n,r){let i=Rl(e),s=Bl.get(e).spec.config,o=(r?t.undone:t.done).popEvent(e,i);if(!o)return;let a=o.selection.resolve(o.transform.doc),l=(r?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,i),c=new El(r?l:o.remaining,r?o.remaining:l,null,0);n(o.transform.setSelection(a).setMeta(Bl,{redo:r,historyState:c}).scrollIntoView())}let $l=!1,Il=null;function Rl(t){let e=t.plugins;if(Il!=e){$l=!1,Il=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){$l=!0;break}}return $l}const Bl=new kr("history"),Fl=new kr("closeHistory");function Pl(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new br({key:Bl,state:{init:()=>new El(Ml.empty,Ml.empty,null,0),apply:(e,n,r)=>function(t,e,n,r){let i,s=n.getMeta(Bl);if(s)return s.historyState;n.getMeta(Fl)&&(t=new El(t.done,t.undone,null,0));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(o&&o.getMeta(Bl))return o.getMeta(Bl).redo?new El(t.done.addTransform(n,void 0,r,Rl(e)),t.undone,Tl(n.mapping.maps[n.steps.length-1]),t.prevTime):new El(t.done,t.undone.addTransform(n,void 0,r,Rl(e)),null,t.prevTime);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new El(t.done.rebased(n,i),t.undone.rebased(n,i),Nl(t.prevRanges,n.mapping),t.prevTime):new El(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Nl(t.prevRanges,n.mapping),t.prevTime);{let i=0==t.prevTime||!o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach(((t,r)=>{for(let i=0;i<e.length;i+=2)t<=e[i+1]&&r>=e[i]&&(n=!0)})),n}(n,t.prevRanges)),s=o?Nl(t.prevRanges,n.mapping):Tl(n.mapping.maps[n.steps.length-1]);return new El(t.done.addTransform(n,i?e.selection.getBookmark():void 0,r,Rl(e)),Ml.empty,s,n.time)}}(n,r,e,t)},config:t,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,r="historyUndo"==n?Vl:"historyRedo"==n?Ll:null;return!!r&&(e.preventDefault(),r(t.state,t.dispatch))}}}})}const Vl=(t,e)=>{let n=Bl.getState(t);return!(!n||0==n.done.eventCount)&&(e&&Dl(n,t,e,!1),!0)},Ll=(t,e)=>{let n=Bl.getState(t);return!(!n||0==n.undone.eventCount)&&(e&&Dl(n,t,e,!0),!0)},zl=ka.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>Vl(t,e),redo:()=>({state:t,dispatch:e})=>Ll(t,e)}),addProseMirrorPlugins(){return[Pl(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});class jl extends X{connect(){for(const t of this.editorTargets){const e=new il({extensions:[ul,wl,zl,al,ll,cl],content:"",injectCSS:!1,element:t,editorProps:{attributes:{class:"ariadne-h-28 ariadne-max-h-48 ariadne-p-2 ariadne-rounded-lg ariadne-overflow-y-auto focus:ariadne-outline-none"}},parseOptions:{preserveWhitespace:!0}}),n=t.previousElementSibling;if(n){const r=t.closest("form");null==r||r.addEventListener("submit",(()=>{n.setAttribute("value",e.getText()||""),e.commands.clearContent()}))}}}}jl.targets=["editor"];class _l extends X{toggle(){this.expandableTarget.classList.toggle("ariadne-hidden");for(const t of this.slidePanelTargets)t.classList.toggle("ariadne-hidden")}}_l.targets=["expandable","expandWrapper","slidePanel","buttonWrapper"];class Kl extends X{constructor(){super(...arguments),this.SELECTED_CLASSES=["ariadne-border-slate-500","ariadne-text-slate-600"],this.UNSELECTED_CLASSES=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"]}connect(){for(const t of this.tabTargets)t.hasAttribute("aria-current")&&(t.classList.add(...this.SELECTED_CLASSES),t.classList.remove(...this.UNSELECTED_CLASSES))}toggle(t){for(const e of this.tabTargets)e===t.target?(e.setAttribute("aria-current","page"),e.classList.add(...this.SELECTED_CLASSES),e.classList.remove(...this.UNSELECTED_CLASSES)):e.hasAttribute("aria-current")&&(e.removeAttribute("aria-current"),e.classList.add(...this.UNSELECTED_CLASSES),e.classList.remove(...this.SELECTED_CLASSES))}}Kl.targets=["tab"];var Wl="top",Hl="bottom",ql="right",Jl="left",Ul=[Wl,Hl,ql,Jl],Gl=Ul.reduce((function(t,e){return t.concat([e+"-start",e+"-end"])}),[]),Yl=[].concat(Ul,["auto"]).reduce((function(t,e){return t.concat([e,e+"-start",e+"-end"])}),[]),Xl=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function Zl(t){return t?(t.nodeName||"").toLowerCase():null}function Ql(t){if(null==t)return window;if("[object Window]"!==t.toString()){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function tc(t){return t instanceof Ql(t).Element||t instanceof Element}function ec(t){return t instanceof Ql(t).HTMLElement||t instanceof HTMLElement}function nc(t){return"undefined"!=typeof ShadowRoot&&(t instanceof Ql(t).ShadowRoot||t instanceof ShadowRoot)}var rc={name:"applyStyles",enabled:!0,phase:"write",fn:function(t){var e=t.state;Object.keys(e.elements).forEach((function(t){var n=e.styles[t]||{},r=e.attributes[t]||{},i=e.elements[t];ec(i)&&Zl(i)&&(Object.assign(i.style,n),Object.keys(r).forEach((function(t){var e=r[t];!1===e?i.removeAttribute(t):i.setAttribute(t,!0===e?"":e)})))}))},effect:function(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach((function(t){var r=e.elements[t],i=e.attributes[t]||{},s=Object.keys(e.styles.hasOwnProperty(t)?e.styles[t]:n[t]).reduce((function(t,e){return t[e]="",t}),{});ec(r)&&Zl(r)&&(Object.assign(r.style,s),Object.keys(i).forEach((function(t){r.removeAttribute(t)})))}))}},requires:["computeStyles"]};function ic(t){return t.split("-")[0]}var sc=Math.max,oc=Math.min,ac=Math.round;function lc(){var t=navigator.userAgentData;return null!=t&&t.brands&&Array.isArray(t.brands)?t.brands.map((function(t){return t.brand+"/"+t.version})).join(" "):navigator.userAgent}function cc(){return!/^((?!chrome|android).)*safari/i.test(lc())}function hc(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=!1);var r=t.getBoundingClientRect(),i=1,s=1;e&&ec(t)&&(i=t.offsetWidth>0&&ac(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&ac(r.height)/t.offsetHeight||1);var o=(tc(t)?Ql(t):window).visualViewport,a=!cc()&&n,l=(r.left+(a&&o?o.offsetLeft:0))/i,c=(r.top+(a&&o?o.offsetTop:0))/s,h=r.width/i,d=r.height/s;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l,x:l,y:c}}function dc(t){var e=hc(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function uc(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&nc(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function pc(t){return Ql(t).getComputedStyle(t)}function fc(t){return["table","td","th"].indexOf(Zl(t))>=0}function mc(t){return((tc(t)?t.ownerDocument:t.document)||window.document).documentElement}function gc(t){return"html"===Zl(t)?t:t.assignedSlot||t.parentNode||(nc(t)?t.host:null)||mc(t)}function yc(t){return ec(t)&&"fixed"!==pc(t).position?t.offsetParent:null}function vc(t){for(var e=Ql(t),n=yc(t);n&&fc(n)&&"static"===pc(n).position;)n=yc(n);return n&&("html"===Zl(n)||"body"===Zl(n)&&"static"===pc(n).position)?e:n||function(t){var e=/firefox/i.test(lc());if(/Trident/i.test(lc())&&ec(t)&&"fixed"===pc(t).position)return null;var n=gc(t);for(nc(n)&&(n=n.host);ec(n)&&["html","body"].indexOf(Zl(n))<0;){var r=pc(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||e&&"filter"===r.willChange||e&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(t)||e}function bc(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function wc(t,e,n){return sc(t,oc(e,n))}function xc(t){return Object.assign({},{top:0,right:0,bottom:0,left:0},t)}function kc(t,e){return e.reduce((function(e,n){return e[n]=t,e}),{})}var Sc={name:"arrow",enabled:!0,phase:"main",fn:function(t){var e,n=t.state,r=t.name,i=t.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=ic(n.placement),l=bc(a),c=[Jl,ql].indexOf(a)>=0?"height":"width";if(s&&o){var h=function(t,e){return xc("number"!=typeof(t="function"==typeof t?t(Object.assign({},e.rects,{placement:e.placement})):t)?t:kc(t,Ul))}(i.padding,n),d=dc(s),u="y"===l?Wl:Jl,p="y"===l?Hl:ql,f=n.rects.reference[c]+n.rects.reference[l]-o[l]-n.rects.popper[c],m=o[l]-n.rects.reference[l],g=vc(s),y=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,v=f/2-m/2,b=h[u],w=y-d[c]-h[p],x=y/2-d[c]/2+v,k=wc(b,x,w),S=l;n.modifiersData[r]=((e={})[S]=k,e.centerOffset=k-x,e)}},effect:function(t){var e=t.state,n=t.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=e.elements.popper.querySelector(r)))&&uc(e.elements.popper,r)&&(e.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Oc(t){return t.split("-")[1]}var Mc={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ac(t){var e,n=t.popper,r=t.popperRect,i=t.placement,s=t.variation,o=t.offsets,a=t.position,l=t.gpuAcceleration,c=t.adaptive,h=t.roundOffsets,d=t.isFixed,u=o.x,p=void 0===u?0:u,f=o.y,m=void 0===f?0:f,g="function"==typeof h?h({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var y=o.hasOwnProperty("x"),v=o.hasOwnProperty("y"),b=Jl,w=Wl,x=window;if(c){var k=vc(n),S="clientHeight",O="clientWidth";if(k===Ql(n)&&"static"!==pc(k=mc(n)).position&&"absolute"===a&&(S="scrollHeight",O="scrollWidth"),i===Wl||(i===Jl||i===ql)&&"end"===s)w=Hl,m-=(d&&k===x&&x.visualViewport?x.visualViewport.height:k[S])-r.height,m*=l?1:-1;if(i===Jl||(i===Wl||i===Hl)&&"end"===s)b=ql,p-=(d&&k===x&&x.visualViewport?x.visualViewport.width:k[O])-r.width,p*=l?1:-1}var M,A=Object.assign({position:a},c&&Mc),E=!0===h?function(t,e){var n=t.x,r=t.y,i=e.devicePixelRatio||1;return{x:ac(n*i)/i||0,y:ac(r*i)/i||0}}({x:p,y:m},Ql(n)):{x:p,y:m};return p=E.x,m=E.y,l?Object.assign({},A,((M={})[w]=v?"0":"",M[b]=y?"0":"",M.transform=(x.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",M)):Object.assign({},A,((e={})[w]=v?m+"px":"",e[b]=y?p+"px":"",e.transform="",e))}var Ec={passive:!0};var Cc={left:"right",right:"left",bottom:"top",top:"bottom"};function Tc(t){return t.replace(/left|right|bottom|top/g,(function(t){return Cc[t]}))}var Nc={start:"end",end:"start"};function Dc(t){return t.replace(/start|end/g,(function(t){return Nc[t]}))}function $c(t){var e=Ql(t);return{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Ic(t){return hc(mc(t)).left+$c(t).scrollLeft}function Rc(t){var e=pc(t),n=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function Bc(t){return["html","body","#document"].indexOf(Zl(t))>=0?t.ownerDocument.body:ec(t)&&Rc(t)?t:Bc(gc(t))}function Fc(t,e){var n;void 0===e&&(e=[]);var r=Bc(t),i=r===(null==(n=t.ownerDocument)?void 0:n.body),s=Ql(r),o=i?[s].concat(s.visualViewport||[],Rc(r)?r:[]):r,a=e.concat(o);return i?a:a.concat(Fc(gc(o)))}function Pc(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Vc(t,e,n){return"viewport"===e?Pc(function(t,e){var n=Ql(t),r=mc(t),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var c=cc();(c||!c&&"fixed"===e)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+Ic(t),y:l}}(t,n)):tc(e)?function(t,e){var n=hc(t,!1,"fixed"===e);return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}(e,n):Pc(function(t){var e,n=mc(t),r=$c(t),i=null==(e=t.ownerDocument)?void 0:e.body,s=sc(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=sc(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+Ic(t),l=-r.scrollTop;return"rtl"===pc(i||n).direction&&(a+=sc(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}(mc(t)))}function Lc(t,e,n,r){var i="clippingParents"===e?function(t){var e=Fc(gc(t)),n=["absolute","fixed"].indexOf(pc(t).position)>=0&&ec(t)?vc(t):t;return tc(n)?e.filter((function(t){return tc(t)&&uc(t,n)&&"body"!==Zl(t)})):[]}(t):[].concat(e),s=[].concat(i,[n]),o=s[0],a=s.reduce((function(e,n){var i=Vc(t,n,r);return e.top=sc(i.top,e.top),e.right=oc(i.right,e.right),e.bottom=oc(i.bottom,e.bottom),e.left=sc(i.left,e.left),e}),Vc(t,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function zc(t){var e,n=t.reference,r=t.element,i=t.placement,s=i?ic(i):null,o=i?Oc(i):null,a=n.x+n.width/2-r.width/2,l=n.y+n.height/2-r.height/2;switch(s){case Wl:e={x:a,y:n.y-r.height};break;case Hl:e={x:a,y:n.y+n.height};break;case ql:e={x:n.x+n.width,y:l};break;case Jl:e={x:n.x-r.width,y:l};break;default:e={x:n.x,y:n.y}}var c=s?bc(s):null;if(null!=c){var h="y"===c?"height":"width";switch(o){case"start":e[c]=e[c]-(n[h]/2-r[h]/2);break;case"end":e[c]=e[c]+(n[h]/2-r[h]/2)}}return e}function jc(t,e){void 0===e&&(e={});var n=e,r=n.placement,i=void 0===r?t.placement:r,s=n.strategy,o=void 0===s?t.strategy:s,a=n.boundary,l=void 0===a?"clippingParents":a,c=n.rootBoundary,h=void 0===c?"viewport":c,d=n.elementContext,u=void 0===d?"popper":d,p=n.altBoundary,f=void 0!==p&&p,m=n.padding,g=void 0===m?0:m,y=xc("number"!=typeof g?g:kc(g,Ul)),v="popper"===u?"reference":"popper",b=t.rects.popper,w=t.elements[f?v:u],x=Lc(tc(w)?w:w.contextElement||mc(t.elements.popper),l,h,o),k=hc(t.elements.reference),S=zc({reference:k,element:b,strategy:"absolute",placement:i}),O=Pc(Object.assign({},b,S)),M="popper"===u?O:k,A={top:x.top-M.top+y.top,bottom:M.bottom-x.bottom+y.bottom,left:x.left-M.left+y.left,right:M.right-x.right+y.right},E=t.modifiersData.offset;if("popper"===u&&E){var C=E[i];Object.keys(A).forEach((function(t){var e=[ql,Hl].indexOf(t)>=0?1:-1,n=[Wl,Hl].indexOf(t)>=0?"y":"x";A[t]+=C[n]*e}))}return A}function _c(t,e){void 0===e&&(e={});var n=e,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?Yl:l,h=Oc(r),d=h?a?Gl:Gl.filter((function(t){return Oc(t)===h})):Ul,u=d.filter((function(t){return c.indexOf(t)>=0}));0===u.length&&(u=d);var p=u.reduce((function(e,n){return e[n]=jc(t,{placement:n,boundary:i,rootBoundary:s,padding:o})[ic(n)],e}),{});return Object.keys(p).sort((function(t,e){return p[t]-p[e]}))}var Kc={name:"flip",enabled:!0,phase:"main",fn:function(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0===o||o,l=n.fallbackPlacements,c=n.padding,h=n.boundary,d=n.rootBoundary,u=n.altBoundary,p=n.flipVariations,f=void 0===p||p,m=n.allowedAutoPlacements,g=e.options.placement,y=ic(g),v=l||(y===g||!f?[Tc(g)]:function(t){if("auto"===ic(t))return[];var e=Tc(t);return[Dc(t),e,Dc(e)]}(g)),b=[g].concat(v).reduce((function(t,n){return t.concat("auto"===ic(n)?_c(e,{placement:n,boundary:h,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:m}):n)}),[]),w=e.rects.reference,x=e.rects.popper,k=new Map,S=!0,O=b[0],M=0;M<b.length;M++){var A=b[M],E=ic(A),C="start"===Oc(A),T=[Wl,Hl].indexOf(E)>=0,N=T?"width":"height",D=jc(e,{placement:A,boundary:h,rootBoundary:d,altBoundary:u,padding:c}),$=T?C?ql:Jl:C?Hl:Wl;w[N]>x[N]&&($=Tc($));var I=Tc($),R=[];if(s&&R.push(D[E]<=0),a&&R.push(D[$]<=0,D[I]<=0),R.every((function(t){return t}))){O=A,S=!1;break}k.set(A,R)}if(S)for(var B=function(t){var e=b.find((function(e){var n=k.get(e);if(n)return n.slice(0,t).every((function(t){return t}))}));if(e)return O=e,"break"},F=f?3:1;F>0;F--){if("break"===B(F))break}e.placement!==O&&(e.modifiersData[r]._skip=!0,e.placement=O,e.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function Wc(t,e,n){return void 0===n&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function Hc(t){return[Wl,ql,Hl,Jl].some((function(e){return t[e]>=0}))}var qc={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(t){var e=t.state,n=t.options,r=t.name,i=n.offset,s=void 0===i?[0,0]:i,o=Yl.reduce((function(t,n){return t[n]=function(t,e,n){var r=ic(t),i=[Jl,Wl].indexOf(r)>=0?-1:1,s="function"==typeof n?n(Object.assign({},e,{placement:t})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[Jl,ql].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}(n,e.rects,s),t}),{}),a=o[e.placement],l=a.x,c=a.y;null!=e.modifiersData.popperOffsets&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=o}};var Jc={name:"preventOverflow",enabled:!0,phase:"main",fn:function(t){var e=t.state,n=t.options,r=t.name,i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0!==o&&o,l=n.boundary,c=n.rootBoundary,h=n.altBoundary,d=n.padding,u=n.tether,p=void 0===u||u,f=n.tetherOffset,m=void 0===f?0:f,g=jc(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:h}),y=ic(e.placement),v=Oc(e.placement),b=!v,w=bc(y),x="x"===w?"y":"x",k=e.modifiersData.popperOffsets,S=e.rects.reference,O=e.rects.popper,M="function"==typeof m?m(Object.assign({},e.rects,{placement:e.placement})):m,A="number"==typeof M?{mainAxis:M,altAxis:M}:Object.assign({mainAxis:0,altAxis:0},M),E=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,C={x:0,y:0};if(k){if(s){var T,N="y"===w?Wl:Jl,D="y"===w?Hl:ql,$="y"===w?"height":"width",I=k[w],R=I+g[N],B=I-g[D],F=p?-O[$]/2:0,P="start"===v?S[$]:O[$],V="start"===v?-O[$]:-S[$],L=e.elements.arrow,z=p&&L?dc(L):{width:0,height:0},j=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},_=j[N],K=j[D],W=wc(0,S[$],z[$]),H=b?S[$]/2-F-W-_-A.mainAxis:P-W-_-A.mainAxis,q=b?-S[$]/2+F+W+K+A.mainAxis:V+W+K+A.mainAxis,J=e.elements.arrow&&vc(e.elements.arrow),U=J?"y"===w?J.clientTop||0:J.clientLeft||0:0,G=null!=(T=null==E?void 0:E[w])?T:0,Y=I+q-G,X=wc(p?oc(R,I+H-G-U):R,I,p?sc(B,Y):B);k[w]=X,C[w]=X-I}if(a){var Z,Q="x"===w?Wl:Jl,tt="x"===w?Hl:ql,et=k[x],nt="y"===x?"height":"width",rt=et+g[Q],it=et-g[tt],st=-1!==[Wl,Jl].indexOf(y),ot=null!=(Z=null==E?void 0:E[x])?Z:0,at=st?rt:et-S[nt]-O[nt]-ot+A.altAxis,lt=st?et+S[nt]+O[nt]-ot-A.altAxis:it,ct=p&&st?function(t,e,n){var r=wc(t,e,n);return r>n?n:r}(at,et,lt):wc(p?at:rt,et,p?lt:it);k[x]=ct,C[x]=ct-et}e.modifiersData[r]=C}},requiresIfExists:["offset"]};function Uc(t,e,n){void 0===n&&(n=!1);var r,i,s=ec(e),o=ec(e)&&function(t){var e=t.getBoundingClientRect(),n=ac(e.width)/t.offsetWidth||1,r=ac(e.height)/t.offsetHeight||1;return 1!==n||1!==r}(e),a=mc(e),l=hc(t,o,n),c={scrollLeft:0,scrollTop:0},h={x:0,y:0};return(s||!s&&!n)&&(("body"!==Zl(e)||Rc(a))&&(c=(r=e)!==Ql(r)&&ec(r)?{scrollLeft:(i=r).scrollLeft,scrollTop:i.scrollTop}:$c(r)),ec(e)?((h=hc(e,!0)).x+=e.clientLeft,h.y+=e.clientTop):a&&(h.x=Ic(a))),{x:l.left+c.scrollLeft-h.x,y:l.top+c.scrollTop-h.y,width:l.width,height:l.height}}function Gc(t){var e=new Map,n=new Set,r=[];function i(t){n.add(t.name),[].concat(t.requires||[],t.requiresIfExists||[]).forEach((function(t){if(!n.has(t)){var r=e.get(t);r&&i(r)}})),r.push(t)}return t.forEach((function(t){e.set(t.name,t)})),t.forEach((function(t){n.has(t.name)||i(t)})),r}var Yc={placement:"bottom",modifiers:[],strategy:"absolute"};function Xc(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return!e.some((function(t){return!(t&&"function"==typeof t.getBoundingClientRect)}))}function Zc(t){void 0===t&&(t={});var e=t,n=e.defaultModifiers,r=void 0===n?[]:n,i=e.defaultOptions,s=void 0===i?Yc:i;return function(t,e,n){void 0===n&&(n=s);var i,o,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},Yc,s),modifiersData:{},elements:{reference:t,popper:e},attributes:{},styles:{}},l=[],c=!1,h={state:a,setOptions:function(n){var i="function"==typeof n?n(a.options):n;d(),a.options=Object.assign({},s,a.options,i),a.scrollParents={reference:tc(t)?Fc(t):t.contextElement?Fc(t.contextElement):[],popper:Fc(e)};var o=function(t){var e=Gc(t);return Xl.reduce((function(t,n){return t.concat(e.filter((function(t){return t.phase===n})))}),[])}(function(t){var e=t.reduce((function(t,e){var n=t[e.name];return t[e.name]=n?Object.assign({},n,e,{options:Object.assign({},n.options,e.options),data:Object.assign({},n.data,e.data)}):e,t}),{});return Object.keys(e).map((function(t){return e[t]}))}([].concat(r,a.options.modifiers)));return a.orderedModifiers=o.filter((function(t){return t.enabled})),a.orderedModifiers.forEach((function(t){var e=t.name,n=t.options,r=void 0===n?{}:n,i=t.effect;if("function"==typeof i){var s=i({state:a,name:e,instance:h,options:r}),o=function(){};l.push(s||o)}})),h.update()},forceUpdate:function(){if(!c){var t=a.elements,e=t.reference,n=t.popper;if(Xc(e,n)){a.rects={reference:Uc(e,vc(n),"fixed"===a.options.strategy),popper:dc(n)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach((function(t){return a.modifiersData[t.name]=Object.assign({},t.data)}));for(var r=0;r<a.orderedModifiers.length;r++)if(!0!==a.reset){var i=a.orderedModifiers[r],s=i.fn,o=i.options,l=void 0===o?{}:o,d=i.name;"function"==typeof s&&(a=s({state:a,options:l,name:d,instance:h})||a)}else a.reset=!1,r=-1}}},update:(i=function(){return new Promise((function(t){h.forceUpdate(),t(a)}))},function(){return o||(o=new Promise((function(t){Promise.resolve().then((function(){o=void 0,t(i())}))}))),o}),destroy:function(){d(),c=!0}};if(!Xc(t,e))return h;function d(){l.forEach((function(t){return t()})),l=[]}return h.setOptions(n).then((function(t){!c&&n.onFirstUpdate&&n.onFirstUpdate(t)})),h}}var Qc=Zc({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(t){var e=t.state,n=t.instance,r=t.options,i=r.scroll,s=void 0===i||i,o=r.resize,a=void 0===o||o,l=Ql(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach((function(t){t.addEventListener("scroll",n.update,Ec)})),a&&l.addEventListener("resize",n.update,Ec),function(){s&&c.forEach((function(t){t.removeEventListener("scroll",n.update,Ec)})),a&&l.removeEventListener("resize",n.update,Ec)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(t){var e=t.state,n=t.name;e.modifiersData[n]=zc({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(t){var e=t.state,n=t.options,r=n.gpuAcceleration,i=void 0===r||r,s=n.adaptive,o=void 0===s||s,a=n.roundOffsets,l=void 0===a||a,c={placement:ic(e.placement),variation:Oc(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:"fixed"===e.options.strategy};null!=e.modifiersData.popperOffsets&&(e.styles.popper=Object.assign({},e.styles.popper,Ac(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:l})))),null!=e.modifiersData.arrow&&(e.styles.arrow=Object.assign({},e.styles.arrow,Ac(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})},data:{}},rc,qc,Kc,Jc,Sc,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(t){var e=t.state,n=t.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=jc(e,{elementContext:"reference"}),a=jc(e,{altBoundary:!0}),l=Wc(o,r),c=Wc(a,i,s),h=Hc(l),d=Hc(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:h,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":h,"data-popper-escaped":d})}}]});class th extends X{connect(){this.popperInstance=Qc(this.triggerTarget,this.tooltipTarget,{placement:this.placementValue,modifiers:[{name:"offset",options:{offset:this.offsetValue}}]})}disconnect(){this.popperInstance&&this.popperInstance.destroy()}show(){this.tooltipTarget.setAttribute("data-tooltip-show",""),this.tooltipTarget.classList.remove("ariadne-invisible"),this.popperInstance.update(),this.dispatch("shown",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}hide(){this.tooltipTarget.removeAttribute("data-tooltip-show"),this.tooltipTarget.classList.add("ariadne-invisible"),this.dispatch("ariadne-hidden",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}}function eh(t){return Array.from(t.querySelectorAll('[role="tablist"] [role="tab"]')).filter((e=>e instanceof HTMLElement&&e.closest(t.tagName)===t))}th.targets=["trigger","tooltip"],th.values={placement:{type:String,default:"top"},offset:{type:Array,default:[0,8]}};class nh extends HTMLElement{static define(t="tab-container",e=customElements){return e.define(t,this),this}connectedCallback(){this.addEventListener("keydown",(t=>{var e;const n=t.target;if(!(n instanceof HTMLElement))return;if(n.closest(this.tagName)!==this)return;if("tab"!==n.getAttribute("role")&&!n.closest('[role="tablist"]'))return;const r=eh(this),i=r.indexOf(r.find((t=>t.matches('[aria-selected="true"]')))),[s,o]="vertical"===(null===(e=n.closest('[role="tablist"]'))||void 0===e?void 0:e.getAttribute("aria-orientation"))?[["ArrowDown","ArrowRight"],["ArrowUp","ArrowLeft"]]:[["ArrowRight"],["ArrowLeft"]];if(s.some((e=>t.code===e))){let t=i+1;t>=r.length&&(t=0),this.selectTab(t)}else if(o.some((e=>t.code===e))){let t=i-1;t<0&&(t=r.length-1),this.selectTab(t)}else"Home"===t.code?(this.selectTab(0),t.preventDefault()):"End"===t.code&&(this.selectTab(r.length-1),t.preventDefault())})),this.addEventListener("click",(t=>{const e=eh(this);if(!(t.target instanceof Element))return;if(t.target.closest(this.tagName)!==this)return;const n=t.target.closest('[role="tab"]');if(!(n instanceof HTMLElement&&n.closest('[role="tablist"]')))return;const r=e.indexOf(n);this.selectTab(r)}));for(const t of eh(this))t.hasAttribute("aria-selected")||t.setAttribute("aria-selected","false"),t.hasAttribute("tabindex")||("true"===t.getAttribute("aria-selected")?t.setAttribute("tabindex","0"):t.setAttribute("tabindex","-1"))}selectTab(t){const e=eh(this),n=Array.from(this.querySelectorAll('[role="tabpanel"]')).filter((t=>t.closest(this.tagName)===this));if(t>e.length-1)throw new RangeError(`Index "${t}" out of bounds`);const r=e[t],i=n[t];if(!!this.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:i}}))){for(const t of e)t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");for(const t of n)t.hidden=!0,t.hasAttribute("tabindex")||t.hasAttribute("data-tab-container-no-tabstop")||t.setAttribute("tabindex","0");r.setAttribute("aria-selected","true"),r.setAttribute("tabindex","0"),r.focus(),i.hidden=!1,this.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:i}}))}}}const rh="undefined"!=typeof globalThis?globalThis:window;try{rh.TabContainerElement=nh.define()}catch(et){if(!(rh.DOMException&&et instanceof DOMException&&"NotSupportedError"===et.name||et instanceof ReferenceError))throw et}const ih=["ariadne-border-slate-500","ariadne-text-slate-600"],sh=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"];for(const t of document.getElementsByTagName("tab-container"))t.addEventListener("tab-container-change",(function(t){var e;const n=t.detail.relatedTarget,r=n.closest("tab-container").firstElementChild,i=r.querySelector('[aria-selected="true"]'),s=null===(e=n.getAttribute("id"))||void 0===e?void 0:e.split("-").slice(1).join("-"),o=r.querySelector(`#${s}`);i.classList.remove(...ih),i.classList.add(...sh),o.classList.add(...ih),o.classList.remove(...sh)}));const oh=["second","minute","hour","day","month","year"];const ah=/^[-+]?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;class lh{constructor(t=0,e=0,n=0,r=0,i=0,s=0,o=0){this.years=t,this.months=e,this.weeks=n,this.days=r,this.hours=i,this.minutes=s,this.seconds=o}abs(){return new lh(Math.abs(this.years),Math.abs(this.months),Math.abs(this.weeks),Math.abs(this.days),Math.abs(this.hours),Math.abs(this.minutes),Math.abs(this.seconds))}static from(t){var e;if("string"==typeof t){const n=String(t).trim(),r=n.startsWith("-")?-1:1,i=null===(e=n.match(ah))||void 0===e?void 0:e.slice(1).map((t=>(Number(t)||0)*r));return i?new lh(...i):new lh}if("object"==typeof t){const{years:e,months:n,weeks:r,days:i,hours:s,minutes:o,seconds:a}=t;return new lh(e,n,r,i,s,o,a)}throw new RangeError("invalid duration")}}function ch(t,e,n){const r=function(t,e){const n=new Date(t);return n.setFullYear(n.getFullYear()+e.years),n.setMonth(n.getMonth()+e.months),n.setDate(n.getDate()+7*e.weeks+e.days),n.setHours(n.getHours()+e.hours),n.setMinutes(n.getMinutes()+e.minutes),n.setSeconds(n.getSeconds()+e.seconds),n}(t,lh.from(n).abs());return!r||Math.abs(Number(r)-Number(t))>Math.abs(Number(t)-Number(e))}var hh,dh,uh,ph,fh,mh,gh,yh=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)},vh=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n};const bh=("undefined"!=typeof globalThis?globalThis:window).HTMLElement||null;class wh extends Event{constructor(t,e,n,r){super("relative-time-updated",{bubbles:!0,composed:!0}),this.oldText=t,this.newText=e,this.oldTitle=n,this.newTitle=r}}function xh(t){if(!t.date)return 1/0;if("elapsed"===t.format){const e=t.precision;if("second"===e)return 1e3;if("minute"===e)return 6e4}const e=Math.abs(Date.now()-t.date.getTime());return e<6e4?1e3:e<36e5?6e4:36e5}const kh=new class{constructor(){this.elements=new Set,this.time=1/0,this.timer=-1}observe(t){if(this.elements.has(t))return;this.elements.add(t);const e=t.date;if(e&&e.getTime()){const e=xh(t),n=Date.now()+e;n<this.time&&(clearTimeout(this.timer),this.timer=setTimeout((()=>this.update()),e),this.time=n)}}unobserve(t){this.elements.has(t)&&this.elements.delete(t)}update(){if(clearTimeout(this.timer),!this.elements.size)return;let t=1/0;for(const e of this.elements)t=Math.min(t,xh(e)),e.update();this.time=Math.min(36e5,t),this.timer=setTimeout((()=>this.update()),this.time),this.time+=Date.now()}};class Sh extends bh{constructor(){super(...arguments),hh.add(this),dh.set(this,!1),uh.set(this,!1),fh.set(this,this.shadowRoot?this.shadowRoot:this.attachShadow?this.attachShadow({mode:"open"}):this)}static get observedAttributes(){return["second","minute","hour","weekday","day","month","year","time-zone-name","prefix","threshold","tense","precision","format","datetime","lang","title"]}get second(){const t=this.getAttribute("second");if("numeric"===t||"2-digit"===t)return t}set second(t){this.setAttribute("second",t||"")}get minute(){const t=this.getAttribute("minute");if("numeric"===t||"2-digit"===t)return t}set minute(t){this.setAttribute("minute",t||"")}get hour(){const t=this.getAttribute("hour");if("numeric"===t||"2-digit"===t)return t}set hour(t){this.setAttribute("hour",t||"")}get weekday(){const t=this.getAttribute("weekday");if("long"===t||"short"===t||"narrow"===t)return t}set weekday(t){this.setAttribute("weekday",t||"")}get day(){var t;const e=null!==(t=this.getAttribute("day"))&&void 0!==t?t:"numeric";if("numeric"===e||"2-digit"===e)return e}set day(t){this.setAttribute("day",t||"")}get month(){var t;const e=null!==(t=this.getAttribute("month"))&&void 0!==t?t:"short";if("numeric"===e||"2-digit"===e||"short"===e||"long"===e||"narrow"===e)return e}set month(t){this.setAttribute("month",t||"")}get year(){var t;const e=this.getAttribute("year");return"numeric"===e||"2-digit"===e?e:this.hasAttribute("year")||(new Date).getUTCFullYear()===(null===(t=this.date)||void 0===t?void 0:t.getUTCFullYear())?void 0:"numeric"}set year(t){this.setAttribute("day",t||"")}get timeZoneName(){const t=this.getAttribute("time-zone-name");if("long"===t||"short"===t||"shortOffset"===t||"longOffset"===t||"shortGeneric"===t||"longGeneric"===t)return t}set timeZoneName(t){this.setAttribute("time-zone-name",t||"")}get prefix(){var t;return null!==(t=this.getAttribute("prefix"))&&void 0!==t?t:"on"}set prefix(t){this.setAttribute("prefix",t)}get threshold(){const t=this.getAttribute("threshold");return t&&(e=t,ah.test(e))?t:"P30D";var e}set threshold(t){this.setAttribute("threshold",t)}get tense(){const t=this.getAttribute("tense");return"past"===t?"past":"future"===t?"future":"auto"}set tense(t){this.setAttribute("tense",t)}get precision(){const t=this.getAttribute("precision");return oh.includes(t)?t:"second"}set precision(t){this.setAttribute("precision",t)}get format(){const t=this.getAttribute("format");return"micro"===t?"micro":"elapsed"===t?"elapsed":"auto"}set format(t){this.setAttribute("format",t)}get datetime(){return this.getAttribute("datetime")||""}set datetime(t){this.setAttribute("datetime",t)}get date(){const t=Date.parse(this.datetime);return Number.isNaN(t)?null:new Date(t)}set date(t){this.datetime=(null==t?void 0:t.toISOString())||""}connectedCallback(){this.update()}disconnectedCallback(){kh.unobserve(this)}attributeChangedCallback(t,e,n){e!==n&&("title"===t&&vh(this,dh,null!==n&&yh(this,hh,"m",mh).call(this)!==n,"f"),yh(this,uh,"f")||"title"===t&&yh(this,dh,"f")||vh(this,uh,(async()=>{await Promise.resolve(),this.update()})(),"f"))}update(){const t=yh(this,fh,"f").textContent||"",e=this.getAttribute("title")||"";let n=e,r=t;const i=new Date;yh(this,dh,"f")||(n=yh(this,hh,"m",mh).call(this)||"",n&&this.setAttribute("title",n)),r=yh(this,hh,"m",gh).call(this,i)||"",r?yh(this,fh,"f").textContent=r:this.shadowRoot===yh(this,fh,"f")&&this.textContent&&(yh(this,fh,"f").textContent=this.textContent),r===t&&n===e||this.dispatchEvent(new wh(t,r,e,n));const s=this.date,o=this.format,a=("auto"===o||"micro"===o)&&s&&ch(i,s,this.threshold);"elapsed"===o||a?kh.observe(this):kh.unobserve(this),vh(this,uh,!1,"f")}}dh=new WeakMap,uh=new WeakMap,fh=new WeakMap,hh=new WeakSet,ph=function(){var t,e;return null!==(e=null===(t=this.closest("[lang]"))||void 0===t?void 0:t.getAttribute("lang"))&&void 0!==e?e:"default"},mh=function(){const t=this.date;if(t&&"undefined"!=typeof Intl&&Intl.DateTimeFormat)return new Intl.DateTimeFormat(yh(this,hh,"a",ph),{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)},gh=function(t=new Date){const e=this.date;if(!e)return;const n=this.format;if("elapsed"===n){const t=oh.indexOf(this.precision)||0,n=function(t){const e=Math.abs(t.getTime()-(new Date).getTime()),n=Math.floor(e/1e3),r=Math.floor(n/60),i=Math.floor(r/60),s=Math.floor(i/24),o=Math.floor(s/30),a=Math.floor(o/12),l=[];return a&&l.push([a,"year"]),o-12*a&&l.push([o-12*a,"month"]),s-30*o&&l.push([s-30*o,"day"]),i-24*s&&l.push([i-24*s,"hour"]),r-60*i&&l.push([r-60*i,"minute"]),n-60*r&&l.push([n-60*r,"second"]),l}(e).filter((e=>oh.indexOf(e[1])>=t));return n.map((([t,e])=>`${t}${e[0]}`)).join(" ")||`0${this.precision[0]}`}const r=this.tense,i="micro"===n,s=t.getTime()<e.getTime(),o=ch(t,e,this.threshold),a=yh(this,hh,"a",ph);if("undefined"!=typeof Intl&&Intl.RelativeTimeFormat){const t=new Intl.RelativeTimeFormat(a,{numeric:"auto"});if("past"===r||"auto"===r&&!s&&o){const[n,r]=i?function(t){const e=(new Date).getTime()-t.getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return r<1?[1,"minute"]:r<60?[r,"minute"]:i<24?[i,"hour"]:s<365?[s,"day"]:[a,"year"]}(e):function(t){const e=(new Date).getTime()-t.getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return e<0||n<10?[0,"second"]:n<45?[-n,"second"]:n<90||r<45?[-r,"minute"]:r<90||i<24?[-i,"hour"]:i<36||s<30?[-s,"day"]:o<18?[-o,"month"]:[-a,"year"]}(e);return i?`${n}${r[0]}`:t.format(n,r)}if("future"===r||"auto"===r&&s&&o){const[n,r]=i?function(t){const e=t.getTime()-(new Date).getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return s>=365?[a,"year"]:i>=24?[s,"day"]:r>=60?[i,"hour"]:r>1?[r,"minute"]:[1,"minute"]}(e):function(t){const e=t.getTime()-(new Date).getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return o>=18||o>=12?[a,"year"]:s>=45||s>=30?[o,"month"]:i>=36||i>=24?[s,"day"]:r>=90||r>=45?[i,"hour"]:n>=90||n>=45?[r,"minute"]:n>=10?[n,"second"]:[0,"second"]}(e);return i?`${n}${r[0]}`:t.format(n,r)}}if("undefined"==typeof Intl||!Intl.DateTimeFormat)return;const l=new Intl.DateTimeFormat(a,{second:this.second,minute:this.minute,hour:this.hour,weekday:this.weekday,day:this.day,month:this.month,year:this.year,timeZoneName:this.timeZoneName});return`${this.prefix} ${l.format(e)}`.trim()};const Oh="undefined"!=typeof globalThis?globalThis:window;try{customElements.define("relative-time",Sh),Oh.RelativeTimeElement=Sh}catch(et){if(!(Oh.DOMException&&et instanceof DOMException&&"NotSupportedError"===et.name||et instanceof ReferenceError))throw et}const Mh=class{constructor(t=document.documentElement,r=_){this.logger=console,this.debug=!1,this.logDebugActivity=(t,e,n={})=>{this.debug&&this.logFormattedMessage(t,e,n)},this.element=t,this.schema=r,this.dispatcher=new e(this),this.router=new j(this),this.actionDescriptorFilters=Object.assign({},n)}static start(t,e){const n=new this(t,e);return n.start(),n}async start(){await new Promise((t=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",(()=>t())):t()})),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(t,e){this.load({identifier:t,controllerConstructor:e})}registerActionOption(t,e){this.actionDescriptorFilters[t]=e}load(t,...e){(Array.isArray(t)?t:[t,...e]).forEach((t=>{t.controllerConstructor.shouldLoad&&this.router.loadDefinition(t)}))}unload(t,...e){(Array.isArray(t)?t:[t,...e]).forEach((t=>this.router.unloadIdentifier(t)))}get controllers(){return this.router.contexts.map((t=>t.controller))}getControllerForElementAndIdentifier(t,e){const n=this.router.getContextForElementAndIdentifier(t,e);return n?n.controller:null}handleError(t,e,n){var r;this.logger.error("%s\n\n%o\n\n%o",e,t,n),null===(r=window.onerror)||void 0===r||r.call(window,e,"",0,0,t)}logFormattedMessage(t,e,n={}){n=Object.assign({application:this},n),this.logger.groupCollapsed(`${t} #${e}`),this.logger.log("details:",Object.assign({},n)),this.logger.groupEnd()}}.start();Mh.register("clipboard-copy-component",class extends X{copy(){const t=this.element.attributes.getNamedItem("value"),e=this.element.attributes.getNamedItem("for");if(t)navigator.clipboard.writeText(t.value);else if(e){const t=document.getElementById(e.value);navigator.clipboard.writeText((null==t?void 0:t.textContent)||"")}else navigator.clipboard.writeText(this.element.textContent||"")}}),Mh.register("ariadne-form",Bt),Mh.register("rich-text-area-component",jl),Mh.register("slideover-component",_l),Mh.register("tab-nav-component",Kl),Mh.register("tooltip-component",th),Mh.register("toggleable",oe),Mh.register("accumulator",re),Mh.register("options",ne),Mh.register("string-match",ee),Mh.register("events",class extends X{stopPropagation(t){t.stopPropagation()}});
7
+ var Z;X.blessings=[function(t){return O(t,"classes").reduce(((t,e)=>{return Object.assign(t,{[`${n=e}Class`]:{get(){const{classes:t}=this;if(t.has(n))return t.get(n);{const e=t.getAttributeName(n);throw new Error(`Missing attribute "${e}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${a(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(t){return O(t,"targets").reduce(((t,e)=>{return Object.assign(t,{[`${n=e}Target`]:{get(){const t=this.targets.find(n);if(t)return t;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${a(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(t){const e=M(t,"values"),n={valueDescriptorMap:{get(){return e.reduce(((t,e)=>{const n=W(e,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(t,{[r]:n})}),{})}}};return e.reduce(((t,e)=>Object.assign(t,function(t,e){const n=W(t,e),{key:r,name:i,reader:s,writer:o}=n;return{[i]:{get(){const t=this.data.get(r);return null!==t?s(t):n.defaultValue},set(t){void 0===t?this.data.delete(r):this.data.set(r,o(t))}},[`has${a(i)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(e))),n)},function(t){return O(t,"outlets").reduce(((t,e)=>Object.assign(t,function(t){const e=o(t);return{[`${e}Outlet`]:{get(){const e=this.outlets.find(t);if(e){const n=this.application.getControllerForElementAndIdentifier(e,t);if(n)return n;throw new Error(`Missing "data-controller=${t}" attribute on outlet element for "${this.identifier}" controller`)}throw new Error(`Missing outlet element "${t}" for "${this.identifier}" controller`)}},[`${e}Outlets`]:{get(){const e=this.outlets.findAll(t);return e.length>0?e.map((e=>{const n=this.application.getControllerForElementAndIdentifier(e,t);if(n)return n;console.warn(`The provided outlet element is missing the outlet controller "${t}" for "${this.identifier}"`,e)})).filter((t=>t)):[]}},[`${e}OutletElement`]:{get(){const e=this.outlets.find(t);if(e)return e;throw new Error(`Missing outlet element "${t}" for "${this.identifier}" controller`)}},[`${e}OutletElements`]:{get(){return this.outlets.findAll(t)}},[`has${a(e)}Outlet`]:{get(){return this.outlets.has(t)}}}}(e))),{})}],X.targets=[],X.outlets=[],X.values={};const Q=window,tt=Q.trustedTypes,et=tt?tt.createPolicy("lit-html",{createHTML:t=>t}):void 0,nt="$lit$",rt=`lit$${(Math.random()+"").slice(9)}$`,it="?"+rt,st=`<${it}>`,ot=document,at=()=>ot.createComment(""),lt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ct=Array.isArray,ht="[ \t\n\f\r]",dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ut=/-->/g,pt=/>/g,ft=RegExp(`>|${ht}(?:([^\\s"'>=/]+)(${ht}*=${ht}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),mt=/'/g,gt=/"/g,yt=/^(?:script|style|textarea|title)$/i,vt=(t=>(e,...n)=>({_$litType$:t,strings:e,values:n}))(1),bt=Symbol.for("lit-noChange"),wt=Symbol.for("lit-nothing"),xt=new WeakMap,kt=ot.createTreeWalker(ot,129,null,!1),St=(t,e)=>{const n=t.length-1,r=[];let i,s=2===e?"<svg>":"",o=dt;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,h=0;for(;h<n.length&&(o.lastIndex=h,l=o.exec(n),null!==l);)h=o.lastIndex,o===dt?"!--"===l[1]?o=ut:void 0!==l[1]?o=pt:void 0!==l[2]?(yt.test(l[2])&&(i=RegExp("</"+l[2],"g")),o=ft):void 0!==l[3]&&(o=ft):o===ft?">"===l[0]?(o=null!=i?i:dt,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?ft:'"'===l[3]?gt:mt):o===gt||o===mt?o=ft:o===ut||o===pt?o=dt:(o=ft,i=void 0);const d=o===ft&&t[e+1].startsWith("/>")?" ":"";s+=o===dt?n+st:c>=0?(r.push(a),n.slice(0,c)+nt+n.slice(c)+rt+d):n+rt+(-2===c?(r.push(void 0),e):d)}const a=s+(t[n]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==et?et.createHTML(a):a,r]};class Ot{constructor({strings:t,_$litType$:e},n){let r;this.parts=[];let i=0,s=0;const o=t.length-1,a=this.parts,[l,c]=St(t,e);if(this.el=Ot.createElement(l,n),kt.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(r=kt.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes()){const t=[];for(const e of r.getAttributeNames())if(e.endsWith(nt)||e.startsWith(rt)){const n=c[s++];if(t.push(e),void 0!==n){const t=r.getAttribute(n.toLowerCase()+nt).split(rt),e=/([.?@])?(.*)/.exec(n);a.push({type:1,index:i,name:e[2],strings:t,ctor:"."===e[1]?Tt:"?"===e[1]?Dt:"@"===e[1]?$t:Ct})}else a.push({type:6,index:i})}for(const e of t)r.removeAttribute(e)}if(yt.test(r.tagName)){const t=r.textContent.split(rt),e=t.length-1;if(e>0){r.textContent=tt?tt.emptyScript:"";for(let n=0;n<e;n++)r.append(t[n],at()),kt.nextNode(),a.push({type:2,index:++i});r.append(t[e],at())}}}else if(8===r.nodeType)if(r.data===it)a.push({type:2,index:i});else{let t=-1;for(;-1!==(t=r.data.indexOf(rt,t+1));)a.push({type:7,index:i}),t+=rt.length-1}i++}}static createElement(t,e){const n=ot.createElement("template");return n.innerHTML=t,n}}function Mt(t,e,n=t,r){var i,s,o,a;if(e===bt)return e;let l=void 0!==r?null===(i=n._$Co)||void 0===i?void 0:i[r]:n._$Cl;const c=lt(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(s=null==l?void 0:l._$AO)||void 0===s||s.call(l,!1),void 0===c?l=void 0:(l=new c(t),l._$AT(t,n,r)),void 0!==r?(null!==(o=(a=n)._$Co)&&void 0!==o?o:a._$Co=[])[r]=l:n._$Cl=l),void 0!==l&&(e=Mt(t,l._$AS(t,e.values),l,r)),e}class At{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:n},parts:r}=this._$AD,i=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:ot).importNode(n,!0);kt.currentNode=i;let s=kt.nextNode(),o=0,a=0,l=r[0];for(;void 0!==l;){if(o===l.index){let e;2===l.type?e=new Et(s,s.nextSibling,this,t):1===l.type?e=new l.ctor(s,l.name,l.strings,this,t):6===l.type&&(e=new It(s,this,t)),this._$AV.push(e),l=r[++a]}o!==(null==l?void 0:l.index)&&(s=kt.nextNode(),o++)}return kt.currentNode=ot,i}v(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class Et{constructor(t,e,n,r){var i;this.type=2,this._$AH=wt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=r,this._$Cp=null===(i=null==r?void 0:r.isConnected)||void 0===i||i}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Mt(this,t,e),lt(t)?t===wt||null==t||""===t?(this._$AH!==wt&&this._$AR(),this._$AH=wt):t!==this._$AH&&t!==bt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>ct(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==wt&&lt(this._$AH)?this._$AA.nextSibling.data=t:this.$(ot.createTextNode(t)),this._$AH=t}g(t){var e;const{values:n,_$litType$:r}=t,i="number"==typeof r?this._$AC(t):(void 0===r.el&&(r.el=Ot.createElement(r.h,this.options)),r);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.v(n);else{const t=new At(i,this),e=t.u(this.options);t.v(n),this.$(e),this._$AH=t}}_$AC(t){let e=xt.get(t.strings);return void 0===e&&xt.set(t.strings,e=new Ot(t)),e}T(t){ct(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,r=0;for(const i of t)r===e.length?e.push(n=new Et(this.k(at()),this.k(at()),this,this.options)):n=e[r],n._$AI(i),r++;r<e.length&&(this._$AR(n&&n._$AB.nextSibling,r),e.length=r)}_$AR(t=this._$AA.nextSibling,e){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class Ct{constructor(t,e,n,r,i){this.type=1,this._$AH=wt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=i,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=wt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,n,r){const i=this.strings;let s=!1;if(void 0===i)t=Mt(this,t,e,0),s=!lt(t)||t!==this._$AH&&t!==bt,s&&(this._$AH=t);else{const r=t;let o,a;for(t=i[0],o=0;o<i.length-1;o++)a=Mt(this,r[n+o],e,o),a===bt&&(a=this._$AH[o]),s||(s=!lt(a)||a!==this._$AH[o]),a===wt?t=wt:t!==wt&&(t+=(null!=a?a:"")+i[o+1]),this._$AH[o]=a}s&&!r&&this.j(t)}j(t){t===wt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Tt extends Ct{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===wt?void 0:t}}const Nt=tt?tt.emptyScript:"";class Dt extends Ct{constructor(){super(...arguments),this.type=4}j(t){t&&t!==wt?this.element.setAttribute(this.name,Nt):this.element.removeAttribute(this.name)}}class $t extends Ct{constructor(t,e,n,r,i){super(t,e,n,r,i),this.type=5}_$AI(t,e=this){var n;if((t=null!==(n=Mt(this,t,e,0))&&void 0!==n?n:wt)===bt)return;const r=this._$AH,i=t===wt&&r!==wt||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,s=t!==wt&&(r===wt||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==n?n:this.element,t):this._$AH.handleEvent(t)}}class It{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){Mt(this,t)}}const Rt=Q.litHtmlPolyfillSupport;null==Rt||Rt(Ot,Et),(null!==(Z=Q.litHtmlVersions)&&void 0!==Z?Z:Q.litHtmlVersions=[]).push("2.7.4");class Bt extends X{constructor(){super(...arguments),this.onBlur=t=>{this.validateField(t.target)},this.onSubmit=t=>{var e;this.validateForm()||(t.preventDefault(),null===(e=this.firstInvalidField)||void 0===e||e.focus())},this.getRenderString=t=>{const{strings:e,values:n}=t,r=[...n,""].map((t=>"object"==typeof t?this.getRenderString(t):t));return e.reduce(((t,e,n)=>t+e+r[n]),"")}}connect(){this.element.setAttribute("novalidate","true"),this.element.addEventListener("blur",this.onBlur,!0),this.element.addEventListener("submit",this.onSubmit),this.element.addEventListener("ajax:beforeSend",this.onSubmit)}disconnect(){this.element.removeEventListener("blur",this.onBlur),this.element.removeEventListener("submit",this.onSubmit),this.element.removeEventListener("ajax:beforeSend",this.onSubmit)}validateForm(){let t=!0;for(const e of this.formFields)this.shouldValidateField(e)&&!this.validateField(e)&&(t=!1);return t}validateField(t){if(!this.shouldValidateField(t))return!0;const e=t.checkValidity();return t.classList.toggle("invalid",!e),this.refreshErrorForInvalidField(t,e),e}shouldValidateField(t){return!t.disabled&&!t.classList.contains("ProseMirror")&&!["file","reset","submit","button"].includes(t.type)}refreshErrorForInvalidField(t,e){this.removeExistingErrorMessage(t),e||this.showErrorForInvalidField(t)}removeExistingErrorMessage(t){var e;const n=t.closest(".field");if(!n)return;const r=n.querySelector(".error");r&&(null===(e=null==r?void 0:r.parentNode)||void 0===e||e.removeChild(r))}showErrorForInvalidField(t){t.insertAdjacentHTML("afterend",this.buildFieldErrorHtml(t))}buildFieldErrorHtml(t){const e=vt`<p class="error">${t.validationMessage}</p>`;return this.getRenderString(e)}get formFields(){return Array.from(this.formFieldTargets)}get firstInvalidField(){return this.formFields.find((t=>!t.checkValidity()))}}function Ft(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}var Pt,Vt,Lt,zt,jt,_t,Kt,Wt,Ht,qt,Jt,Ut,Gt,Yt,Xt,Zt;Bt.targets=["formField"],"function"==typeof SuppressedError&&SuppressedError;class Qt extends X{constructor(){super(...arguments),Pt.add(this),this.outletEventsLookup=null,this.eventRecords=new Map}getOutlets(){return null}outletUpdate(t,e){}getState(){return null}connect(){this.syncOutlets()}syncOutlets(){const t=new Event("init");this.sendToOutlets(t,{data:this.getState(),eventKey:this.getEventKey(t)})}sendToOutlets(t,e={}){var n;const r=null!==(n=e.eventKey)&&void 0!==n?n:this.getEventKey(t),i=Ft(this,Pt,"a",Vt);if(null==i?void 0:i.length)for(const n in i){const s=i[n];if(s.isListeningForOutletEvent(r)&&!this.hasHeardEvent(t)){const n=this.identifier===s.identifier;s.outletUpdate(t,{eventKey:r,data:n?e.data:void 0})}}}isListeningForOutletEvent(t){const e=t.split("-");if(!e.length)return!1;let n=this.outletEvents;for(let t=0;t<e.length;t++){const r=e[t];if("boolean"==typeof n)return n;let i=r;if(void 0!==n["*"])i="*";else{const t=void 0!==n.domEvent;if(t&&!this.isDOMEventName(r))return!1;t&&(i="domEvent")}if(!n[i])return!1;n=n[i]}return!0}isDOMEventName(t){return Qt.domEvents[t]}getEventKey(t){const e=this.event_key_prefix,n=this.event_key_postfix,r=e?"-":"",i=null!=e?e:"",s=n?"-":"",o=null!=n?n:"";return`${this.identifier}-${i}${r}${t.type}${s}${o}`}hasHeardEvent(t){return!!this.eventRecords.has(t)||(this.eventRecords.set(t,!0),setTimeout((()=>this.eventRecords.delete(t))),!1)}get event_key_prefix(){return""}get event_key_postfix(){return""}get outletEvents(){return!this.outletEventsLookup&&this.hasOutletEventsValue?this.outletEventsLookup=this.outletEventsValue.reduce(((t,e)=>{let n=t;return e.split("-").forEach(((t,e,r)=>{"boolean"!=typeof n&&(e===r.length-1?n[t]=!0:void 0===n[t]&&(n[t]={}),n=n[t])})),t}),{}):this.outletEventsLookup||(this.outletEventsLookup={"*":!0}),this.outletEventsLookup}}Pt=new WeakSet,Vt=function(){const t=this.getOutlets();if(t)return t;const e=[];return this.hasToggleableOutlet&&e.push(...this.toggleableOutlets),this.hasOptionsOutlet&&e.push(...this.optionsOutlets),this.hasStringMatchOutlet&&e.push(...this.stringMatchOutlets),e},Qt.values={outletEvents:Array},Qt.outlets=["toggleable","options","string-match"],Qt.domEvents={abort:!0,afterprint:!0,animationend:!0,animationiteration:!0,animationstart:!0,beforeprint:!0,beforeunload:!0,blur:!0,canplay:!0,canplaythrough:!0,change:!0,click:!0,contextmenu:!0,copy:!0,cut:!0,dblclick:!0,drag:!0,dragend:!0,dragenter:!0,dragleave:!0,dragover:!0,dragstart:!0,drop:!0,durationchange:!0,ended:!0,error:!0,focus:!0,focusin:!0,focusout:!0,fullscreenchange:!0,fullscreenerror:!0,hashchange:!0,input:!0,invalid:!0,keydown:!0,keypress:!0,keyup:!0,load:!0,loadeddata:!0,loadedmetadata:!0,loadstart:!0,message:!0,mousedown:!0,mouseenter:!0,mouseleave:!0,mousemove:!0,mouseover:!0,mouseout:!0,mouseup:!0,mousewheel:!0,offline:!0,online:!0,open:!0,pagehide:!0,pageshow:!0,paste:!0,pause:!0,play:!0,playing:!0,popstate:!0,progress:!0,ratechange:!0,resize:!0,reset:!0,scroll:!0,search:!0,seeked:!0,seeking:!0,select:!0,show:!0,stalled:!0,storage:!0,submit:!0,suspend:!0,timeupdate:!0,toggle:!0,touchcancel:!0,touchend:!0,touchmove:!0,touchstart:!0,transitionend:!0,unload:!0,volumechange:!0,waiting:!0,wheel:!0};class te extends Qt{constructor(){super(...arguments),Lt.add(this),this.syncedAttrsLookup=null,this.antiAttrsLookup=null}getValueForElement(t){return null}getElementsToSync(){return[]}connect(){this.syncElementAttributes()}updateAttributesForElement(t,e){this.hasSyncedAttrsValue&&Ft(this,Lt,"m",Kt).call(this,t,this.syncedAttrsValue,e),this.hasAntiAttrsValue&&Ft(this,Lt,"m",Kt).call(this,t,this.antiAttrsValue,!e)}syncElementAttributes(){var t;this.syncOutlets();const e=this.getElementsToSync();if(null==e?void 0:e.length)for(let n in e){const r=e[n],i=null!==(t=this.getValueForElement(r))&&void 0!==t&&t;this.updateAttributesForElement(r,i)}}validateAttrChange(t){const{target:e,detail:n}=t;if(e&&n){null!==this.getValueForElement(e)&&this.protectAttrsValue&&Ft(this,Lt,"m",_t).call(this,n.attr)&&t.preventDefault()}}}Lt=new WeakSet,zt=function(t){var e;return null===this.syncedAttrsLookup&&(this.syncedAttrsLookup=Ft(this,Lt,"m",Wt).call(this,this.syncedAttrsValue)),null!==(e=this.syncedAttrsLookup[t])&&void 0!==e&&e},jt=function(t){var e;return null===this.antiAttrsLookup&&(this.antiAttrsLookup=Ft(this,Lt,"m",Wt).call(this,this.antiAttrsValue)),null!==(e=this.antiAttrsLookup[t])&&void 0!==e&&e},_t=function(t){return Ft(this,Lt,"m",jt).call(this,t)||Ft(this,Lt,"m",zt).call(this,t)},Kt=function(t,e,n){const r=JSON.stringify(n);for(let i in e){const s=e[i];this.dispatch("attrChange",{target:t,detail:{attr:s,value:n}}).defaultPrevented||("false"===r&&te.removeOnFalseAttrs[s]?t.removeAttribute(s):t.setAttribute(s,r))}},Wt=function(t){return(null==t?void 0:t.length)?t.reduce(((t,e)=>(t[e]=!0,t)),{}):{}},te.values=Object.assign(Object.assign({},Qt.values),{syncedAttrs:Array,antiAttrs:Array,protectAttrs:Boolean}),te.removeOnFalseAttrs={checked:!0};class ee extends te{constructor(){super(...arguments),Ht.add(this),this.outletUpdate=this.change}change(t,e={}){var n;const r=null!==(n=e.data)&&void 0!==n?n:t.currentTarget.value;this.keywordValue=r,Ft(this,Ht,"m",qt).call(this),this.sendToOutlets(t,Object.assign(Object.assign({},e),{data:this.keywordValue}))}getElementsToSync(){return this.matchTargets}getValueForElement(t){var e,n;return null!==(n=null===(e=t.innerText)||void 0===e?void 0:e.toLowerCase().includes(this.keywordValue.toLowerCase()))&&void 0!==n&&n}getState(){return this.keywordValue}}Ht=new WeakSet,qt=function(){if(this.hasMatchTarget){let t=!1;for(let e in this.matchTargets){const n=this.matchTargets[e],r=this.getValueForElement(n);this.updateAttributesForElement(n,r),r&&(t=!0)}this.hasEmptyTarget&&this.emptyTarget.setAttribute("aria-hidden",String(t))}},ee.outlets=te.outlets,ee.targets=["match","empty"],ee.values=Object.assign(Object.assign({},te.values),{keyword:String});class ne extends te{constructor(){super(...arguments),Jt.add(this),this.optionTargetLookup=new Map,this.outletUpdate=this.select}connect(){Ft(this,Jt,"m",Zt).call(this),this.syncElementAttributes()}select(t,e={}){var n;const r=e.data;for(let e in this.optionTargets){const i=this.optionTargets[e],s=i===t.currentTarget,o=null!==(n=this.getValueForElement(i))&&void 0!==n&&n,a=Ft(this,Jt,"m",Xt).call(this,i);if(void 0!==r?!!r[a]!==o:Ft(this,Jt,"m",Ut).call(this,o,s)){const t=!o;this.updateAttributesForElement(i,t),t?Ft(this,Jt,"m",Gt).call(this,a):Ft(this,Jt,"m",Yt).call(this,a)}}this.sendToOutlets(t,Object.assign(Object.assign({},e),{data:this.activeOptionsValue}))}getValueForElement(t){var e;if(!this.optionTargetLookup.has(t))return null;const n=Ft(this,Jt,"m",Xt).call(this,t);return null!==(e=this.activeOptionsValue[n])&&void 0!==e&&e}getState(){return this.activeOptionsValue}}Jt=new WeakSet,Ut=function(t,e){return!(!e&&!t)&&(!(!e&&t&&this.isMultiValue)&&!(e&&t&&!this.toggleableValue))},Gt=function(t){this.activeOptionsValue=Object.assign(Object.assign({},this.activeOptionsValue),{[t]:!0})},Yt=function(t){const e=Object.assign({},this.activeOptionsValue);delete e[t],this.activeOptionsValue=e},Xt=function(t){const e=t.getAttribute("data-option-value");return e||t.innerText.trim()},Zt=function(){this.optionTargetLookup=new Map;for(let t in this.optionTargets){const e=this.optionTargets[t],n=Ft(this,Jt,"m",Xt).call(this,e);this.optionTargetLookup.set(e,n);if(!!this.syncedAttrsValue.find((t=>"true"===e.getAttribute(t))))Ft(this,Jt,"m",Gt).call(this,n);else{!!this.antiAttrsValue.find((t=>"false"===e.getAttribute(t)))&&Ft(this,Jt,"m",Gt).call(this,n)}}},ne.outlets=te.outlets,ne.targets=["option"],ne.values=Object.assign(Object.assign({},te.values),{activeOptions:Object,isMulti:{type:Boolean,default:!1},toggleable:{type:Boolean,default:!1}});class re extends X{connect(){this.accumulate()}accumulate(){let t=0;for(let e in this.sumTargets){const n=this.sumTargets[e],r=Number(n.getAttribute(this.sumAttrValue));isNaN(r)||(t+=r)}this.setAttributesTo(t)}setAttributesTo(t){for(let e in this.syncAttrsValue){const n=this.syncAttrsValue[e];this.accumulator.setAttribute(n,t.toString())}}get accumulator(){var t;return null!==(t=this.accumulatorTarget)&&void 0!==t?t:this.element}}re.targets=["sum","accumulator"],re.values={syncAttrs:{type:Array,default:["aria-valuenow"]},sumAttr:{type:"string",default:"data-value"}};const ie={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},se=(t,e={})=>{const n=t,{onlyVisible:r,dispatchEvent:i,events:s,eventPrefix:o}=Object.assign({},ie,e),a=t=>{const s=(null==e?void 0:e.element)||n.element;if(!(s.contains(t.target)||!function(t){const e=t.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,r=window.innerWidth||document.documentElement.clientWidth,i=e.top<=n&&e.top+e.height>0,s=e.left<=r&&e.left+e.width>0;return i&&s}(s)&&r)&&(n.clickOutside&&n.clickOutside(t),i)){const e=((t,e,n)=>{let r=t;return!0===n?r=`${e.identifier}:${t}`:"string"==typeof n&&(r=`${n}:${t}`),r})("click:outside",n,o),r=((t,e,n)=>{const{bubbles:r,cancelable:i,composed:s}=e||{bubbles:!0,cancelable:!0,composed:!0};return e&&Object.assign(n,{originalEvent:e}),new CustomEvent(t,{bubbles:r,cancelable:i,composed:s,detail:n})})(e,t,{controller:n});s.dispatchEvent(r)}},l=()=>{null==s||s.forEach((t=>{window.addEventListener(t,a,!0)}))},c=()=>{null==s||s.forEach((t=>{window.removeEventListener(t,a,!0)}))},h=n.disconnect.bind(n);return Object.assign(n,{disconnect(){c(),h()}}),l(),[l,c]};(class extends X{}).debounces=[];(class extends X{}).throttles=[];class oe extends te{constructor(){super(...arguments),this.outletUpdate=this.toggle}connect(){this.syncElementAttributes(),se(this,{dispatchEvent:this.closeOnOutsideClickValue&&this.stateValue})}toggle(t,e={}){var n;const r=null!==(n=e.data)&&void 0!==n?n:!this.stateValue;this.updateAttributesForElement(this.element,r),this.stateValue=r,this.sendToOutlets(t,Object.assign(Object.assign({},e),{data:r}))}on(t){this.toggle(t,{data:!0})}off(t){this.toggle(t,{data:!1})}clickOutside(t){this.closeOnOutsideClickValue&&this.stateValue&&this.toggle(t,{data:!1})}getValueForElement(t){return t!==this.element?null:this.stateValue}getElementsToSync(){return[this.element]}getState(){return this.stateValue}get event_key_postfix(){return this.stateValue?"on":"off"}}oe.outlets=te.outlets,oe.values=Object.assign(Object.assign({},te.values),{state:{type:Boolean,default:!1},closeOnOutsideClick:{type:Boolean,default:!1}});function ae(t){this.content=t}function le(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let t=0;i.text[t]==s.text[t];t++)n++;return n}if(i.content.size||s.content.size){let t=le(i.content,s.content,n+1);if(null!=t)return t}n+=i.nodeSize}else n+=i.nodeSize}}function ce(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o!=a){if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let t=0,e=Math.min(o.text.length,a.text.length);for(;t<e&&o.text[o.text.length-t-1]==a.text[a.text.length-t-1];)t++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let t=ce(o.content,a.content,n-1,r-1);if(t)return t}n-=l,r-=l}else n-=l,r-=l}}ae.prototype={constructor:ae,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return-1==i?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new ae(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new ae(n)},addToStart:function(t,e){return new ae([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ae(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(-1==s?i.length:s,0,e,n),new ae(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=ae.from(t)).size?new ae(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=ae.from(t)).size?new ae(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ae.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},get size(){return this.content.length>>1}},ae.from=function(t){if(t instanceof ae)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ae(e)};class he{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,r=0,i){for(let s=0,o=0;o<e;s++){let a=this.content[s],l=o+a.nodeSize;if(l>t&&!1!==n(a,r+o,i||null,s)&&a.content.size){let i=o+1;a.nodesBetween(Math.max(0,t-i),Math.min(a.content.size,e-i),n,r+i)}o=l}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let i="",s=!0;return this.nodesBetween(t,e,((o,a)=>{o.isText?(i+=o.text.slice(Math.max(t,a)-a,e-a),s=!n):o.isLeaf?(r?i+="function"==typeof r?r(o):r:o.type.spec.leafText&&(i+=o.type.spec.leafText(o)),s=!n):!s&&o.isBlock&&(i+=n,s=!0)}),0),i}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),i=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),i=1);i<t.content.length;i++)r.push(t.content[i]);return new he(r,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],r=0;if(e>t)for(let i=0,s=0;s<e;i++){let o=this.content[i],a=s+o.nodeSize;a>t&&((s<t||a>e)&&(o=o.isText?o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s)):o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))),n.push(o),r+=o.nodeSize),s=a}return new he(n,r)}cutByIndex(t,e){return t==e?he.empty:0==t&&e==this.content.length?this:new he(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice(),i=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new he(r,i)}addToStart(t){return new he([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new he(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))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(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return le(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return ce(this,t,e,n)}findIndex(t,e=-1){if(0==t)return ue(0,t);if(t==this.size)return ue(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=r+this.child(n).nodeSize;if(i>=t)return i==t||e>0?ue(n+1,i):ue(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return he.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new he(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return he.empty;let e,n=0;for(let r=0;r<t.length;r++){let i=t[r];n+=i.nodeSize,r&&i.isText&&t[r-1].sameMarkup(i)?(e||(e=t.slice(0,r)),e[e.length-1]=i.withText(e[e.length-1].text+i.text)):e&&e.push(i)}return new he(e||t,n)}static from(t){if(!t)return he.empty;if(t instanceof he)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new he([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}he.empty=new he([],0);const de={index:0,offset:0};function ue(t,e){return de.index=t,de.offset=e,de}function pe(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!pe(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!pe(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}class fe{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(this.eq(i))return t;if(this.type.excludes(i.type))e||(e=t.slice(0,r));else{if(i.type.excludes(this.type))return t;!n&&i.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(i)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&pe(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);return n.create(e.attrs)}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return fe.none;if(t instanceof fe)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}fe.none=[];class me extends Error{}class ge{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=ve(this.content,t+this.openStart,e);return n&&new ge(n,this.openStart,this.openEnd)}removeBetween(t,e){return new ge(ye(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return ge.empty;let n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new ge(he.fromJSON(t,e.content),n,r)}static maxOpen(t,e=!0){let n=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)r++;return new ge(t,n,r)}}function ye(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(ye(s.content,e-i-1,n-i-1)))}function ve(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=ve(o.content,e-s-1,n);return a&&t.replaceChild(i,o.copy(a))}function be(t,e,n){if(n.openStart>t.depth)throw new me("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new me("Inconsistent open depths");return we(t,e,n,0)}function we(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=we(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){let{start:i,end:o}=function(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)r=e.node(t).copy(he.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return Me(s,Ae(t,i,o,e,r))}{let r=t.parent,i=r.content;return Me(r,i.cut(0,t.parentOffset).append(n.content).append(i.cut(e.parentOffset)))}}return Me(s,Ee(t,e,r))}function xe(t,e){if(!e.type.compatibleContent(t.type))throw new me("Cannot join "+e.type.name+" onto "+t.type.name)}function ke(t,e,n){let r=t.node(n);return xe(r,e.node(n)),r}function Se(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Oe(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Se(t.nodeAfter,r),s++));for(let t=s;t<o;t++)Se(i.child(t),r);e&&e.depth==n&&e.textOffset&&Se(e.nodeBefore,r)}function Me(t,e){return t.type.checkContent(e),t.copy(e)}function Ae(t,e,n,r,i){let s=t.depth>i&&ke(t,e,i+1),o=r.depth>i&&ke(n,r,i+1),a=[];return Oe(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(xe(s,o),Se(Me(s,Ae(t,e,n,r,i+1)),a)):(s&&Se(Me(s,Ee(t,e,i+1)),a),Oe(e,n,i,a),o&&Se(Me(o,Ee(n,r,i+1)),a)),Oe(r,null,i,a),new he(a)}function Ee(t,e,n){let r=[];if(Oe(null,t,n,r),t.depth>n){Se(Me(ke(t,e,n+1),Ee(t,e,n+1)),r)}return Oe(e,null,n,r),new he(r)}ge.empty=new ge(he.empty,0,0);class Ce{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)r+=n.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return fe.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){let t=n;n=r,r=t}let i=n.marks;for(var s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,r=t.parent.maybeChild(t.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new $e(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],r=0,i=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(i),o=i-s;if(n.push(e,t,r+s),!o)break;if(e=e.child(t),e.isText)break;i=o-1,r+=s+1}return new Ce(e,n,i)}static resolveCached(t,e){for(let n=0;n<Te.length;n++){let r=Te[n];if(r.pos==e&&r.doc==t)return r}let n=Te[Ne]=Ce.resolve(t,e);return Ne=(Ne+1)%De,n}}let Te=[],Ne=0,De=12;class $e{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Ie=Object.create(null);class Re{constructor(t,e,n,r=fe.none){this.type=t,this.attrs=e,this.marks=r,this.content=n||he.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,r=0){this.content.nodesBetween(t,e,n,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,r){return this.content.textBetween(t,e,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&pe(this.attrs,e||t.defaultAttrs||Ie)&&fe.sameSet(this.marks,n||fe.none)}copy(t=null){return t==this.content?this:new Re(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Re(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return ge.empty;let r=this.resolve(t),i=this.resolve(e),s=n?0:r.sharedDepth(e),o=r.start(s),a=r.node(s).content.cut(r.pos-o,i.pos-o);return new ge(a,r.depth-s,i.depth-s)}replace(t,e,n){return be(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:r}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let r=this.content.child(e-1);return{node:r,index:e-1,offset:n-r.nodeSize}}resolve(t){return Ce.resolveCached(this,t)}resolveNoCache(t){return Ce.resolve(this,t)}rangeHasMark(t,e,n){let r=!1;return e>t&&this.nodesBetween(t,e,(t=>(n.isInSet(t.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Fe(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=he.empty,r=0,i=n.childCount){let s=this.contentMatchAt(t).matchFragment(n,r,i),o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let t=r;t<i;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(t).matchType(n),s=i&&i.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);let t=fe.none;for(let e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!fe.sameSet(t,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 t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let r=he.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)}}Re.prototype.text=void 0;class Be extends Re{constructor(t,e,n,r){if(super(t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Fe(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new Be(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new Be(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function Fe(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Pe{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new Ve(t,e);if(null==n.next)return Pe.empty;let r=Le(n);n.next&&n.err("Unexpected trailing text");let i=function(t){let e=Object.create(null);return n(He(t,0));function n(r){let i=[];r.forEach((e=>{t[e].forEach((({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);He(t,n).forEach((t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)}))}))}));let s=e[r.join(",")]=new Pe(r.indexOf(t.length-1)>-1);for(let t=0;t<i.length;t++){let r=i[t][1].sort(We);s.next.push({type:i[t][0],next:e[r.join(",")]||n(r)})}return s}}(function(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){let i={term:r,to:n};return e[t].push(i),i}function i(t,e){t.forEach((t=>t.to=e))}function s(t,e){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(s(n,e))),[]);if("seq"!=t.type){if("star"==t.type){let o=n();return r(e,o),i(s(t.expr,o),o),[r(o)]}if("plus"==t.type){let o=n();return i(s(t.expr,e),o),i(s(t.expr,o),o),[r(o)]}if("opt"==t.type)return[r(e)].concat(s(t.expr,e));if("range"==t.type){let o=e;for(let e=0;e<t.min;e++){let e=n();i(s(t.expr,o),e),o=e}if(-1==t.max)i(s(t.expr,o),o);else for(let e=t.min;e<t.max;e++){let e=n();r(o,e),i(s(t.expr,o),e),o=e}return[r(o)]}if("name"==t.type)return[r(e,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=s(t.exprs[r],e);if(r==t.exprs.length-1)return o;i(o,e=n())}}}(r));return function(t,e){for(let n=0,r=[t];n<r.length;n++){let t=r[n],i=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:n,next:o}=t.next[e];s.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,n),i}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let i=e;r&&i<n;i++)r=r.matchType(t.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];return function i(s,o){let a=s.matchFragment(t,n);if(a&&(!e||a.validEnd))return he.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:n}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let t=i(n,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<i.next.length;t++){let{type:s,next:o}=i.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let r=0;r<n.next.length;r++)-1==t.indexOf(n.next[r].next)&&e(n.next[r].next)}(this),t.map(((e,n)=>{let r=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)r+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return r})).join("\n")}}Pe.empty=new Pe(!0);class Ve{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Le(t){let e=[];do{e.push(ze(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function ze(t){let e=[];do{e.push(je(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function je(t){let e=function(t){if(t.eat("(")){let e=Le(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let t in n){let r=n[t];r.groups.indexOf(e)>-1&&i.push(r)}0==i.length&&t.err("No node type or group '"+e+"' found");return i}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=Ke(t,e)}return e}function _e(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Ke(t,e){let n=_e(t),r=n;return t.eat(",")&&(r="}"!=t.next?_e(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function We(t,e){return e-t}function He(t,e){let n=[];return function e(r){let i=t[r];if(1==i.length&&!i[0].term)return e(i[0].to);n.push(r);for(let t=0;t<i.length;t++){let{term:r,to:s}=i[t];r||-1!=n.indexOf(s)||e(s)}}(e),n.sort(We)}function qe(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Je(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(void 0===i){let e=t[r];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=e.default}n[r]=i}return n}function Ue(t){let e=Object.create(null);if(t)for(let n in t)e[n]=new Ye(t[n]);return e}class Ge{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Ue(n.attrs),this.defaultAttrs=qe(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Pe.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Je(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Re(this,this.computeAttrs(t),he.from(e),fe.setFrom(n))}createChecked(t=null,e,n){return e=he.from(e),this.checkContent(e),new Re(this,this.computeAttrs(t),e,fe.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=he.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e),i=r&&r.fillBefore(he.empty,!0);return i?new Re(this,t,e.append(i),fe.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:fe.none:t}static compile(t,e){let n=Object.create(null);t.forEach(((t,r)=>n[t]=new Ge(t,e,r)));let r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let t in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class Ye{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default}get isRequired(){return!this.hasDefault}}class Xe{constructor(t,e,n,r){this.name=t,this.rank=e,this.schema=n,this.spec=r,this.attrs=Ue(r.attrs),this.excluded=null;let i=qe(this.attrs);this.instance=i?new fe(this,i):null}create(t=null){return!t&&this.instance?this.instance:new fe(this,Je(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;return t.forEach(((t,i)=>n[t]=new Xe(t,r++,e,i))),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}excludes(t){return this.excluded.indexOf(t)>-1}}class Ze{constructor(t){this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=ae.from(t.nodes),e.marks=ae.from(t.marks||{}),this.nodes=Ge.compile(this.spec.nodes,this),this.marks=Xe.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",i=e.spec.marks;e.contentMatch=n[r]||(n[r]=Pe.parse(r,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.markSet="_"==i?null:i?Qe(this,i.split(" ")):""!=i&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:Qe(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof Ge))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)}text(t,e){let n=this.nodes.text;return new Be(n,n.defaultAttrs,t,fe.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return Re.fromJSON(this,t)}markFromJSON(t){return fe.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function Qe(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let e in t.marks){let r=t.marks[e];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=r)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class tn{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((t=>{t.tag?this.tags.push(t):t.style&&this.styles.push(t)})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new an(this,e,!1);return n.addAll(t,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new an(this,e,!0);return n.addAll(t,e.from,e.to),ge.maxOpen(n.finish())}matchTag(t,e,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(ln(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],s=r.style;if(!(0!=s.indexOf(t)||r.context&&!n.matchesContext(r.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(r.getAttrs){let t=r.getAttrs(e);if(!1===t)continue;r.attrs=t||void 0}return r}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r];if((null==t.priority?50:t.priority)<n)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;r&&r.forEach((t=>{n(t=cn(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;r&&r.forEach((t=>{n(t=cn(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new tn(t,tn.schemaRules(t)))}}const en={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},nn={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},rn={ol:!0,ul:!0};function sn(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class on{constructor(t,e,n,r,i,s,o){this.type=t,this.attrs=e,this.marks=n,this.pendingMarks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=fe.none,this.stashMarks=[],this.match=s||(4&o?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(he.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=he.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(he.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}popFromStashMark(t){for(let e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]}applyPending(t){for(let e=0,n=this.pendingMarks;e<n.length;e++){let r=n[e];(this.type?this.type.allowsMarkType(r.type):hn(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!en.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class an{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0;let r,i=e.topNode,s=sn(null,e.preserveWhitespace,0)|(n?4:0);r=i?new on(i.type,i.attrs,fe.none,fe.none,!0,e.topMatch||i.type.contentMatch,s):new on(n?null:t.schema.topNodeType,null,fe.none,fe.none,!0,null,s),this.nodes=[r],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){let e=t.getAttribute("style");if(e){let n=this.readStyles(function(t){let e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e));if(!n)return;let[r,i]=n,s=this.top;for(let t=0;t<i.length;t++)this.removePendingMark(i[t],s);for(let t=0;t<r.length;t++)this.addPendingMark(r[t]);this.addElement(t);for(let t=0;t<r.length;t++)this.removePendingMark(r[t],s);for(let t=0;t<i.length;t++)this.addPendingMark(i[t])}else this.addElement(t)}}addTextNode(t){let e=t.nodeValue,n=this.top;if(2&n.options||n.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){let r=n.content[n.content.length-1],i=t.previousSibling;(!r||i&&"BR"==i.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)}addElement(t,e){let n,r=t.nodeName.toLowerCase();rn.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&rn.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let i=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(i?i.ignore:nn.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(t=i.skip);let e,n=this.top,s=this.needsBlock;if(en.hasOwnProperty(r))n.content.length&&n.content[0].isInline&&this.open&&(this.open--,n=this.top),e=!0,n.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),e&&this.sync(n),this.needsBlock=s}else this.addElementByRule(t,i,!1===i.consuming?n:void 0)}leafFallback(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))}ignoreFallback(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(t){let e=fe.none,n=fe.none;t:for(let r=0;r<t.length;r+=2)for(let i;;){let s=this.parser.matchStyle(t[r],t[r+1],this,i);if(!s)continue t;if(s.ignore)return null;if(s.clearMark?this.top.pendingMarks.forEach((t=>{s.clearMark(t)&&(n=t.addToSet(n))})):e=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(e),!1!==s.consuming)break;i=s}return[e,n]}addElementByRule(t,e,n){let r,i,s;if(e.node)i=this.parser.schema.nodes[e.node],i.isLeaf?this.insertNode(i.create(e.attrs))||this.leafFallback(t):r=this.enter(i,e.attrs||null,e.preserveWhitespace);else{s=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(s)}let o=this.top;if(i&&i.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t)));else{let n=t;"string"==typeof e.contentElement?n=t.querySelector(e.contentElement):"function"==typeof e.contentElement?n=e.contentElement(t):e.contentElement&&(n=e.contentElement),this.findAround(t,n,!0),this.addAll(n)}r&&this.sync(o)&&this.open--,s&&this.removePendingMark(s,o)}addAll(t,e,n){let r=e||0;for(let i=e?t.childNodes[e]:t.firstChild,s=null==n?null:t.childNodes[n];i!=s;i=i.nextSibling,++r)this.findAtPoint(t,r),this.addDOM(i);this.findAtPoint(t,r)}findPlace(t){let e,n;for(let r=this.open;r>=0;r--){let i=this.nodes[r],s=i.findWrapping(t);if(s&&(!e||e.length>s.length)&&(e=s,n=i,!s.length))break;if(i.solid)break}if(!e)return!1;this.sync(n);for(let t=0;t<e.length;t++)this.enterInner(e[t],null,!1);return!0}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(t)){this.closeExtra();let e=this.top;e.applyPending(t.type),e.match&&(e.match=e.match.matchType(t.type));let n=e.activeMarks;for(let r=0;r<t.marks.length;r++)e.type&&!e.type.allowsMarkType(t.marks[r].type)||(n=t.marks[r].addToSet(n));return e.content.push(t.mark(n)),!0}return!1}enter(t,e,n){let r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r}enterInner(t,e=null,n=!1,r){this.closeExtra();let i=this.top;i.applyPending(t),i.match=i.match&&i.match.matchType(t);let s=sn(t,r,i.options);4&i.options&&0==i.content.length&&(s|=4),this.nodes.push(new on(t,e,i.activeMarks,i.pendingMarks,n,null,s)),this.open++}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));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(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)){e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),s=(t,o)=>{for(;t>=0;t--){let a=e[t];if(""==a){if(t==e.length-1||0==t)continue;for(;o>=i;o--)if(s(t-1,o))return!0;return!1}{let t=o>0||0==o&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!t||t.name!=a&&-1==t.groups.indexOf(a))return!1;o--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}addPendingMark(t){let e=function(t,e){for(let n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,e){for(let n=this.open;n>=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);let e=r.popFromStashMark(t);e&&r.type&&r.type.allowsMarkType(e.type)&&(r.activeMarks=e.addToSet(r.activeMarks))}if(r==e)break}}}function ln(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function cn(t){let e={};for(let n in t)e[n]=t[n];return e}function hn(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let n=0;n<t.edgeCount;n++){let{type:r,next:i}=t.edge(n);if(r==e)return!0;if(s.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}class dn{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=pn(e).createDocumentFragment());let r=n,i=[];return t.forEach((t=>{if(i.length||t.marks.length){let n=0,s=0;for(;n<i.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(i[n][0])||!1===e.type.spec.spanning)break;n++,s++}else s++}for(;n<i.length;)r=i.pop()[1];for(;s<t.marks.length;){let n=t.marks[s++],o=this.serializeMark(n,t.isInline,e);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(t,e))})),n}serializeNodeInner(t,e){let{dom:n,contentDOM:r}=dn.renderSpec(pn(e),this.nodes[t.type.name](t));if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let i=this.serializeMark(t.marks[r],t.isInline,e);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(t,e,n={}){let r=this.marks[t.type.name];return r&&dn.renderSpec(pn(n),r(t,e))}static renderSpec(t,e,n=null){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let r,i=e[0],s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o=n?t.createElementNS(n,i):t.createElement(i),a=e[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let t in a)if(null!=a[t]){let e=t.indexOf(" ");e>0?o.setAttributeNS(t.slice(0,e),t.slice(e+1),a[t]):o.setAttribute(t,a[t])}}for(let i=l;i<e.length;i++){let s=e[i];if(0===s){if(i<e.length-1||i>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}{let{dom:e,contentDOM:i}=dn.renderSpec(t,s,n);if(o.appendChild(e),i){if(r)throw new RangeError("Multiple content holes");r=i}}}return{dom:o,contentDOM:r}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new dn(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=un(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return un(t.marks)}}function un(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function pn(t){return t.document||window.document}const fn=Math.pow(2,16);function mn(t,e){return t+e*fn}function gn(t){return 65535&t}class yn{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class vn{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&vn.empty)return vn.empty}recover(t){let e=0,n=gn(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/fn}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let a=this.ranges[o]-(this.inverted?r:0);if(a>t)break;let l=this.ranges[o+i],c=this.ranges[o+s],h=a+l;if(t<=h){let i=a+r+((l?t==a?-1:t==h?1:e:e)<0?0:c);if(n)return i;let s=t==(e<0?a:h)?null:mn(o/3,t-a),d=t==a?2:t==h?1:4;return(e<0?t!=a:t!=h)&&(d|=8),new yn(i,d,s)}r+=c-l}return n?t+r:new yn(t+r,0,null)}touches(t,e){let n=0,r=gn(e),i=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?n:0);if(o>t)break;let a=this.ranges[e+i];if(t<=o+a&&e==3*r)return!0;n+=this.ranges[e+s]-a}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),a=s+(this.inverted?0:i),l=this.ranges[r+e],c=this.ranges[r+n];t(o,o+l,a,a+c),i+=c-l}}invert(){return new vn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?vn.empty:new vn(t<0?[0,-t,0]:[0,0,t])}}vn.empty=new vn([]);class bn{constructor(t=[],e,n=0,r=t.length){this.maps=t,this.mirror=e,this.from=n,this.to=r}slice(t=0,e=this.maps.length){return new bn(this.maps,this.mirror,t,e)}copy(){return new bn(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,n=this.maps.length;e<t.maps.length;e++){let r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:void 0)}}invert(){let t=new bn;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this.maps[n].mapResult(t,e);if(null!=i.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this.maps[e].recover(i.recover);continue}}r|=i.delInfo,t=i.pos}return n?t:new yn(t,r,null)}}const wn=Object.create(null);class xn{getMap(){return vn.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=wn[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in wn)throw new RangeError("Duplicate use of step JSON ID "+t);return wn[t]=e,e.prototype.jsonID=t,e}}class kn{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new kn(t,null)}static fail(t){return new kn(null,t)}static fromReplace(t,e,n,r){try{return kn.ok(t.replace(e,n,r))}catch(t){if(t instanceof me)return kn.fail(t.message);throw t}}}function Sn(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Sn(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return he.fromArray(r)}class On extends xn{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new ge(Sn(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),r),e.openStart,e.openEnd);return kn.fromReplace(t,this.from,this.to,i)}invert(){return new Mn(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new On(e.pos,n.pos,this.mark)}merge(t){return t instanceof On&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new On(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new On(e.from,e.to,t.markFromJSON(e.mark))}}xn.jsonID("addMark",On);class Mn extends xn{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new ge(Sn(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return kn.fromReplace(t,this.from,this.to,n)}invert(){return new On(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Mn(e.pos,n.pos,this.mark)}merge(t){return t instanceof Mn&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Mn(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Mn(e.from,e.to,t.markFromJSON(e.mark))}}xn.jsonID("removeMark",Mn);class An extends xn{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kn.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return kn.fromReplace(t,this.pos,this.pos+1,new ge(he.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new An(this.pos,e.marks[n]);return new An(this.pos,this.mark)}}return new En(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new An(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new An(e.pos,t.markFromJSON(e.mark))}}xn.jsonID("addNodeMark",An);class En extends xn{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kn.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return kn.fromReplace(t,this.pos,this.pos+1,new ge(he.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new An(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new En(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new En(e.pos,t.markFromJSON(e.mark))}}xn.jsonID("removeNodeMark",En);class Cn extends xn{constructor(t,e,n,r=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=r}apply(t){return this.structure&&Nn(t,this.from,this.to)?kn.fail("Structure replace would overwrite content"):kn.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new vn([this.from,this.to-this.from,this.slice.size])}invert(t){return new Cn(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deletedAcross&&n.deletedAcross?null:new Cn(e.pos,Math.max(e.pos,n.pos),this.slice)}merge(t){if(!(t instanceof Cn)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?ge.empty:new ge(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Cn(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?ge.empty:new ge(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Cn(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Cn(e.from,e.to,ge.fromJSON(t,e.slice),!!e.structure)}}xn.jsonID("replace",Cn);class Tn extends xn{constructor(t,e,n,r,i,s,o=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(t){if(this.structure&&(Nn(t,this.from,this.gapFrom)||Nn(t,this.gapTo,this.to)))return kn.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return kn.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?kn.fromReplace(t,this.from,this.to,n):kn.fail("Content does not fit in gap")}getMap(){return new vn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Tn(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),r=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||r<e.pos||i>n.pos?null:new Tn(e.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Tn(e.from,e.to,e.gapFrom,e.gapTo,ge.fromJSON(t,e.slice),e.insert,!!e.structure)}}function Nn(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let t=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,i--}}return!1}function Dn(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function $n(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth;;--n){let r=t.$from.node(n),i=t.$from.index(n),s=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(i,s,e))return n;if(0==n||r.type.spec.isolating||!Dn(r,i,s))break}return null}function In(t,e,n=null,r=t){let i=function(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}(t,e),s=i&&function(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let t=r;a&&t<i;t++)a=a.matchType(n.child(t).type);return a&&a.validEnd?o:null}(r,e);return s?i.map(Rn).concat({type:e,attrs:n}).concat(s.map(Rn)):null}function Rn(t){return{type:t,attrs:null}}function Bn(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let t=i.depth-1,e=n-2;t>s;t--,e--){let n=i.node(t),s=i.index(t);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(s,n.childCount),a=r&&r[e]||n;if(a!=n&&(o=o.replaceChild(0,a.type.create(a.attrs))),!n.canReplace(s+1,n.childCount)||!a.type.validContent(o))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function Fn(t,e){let n=t.resolve(e),r=n.index();return Pn(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Pn(t,e){return!(!t||!e||t.isLeaf||!t.canAppend(e))}function Vn(t,e,n=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let i,s,o=r.index(t);if(t==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(t+1),o++,s=r.node(t).maybeChild(o)):(i=r.node(t).maybeChild(o-1),s=r.node(t+1)),i&&!i.isTextblock&&Pn(i,s)&&r.node(t).canReplace(o,o+1))return e;if(0==t)break;e=n<0?r.before(t):r.after(t)}}function Ln(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let t=0;t<n.openStart;t++)i=i.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=r.depth;e>=0;e--){let n=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,s=r.index(e)+(n>0?1:0),o=r.node(e),a=!1;if(1==t)a=o.canReplace(s,s,i);else{let t=o.contentMatchAt(s).findWrapping(i.firstChild.type);a=t&&o.canReplaceWith(s,s,t[0])}if(a)return 0==n?r.pos:n<0?r.before(e+1):r.after(e+1)}return null}function zn(t,e,n=e,r=ge.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return jn(i,s,r)?new Cn(e,n,r):new _n(i,s,r).fit()}function jn(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}xn.jsonID("replaceAround",Tn);class _n{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=he.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=he.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(t<0?this.$to:n.doc.resolve(t));if(!r)return null;let i=this.placed,s=n.depth,o=r.depth;for(;s&&o&&1==i.childCount;)i=i.firstChild.content,s--,o--;let a=new ge(i,s,o);return t>-1?new Tn(n.pos,t,this.$to.pos,this.$to.end(),a,e):a.size||n.pos!=this.$to.pos?new Cn(n.pos,r.pos,a):null}findFittable(){for(let t=1;t<=2;t++)for(let e=this.unplaced.openStart;e>=0;e--){let n,r=null;e?(r=Hn(this.unplaced.content,e-1).firstChild,n=r.content):n=this.unplaced.content;let i=n.firstChild;for(let n=this.depth;n>=0;n--){let s,{type:o,match:a}=this.frontier[n],l=null;if(1==t&&(i?a.matchType(i.type)||(l=a.fillBefore(he.from(i),!1)):r&&o.compatibleContent(r.type)))return{sliceDepth:e,frontierDepth:n,parent:r,inject:l};if(2==t&&i&&(s=a.findWrapping(i.type)))return{sliceDepth:e,frontierDepth:n,parent:r,wrap:s};if(r&&a.matchType(r.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=Hn(t,e);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new ge(t,e+1,Math.max(n,r.size+e>=t.size-n?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=Hn(t,e);if(r.childCount<=1&&e>0){let i=t.size-e<=e+r.size;this.unplaced=new ge(Kn(t,e-1,1),e-1,i?e-1:n)}else this.unplaced=new ge(Kn(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:r,wrap:i}){for(;this.depth>e;)this.closeFrontierNode();if(i)for(let t=0;t<i.length;t++)this.openFrontierNode(i[t]);let s=this.unplaced,o=n?n.content:s.content,a=s.openStart-t,l=0,c=[],{match:h,type:d}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)c.push(r.child(t));h=h.matchFragment(r)}let u=o.size+t-(s.content.size-s.openEnd);for(;l<o.childCount;){let t=o.child(l),e=h.matchType(t.type);if(!e)break;l++,(l>1||0==a||t.content.size)&&(h=e,c.push(qn(t.mark(d.allowedMarks(t.marks)),1==l?a:0,l==o.childCount?u:-1)))}let p=l==o.childCount;p||(u=-1),this.placed=Wn(this.placed,e,he.from(c)),this.frontier[e].match=h,p&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=o;t<u;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=p?0==t?ge.empty:new ge(Kn(s.content,t-1,1),t-1,u<0?s.openEnd:t-1):new ge(Kn(s.content,t,l),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Jn(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:r}=this.frontier[e],i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Jn(t,e,r,n,i);if(s){for(let n=e-1;n>=0;n--){let{match:e,type:r}=this.frontier[n],i=Jn(t,n,r,e,!0);if(!i||i.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Wn(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),r=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=Wn(this.placed,this.depth,he.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(he.empty,!0);t.childCount&&(this.placed=Wn(this.placed,this.frontier.length,t))}}function Kn(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Kn(t.firstChild.content,e-1,n)))}function Wn(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Wn(t.lastChild.content,e-1,n)))}function Hn(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function qn(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,qn(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(he.empty,!0)))),t.copy(r)}function Jn(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!function(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,s.content,o)?a:null}function Un(t){return t.spec.defining||t.spec.definingForContent}function Gn(t,e,n,r,i){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Gn(i.content,e+1,n,r,i)))}if(e>r){let e=i.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(he.empty,!0))}return t}function Yn(t,e){let n=[];for(let r=Math.min(t.depth,e.depth);r>=0;r--){let i=t.start(r);if(i<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(i==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==i-1)&&n.push(r)}return n}class Xn extends xn{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return kn.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return kn.fromReplace(t,this.pos,this.pos+1,new ge(he.from(r),0,e.isLeaf?0:1))}getMap(){return vn.empty}invert(t){return new Xn(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Xn(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Xn(e.pos,e.attr,e.value)}}xn.jsonID("attr",Xn);let Zn=class extends Error{};Zn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(Zn.prototype=Object.create(Error.prototype)).constructor=Zn,Zn.prototype.name="TransformError";const Qn=Object.create(null);class tr{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new er(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=ge.empty){let n=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++)r=n,n=n.lastChild;let i=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=t.mapping.slice(i);t.replaceRange(c.map(a.pos),c.map(l.pos),o?ge.empty:e),0==o&&dr(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],a=t.mapping.slice(n),l=a.map(s.pos),c=a.map(o.pos);i?t.deleteRange(l,c):(t.replaceRangeWith(l,c,e),dr(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new ir(t):hr(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let r=t.depth-1;r>=0;r--){let i=e<0?hr(t.node(0),t.node(r),t.before(r+1),t.index(r),e,n):hr(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,n);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new lr(t.node(0))}static atStart(t){return hr(t,t,0,0,1)||new lr(t)}static atEnd(t){return hr(t,t,t.content.size,t.childCount,-1)||new lr(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Qn[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Qn)throw new RangeError("Duplicate use of selection JSON ID "+t);return Qn[t]=e,e.prototype.jsonID=t,e}getBookmark(){return ir.between(this.$anchor,this.$head).getBookmark()}}tr.prototype.visible=!0;class er{constructor(t,e){this.$from=t,this.$to=e}}let nr=!1;function rr(t){nr||t.parent.inlineContent||(nr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ir extends tr{constructor(t,e=t){rr(t),rr(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return tr.near(n);let r=t.resolve(e.map(this.anchor));return new ir(r.parent.inlineContent?r:n,n)}replace(t,e=ge.empty){if(super.replace(t,e),e==ge.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof ir&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new sr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new ir(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(t,e,n){let r=t.pos-e.pos;if(n&&!r||(n=r>=0?1:-1),!e.parent.inlineContent){let t=tr.findFrom(e,n,!0)||tr.findFrom(e,-n,!0);if(!t)return tr.near(e,n);e=t.$head}return t.parent.inlineContent||(0==r||(t=(tr.findFrom(t,-n,!0)||tr.findFrom(t,n,!0)).$anchor).pos<e.pos!=r<0)&&(t=e),new ir(t,e)}}tr.jsonID("text",ir);class sr{constructor(t,e){this.anchor=t,this.head=e}map(t){return new sr(t.map(this.anchor),t.map(this.head))}resolve(t){return ir.between(t.resolve(this.anchor),t.resolve(this.head))}}class or extends tr{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:r}=e.mapResult(this.anchor),i=t.resolve(r);return n?tr.near(i):new or(i)}content(){return new ge(he.from(this.node),0,0)}eq(t){return t instanceof or&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ar(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new or(t.resolve(e.anchor))}static create(t,e){return new or(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}or.prototype.visible=!1,tr.jsonID("node",or);class ar{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new sr(n,n):new ar(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&or.isSelectable(n)?new or(e):tr.near(e)}}class lr extends tr{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=ge.empty){if(e==ge.empty){t.delete(0,t.doc.content.size);let e=tr.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new lr(t)}map(t){return new lr(t)}eq(t){return t instanceof lr}getBookmark(){return cr}}tr.jsonID("all",lr);const cr={map(){return this},resolve:t=>new lr(t)};function hr(t,e,n,r,i,s=!1){if(e.inlineContent)return ir.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let r=e.child(o);if(r.isAtom){if(!s&&or.isSelectable(r))return or.create(t,n-(i<0?r.nodeSize:0))}else{let e=hr(t,r,n+i,i<0?r.childCount:0,i,s);if(e)return e}n+=r.nodeSize*i}return null}function dr(t,e,n){let r=t.steps.length-1;if(r<e)return;let i,s=t.steps[r];(s instanceof Cn||s instanceof Tn)&&(t.mapping.maps[r].forEach(((t,e,n,r)=>{null==i&&(i=r)})),t.setSelection(tr.near(t.doc.resolve(i),n)))}class ur extends class{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new bn}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Zn(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=ge.empty){let r=zn(this.doc,t,e,n);return r&&this.step(r),this}replaceWith(t,e,n){return this.replace(t,e,new ge(he.from(n),0,0))}delete(t,e){return this.replace(t,e,ge.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(jn(i,s,r))return t.step(new Cn(e,n,r));let o=Yn(i,t.doc.resolve(n));0==o[o.length-1]&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let t=i.depth,e=i.pos-1;t>0;t--,e--){let n=i.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(t)>-1?a=t:i.before(t)==e&&o.splice(1,0,-t)}let l=o.indexOf(a),c=[],h=r.openStart;for(let t=r.content,e=0;;e++){let n=t.firstChild;if(c.push(n),e==r.openStart)break;t=n.content}for(let t=h-1;t>=0;t--){let e=c[t].type,n=Un(e);if(n&&i.node(l).type!=e)h=t;else if(n||!e.isTextblock)break}for(let e=r.openStart;e>=0;e--){let a=(e+h+1)%(r.openStart+1),d=c[a];if(d)for(let e=0;e<o.length;e++){let c=o[(e+l)%o.length],h=!0;c<0&&(h=!1,c=-c);let u=i.node(c-1),p=i.index(c-1);if(u.canReplaceWith(p,p,d.type,d.marks))return t.replace(i.before(c),h?s.after(c):n,new ge(Gn(r.content,0,r.openStart,a),a,r.openEnd))}}let d=t.steps.length;for(let a=o.length-1;a>=0&&(t.replace(e,n,r),!(t.steps.length>d));a--){let t=o[a];t<0||(e=i.before(t),n=s.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=function(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,n))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,n))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}(t.doc,e,r.type);null!=i&&(e=n=i)}t.replaceRange(e,n,new ge(he.from(r),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=Yn(r,i);for(let e=0;e<s.length;e++){let n=s[e],o=e==s.length-1;if(o&&0==n||r.node(n).type.contentMatch.validEnd)return t.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return t.delete(r.before(n),i.after(n))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),a=i.after(s+1),l=o,c=a,h=he.empty,d=0;for(let t=s,e=!1;t>n;t--)e||r.index(t)>0?(e=!0,h=he.from(r.node(t).copy(h)),d++):l--;let u=he.empty,p=0;for(let t=s,e=!1;t>n;t--)e||i.after(t+1)<i.end(t)?(e=!0,u=he.from(i.node(t).copy(u)),p++):c++;t.step(new Tn(l,c,o,a,new ge(h.append(u),d,p),h.size-d,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let r=new Cn(e-n,e+n,ge.empty,!0);t.step(r)}(this,t,e),this}wrap(t,e){return function(t,e,n){let r=he.empty;for(let t=n.length-1;t>=0;t--){if(r.size){let e=n[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=he.from(n[t].type.create(n[t].attrs,r))}let i=e.start,s=e.end;t.step(new Tn(i,s,i,s,new ge(r,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,r=null){return function(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{if(e.isTextblock&&!e.hasMarkup(r,i)&&function(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(t.doc,t.mapping.slice(s).map(n),r)){t.clearIncompatible(t.mapping.slice(s).map(n,1),r);let o=t.mapping.slice(s),a=o.map(n,1),l=o.map(n+e.nodeSize,1);return t.step(new Tn(a,l,a+1,l-1,new ge(he.from(r.create(i,null,e.marks)),0,0),1,!0)),!1}}))}(this,t,e,n,r),this}setNodeMarkup(t,e,n=null,r=[]){return function(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Tn(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new ge(he.from(o),0,0),1,!0))}(this,t,e,n,r),this}setNodeAttribute(t,e,n){return this.step(new Xn(t,e,n)),this}addNodeMark(t,e){return this.step(new An(t,e)),this}removeNodeMark(t,e){if(!(e instanceof fe)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(n.marks)))return this}return this.step(new En(t,e)),this}split(t,e=1,n){return function(t,e,n=1,r){let i=t.doc.resolve(e),s=he.empty,o=he.empty;for(let t=i.depth,e=i.depth-n,a=n-1;t>e;t--,a--){s=he.from(i.node(t).copy(s));let e=r&&r[a];o=he.from(e?e.type.create(e.attrs,o):i.node(t).copy(o))}t.step(new Cn(e,e,new ge(s.append(o),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,r){let i,s,o=[],a=[];t.doc.nodesBetween(e,n,((t,l,c)=>{if(!t.isInline)return;let h=t.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,e),d=Math.min(l+t.nodeSize,n),u=r.addToSet(h);for(let t=0;t<h.length;t++)h[t].isInSet(u)||(i&&i.to==c&&i.mark.eq(h[t])?i.to=d:o.push(i=new Mn(c,d,h[t])));s&&s.to==c?s.to=d:a.push(s=new On(c,d,r))}})),o.forEach((e=>t.step(e))),a.forEach((e=>t.step(e)))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,((t,o)=>{if(!t.isInline)return;s++;let a=null;if(r instanceof Xe){let e,n=t.marks;for(;e=r.isInSet(n);)(a||(a=[])).push(e),n=e.removeFromSet(n)}else r?r.isInSet(t.marks)&&(a=[r]):a=t.marks;if(a&&a.length){let r=Math.min(o+t.nodeSize,n);for(let t=0;t<a.length;t++){let n,l=a[t];for(let t=0;t<i.length;t++){let e=i[t];e.step==s-1&&l.eq(i[t].style)&&(n=e)}n?(n.to=r,n.step=s):i.push({style:l,from:Math.max(o,e),to:r,step:s})}}})),i.forEach((e=>t.step(new Mn(e.from,e.to,e.style))))}(this,t,e,n),this}clearIncompatible(t,e,n){return function(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),s=[],o=e+1;for(let e=0;e<i.childCount;e++){let a=i.child(e),l=o+a.nodeSize,c=r.matchType(a.type);if(c){r=c;for(let e=0;e<a.marks.length;e++)n.allowsMarkType(a.marks[e].type)||t.step(new Mn(o,l,a.marks[e]))}else s.push(new Cn(o,l,ge.empty));o=l}if(!r.validEnd){let e=r.fillBefore(he.empty,!0);t.replace(o,o,new ge(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}(this,t,e,n),this}}{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.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(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return fe.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||fe.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=null==n?e:n,!t)return this.deleteRange(e,n);let i=this.storedMarks;if(!i){let t=this.doc.resolve(e);i=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,i)),this.selection.empty||this.setSelection(tr.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function pr(t,e){return e&&t?t.bind(e):t}class fr{constructor(t,e,n){this.name=t,this.init=pr(e.init,n),this.apply=pr(e.apply,n)}}const mr=[new fr("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new fr("selection",{init:(t,e)=>t.selection||tr.atStart(e.doc),apply:t=>t.selection}),new fr("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,r)=>r.selection.$cursor?t.storedMarks:null}),new fr("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class gr{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=mr.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new fr(t.key,t.spec.state,t))}))}}class yr{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),r=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let a=r?r[s].n:0,l=r?r[s].state:this,c=a<e.length&&o.spec.appendTransaction.call(o,a?e.slice(a):e,l,n);if(c&&n.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",t),!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<s?{state:n,n:e.length}:{state:this,n:0})}e.push(c),n=n.applyInner(c),i=!0}r&&(r[s]={state:n,n:e.length})}}if(!i)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new yr(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];e[i.name]=i.apply(t,this[i.name],this,e)}return e}get tr(){return new ur(this)}static create(t){let e=new gr(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new yr(e);for(let r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n}reconfigure(t){let e=new gr(this.schema,t.plugins),n=e.fields,r=new yr(e);for(let e=0;e<n.length;e++){let i=n[e].name;r[i]=this.hasOwnProperty(i)?this[i]:n[e].init(t,r)}return r}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[n],i=r.spec.state;i&&i.toJSON&&(e[n]=i.toJSON.call(r,this[r.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new gr(t.schema,t.plugins),i=new yr(r);return r.fields.forEach((r=>{if("doc"==r.name)i.doc=Re.fromJSON(t.schema,e.doc);else if("selection"==r.name)i.selection=tr.fromJSON(i.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(i.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let s in n){let o=n[s],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(e,s))return void(i[r.name]=a.fromJSON.call(o,t,e[s],i))}i[r.name]=r.init(t,i)}})),i}}function vr(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):"handleDOMEvents"==r&&(i=vr(i,e,{})),n[r]=i}return n}class br{constructor(t){this.spec=t,this.props={},t.props&&vr(t.props,this,this.props),this.key=t.key?t.key.key:xr("plugin")}getState(t){return t[this.key]}}const wr=Object.create(null);function xr(t){return t in wr?t+"$"+ ++wr[t]:(wr[t]=0,t+"$")}class kr{constructor(t="key"){this.key=xr(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Sr=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Or=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let Mr=null;const Ar=function(t,e,n){let r=Mr||(Mr=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},Er=function(t,e,n,r){return n&&(Tr(t,e,n,r,-1)||Tr(t,e,n,r,1))},Cr=/^(img|br|input|textarea|hr)$/i;function Tr(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Nr(t))){let n=t.parentNode;if(!n||1!=n.nodeType||Dr(t)||Cr.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Sr(t)+(i<0?0:1),t=n}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(i<0?-1:0)]).contentEditable)return!1;e=i<0?Nr(t):0}}}function Nr(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Dr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const $r=function(t){return t.focusNode&&Er(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ir(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Rr="undefined"!=typeof navigator?navigator:null,Br="undefined"!=typeof document?document:null,Fr=Rr&&Rr.userAgent||"",Pr=/Edge\/(\d+)/.exec(Fr),Vr=/MSIE \d/.exec(Fr),Lr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fr),zr=!!(Vr||Lr||Pr),jr=Vr?document.documentMode:Lr?+Lr[1]:Pr?+Pr[1]:0,_r=!zr&&/gecko\/(\d+)/i.test(Fr);_r&&(/Firefox\/(\d+)/.exec(Fr)||[0,0])[1];const Kr=!zr&&/Chrome\/(\d+)/.exec(Fr),Wr=!!Kr,Hr=Kr?+Kr[1]:0,qr=!zr&&!!Rr&&/Apple Computer/.test(Rr.vendor),Jr=qr&&(/Mobile\/\w+/.test(Fr)||!!Rr&&Rr.maxTouchPoints>2),Ur=Jr||!!Rr&&/Mac/.test(Rr.platform),Gr=/Android \d/.test(Fr),Yr=!!Br&&"webkitFontSmoothing"in Br.documentElement.style,Xr=Yr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Zr(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Qr(t,e){return"number"==typeof t?t:t[e]}function ti(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function ei(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;o=Or(o)){if(1!=o.nodeType)continue;let t=o,n=t==s.body,a=n?Zr(s):ti(t),l=0,c=0;if(e.top<a.top+Qr(r,"top")?c=-(a.top-e.top+Qr(i,"top")):e.bottom>a.bottom-Qr(r,"bottom")&&(c=e.bottom-a.bottom+Qr(i,"bottom")),e.left<a.left+Qr(r,"left")?l=-(a.left-e.left+Qr(i,"left")):e.right>a.right-Qr(r,"right")&&(l=e.right-a.right+Qr(i,"right")),l||c)if(n)s.defaultView.scrollBy(l,c);else{let n=t.scrollLeft,r=t.scrollTop;c&&(t.scrollTop+=c),l&&(t.scrollLeft+=l);let i=t.scrollLeft-n,s=t.scrollTop-r;e={left:e.left-i,top:e.top-s,right:e.right-i,bottom:e.bottom-s}}if(n)break}}function ni(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Or(r));return e}function ri(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ii=null;function si(t,e){let n,r,i=2e8,s=0,o=e.top,a=e.top;for(let l=t.firstChild,c=0;l;l=l.nextSibling,c++){let t;if(1==l.nodeType)t=l.getClientRects();else{if(3!=l.nodeType)continue;t=Ar(l).getClientRects()}for(let h=0;h<t.length;h++){let d=t[h];if(d.top<=o&&d.bottom>=a){o=Math.max(d.bottom,o),a=Math.min(d.top,a);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<i){n=l,i=t,r=t&&3==n.nodeType?{left:d.right<e.left?d.right:d.left,top:e.top}:e,1==l.nodeType&&t&&(s=c+(e.left>=(d.left+d.right)/2?1:0));continue}}!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(s=c+1)}}return n&&3==n.nodeType?function(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let n=ci(r,1);if(n.top!=n.bottom&&oi(e,n))return{node:t,offset:i+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||i&&1==n.nodeType?{node:t,offset:s}:si(n,r)}function oi(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ai(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let n=t.childNodes[s];if(1==n.nodeType){let t=n.getClientRects();for(let r=0;r<t.length;r++){let i=t[r];if(oi(e,i))return ai(n,e,i)}}if((s=(s+1)%r)==i)break}return t}function li(t,e){let n,r=t.dom.ownerDocument,i=0;if(r.caretPositionFromPoint)try{let t=r.caretPositionFromPoint(e.left,e.top);t&&({offsetNode:n,offset:i}=t)}catch(t){}if(!n&&r.caretRangeFromPoint){let t=r.caretRangeFromPoint(e.left,e.top);t&&({startContainer:n,startOffset:i}=t)}let s,o=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);if(!o||!t.dom.contains(1!=o.nodeType?o.parentNode:o)){let n=t.dom.getBoundingClientRect();if(!oi(e,n))return null;if(o=ai(t.dom,e,n),!o)return null}if(qr)for(let t=o;n&&t;t=Or(t))t.draggable&&(n=void 0);if(o=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(o,e),n){if(_r&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let t,r=n.childNodes[i];"IMG"==r.nodeName&&(t=r.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&i++}n==t.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(s=function(t,e,n,r){let i=-1;for(let n=e;n!=t.dom;){let e=t.docView.nearestDesc(n,!0);if(!e)return null;if(e.node.isBlock&&e.parent){let t=e.dom.getBoundingClientRect();if(t.left>r.left||t.top>r.top)i=e.posBefore;else{if(!(t.right<r.left||t.bottom<r.top))break;i=e.posAfter}}n=e.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,1)}(t,n,i,e))}null==s&&(s=function(t,e,n){let{node:r,offset:i}=si(e,n),s=-1;if(1==r.nodeType&&!r.firstChild){let t=r.getBoundingClientRect();s=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function ci(t,e){let n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}const hi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function di(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Yr||_r;if(3==r.nodeType){if(!o||!hi.test(r.nodeValue)&&(n<0?i:i!=r.nodeValue.length)){let t=i,e=i,s=n<0?1:-1;return n<0&&!i?(e++,s=-1):n>=0&&i==r.nodeValue.length?(t--,s=1):n<0?t--:e++,ui(ci(Ar(r,t,e),1),s<0)}{let t=ci(Ar(r,i,i),n);if(_r&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let e=ci(Ar(r,i-1,i-1),-1);if(e.top==t.top){let n=ci(Ar(r,i,i+1),-1);if(n.top!=t.top)return ui(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(null==s&&i&&(n<0||i==Nr(r))){let t=r.childNodes[i-1];if(1==t.nodeType)return pi(t.getBoundingClientRect(),!1)}if(null==s&&i<Nr(r)){let t=r.childNodes[i];if(1==t.nodeType)return pi(t.getBoundingClientRect(),!0)}return pi(r.getBoundingClientRect(),n>=0)}if(null==s&&i&&(n<0||i==Nr(r))){let t=r.childNodes[i-1],e=3==t.nodeType?Ar(t,Nr(t)-(o?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return ui(ci(e,1),!1)}if(null==s&&i<Nr(r)){let t=r.childNodes[i];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?Ar(t,0,o?0:1):1==t.nodeType?t:null:null;if(e)return ui(ci(e,-1),!0)}return ui(ci(3==r.nodeType?Ar(r):r,-n),n>=0)}function ui(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function pi(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function fi(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}const mi=/[\u0590-\u08ac]/;let gi=null,yi=null,vi=!1;function bi(t,e,n){return gi==e&&yi==n?vi:(gi=e,yi=n,vi="up"==n||"down"==n?function(t,e,n){let r=e.selection,i="up"==n?r.$from:r.$to;return fi(t,e,(()=>{let{node:e}=t.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.dom;break}e=n.dom.parentNode}let r=di(t,i.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=Ar(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let i=e[t];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>2*(i.bottom-r.top):i.bottom-r.bottom>2*(r.bottom-i.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=t.domSelection();return mi.test(r.parent.textContent)&&a.modify?fi(t,e,(()=>{let{focusNode:e,focusOffset:i,anchorNode:s,anchorOffset:o}=t.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:d}=t.domSelectionRange(),u=h&&!c.contains(1==h.nodeType?h:h.parentNode)||e==h&&i==d;try{a.collapse(s,o),e&&(e!=s||i!=o)&&a.extend&&a.extend(e,i)}catch(t){}return null!=l&&(a.caretBidiLevel=l),u})):"left"==n||"backward"==n?s:o}(t,e,n))}class wi{constructor(t,e,n,r){this.parent=t,this.children=e,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let r=this.children[e];if(r==t)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,r;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM)r=e>Sr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!1;break}if(e.previousSibling)break}if(null==r&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!0;break}if(e.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,r=t;r;r=r.parentNode){let i,s=this.getDesc(r);if(s&&(!e||s.node)){if(!n||!(i=s.nodeDOM)||(1==i.nodeType?i.contains(1==t.nodeType?t:t.parentNode):i==t))return s;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let r=t;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let r=this.children[e],i=n+r.size;if(n==t&&i!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<i)return r.descAt(t-n-r.border);n=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n,r=0,i=0;for(let e=0;r<this.children.length;r++){let n=this.children[r],s=e+n.size;if(s>t||n instanceof Ei){i=t-e;break}e=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(;r&&!(n=this.children[r-1]).size&&n instanceof xi&&n.side>=0;r--);if(e<=0){let t,n=!0;for(;t=r?this.children[r-1]:null,t&&t.dom.parentNode!=this.contentDOM;r--,n=!1);return t&&e&&n&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?Sr(t.dom)+1:0}}{let t,n=!0;for(;t=r<this.children.length?this.children[r]:null,t&&t.dom.parentNode!=this.contentDOM;r++,n=!1);return t&&n&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?Sr(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=n,o=0;;o++){let n=this.children[o],a=s+n.size;if(-1==r&&t<=a){let i=s+n.border;if(t>=i&&e<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,i);t=s;for(let e=o;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Sr(n.dom)+1;break}t-=n.size}-1==r&&(r=0)}if(r>-1&&(a>e||o==this.children.length-1)){e=a;for(let t=o+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=Sr(n.dom);break}e+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,r=!1){let i=Math.min(t,e),s=Math.max(t,e);for(let o=0,a=0;o<this.children.length;o++){let l=this.children[o],c=a+l.size;if(i>a&&s<c)return l.setSelection(t-a-l.border,e-a-l.border,n,r);a=c}let o=this.domFromPos(t,t?-1:1),a=e==t?o:this.domFromPos(e,e?-1:1),l=n.getSelection(),c=!1;if((_r||qr)&&t==e){let{node:t,offset:e}=o;if(3==t.nodeType){if(c=!(!e||"\n"!=t.nodeValue[e-1]),c&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(o=a={node:e.parentNode,offset:Sr(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(_r&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let t=l.focusNode.childNodes[l.focusOffset];t&&"false"==t.contentEditable&&(r=!0)}if(!(r||c&&qr)&&Er(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Er(a.node,a.offset,l.focusNode,l.focusOffset))return;let h=!1;if((l.extend||t==e)&&!c){l.collapse(o.node,o.offset);try{t!=e&&l.extend(a.node,a.offset),h=!0}catch(t){}}if(!h){if(t>e){let t=o;o=a,a=t}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],s=n+i.size;if(n==s?t<=s&&e>=n:t<s&&e>n){let r=n+i.border,o=s-i.border;if(t>=r&&e<=o)return this.dirty=t==n||e==s?2:1,void(t!=r||e!=o||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(t-r,e-r):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=s}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class xi extends wi{constructor(t,e,n,r){let i,s=e.type.toDOM;if("function"==typeof s&&(s=s(n,(()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r))),!e.type.spec.raw){if(1!=s.nodeType){let t=document.createElement("span");t.appendChild(s),s=t}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,i=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class ki extends wi{constructor(t,e,n,r){super(t,[],e,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class Si extends wi{constructor(t,e,n,r){super(t,[],n,r),this.mark=e}static create(t,e,n,r){let i=r.nodeViews[e.type.name],s=i&&i(e,r,n);return s&&s.dom||(s=dn.renderSpec(document,e.type.spec.toDOM(e,n))),new Si(t,e,s.dom,s.contentDOM||s.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let r=Si.create(this.parent,this.mark,!0,n),i=this.children,s=this.size;e<s&&(i=zi(i,e,s,n)),t>0&&(i=zi(i,0,t,n));for(let t=0;t<i.length;t++)i[t].parent=r;return r.children=i,r}}class Oi extends wi{constructor(t,e,n,r,i,s,o,a,l){super(t,[],i,s),this.node=e,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o,s&&this.updateChildren(a,l)}static create(t,e,n,r,i,s){let o,a=i.nodeViews[e.type.name],l=a&&a(e,i,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),n,r),c=l&&l.dom,h=l&&l.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else c||({dom:c,contentDOM:h}=dn.renderSpec(document,e.type.spec.toDOM(e)));h||e.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let d=c;return c=Bi(c,n,e),l?o=new Ci(t,e,n,r,c,h||null,d,l,i,s+1):e.isText?new Ai(t,e,n,r,c,d,i):new Oi(t,e,n,r,c,h||null,d,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>he.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&Fi(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,r=e,i=t.composing?this.localCompositionInfo(t,e):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,a=new Vi(this,s&&s.node,t);!function(t,e,n,r){let i=e.locals(t),s=0;if(0==i.length){for(let n=0;n<t.childCount;n++){let o=t.child(n);r(o,i,e.forChild(s,o),n),s+=o.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){if(o<i.length&&i[o].to==s){let t,e=i[o++];for(;o<i.length&&i[o].to==s;)(t||(t=[e])).push(i[o++]);if(t){t.sort(Li);for(let e=0;e<t.length;e++)n(t[e],c,!!l)}else n(e,c,!!l)}let h,d;if(l)d=-1,h=l,l=null;else{if(!(c<t.childCount))break;d=c,h=t.child(c++)}for(let t=0;t<a.length;t++)a[t].to<=s&&a.splice(t--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let u=s+h.nodeSize;if(h.isText){let t=u;o<i.length&&i[o].from<t&&(t=i[o].from);for(let e=0;e<a.length;e++)a[e].to<t&&(t=a[e].to);t<u&&(l=h.cut(t-s),h=h.cut(0,t-s),u=t,d=-1)}let p=h.isInline&&!h.isLeaf?a.filter((t=>!t.inline)):a.slice();r(h,p,e.forChild(s,h),d),s=u}}(this.node,this.innerDeco,((e,i,s)=>{e.spec.marks?a.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?fe.none:this.node.child(i).marks,n,t),a.placeWidget(e,t,r)}),((e,s,l,c)=>{let h;a.syncToMarks(e.marks,n,t),a.findNodeMatch(e,s,l,c)||o&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(e,s,l,h,t)||a.updateNextNode(e,s,l,t,c)||a.addNode(e,s,l,t,r),r+=e.nodeSize})),a.syncToMarks([],n,t),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),Ti(this.contentDOM,this.children,t),Jr&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:r}=t.state.selection;if(!(t.state.selection instanceof ir)||n<e||r>e+this.node.content.size)return null;let i=t.domSelectionRange(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];e=Nr(t=t.childNodes[e-1])}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let t=s.nodeValue,i=function(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<t.childCount;){let e=t.child(i++);if(s+=e.nodeSize,!e.isText)break;l+=e.text}if(s>=n){let t=a<r?l.lastIndexOf(e,r-a-1):-1;if(t>=0&&t+e.length+a>=n)return a+t;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}(this.node.content,t,n-e,r-e);return i<0?null:{node:s,pos:i,text:t}}return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:r}){if(this.getDesc(e))return;let i=e;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 s=new ki(this,i,e,r);t.input.compositionNodes.push(s),this.children=zi(this.children,n,n+r.length,t,s)}update(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)}updateInner(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(Fi(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Ii(this.dom,this.nodeDOM,$i(this.outerDeco,this.node,e),$i(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function Mi(t,e,n,r,i){return Bi(r,e,t),new Oi(void 0,t,e,n,r,r,r,i,0)}class Ai extends Oi{constructor(t,e,n,r,i,s,o){super(t,e,n,r,i,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,!0)}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let r=this.node.cut(t,e),i=document.createTextNode(r.text);return new Ai(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}}class Ei extends wi{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Ci extends Oi{constructor(t,e,n,r,i,s,o,a,l,c){super(t,e,n,r,i,s,o,l,c),this.spec=a}update(t,e,n,r){if(3==this.dirty)return!1;if(this.spec.update){let i=this.spec.update(t,e,n);return i&&this.updateInner(t,e,n,r),i}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n):super.setSelection(t,e,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Ti(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],a=o.dom;if(a.parentNode==t){for(;a!=r;)r=Pi(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(o instanceof Si){let e=r?r.previousSibling:t.lastChild;Ti(o.contentDOM,o.children,n),r=e?e.nextSibling:t.firstChild}}for(;r;)r=Pi(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Ni=function(t){t&&(this.nodeName=t)};Ni.prototype=Object.create(null);const Di=[new Ni];function $i(t,e,n){if(0==t.length)return Di;let r=n?Di[0]:new Ni,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new Ni(o.nodeName));for(let t in o){let s=o[t];null!=s&&(n&&1==i.length&&i.push(r=new Ni(e.isInline?"span":"div")),"class"==t?r.class=(r.class?r.class+" ":"")+s:"style"==t?r.style=(r.style?r.style+";":"")+s:"nodeName"!=t&&(r[t]=s))}}}return i}function Ii(t,e,n,r){if(n==Di&&r==Di)return e;let i=e;for(let e=0;e<r.length;e++){let s=r[e],o=n[e];if(e){let e;o&&o.nodeName==s.nodeName&&i!=t&&(e=i.parentNode)&&e.nodeName.toLowerCase()==s.nodeName||(e=document.createElement(s.nodeName),e.pmIsDeco=!0,e.appendChild(i),o=Di[0]),i=e}Ri(i,o||Di[0],s)}return i}function Ri(t,e,n){for(let r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)-1==i.indexOf(r[e])&&t.classList.remove(r[e]);for(let e=0;e<i.length;e++)-1==r.indexOf(i[e])&&t.classList.add(i[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function Bi(t,e,n){return Ii(t,t,Di,$i(e,n,1!=t.nodeType))}function Fi(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Pi(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Vi{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];t:for(;i>0;){let a;for(;;)if(r){let t=n.children[r-1];if(!(t instanceof Si)){a=t,r--;break}n=t,r=t.children.length}else{if(n==e)break t;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let r=0,i=this.stack.length>>1,s=Math.min(i,t.length);for(;r<s&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<t.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++)if(this.top.children[e].matchesMark(t[i])){r=e;break}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Si.create(this.top,t[i],e,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(t,e,n,r){let i,s=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(t,e,n))s=this.top.children.indexOf(i,this.index);else for(let r=this.index,i=Math.min(this.top.children.length,r+5);r<i;r++){let i=this.top.children[r];if(i.matchesNode(t,e,n)&&!this.preMatch.matched.has(i)){s=r;break}}return!(s<0)&&(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(t,e,n,r,i){let s=this.top.children[r];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(t,e,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,r,i){for(let s=this.index;s<this.top.children.length;s++){let o=this.top.children[s];if(o instanceof Oi){let a=this.preMatch.matched.get(o);if(null!=a&&a!=i)return!1;let l=o.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(t.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==t.text&&3!=o.dirty&&Fi(e,o.outerDeco)))&&o.update(t,e,n,r))return this.destroyBetween(this.index,s),o.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1}addNode(t,e,n,r,i){this.top.children.splice(this.index++,0,Oi.create(this.top,t,e,n,r,i)),this.changed=!0}placeWidget(t,e,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){let r=new xi(this.top,t,e,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof Si;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Ai)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((qr||Wr)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let r=new Ei(this.top,[],n,null);e!=this.top?e.children.push(r):e.children.splice(this.index++,0,r),this.changed=!0}}}function Li(t,e){return t.type.side-e.type.side}function zi(t,e,n,r,i){let s=[];for(let o=0,a=0;o<t.length;o++){let l=t[o],c=a,h=a+=l.size;c>=n||h<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),i&&(s.push(i),i=void 0),h>n&&s.push(l.slice(n-c,l.size,r)))}return s}function ji(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&0==i.size,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a,l,c=r.resolve(o);if($r(n)){for(a=c;i&&!i.node;)i=i.parent;let t=i.node;if(i&&t.isAtom&&or.isSelectable(t)&&i.parent&&(!t.isInline||!function(t,e,n){for(let r=0==e,i=e==Nr(t);r||i;){if(t==n)return!0;let e=Sr(t);if(!(t=t.parentNode))return!1;r=r&&0==e,i=i&&e==Nr(t)}}(n.focusNode,n.focusOffset,i.dom))){let t=i.posBefore;l=new or(o==t?c:r.resolve(t))}}else{let e=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(e<0)return null;a=r.resolve(e)}if(!l){l=Yi(t,a,c,"pointer"==e||t.state.selection.head<c.pos&&!s?1:-1)}return l}function _i(t){return t.editable?t.hasFocus():Zi(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ki(t,e=!1){let n=t.state.selection;if(Ui(t,n),_i(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Wr){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&Er(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i="IMG"==r.nodeName;i?n.setEnd(r.parentNode,Sr(r)+1):n.setEnd(r,0);n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&zr&&jr<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{let r,i,{anchor:s,head:o}=n;!Wi||n instanceof ir||(n.$from.parent.inlineContent||(r=Hi(t,n.from)),n.empty||n.$from.parent.inlineContent||(i=Hi(t,n.to))),t.docView.setSelection(s,o,t.root,e),Wi&&(r&&Ji(r),i&&Ji(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==i||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{_i(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Wi=qr||Wr&&Hr<63;function Hi(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(qr&&i&&"false"==i.contentEditable)return qi(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return qi(i);if(s)return qi(s)}}function qi(t){return t.contentEditable="true",qr&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ji(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Ui(t,e){if(e instanceof or){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Gi(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Gi(t)}function Gi(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Yi(t,e,n,r){return t.someProp("createSelectionBetween",(r=>r(t,e,n)))||ir.between(e,n,r)}function Xi(t){return!(t.editable&&!t.hasFocus())&&Zi(t)}function Zi(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Qi(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&tr.findFrom(s,e)}function ts(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function es(t,e,n){let r=t.state.selection;if(!(r instanceof ir)){if(r instanceof or&&r.node.isInline)return ts(t,new ir(e>0?r.$to:r.$from));{let n=Qi(t.state,e);return!!n&&ts(t,n)}}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){let n=Qi(t.state,e);return!!(n&&n instanceof or)&&ts(t,n)}if(!(Ur&&n.indexOf("m")>-1)){let n,i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let o=e<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=t.docView.descAt(o))&&!n.contentDOM)&&(or.isSelectable(s)?ts(t,new or(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):!!Yr&&ts(t,new ir(t.state.doc.resolve(e<0?o:o+s.nodeSize))))}}function ns(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function rs(t){let e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function is(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(_r&&1==n.nodeType&&r<ns(n)&&rs(n.childNodes[r])&&(o=!0);;)if(r>0){if(1!=n.nodeType)break;{let t=n.childNodes[r-1];if(rs(t))i=n,s=--r;else{if(3!=t.nodeType)break;n=t,r=n.nodeValue.length}}}else{if(as(n))break;{let e=n.previousSibling;for(;e&&rs(e);)i=n.parentNode,s=Sr(e),e=e.previousSibling;if(e)n=e,r=ns(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?ls(t,n,r):i&&ls(t,i,s)}function ss(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=ns(n);for(;;)if(r<o){if(1!=n.nodeType)break;if(!rs(n.childNodes[r]))break;i=n,s=++r}else{if(as(n))break;{let e=n.nextSibling;for(;e&&rs(e);)i=e.parentNode,s=Sr(e)+1,e=e.nextSibling;if(e)n=e,r=0,o=ns(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&ls(t,i,s)}function as(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function ls(t,e,n){let r=t.domSelection();if($r(r)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),r.removeAllRanges(),r.addRange(t)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout((()=>{t.state==i&&Ki(t)}),50)}function cs(t,e,n){let r=t.state.selection;if(r instanceof ir&&!r.empty||n.indexOf("s")>-1)return!1;if(Ur&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=Qi(t.state,e);if(n&&n instanceof or)return ts(t,n)}if(!i.parent.inlineContent){let n=e<0?i:s,o=r instanceof lr?tr.near(n,e):tr.findFrom(n,e);return!!o&&ts(t,o)}return!1}function hs(t,e){if(!(t.state.selection instanceof ir))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=t.state.tr;return e<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),t.dispatch(r),!0}return!1}function ds(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function us(t,e){let n=e.keyCode,r=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||Ur&&72==n&&"c"==r?hs(t,-1)||is(t):46==n||Ur&&68==n&&"c"==r?hs(t,1)||ss(t):13==n||27==n||(37==n||Ur&&66==n&&"c"==r?es(t,-1,r)||is(t):39==n||Ur&&70==n&&"c"==r?es(t,1,r)||ss(t):38==n||Ur&&80==n&&"c"==r?cs(t,-1,r)||is(t):40==n||Ur&&78==n&&"c"==r?function(t){if(!qr||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;ds(t,n,"true"),setTimeout((()=>ds(t,n,"false")),20)}return!1}(t)||cs(t,1,r)||ss(t):r==(Ur?"m":"c")&&(66==n||73==n||89==n||90==n))}function ps(t,e){t.someProp("transformCopied",(t=>{e=t(e)}));let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let t=r.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),r=t.content}let o=t.someProp("clipboardSerializer")||dn.fromSchema(t.state.schema),a=Ss(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c,h=l.firstChild,d=0;for(;h&&1==h.nodeType&&(c=xs[h.nodeName.toLowerCase()]);){for(let t=c.length-1;t>=0;t--){let e=a.createElement(c[t]);for(;l.firstChild;)e.appendChild(l.firstChild);l.appendChild(e),d++}h=l.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let u=t.someProp("clipboardTextSerializer",(t=>t(e)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:l,text:u}}function fs(t,e,n,r,i){let s,o,a=i.parent.type.spec.code;if(!n&&!e)return null;let l=e&&(r||a||!n);if(l){if(t.someProp("transformPastedText",(t=>{e=t(e,a||r)})),a)return e?new ge(he.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):ge.empty;let n=t.someProp("clipboardTextParser",(t=>t(e,i,r)));if(n)o=n;else{let n=i.marks(),{schema:r}=t.state,o=dn.fromSchema(r);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=s.appendChild(document.createElement("p"));t&&e.appendChild(o.serializeNode(r.text(t,n)))}))}}else t.someProp("transformPastedHTML",(t=>{n=t(n)})),s=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,r=Ss().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(t);(n=i&&xs[i[1].toLowerCase()])&&(t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join(""));if(r.innerHTML=t,n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}(n),Yr&&function(t){let e=t.querySelectorAll(Wr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(s);let c=s&&s.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let t=+h[3];t>0&&s.firstChild;t--)s=s.firstChild;if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||tn.fromSchema(t.state.schema);o=e.parseSlice(s,{preserveWhitespace:!(!l&&!h),context:i,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||ms.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(h)o=function(t,e){if(!t.size)return t;let n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}let{content:i,openStart:s,openEnd:o}=t;for(let t=n.length-2;t>=0;t-=2){let e=r.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;i=he.from(e.create(n[t+1],i)),s++,o++}return new ge(i,s,o)}(ws(o,+h[1],+h[2]),h[4]);else if(o=ge.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r,i=e.node(n).contentMatchAt(e.index(n)),s=[];if(t.forEach((t=>{if(!s)return;let e,n=i.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&r.length&&ys(n,r,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=vs(s[s.length-1],r.length));let e=gs(t,n);s.push(e),i=i.matchType(e.type),r=n}})),s)return he.from(s)}return t}(o.content,i),!0),o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);o=ws(o,t,e)}return t.someProp("transformPasted",(t=>{o=t(o)})),o}const ms=/^(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 gs(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,he.from(t));return t}function ys(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=ys(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(he.from(gs(n,t,i+1))))}}function vs(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,vs(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(he.empty,!0);return t.copy(n.append(r))}function bs(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,a=o.content;return i<r-1&&(a=bs(a,e,n,r,i+1,s)),i>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,t.childCount>1||s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(he.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function ws(t,e,n){return e<t.openStart&&(t=new ge(bs(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new ge(bs(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const xs={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 ks=null;function Ss(){return ks||(ks=document.implementation.createHTMLDocument("title"))}const Os={},Ms={},As={touchstart:!0,touchmove:!0};class Es{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Cs(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Ts(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>Ns(t,e))}))}function Ns(t,e){return t.someProp("handleDOMEvents",(n=>{let r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function Ds(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function $s(t){return{left:t.clientX,top:t.clientY}}function Is(t,e,n,r,i){if(-1==r)return!1;let s=t.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--)if(t.someProp(e,(e=>r>s.depth?e(t,n,s.nodeAfter,s.before(r),i,!0):e(t,n,s.node(r),s.before(r),i,!1))))return!0;return!1}function Rs(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Bs(t,e,n,r,i){return Is(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(n=>n(t,e,r)))||(i?function(t,e){if(-1==e)return!1;let n,r,i=t.state.selection;i instanceof or&&(n=i.node);let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(or.isSelectable(e)){r=n&&i.$from.depth>0&&t>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(t);break}}return null!=r&&(Rs(t,or.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&or.isSelectable(r))&&(Rs(t,new or(n),"pointer"),!0)}(t,n))}function Fs(t,e,n,r){return Is(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(n=>n(t,e,r)))}function Ps(t,e,n,r){return Is(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(n=>n(t,e,r)))||function(t,e,n){if(0!=n.button)return!1;let r=t.state.doc;if(-1==e)return!!r.inlineContent&&(Rs(t,ir.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(e);for(let e=i.depth+1;e>0;e--){let n=e>i.depth?i.nodeAfter:i.node(e),s=i.before(e);if(n.inlineContent)Rs(t,ir.create(r,s+1,s+1+n.content.size),"pointer");else{if(!or.isSelectable(n))continue;Rs(t,or.create(r,s),"pointer")}return!0}}(t,n,r)}function Vs(t){return Hs(t)}Ms.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!js(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!Gr||!Wr||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!Jr||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",(e=>e(t,n)))||us(t,n)?n.preventDefault():Cs(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,Ir(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},Ms.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},Ms.keypress=(t,e)=>{let n=e;if(js(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ur&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n))))return void n.preventDefault();let r=t.state.selection;if(!(r instanceof ir&&r.$from.sameParent(r.$to))){let e=String.fromCharCode(n.charCode);t.someProp("handleTextInput",(n=>n(t,r.$from.pos,r.$to.pos,e)))||t.dispatch(t.state.tr.insertText(e).scrollIntoView()),n.preventDefault()}};const Ls=Ur?"metaKey":"ctrlKey";Os.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Vs(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(n,t.input.lastClick)&&!n[Ls]&&("singleClick"==t.input.lastClick.type?s="doubleClick":"doubleClick"==t.input.lastClick.type&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=t.posAtCoords($s(n));o&&("singleClick"==s?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new zs(t,o,n,!!r)):("doubleClick"==s?Fs:Ps)(t,o.pos,o.inside,n)?n.preventDefault():Cs(t,"pointer"))};class zs{constructor(t,e,n,r){let i,s;if(this.view=t,this.pos=e,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[Ls],this.allowDefault=n.shiftKey,e.inside>-1)i=t.state.doc.nodeAt(e.inside),s=e.inside;else{let n=t.state.doc.resolve(e.pos);i=n.parent,s=n.depth?n.before():0}const o=r?null:n.target,a=o?t.docView.nearestDesc(o,!0):null;this.target=a?a.dom:null;let{selection:l}=t.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof or&&l.from<=s&&l.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!_r||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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Cs(t,"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((()=>Ki(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords($s(t))),this.updateAllowDefault(t),this.allowDefault||!e?Cs(this.view,"pointer"):Bs(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||qr&&this.mightDrag&&!this.mightDrag.node.isAtom||Wr&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Rs(this.view,tr.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):Cs(this.view,"pointer")}move(t){this.updateAllowDefault(t),Cs(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function js(t,e){return!!t.composing||!!(qr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}Os.touchstart=t=>{t.input.lastTouch=Date.now(),Vs(t),Cs(t,"pointer")},Os.touchmove=t=>{t.input.lastTouch=Date.now(),Cs(t,"pointer")},Os.contextmenu=t=>Vs(t);const _s=Gr?5e3:-1;function Ks(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>Hs(t)),e))}function Ws(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Hs(t,e=!1){if(!(Gr&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Ws(t),e||t.docView&&t.docView.dirty){let e=ji(t);return e&&!e.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(e)):t.updateState(t.state),!0}return!1}}Ms.compositionstart=Ms.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||n.marks(),Hs(t,!0),t.markCursor=null;else if(Hs(t),_r&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,r=e.focusOffset;n&&1==n.nodeType&&0!=r;){let e=r<0?n.lastChild:n.childNodes[r-1];if(!e)break;if(3==e.nodeType){t.domSelection().collapse(e,e.nodeValue.length);break}n=e,r=-1}}t.input.composing=!0}Ks(t,_s)},Ms.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,Ks(t,20))};const qs=zr&&jr<15||Jr&&Xr<604;function Js(t,e,n,r){let i=fs(t,e,n,t.input.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,r,i||ge.empty))))return!0;if(!i)return!1;let s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),o=s?t.state.tr.replaceSelectionWith(s,t.input.shiftKey):t.state.tr.replaceSelection(i);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Os.copy=Ms.cut=(t,e)=>{let n=e,r=t.state.selection,i="cut"==n.type;if(r.empty)return;let s=qs?null:n.clipboardData,o=r.content(),{dom:a,text:l}=ps(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Ms.paste=(t,e)=>{let n=e;if(t.composing&&!Gr)return;let r=qs?null:n.clipboardData;r&&Js(t,r.getData("text/plain"),r.getData("text/html"),n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Js(t,r.value,null,e):Js(t,r.textContent,r.innerHTML,e)}),50)}(t,n)};class Us{constructor(t,e){this.slice=t,this.move=e}}const Gs=Ur?"altKey":"ctrlKey";Os.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords($s(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof or?i.to-1:i.to));else if(r&&r.mightDrag)t.dispatch(t.state.tr.setSelection(or.create(t.state.doc,r.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&t.dispatch(t.state.tr.setSelection(or.create(t.state.doc,e.posBefore)))}let o=t.state.selection.content(),{dom:a,text:l}=ps(t,o);n.dataTransfer.clearData(),n.dataTransfer.setData(qs?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",qs||n.dataTransfer.setData("text/plain",l),t.dragging=new Us(o,!n[Gs])},Os.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},Ms.dragover=Ms.dragenter=(t,e)=>e.preventDefault(),Ms.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords($s(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",(t=>{o=t(o)})):o=fs(t,n.dataTransfer.getData(qs?"Text":"text/plain"),qs?null:n.dataTransfer.getData("text/html"),!1,s);let a=!(!r||n[Gs]);if(t.someProp("handleDrop",(e=>e(t,n,o||ge.empty,a))))return void n.preventDefault();if(!o)return;n.preventDefault();let l=o?Ln(t.state.doc,s.pos,o):s.pos;null==l&&(l=s.pos);let c=t.state.tr;a&&c.deleteSelection();let h=c.mapping.map(l),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=c.doc;if(d?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(u))return;let p=c.doc.resolve(h);if(d&&or.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new or(p));else{let e=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((t,n,r,i)=>e=i)),c.setSelection(Yi(t,p,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},Os.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Ki(t)}),20))},Os.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},Os.beforeinput=(t,e)=>{if(Wr&&Gr&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,Ir(8,"Backspace")))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let t in Ms)Os[t]=Ms[t];function Ys(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Xs{constructor(t,e){this.toDOM=t,this.spec=e||no,this.side=this.spec.side||0}map(t,e,n,r){let{pos:i,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new to(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof Xs&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ys(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Zs{constructor(t,e){this.attrs=t,this.spec=e||no}map(t,e,n,r){let i=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new to(i,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Zs&&Ys(this.attrs,t.attrs)&&Ys(this.spec,t.spec)}static is(t){return t.type instanceof Zs}destroy(){}}class Qs{constructor(t,e){this.attrs=t,this.spec=e||no}map(t,e,n,r){let i=t.mapResult(e.from+r,1);if(i.deleted)return null;let s=t.mapResult(e.to+r,-1);return s.deleted||s.pos<=i.pos?null:new to(i.pos-n,s.pos-n,this)}valid(t,e){let n,{index:r,offset:i}=t.content.findIndex(e.from);return i==e.from&&!(n=t.child(r)).isText&&i+n.nodeSize==e.to}eq(t){return this==t||t instanceof Qs&&Ys(this.attrs,t.attrs)&&Ys(this.spec,t.spec)}destroy(){}}class to{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new to(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new to(t,t,new Xs(e,n))}static inline(t,e,n,r){return new to(t,e,new Zs(n,r))}static node(t,e,n,r){return new to(t,e,new Qs(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Zs}}const eo=[],no={};class ro{constructor(t,e){this.local=t.length?t:eo,this.children=e.length?e:eo}static create(t,e){return e.length?co(e,t,0,no):io}find(t,e,n){let r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r}findInner(t,e,n,r,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=e&&o.to>=t&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,n,r+o,i)}}map(t,e,n){return this==io||0==t.maps.length?this:this.mapInner(t,e,0,0,n||no)}mapInner(t,e,n,r,i){let s;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(t,n,r);a&&a.type.valid(e,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?function(t,e,n,r,i,s,o){let a=t.slice();for(let t=0,e=s;t<n.maps.length;t++){let r=0;n.maps[t].forEach(((t,n,s,o)=>{let l=o-s-(n-t);for(let o=0;o<a.length;o+=3){let c=a[o+1];if(c<0||t>c+e-r)continue;let h=a[o]+e-r;n>=h?a[o+1]=t<=h?-2:-1:s>=i&&l&&(a[o]+=l,a[o+1]+=l)}r+=l})),e=n.maps[t].map(e,-1)}let l=!1;for(let e=0;e<a.length;e+=3)if(a[e+1]<0){if(-2==a[e+1]){l=!0,a[e+1]=-1;continue}let c=n.map(t[e]+s),h=c-i;if(h<0||h>=r.content.size){l=!0;continue}let d=n.map(t[e+1]+s,-1)-i,{index:u,offset:p}=r.content.findIndex(h),f=r.maybeChild(u);if(f&&p==h&&p+f.nodeSize==d){let r=a[e+2].mapInner(n,f,c+1,t[e]+s+1,o);r!=io?(a[e]=h,a[e+1]=d,a[e+2]=r):(a[e+1]=-2,l=!0)}else l=!0}if(l){let l=function(t,e,n,r,i,s,o){function a(t,e){for(let s=0;s<t.local.length;s++){let a=t.local[s].map(r,i,e);a?n.push(a):o.onRemove&&o.onRemove(t.local[s].spec)}for(let n=0;n<t.children.length;n+=3)a(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&a(t[n+2],e[n]+s+1);return n}(a,t,e,n,i,s,o),c=co(l,r,0,o);e=c.local;for(let t=0;t<a.length;t+=3)a[t+1]<0&&(a.splice(t,3),t-=3);for(let t=0,e=0;t<c.children.length;t+=3){let n=c.children[t];for(;e<a.length&&a[e]<n;)e+=3;a.splice(e,0,c.children[t],c.children[t+1],c.children[t+2])}}return new ro(e.sort(ho),a)}(this.children,s||[],t,e,n,r,i):s?new ro(s.sort(ho),eo):io}add(t,e){return e.length?this==io?ro.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let r,i=0;t.forEach(((t,s)=>{let o,a=s+n;if(o=ao(e,t,a)){for(r||(r=this.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,o,a+1):r.splice(i,0,s,s+t.nodeSize,co(o,t,a+1,no)),i+=3}}));let s=oo(i?lo(e):e,-n);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||s.splice(e--,1);return new ro(s.length?this.local.concat(s).sort(ho):this.local,r||this.children)}remove(t){return 0==t.length||this==io?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,s=n[r]+e,o=n[r+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>s&&e.to<o&&(t[n]=null,(i||(i=[])).push(e));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,s+1);a!=io?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,i=0;i<t.length;i++)if(n=t[i])for(let t=0;t<r.length;t++)r[t].eq(n,e)&&(r==this.local&&(r=this.local.slice()),r.splice(t--,1));return n==this.children&&r==this.local?this:r.length||n.length?new ro(r,n):io}forChild(t,e){if(this==io)return this;if(e.isLeaf)return ro.empty;let n,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let i=t+1,s=i+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>i&&e.type instanceof Zs){let t=Math.max(i,e.from)-i,n=Math.min(s,e.to)-i;t<n&&(r||(r=[])).push(e.copy(t,n))}}if(r){let t=new ro(r.sort(ho),eo);return n?new so([t,n]):t}return n||io}eq(t){if(this==t)return!0;if(!(t instanceof ro)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return uo(this.localsInner(t))}localsInner(t){if(this==io)return eo;if(t.inlineContent||!this.local.some(Zs.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof Zs||e.push(this.local[t]);return e}}ro.empty=new ro([],[]),ro.removeOverlap=uo;const io=ro.empty;class so{constructor(t){this.members=t}map(t,e){const n=this.members.map((n=>n.map(t,e,no)));return so.from(n)}forChild(t,e){if(e.isLeaf)return ro.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(t,e);i!=io&&(i instanceof so?n=n.concat(i.members):n.push(i))}return so.from(n)}eq(t){if(!(t instanceof so)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(t);if(i.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<i.length;t++)e.push(i[t])}else e=i}return e?uo(n?e:e.sort(ho)):eo}static from(t){switch(t.length){case 0:return io;case 1:return t[0];default:return new so(t)}}}function oo(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new to(i.from+e,i.to+e,i.type))}return n}function ao(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let e,s=0;s<t.length;s++)(e=t[s])&&e.from>n&&e.to<r&&((i||(i=[])).push(e),t[s]=null);return i}function lo(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function co(t,e,n,r){let i=[],s=!1;e.forEach(((e,o)=>{let a=ao(t,e,o+n);if(a){s=!0;let t=co(a,e,n+o+1,r);t!=io&&i.push(o,o+e.nodeSize,t)}}));let o=oo(s?lo(t):t,-n).sort(ho);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||(r.onRemove&&r.onRemove(o[t].spec),o.splice(t--,1));return o.length||i.length?new ro(o,i):io}function ho(t,e){return t.from-e.from||t.to-e.to}function uo(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from!=r.from){s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),po(e,i,r.copy(s.from,r.to)));break}s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),po(e,i+1,s.copy(r.to,s.to)))}}return e}function po(t,e,n){for(;e<t.length&&ho(n,t[e])>0;)e++;t.splice(e,0,n)}function fo(t){let e=[];return t.someProp("decorations",(n=>{let r=n(t.state);r&&r!=io&&e.push(r)})),t.cursorWrapper&&e.push(ro.create(t.state.doc,[t.cursorWrapper.deco])),so.from(e)}const mo={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},go=zr&&jr<=11;class yo{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class vo{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yo,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);zr&&jr<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),go&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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,mo)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);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(Xi(this.view)){if(this.suppressingSelectionUpdates)return Ki(this.view);if(zr&&jr<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Er(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=Or(e))n.add(e);for(let r=t.anchorNode;r;r=Or(r))if(n.has(r)){e=r;break}let r=e&&this.view.docView.nearestDesc(e);return r&&r.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.observer?this.observer.takeRecords():[];this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);let n=t.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Xi(t)&&!this.ignoreSelectionChange(n),i=-1,s=-1,o=!1,a=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],a);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(o=!0))}if(_r&&a.length>1){let t=a.filter((t=>"BR"==t.nodeName));if(2==t.length){let e=t[0],n=t[1];e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}}let l=null;i<0&&r&&t.input.lastFocus>Date.now()-200&&t.input.lastTouch<Date.now()-300&&$r(n)&&(l=ji(t))&&l.eq(tr.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Ki(t),this.currentSelection.set(n),t.scrollToSelection()):(i>-1||r)&&(i>-1&&(t.docView.markDirty(i,s),function(t){if(bo.has(t))return;if(bo.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)){if(t.requiresGeckoHackNode=_r,wo)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."),wo=!0}}(t)),this.handleDOMChange(i,s,o,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||Ki(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++)e.push(t.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let r=t.previousSibling,i=t.nextSibling;if(zr&&jr<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:s}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(r=n),(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)&&(i=s)}let s=r&&r.parentNode==t.target?Sr(r)+1:0,o=n.localPosFromDOM(t.target,s,-1),a=i&&i.parentNode==t.target?Sr(i):t.target.childNodes.length;return{from:o,to:n.localPosFromDOM(t.target,a,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}let bo=new WeakMap,wo=!1;function xo(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(qr&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||qr&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}function ko(t,e,n,r,i){if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=ji(t,e);if(n&&!t.state.selection.eq(n)){let r=t.state.tr.setSelection(n);"pointer"==e?r.setMeta("pointer",!0):"key"==e&&r.scrollIntoView(),t.dispatch(r)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let a,l,c=t.state.selection,h=function(t,e,n){let r,{node:i,fromOffset:s,toOffset:o,from:a,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),h=c.anchorNode;if(h&&t.dom.contains(1==h.nodeType?h:h.parentNode)&&(r=[{node:h,offset:c.anchorOffset}],$r(c)||r.push({node:c.focusNode,offset:c.focusOffset})),Wr&&8===t.input.lastKeyCode)for(let t=o;t>s;t--){let e=i.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){o=t;break}if(!n||n.size)break}let d=t.state.doc,u=t.someProp("domParser")||tn.fromSchema(t.state.schema),p=d.resolve(a),f=null,m=u.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:xo,context:p});if(r&&null!=r[0].pos){let t=r[0].pos,e=r[1]&&r[1].pos;null==e&&(e=t),f={anchor:t+a,head:e+a}}return{doc:m,sel:f,from:a,to:l}}(t,e,n),d=t.state.doc,u=d.slice(h.from,h.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(a=t.state.selection.to,l="end"):(a=t.state.selection.from,l="start"),t.input.lastKeyCode=null;let p=function(t,e,n,r,i){let s=t.findDiffStart(e,n);if(null==s)return null;let{a:o,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==i){r-=o+Math.max(0,s-Math.min(o,a))-s}if(o<s&&t.size<e.size){s-=r<=s&&r>=o?s-r:0,a=s+(a-o),o=s}else if(a<s){s-=r<=s&&r>=a?s-r:0,o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}(u.content,h.doc.content,h.from,a,l);if((Jr&&t.input.lastIOSEnter>Date.now()-225||Gr)&&i.some((t=>"DIV"==t.nodeName||"P"==t.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,Ir(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!p){if(!(r&&c instanceof ir&&!c.empty&&c.$head.sameParent(c.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let e=So(t,t.state.doc,h.sel);e&&!e.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(e))}return}p={start:c.from,endA:c.to,endB:c.to}}if(Wr&&t.cursorWrapper&&h.sel&&h.sel.anchor==t.cursorWrapper.deco.from&&h.sel.head==h.sel.anchor){let t=p.endB-p.start;h.sel={anchor:h.sel.anchor+t,head:h.sel.anchor+t}}t.input.domChangeCount++,t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ir&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),zr&&jr<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&"  "==h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)&&(p.start--,p.endA--,p.endB--);let f,m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=d.resolve(p.start),v=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Jr&&t.input.lastIOSEnter>Date.now()-225&&(!v||i.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!v&&m.pos<h.doc.content.size&&(f=tr.findFrom(h.doc.resolve(m.pos+1),1,!0))&&f.head==g.pos)&&t.someProp("handleKeyDown",(e=>e(t,Ir(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>p.start&&function(t,e,n,r,i){if(!r.parent.isTextblock||n-e<=i.pos-r.pos||Oo(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Oo(s,!0,!0));return!(!o.parent.isTextblock||o.pos>n||Oo(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(d,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",(e=>e(t,Ir(8,"Backspace")))))return void(Gr&&Wr&&t.domObserver.suppressSelectionUpdates());Wr&&Gr&&p.endB==p.start&&(t.input.lastAndroidDelete=Date.now()),Gr&&!v&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Ir(13,"Enter"))}))}),20));let b,w,x,k=p.start,S=p.endA;if(v)if(m.pos==g.pos)zr&&jr<=11&&0==m.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>Ki(t)),20)),b=t.state.tr.delete(k,S),w=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(x=function(t,e){let n,r,i,s=t.firstChild.marks,o=e.firstChild.marks,a=s,l=o;for(let t=0;t<o.length;t++)a=o[t].removeFromSet(a);for(let t=0;t<s.length;t++)l=s[t].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",i=t=>t.mark(r.addToSet(t.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",i=t=>t.mark(r.removeFromSet(t.marks))}let c=[];for(let t=0;t<e.childCount;t++)c.push(i(e.child(t)));if(he.from(c).eq(t))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))b=t.state.tr,"add"==x.type?b.addMark(k,S,x.mark):b.removeMark(k,S,x.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,g.parentOffset);if(t.someProp("handleTextInput",(n=>n(t,k,S,e))))return;b=t.state.tr.insertText(e,k,S)}if(b||(b=t.state.tr.replace(k,S,h.doc.slice(p.start-h.from,p.endB-h.from))),h.sel){let e=So(t,b.doc,h.sel);e&&!(Wr&&Gr&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastAndroidDelete<Date.now()-100)&&(e.head==k||e.head==b.mapping.map(S)-1)||zr&&e.empty&&e.head==k)&&b.setSelection(e)}w&&b.ensureMarks(w),t.dispatch(b.scrollIntoView())}function So(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Yi(t,e.resolve(n.anchor),e.resolve(n.head))}function Oo(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let e=t.node(r).maybeChild(t.indexAfter(r));for(;e&&!e.isLeaf;)e=e.firstChild,i++}return i}class Mo{constructor(t,e){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 Es,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(No),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Co(this),Eo(this),this.nodeViews=To(this),this.docView=Mi(this.state.doc,Ao(this),fo(this),this.dom,this),this.domObserver=new vo(this,((t,e,n,r)=>ko(this,t,e,n,r))),this.domObserver.start(),function(t){for(let e in Os){let n=Os[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Ds(t,e)||Ns(t,e)||!t.editable&&e.type in Ms||n(t,e)},As[e]?{passive:!0}:void 0)}qr&&t.dom.addEventListener("input",(()=>null)),Ts(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Ts(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(No),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){let n=this.state,r=!1,i=!1;t.storedMarks&&this.composing&&(Ws(this),i=!0),this.state=t;let s=n.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=To(this);(function(t,e){let n=0,r=0;for(let r in t){if(t[r]!=e[r])return!0;n++}for(let t in e)r++;return n!=r})(t,this.nodeViews)&&(this.nodeViews=t,r=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&Ts(this),this.editable=Co(this),Eo(this);let o=fo(this),a=Ao(this),l=n.plugins==t.plugins||n.doc.eq(t.doc)?t.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=r||!this.docView.matchesNode(t.doc,a,o);!c&&t.selection.eq(n.selection)||(i=!0);let h="preserve"==l&&i&&null==this.dom.style.overflowAnchor&&function(t){let e,n,r=t.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let s=(r.left+r.right)/2,o=i+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=t.root.elementFromPoint(s,o);if(!r||r==t.dom||!t.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){e=r,n=a.top;break}}return{refDOM:e,refTop:n,stack:ni(t.dom)}}(this);if(i){this.domObserver.stop();let e=c&&(zr||Wr)&&!this.composing&&!n.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(n.selection,t.selection);if(c){let n=Wr?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(t.doc,a,o,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Mi(t.doc,a,o,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Er(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?Ki(this,e):(Ui(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():h&&function({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;ri(n,0==r?0:r-e)}(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof or){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&ei(this,e.getBoundingClientRect(),t)}else ei(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}someProp(t,e){let n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[t];if(null!=i&&(n=e?e(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let s=i[r].props[t];if(null!=s&&(n=e?e(s):s))return n}}hasFocus(){if(zr){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(ii)return t.focus(ii);let e=ni(t);t.focus(null==ii?{get preventScroll(){return ii={preventScroll:!0},!0}}:void 0),ii||(ii=!1,ri(e,0))}(this.dom),Ki(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}posAtCoords(t){return li(this,t)}coordsAtPos(t,e=1){return di(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return bi(this,e||this.state,t)}destroy(){this.docView&&(!function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],fo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Ns(t,e)||!Os[e.type]||!t.editable&&e.type in Ms||Os[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){return qr&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom?function(t){let e;function n(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",n,!0);let r=e.startContainer,i=e.startOffset,s=e.endContainer,o=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return Er(a.node,a.offset,s,o)&&([r,i,s,o]=[s,o,r,i]),{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:o}}(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function Ao(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),e.translate="no",t.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t&&(e.class+=" "+n[t]),"style"==t?e.style=(e.style?e.style+";":"")+n[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(n[t]))})),[to.node(0,t.state.doc.content.size,e)]}function Eo(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:to.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Co(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function To(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function No(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Do={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:"'"},$o={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Io="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent);"undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent);for(var Ro="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Bo="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Fo=Ro||Io&&+Io[1]<57,Po=0;Po<10;Po++)Do[48+Po]=Do[96+Po]=String(Po);for(Po=1;Po<=24;Po++)Do[Po+111]="F"+Po;for(Po=65;Po<=90;Po++)Do[Po]=String.fromCharCode(Po+32),$o[Po]=String.fromCharCode(Po);for(var Vo in Do)$o.hasOwnProperty(Vo)||($o[Vo]=Do[Vo]);const Lo="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function zo(t){let e,n,r,i,s=t.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let t=0;t<s.length-1;t++){let o=s[t];if(/^(cmd|meta|m)$/i.test(o))i=!0;else if(/^a(lt)?$/i.test(o))e=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);Lo?i=!0:n=!0}}return e&&(o="Alt-"+o),n&&(o="Ctrl-"+o),i&&(o="Meta-"+o),r&&(o="Shift-"+o),o}function jo(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}function _o(t){let e=function(t){let e=Object.create(null);for(let n in t)e[zo(n)]=t[n];return e}(t);return function(t,n){let r,i=function(t){var e=!(Fo&&(t.ctrlKey||t.altKey||t.metaKey)||Bo&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?$o:Do)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),s=1==i.length&&" "!=i,o=e[jo(i,n,!s)];if(o&&o(t.state,t.dispatch,t))return!0;if(s&&(n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(r=Do[n.keyCode])&&r!=i){let i=e[jo(r,n,!0)];if(i&&i(t.state,t.dispatch,t))return!0}else if(s&&n.shiftKey){let r=e[jo(i,n,!0)];if(r&&r(t.state,t.dispatch,t))return!0}return!1}}function Ko(t,e,n=!1){for(let r=t;r;r="start"==e?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function Wo(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Ho(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}function qo(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Jo(t,e,n){let r,i,s=e.nodeBefore,o=e.nodeAfter;if(s.type.spec.isolating||o.type.spec.isolating)return!1;if(function(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(s,s+1)||!i.isTextblock&&!Fn(t.doc,e.pos)||(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let a=e.parent.canReplace(e.index(),e.index()+1);if(a&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&i.matchType(r[0]||o.type).validEnd){if(n){let i=e.pos+o.nodeSize,a=he.empty;for(let t=r.length-1;t>=0;t--)a=he.from(r[t].create(null,a));a=he.from(s.copy(a));let l=t.tr.step(new Tn(e.pos-1,i,e.pos,i,new ge(a,1,0),r.length,!0)),c=i+2*r.length;Fn(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=tr.findFrom(e,1),c=l&&l.$from.blockRange(l.$to),h=c&&$n(c);if(null!=h&&h>=e.depth)return n&&n(t.tr.lift(c,h).scrollIntoView()),!0;if(a&&Ko(o,"start",!0)&&Ko(s,"end")){let r=s,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let a=o,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,a.content)){if(n){let r=he.empty;for(let t=i.length-1;t>=0;t--)r=he.from(i[t].copy(r));n(t.tr.step(new Tn(e.pos-i.length,e.pos+o.nodeSize,e.pos+l,e.pos+o.nodeSize-l,new ge(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Uo(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return!!i.node(s).isTextblock&&(n&&n(e.tr.setSelection(ir.create(e.doc,t<0?i.start(s):i.end(s)))),!0)}}const Go=Uo(-1),Yo=Uo(1);function Xo(t,e=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(s,o,((r,s)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(t,e))if(r.type==t)i=!0;else{let e=n.doc.resolve(s),r=e.index();i=e.parent.canReplaceWith(r,r+1,t)}}))}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(s,o,t,e)}r(i.scrollIntoView())}return!0}}function Zo(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=!1,l=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(t)&&0==o.startIndex){if(0==i.index(o.depth-1))return!1;let t=n.doc.resolve(o.start-2);l=new $e(t,t,o.depth),o.endIndex<o.parent.childCount&&(o=new $e(i,n.doc.resolve(s.end(o.depth)),o.depth)),a=!0}let c=In(l,t,e,o);return!!c&&(r&&r(function(t,e,n,r,i){let s=he.empty;for(let t=n.length-1;t>=0;t--)s=he.from(n[t].type.create(n[t].attrs,s));t.step(new Tn(e.start-(r?2:0),e.end,e.start,e.end,new ge(s,0,0),n.length,!0));let o=0;for(let t=0;t<n.length;t++)n[t].type==i&&(o=t+1);let a=n.length-o,l=e.start+n.length-(r?2:0),c=e.parent;for(let n=e.startIndex,r=e.endIndex,i=!0;n<r;n++,i=!1)!i&&Bn(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return t}(n.tr,o,c,a,t).scrollIntoView()),!0)}}function Qo(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));return!!s&&(!n||(r.node(s.depth-1).type==t?function(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Tn(s-1,o,s,o,new ge(he.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new $e(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const a=$n(r);if(null==a)return!1;i.lift(r,a);let l=i.mapping.map(s,-1)-1;Fn(i.doc,l)&&i.join(l);return e(i.scrollIntoView()),!0}(e,n,t,s):function(t,e,n){let r=t.tr,i=n.parent;for(let t=n.end,e=n.endIndex-1,s=n.startIndex;e>s;e--)t-=i.child(e).nodeSize,r.delete(t-1,t+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=s.node(-1),h=s.index(-1);if(!c.canReplace(h+(a?0:1),h+1,o.content.append(l?he.empty:he.from(i))))return!1;let d=s.pos,u=d+o.nodeSize;return r.step(new Tn(d-(a?1:0),u+(l?1:0),d+1,u-1,new ge((a?he.empty:he.from(i.copy(he.empty))).append(l?he.empty:he.from(i.copy(he.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}(e,n,s)))}}function ta(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),filterTransaction:e.filterTransaction,plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class ea{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(...t)=>{const n=e(...t)(s);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],a=!!t,l=t||i.tr,c={...Object.fromEntries(Object.entries(n).map((([t,n])=>[t,(...t)=>{const r=this.buildProps(l,e),i=n(...t)(r);return o.push(i),c}]))),run:()=>(a||!e||l.getMeta("preventDispatch")||this.hasCustomState||s.dispatch(l),o.every((t=>!0===t)))};return c}createCan(t){const{rawCommands:e,state:n}=this,r=t||n.tr,i=this.buildProps(r,false),s=Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...i,dispatch:void 0})])));return{...s,chain:()=>this.createChain(r,false)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r;i.storedMarks&&t.setStoredMarks(i.storedMarks);const o={tr:t,editor:r,view:s,state:ta({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map((([t,e])=>[t,(...t)=>e(...t)(o)])))}};return o}}function na(t,e,n){if(void 0===t.config[e]&&t.parent)return na(t.parent,e,n);if("function"==typeof t.config[e]){return t.config[e].bind({...n,parent:t.parent?na(t.parent,e,n):null})}return t.config[e]}function ra(t){return{baseExtensions:t.filter((t=>"extension"===t.type)),nodeExtensions:t.filter((t=>"node"===t.type)),markExtensions:t.filter((t=>"mark"===t.type))}}function ia(t){const e=[],{nodeExtensions:n,markExtensions:r}=ra(t),i=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach((t=>{const n=na(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage});if(!n)return;n().forEach((t=>{t.types.forEach((n=>{Object.entries(t.attributes).forEach((([t,r])=>{e.push({type:n,name:t,attribute:{...s,...r}})}))}))}))})),i.forEach((t=>{const n={name:t.name,options:t.options,storage:t.storage},r=na(t,"addAttributes",n);if(!r)return;const i=r();Object.entries(i).forEach((([n,r])=>{const i={...s,...r};"function"==typeof(null==i?void 0:i.default)&&(i.default=i.default()),(null==i?void 0:i.isRequired)&&void 0===(null==i?void 0:i.default)&&delete i.default,e.push({type:t.name,name:n,attribute:i})}))})),e}function sa(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function oa(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};return Object.entries(e).forEach((([t,e])=>{n[t]?n[t]="class"===t?[n[t],e].join(" "):"style"===t?[n[t],e].join("; "):e:n[t]=e})),n}),{})}function aa(t,e){return e.filter((t=>t.attribute.rendered)).map((e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]})).reduce(((t,e)=>oa(t,e)),{})}function la(t){return"function"==typeof t}function ca(t,e,...n){return la(t)?e?t.bind(e)(...n):t(...n):t}function ha(t,e){return t.style?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===r)return!1;const i=e.reduce(((t,e)=>{const r=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==r?t:{...t,[e.name]:r}}),{});return{...r,...i}}}}function da(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e)))}function ua(t,e){return e.nodes[t]||e.marks[t]||null}function pa(t,e){return Array.isArray(e)?e.some((e=>("string"==typeof e?e:e.name)===t.name)):e}function fa(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function ma(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null===(e=c.nodeBefore||c.nodeAfter)||void 0===e?void 0:e.marks.find((t=>t.type.spec.code))))return!1;let h=!1;const d=((t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,((t,e,i,s)=>{var o,a;const l=(null===(a=(o=t.type.spec).toText)||void 0===a?void 0:a.call(o,{node:t,pos:e,parent:i,index:s}))||t.textContent||"%leaf%";n+=l.slice(0,Math.max(0,r-e))})),n})(c)+s;return o.forEach((t=>{if(h)return;const e=((t,e)=>{if(fa(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(d,t.find);if(!e)return;const o=l.state.tr,c=ta({state:l.state,transaction:o}),u={from:r-(e[0].length-s.length),to:i},{commands:p,chain:f,can:m}=new ea({editor:n,state:c});null!==t.handler({state:c,range:u,match:e,commands:p,chain:f,can:m})&&o.steps.length&&(o.setMeta(a,{transform:o,from:r,to:i,text:s}),l.dispatch(o),h=!0)})),h}function ga(t){const{editor:e,rules:n}=t,r=new br({state:{init:()=>null,apply(t,e){const n=t.getMeta(r);return n||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:(t,i,s,o)=>ma({editor:e,from:i,to:s,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:t=>(setTimeout((()=>{const{$cursor:i}=t.state.selection;i&&ma({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(t,i){if("Enter"!==i.key)return!1;const{$cursor:s}=t.state.selection;return!!s&&ma({editor:e,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function ya(t){const{editor:e,state:n,from:r,to:i,rule:s}=t,{commands:o,chain:a,can:l}=new ea({editor:e,state:n}),c=[];n.doc.nodesBetween(r,i,((t,e)=>{if(!t.isTextblock||t.type.spec.code)return;const h=Math.max(r,e),d=Math.min(i,e+t.content.size);((t,e)=>{if(fa(e))return[...t.matchAll(e)];const n=e(t);return n?n.map((e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n})):[]})(t.textBetween(h-e,d-e,void 0,""),s.find).forEach((t=>{if(void 0===t.index)return;const e=h+t.index+1,r=e+t[0].length,i={from:n.tr.mapping.map(e),to:n.tr.mapping.map(r)},d=s.handler({state:n,range:i,match:t,commands:o,chain:a,can:l});c.push(d)}))}));return c.every((t=>null!==t))}function va(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1;return n.map((t=>new br({view(t){const e=e=>{var n;r=(null===(n=t.dom.parentElement)||void 0===n?void 0:n.contains(e.target))?t.dom.parentElement:null};return window.addEventListener("dragstart",e),{destroy(){window.removeEventListener("dragstart",e)}}},props:{handleDOMEvents:{drop:t=>(s=r===t.dom.parentElement,!1),paste:(t,e)=>{var n;const r=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/html");return i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(n,r,o)=>{const a=n[0],l="paste"===a.getMeta("uiEvent")&&!i,c="drop"===a.getMeta("uiEvent")&&!s;if(!l&&!c)return;const h=r.doc.content.findDiffStart(o.doc.content),d=r.doc.content.findDiffEnd(o.doc.content);if("number"!=typeof h||!d||h===d.b)return;const u=o.tr,p=ta({state:o,transaction:u});return ya({editor:e,state:p,from:Math.max(h-1,0),to:d.b-1,rule:t})&&u.steps.length?u:void 0}})))}class ba{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=ba.resolve(t),this.schema=function(t,e){var n;const r=ia(t),{nodeExtensions:i,markExtensions:s}=ra(t),o=null===(n=i.find((t=>na(t,"topNode"))))||void 0===n?void 0:n.name,a=Object.fromEntries(i.map((n=>{const i=r.filter((t=>t.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:e},o=t.reduce(((t,e)=>{const r=na(e,"extendNodeSchema",s);return{...t,...r?r(n):{}}}),{}),a=da({...o,content:ca(na(n,"content",s)),marks:ca(na(n,"marks",s)),group:ca(na(n,"group",s)),inline:ca(na(n,"inline",s)),atom:ca(na(n,"atom",s)),selectable:ca(na(n,"selectable",s)),draggable:ca(na(n,"draggable",s)),code:ca(na(n,"code",s)),defining:ca(na(n,"defining",s)),isolating:ca(na(n,"isolating",s)),attrs:Object.fromEntries(i.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=ca(na(n,"parseHTML",s));l&&(a.parseDOM=l.map((t=>ha(t,i))));const c=na(n,"renderHTML",s);c&&(a.toDOM=t=>c({node:t,HTMLAttributes:aa(t,i)}));const h=na(n,"renderText",s);return h&&(a.toText=h),[n.name,a]}))),l=Object.fromEntries(s.map((n=>{const i=r.filter((t=>t.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:e},o=t.reduce(((t,e)=>{const r=na(e,"extendMarkSchema",s);return{...t,...r?r(n):{}}}),{}),a=da({...o,inclusive:ca(na(n,"inclusive",s)),excludes:ca(na(n,"excludes",s)),group:ca(na(n,"group",s)),spanning:ca(na(n,"spanning",s)),code:ca(na(n,"code",s)),attrs:Object.fromEntries(i.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=ca(na(n,"parseHTML",s));l&&(a.parseDOM=l.map((t=>ha(t,i))));const c=na(n,"renderHTML",s);return c&&(a.toDOM=t=>c({mark:t,HTMLAttributes:aa(t,i)})),[n.name,a]})));return new Ze({topNode:o,nodes:a,marks:l})}(this.extensions,e),this.extensions.forEach((t=>{var e;this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:ua(t.name,this.schema)};if("mark"===t.type){(null===(e=ca(na(t,"keepOnSplit",n)))||void 0===e||e)&&this.splittableMarks.push(t.name)}const r=na(t,"onBeforeCreate",n);r&&this.editor.on("beforeCreate",r);const i=na(t,"onCreate",n);i&&this.editor.on("create",i);const s=na(t,"onUpdate",n);s&&this.editor.on("update",s);const o=na(t,"onSelectionUpdate",n);o&&this.editor.on("selectionUpdate",o);const a=na(t,"onTransaction",n);a&&this.editor.on("transaction",a);const l=na(t,"onFocus",n);l&&this.editor.on("focus",l);const c=na(t,"onBlur",n);c&&this.editor.on("blur",c);const h=na(t,"onDestroy",n);h&&this.editor.on("destroy",h)}))}static resolve(t){const e=ba.sort(ba.flatten(t)),n=function(t){const e=t.filter(((e,n)=>t.indexOf(e)!==n));return[...new Set(e)]}(e.map((t=>t.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`),e}static flatten(t){return t.map((t=>{const e=na(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...this.flatten(e())]:t})).flat(10)}static sort(t){return t.sort(((t,e)=>{const n=na(t,"priority")||100,r=na(e,"priority")||100;return n>r?-1:n<r?1:0}))}get commands(){return this.extensions.reduce(((t,e)=>{const n=na(e,"addCommands",{name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:ua(e.name,this.schema)});return n?{...t,...n()}:t}),{})}get plugins(){const{editor:t}=this,e=ba.sort([...this.extensions].reverse()),n=[],r=[],i=e.map((e=>{const i={name:e.name,options:e.options,storage:e.storage,editor:t,type:ua(e.name,this.schema)},s=[],o=na(e,"addKeyboardShortcuts",i);let a={};if("mark"===e.type&&e.config.exitable&&(a.ArrowRight=()=>sl.handleExit({editor:t,mark:e})),o){const e=Object.fromEntries(Object.entries(o()).map((([e,n])=>[e,()=>n({editor:t})])));a={...a,...e}}const l=new br({props:{handleKeyDown:_o(a)}});s.push(l);const c=na(e,"addInputRules",i);pa(e,t.options.enableInputRules)&&c&&n.push(...c());const h=na(e,"addPasteRules",i);pa(e,t.options.enablePasteRules)&&h&&r.push(...h());const d=na(e,"addProseMirrorPlugins",i);if(d){const t=d();s.push(...t)}return s})).flat();return[ga({editor:t,rules:n}),...va({editor:t,rules:r}),...i]}get attributes(){return ia(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ra(this.extensions);return Object.fromEntries(e.filter((t=>!!na(t,"addNodeView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name)),r={name:e.name,options:e.options,storage:e.storage,editor:t,type:sa(e.name,this.schema)},i=na(e,"addNodeView",r);if(!i)return[];return[e.name,(r,s,o,a)=>{const l=aa(r,n);return i()({editor:t,node:r,getPos:o,decorations:a,HTMLAttributes:l,extension:e})}]})))}}function wa(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&(t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype)}function xa(t,e){const n={...t};return wa(t)&&wa(e)&&Object.keys(e).forEach((r=>{wa(e[r])?r in t?n[r]=xa(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})})),n}class ka{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ca(na(this,"addOptions",{name:this.name}))),this.storage=ca(na(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ka(t)}configure(t={}){const e=this.extend();return e.options=xa(this.options,t),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}extend(t={}){const e=new ka(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=ca(na(e,"addOptions",{name:e.name})),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}}function Sa(t,e,n){const{from:r,to:i}=e,{blockSeparator:s="\n\n",textSerializers:o={}}=n||{};let a="",l=!0;return t.nodesBetween(r,i,((t,n,c,h)=>{var d;const u=null==o?void 0:o[t.type.name];u?(t.isBlock&&!l&&(a+=s,l=!0),c&&(a+=u({node:t,pos:n,parent:c,index:h,range:e}))):t.isText?(a+=null===(d=null==t?void 0:t.text)||void 0===d?void 0:d.slice(Math.max(r,n)-n,i-n),l=!1):t.isBlock&&!l&&(a+=s,l=!0)})),a}function Oa(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}const Ma=ka.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new br({key:new kr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map((t=>t.$from.pos))),a=Math.max(...s.map((t=>t.$to.pos)));return Sa(r,{from:o,to:a},{textSerializers:Oa(n)})}}})]}});function Aa(t,e,n={strict:!0}){const r=Object.keys(e);return!r.length||r.every((r=>n.strict?e[r]===t[r]:fa(e[r])?e[r].test(t[r]):e[r]===t[r]))}function Ea(t,e,n={}){return t.find((t=>t.type===e&&Aa(t.attrs,n)))}function Ca(t,e,n={}){return!!Ea(t,e,n)}function Ta(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&0!==r.offset&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const i=Ea([...r.node.marks],e,n);if(!i)return;let s=r.index,o=t.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(Ea([...r.node.marks],e,n);s>0&&i.isInSet(t.parent.child(s-1).marks);)s-=1,o-=t.parent.child(s).nodeSize;for(;a<t.parent.childCount&&Ca([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function Na(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function Da(t){return t instanceof ir}function $a(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ia(t,e=null){if(!e)return null;const n=tr.atStart(t),r=tr.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return r;const i=n.from,s=r.to;return"all"===e?ir.create(t,$a(0,i,s),$a(t.content.size,i,s)):ir.create(t,$a(e,i,s),$a(e,i,s))}function Ra(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Ba(t){const e=`<body>${t}</body>`;return(new window.DOMParser).parseFromString(e,"text/html").body}function Fa(t,e,n){if(n={slice:!0,parseOptions:{},...n},"object"==typeof t&&null!==t)try{return Array.isArray(t)&&t.length>0?he.fromArray(t.map((t=>e.nodeFromJSON(t)))):e.nodeFromJSON(t)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),Fa("",e,n)}if("string"==typeof t){const r=tn.fromSchema(e);return n.slice?r.parseSlice(Ba(t),n.parseOptions).content:r.parse(Ba(t),n.parseOptions)}return Fa("",e,n)}function Pa(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function Va(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?sa(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,((t,e)=>{if(t.isText)return;const n=Math.max(r,e),s=Math.min(i,e+t.nodeSize);a.push({node:t,from:n,to:s})}));const l=i-r,c=a.filter((t=>!o||o.name===t.node.type.name)).filter((t=>Aa(t.node.attrs,n,{strict:!1})));if(s)return!!c.length;return c.reduce(((t,e)=>t+e.to-e.from),0)>=l}function La(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function za(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce(((e,r)=>(n.includes(r)||(e[r]=t[r]),e)),{})}function ja(t,e,n={}){return Fa(t,e,{slice:!1,parseOptions:n})}function _a(t){return e=>function(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}(e.$from,t)}function Ka(t,e){const n=Na(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,(t=>{o.push(...t.marks)}));const a=o.find((t=>t.type.name===n.name));return a?{...a.attrs}:{}}function Wa(t,e){const n=La("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=sa(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,(t=>{s.push(t)}));const o=s.reverse().find((t=>t.type.name===n.name));return o?{...o.attrs}:{}}(t,e):"mark"===n?Ka(t,e):{}}function Ha(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=t.find((t=>t.type===e&&t.name===n));return!!r&&r.attribute.keepOnSplit})))}function qa(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Na(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>!s||s.name===t.type.name)).find((t=>Aa(t.attrs,n,{strict:!1})));let o=0;const a=[];if(i.forEach((({$from:e,$to:n})=>{const r=e.pos,i=n.pos;t.doc.nodesBetween(r,i,((t,e)=>{if(!t.isText&&!t.marks.length)return;const n=Math.max(r,e),s=Math.min(i,e+t.nodeSize);o+=s-n,a.push(...t.marks.map((t=>({mark:t,from:n,to:s}))))}))})),0===o)return!1;const l=a.filter((t=>!s||s.name===t.mark.type.name)).filter((t=>Aa(t.mark.attrs,n,{strict:!1}))).reduce(((t,e)=>t+e.to-e.from),0),c=a.filter((t=>!s||t.mark.type!==s&&t.mark.type.excludes(s))).reduce(((t,e)=>t+e.to-e.from),0);return(l>0?l+c:l)>=o}function Ja(t,e){const{nodeExtensions:n}=ra(e),r=n.find((e=>e.name===t));if(!r)return!1;const i=ca(na(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function Ua(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter((t=>null==e?void 0:e.includes(t.type.name)));t.tr.ensureMarks(r)}}const Ga=(t,e)=>{const n=_a((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=t.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!Fn(t.doc,n.pos)||(t.join(n.pos),!0)},Ya=(t,e)=>{const n=_a((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=t.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!Fn(t.doc,r)||(t.join(r),!0)};var Xa=Object.freeze({__proto__:null,blur:()=>({editor:t,view:e})=>(requestAnimationFrame((()=>{var n;t.isDestroyed||(e.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(t=!1)=>({commands:e})=>e.setContent("",t),clearNodes:()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return!n||(i.forEach((({$from:n,$to:r})=>{t.doc.nodesBetween(n.pos,r.pos,((t,n)=>{if(t.type.isText)return;const{doc:r,mapping:i}=e,s=r.resolve(i.map(n)),o=r.resolve(i.map(n+t.nodeSize)),a=s.blockRange(o);if(!a)return;const l=$n(a);if(t.type.isTextblock){const{defaultType:t}=s.parent.contentMatchAt(s.index());e.setNodeMarkup(a.start,t)}(l||0===l)&&e.lift(a,l)}))})),!0)},command:t=>e=>t(e),createParagraphNear:()=>({state:t,dispatch:e})=>((t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof lr||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=qo(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(n,s.createAndFill());o.setSelection(ir.create(o.doc,n+1)),e(o.scrollIntoView())}return!0})(t,e),deleteCurrentNode:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let n=i.depth;n>0;n-=1){if(i.node(n).type===r.type){if(e){const e=i.before(n),r=i.after(n);t.delete(e,r).scrollIntoView()}return!0}}return!1},deleteNode:t=>({tr:e,state:n,dispatch:r})=>{const i=sa(t,n.schema),s=e.selection.$anchor;for(let t=s.depth;t>0;t-=1){if(s.node(t).type===i){if(r){const n=s.before(t),r=s.after(t);e.delete(n,r).scrollIntoView()}return!0}}return!1},deleteRange:t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},deleteSelection:()=>({state:t,dispatch:e})=>((t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0))(t,e),enter:()=>({commands:t})=>t.keyboardShortcut("Enter"),exitCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=qo(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let r=n.after(),i=t.tr.replaceWith(r,r,o.createAndFill());i.setSelection(tr.near(i.doc.resolve(r),1)),e(i.scrollIntoView())}return!0})(t,e),extendMarkRange:(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Na(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:h}=a;if(i){const t=Ta(l,s,e);if(t&&t.from<=c&&t.to>=h){const e=ir.create(o,t.from,t.to);n.setSelection(e)}}return!0},first:t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1},focus:(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{Ra()&&r.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())}))};if(r.hasFocus()&&null===t||!1===t)return!0;if(s&&null===t&&!Da(n.state.selection))return o(),!0;const a=Ia(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},forEach:(t,e)=>n=>t.every(((t,r)=>e(t,{...n,index:r}))),insertContent:(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),insertContentAt:(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const i=Fa(e,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if("<>"===i.toString())return!0;let{from:o,to:a}="number"==typeof t?{from:t,to:t}:t,l=!0,c=!0;if((i.toString().startsWith("<")?i:[i]).forEach((t=>{t.check(),l=!!l&&(t.isText&&0===t.marks.length),c=!!c&&t.isBlock})),o===a&&c){const{parent:t}=r.doc.resolve(o);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(o-=1,a+=1)}l?Array.isArray(e)?r.insertText(e.map((t=>t.text||"")).join(""),o,a):"object"==typeof e&&e&&e.text?r.insertText(e.text,o,a):r.insertText(e,o,a):r.replaceWith(o,a,i),n.updateSelection&&function(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Cn||i instanceof Tn))return;const s=t.mapping.maps[r];let o=0;s.forEach(((t,e,n,r)=>{0===o&&(o=r)})),t.setSelection(tr.near(t.doc.resolve(o),n))}(r,r.steps.length-1,-1)}return!0},joinUp:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection,i=r instanceof or;if(i){if(r.node.isTextblock||!Fn(t.doc,r.from))return!1;n=r.from}else if(n=Vn(t.doc,r.from,-1),null==n)return!1;if(e){let r=t.tr.join(n);i&&r.setSelection(or.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(r.scrollIntoView())}return!0})(t,e),joinDown:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection;if(r instanceof or){if(r.node.isTextblock||!Fn(t.doc,r.to))return!1;n=r.to}else if(n=Vn(t.doc,r.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),joinBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=function(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}(t,n);if(!r)return!1;let i=Wo(r);if(!i){let n=r.blockRange(),i=n&&$n(n);return null!=i&&(e&&e(t.tr.lift(n,i).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&Jo(t,i,e))return!0;if(0==r.parent.content.size&&(Ko(s,"end")||or.isSelectable(s))){let n=zn(t.doc,r.before(),r.after(),ge.empty);if(n&&n.slice.size<n.to-n.from){if(e){let r=t.tr.step(n);r.setSelection(Ko(s,"end")?tr.findFrom(r.doc.resolve(r.mapping.map(i.pos,-1)),-1):or.create(r.doc,i.pos-s.nodeSize)),e(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),0))})(t,e),joinForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=function(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}(t,n);if(!r)return!1;let i=Ho(r);if(!i)return!1;let s=i.nodeAfter;if(Jo(t,i,e))return!0;if(0==r.parent.content.size&&(Ko(s,"start")||or.isSelectable(s))){let n=zn(t.doc,r.before(),r.after(),ge.empty);if(n&&n.slice.size<n.to-n.from){if(e){let r=t.tr.step(n);r.setSelection(Ko(s,"start")?tr.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):or.create(r.doc,r.mapping.map(i.pos))),e(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),0))})(t,e),keyboardShortcut:t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=function(t){const e=t.split(/-(?!$)/);let n,r,i,s,o=e[e.length-1];"Space"===o&&(o=" ");for(let t=0;t<e.length-1;t+=1){const o=e[t];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))n=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error(`Unrecognized modifier name: ${o}`);Ra()||Pa()?s=!0:r=!0}}return n&&(o=`Alt-${o}`),r&&(o=`Ctrl-${o}`),s&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o}(t).split(/-(?!$)/),o=s.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t))),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,a)))}));return null==l||l.steps.forEach((t=>{const e=t.map(r.mapping);e&&i&&r.maybeStep(e)})),!0},lift:(t,e={})=>({state:n,dispatch:r})=>!!Va(n,sa(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&$n(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)})(n,r),liftEmptyBlock:()=>({state:t,dispatch:e})=>((t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Bn(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&$n(r);return null!=i&&(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)})(t,e),liftListItem:t=>({state:e,dispatch:n})=>Qo(sa(t,e.schema))(e,n),newlineInCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))})(t,e),resetAttributes:(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=La("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(s=sa(t,r.schema)),"mark"===a&&(o=Na(t,r.schema)),i&&n.selection.ranges.forEach((t=>{r.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,r)=>{s&&s===t.type&&n.setNodeMarkup(r,void 0,za(t.attrs,e)),o&&t.marks.length&&t.marks.forEach((i=>{o===i.type&&n.addMark(r,r+t.nodeSize,o.create(za(i.attrs,e)))}))}))})),!0)},scrollIntoView:()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),selectAll:()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),selectNodeBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Wo(r)}let o=s&&s.nodeBefore;return!(!o||!or.isSelectable(o)||(e&&e(t.tr.setSelection(or.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),0))})(t,e),selectNodeForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Ho(r)}let o=s&&s.nodeAfter;return!(!o||!or.isSelectable(o)||(e&&e(t.tr.setSelection(or.create(t.doc,s.pos)).scrollIntoView()),0))})(t,e),selectParentNode:()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:r,to:i}=t.selection,s=r.sharedDepth(i);return 0!=s&&(n=r.before(s),e&&e(t.tr.setSelection(or.create(t.doc,n))),!0)})(t,e),selectTextblockEnd:()=>({state:t,dispatch:e})=>Yo(t,e),selectTextblockStart:()=>({state:t,dispatch:e})=>Go(t,e),setContent:(t,e=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,a=ja(t,i.schema,n);return s&&r.replaceWith(0,o.content.size,a).setMeta("preventUpdate",!e),!0},setMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:a}=s,l=Na(t,r.schema);if(i)if(o){const t=Ka(r,l);n.addStoredMark(l.create({...t,...e}))}else a.forEach((t=>{const i=t.$from.pos,s=t.$to.pos;r.doc.nodesBetween(i,s,((t,r)=>{const o=Math.max(r,i),a=Math.min(r+t.nodeSize,s);t.marks.find((t=>t.type===l))?t.marks.forEach((t=>{l===t.type&&n.addMark(o,a,l.create({...t.attrs,...e}))})):n.addMark(o,a,l.create(e))}))}));return function(t,e,n){var r;const{selection:i}=e;let s=null;if(Da(i)&&(s=i.$cursor),s){const e=null!==(r=t.storedMarks)&&void 0!==r?r:s.marks();return!!n.isInSet(e)||!e.some((t=>t.type.excludes(n)))}const{ranges:o}=i;return o.some((({$from:e,$to:r})=>{let i=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,r.pos,((t,e,r)=>{if(i)return!1;if(t.isInline){const e=!r||r.type.allowsMarkType(n),s=!!n.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(n)));i=e&&s}return!i})),i}))}(r,n,l)},setMeta:(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),setNode:(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=sa(t,n.schema);return s.isTextblock?i().command((({commands:t})=>!!Xo(s,e)(n)||t.clearNodes())).command((({state:t})=>Xo(s,e)(t,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,r=$a(t,0,n.content.size),i=or.create(n,r);e.setSelection(i)}return!0},setTextSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:r,to:i}="number"==typeof t?{from:t,to:t}:t,s=ir.atStart(n).from,o=ir.atEnd(n).to,a=$a(r,s,o),l=$a(i,s,o),c=ir.create(n,a,l);e.setSelection(c)}return!0},sinkListItem:t=>({state:e,dispatch:n})=>{const r=sa(t,e.schema);return(i=r,function(t,e){let{$from:n,$to:r}=t.selection,s=n.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==i));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=i)return!1;if(e){let n=l.lastChild&&l.lastChild.type==a.type,r=he.from(n?i.create():null),o=new ge(he.from(i.create(null,he.from(a.type.create(null,r)))),n?3:1,0),c=s.start,h=s.end;e(t.tr.step(new Tn(c-(n?3:1),h,c,h,o,1,!0)).scrollIntoView())}return!0})(e,n);var i},splitBlock:({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:a,$to:l}=s,c=Ha(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(s instanceof or&&s.node.isBlock)return!(!a.parentOffset||!Bn(o,a.pos))&&(r&&(t&&Ua(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){const r=l.parentOffset===l.parent.content.size;s instanceof ir&&e.deleteSelection();const o=0===a.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=r&&o?[{type:o,attrs:c}]:void 0,d=Bn(e.doc,e.mapping.map(a.pos),1,h);if(h||d||!Bn(e.doc,e.mapping.map(a.pos),1,o?[{type:o}]:void 0)||(d=!0,h=o?[{type:o,attrs:c}]:void 0),d&&(e.split(e.mapping.map(a.pos),1,h),o&&!r&&!a.parentOffset&&a.parent.type!==o)){const t=e.mapping.map(a.before()),n=e.doc.resolve(t);a.node(-1).canReplaceWith(n.index(),n.index()+1,o)&&e.setNodeMarkup(e.mapping.map(a.before()),o)}t&&Ua(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},splitListItem:t=>({tr:e,state:n,dispatch:r,editor:i})=>{var s;const o=sa(t,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const h=a.node(-1);if(h.type!==o)return!1;const d=i.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==o||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let t=he.empty;const n=a.index(-1)?1:a.index(-2)?2:3;for(let e=a.depth-n;e>=a.depth-3;e-=1)t=he.from(a.node(e).copy(t));const r=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,i=Ha(d,a.node().type.name,a.node().attrs),l=(null===(s=o.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;t=t.append(he.from(o.createAndFill(null,l)||void 0));const c=a.before(a.depth-(n-1));e.replace(c,a.after(-r),new ge(t,4-n,0));let h=-1;e.doc.nodesBetween(c,e.doc.content.size,((t,e)=>{if(h>-1)return!1;t.isTextblock&&0===t.content.size&&(h=e+1)})),h>-1&&e.setSelection(ir.near(e.doc.resolve(h))),e.scrollIntoView()}return!0}const u=l.pos===a.end()?h.contentMatchAt(0).defaultType:null,p=Ha(d,h.type.name,h.attrs),f=Ha(d,a.node().type.name,a.node().attrs);e.delete(a.pos,l.pos);const m=u?[{type:o,attrs:p},{type:u,attrs:f}]:[{type:o,attrs:p}];if(!Bn(e.doc,a.pos,2))return!1;if(r){const{selection:t,storedMarks:s}=n,{splittableMarks:o}=i.extensionManager,l=s||t.$to.parentOffset&&t.$from.marks();if(e.split(a.pos,2,m).scrollIntoView(),!l||!r)return!0;const c=l.filter((t=>o.includes(t.type.name)));e.ensureMarks(c)}return!0},toggleList:(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:h})=>{const{extensions:d,splittableMarks:u}=i.extensionManager,p=sa(t,o.schema),f=sa(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:v}=m,b=y.blockRange(v),w=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const x=_a((t=>Ja(t.type.name,d)))(m);if(b.depth>=1&&x&&b.depth-x.depth<=1){if(x.node.type===p)return c.liftListItem(f);if(Ja(x.node.type.name,d)&&p.validContent(x.node.content)&&a)return l().command((()=>(s.setNodeMarkup(x.pos,p),!0))).command((()=>Ga(s,p))).command((()=>Ya(s,p))).run()}return n&&w&&a?l().command((()=>{const t=h().wrapInList(p,r),e=w.filter((t=>u.includes(t.type.name)));return s.ensureMarks(e),!!t||c.clearNodes()})).wrapInList(p,r).command((()=>Ga(s,p))).command((()=>Ya(s,p))).run():l().command((()=>!!h().wrapInList(p,r)||c.clearNodes())).wrapInList(p,r).command((()=>Ga(s,p))).command((()=>Ya(s,p))).run()},toggleMark:(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Na(t,r.schema);return qa(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},toggleNode:(t,e,n={})=>({state:r,commands:i})=>{const s=sa(t,r.schema),o=sa(e,r.schema);return Va(r,s,n)?i.setNode(o):i.setNode(s,n)},toggleWrap:(t,e={})=>({state:n,commands:r})=>{const i=sa(t,n.schema);return Va(n,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const e=t.tr,n=s.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(s.text){const n=e.doc.resolve(s.from).marks();e.replaceWith(s.from,s.to,t.schema.text(s.text,n))}else e.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)})),!0},unsetMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=Na(t,r.schema),{$from:c,empty:h,ranges:d}=a;if(!i)return!0;if(h&&o){let{from:t,to:e}=a;const r=null===(s=c.marks().find((t=>t.type===l)))||void 0===s?void 0:s.attrs,i=Ta(c,l,r);i&&(t=i.from,e=i.to),n.removeMark(t,e,l)}else d.forEach((t=>{n.removeMark(t.$from.pos,t.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=La("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(s=sa(t,r.schema)),"mark"===a&&(o=Na(t,r.schema)),i&&n.selection.ranges.forEach((t=>{const i=t.$from.pos,a=t.$to.pos;r.doc.nodesBetween(i,a,((t,r)=>{s&&s===t.type&&n.setNodeMarkup(r,void 0,{...t.attrs,...e}),o&&t.marks.length&&t.marks.forEach((s=>{if(o===s.type){const l=Math.max(r,i),c=Math.min(r+t.nodeSize,a);n.addMark(l,c,o.create({...s.attrs,...e}))}}))}))})),!0)},wrapIn:(t,e={})=>({state:n,dispatch:r})=>function(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&In(o,t,e);return!!a&&(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0)}}(sa(t,n.schema),e)(n,r),wrapInList:(t,e={})=>({state:n,dispatch:r})=>Zo(sa(t,n.schema),e)(n,r)});const Za=ka.create({name:"commands",addCommands:()=>({...Xa})}),Qa=ka.create({name:"editable",addProseMirrorPlugins(){return[new br({key:new kr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),tl=ka.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new br({key:new kr("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),el=ka.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:n,doc:r}=e,{empty:i,$anchor:s}=n,{pos:o,parent:a}=s,l=tr.atStart(r).from===o;return!(!(i&&l&&a.type.isTextblock)||a.textContent.length)&&t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()])),e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ra()||Pa()?i:r},addProseMirrorPlugins(){return[new br({key:new kr("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some((t=>t.docChanged))&&!e.doc.eq(n.doc)))return;const{empty:r,from:i,to:s}=e.selection,o=tr.atStart(e.doc).from,a=tr.atEnd(e.doc).to;if(r||!(i===o&&s===a))return;if(!(0===n.doc.textBetween(0,n.doc.content.size," "," ").length))return;const l=n.tr,c=ta({state:n,transaction:l}),{commands:h}=new ea({editor:this.editor,state:c});return h.clearNodes(),l.steps.length?l:void 0}})]}}),nl=ka.create({name:"tabindex",addProseMirrorPlugins(){return[new br({key:new kr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var rl=Object.freeze({__proto__:null,ClipboardTextSerializer:Ma,Commands:Za,Editable:Qa,FocusEvents:tl,Keymap:el,Tabindex:nl});class il extends class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}{constructor(t={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(t,e){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute("data-tiptap-style",""),r.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(r),r}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,e){const n=la(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});this.view.updateState(r)}unregisterPlugin(t){if(this.isDestroyed)return;const e="string"==typeof t?`${t}$`:t.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((t=>!t.key.startsWith(e)))});this.view.updateState(n)}createExtensionManager(){const t=[...this.options.enableCoreExtensions?Object.values(rl):[],...this.options.extensions].filter((t=>["extension","node","mark"].includes(null==t?void 0:t.type)));this.extensionManager=new ba(t,this)}createCommandManager(){this.commandManager=new ea({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const t=ja(this.options.content,this.schema,this.options.parseOptions),e=Ia(t,this.options.autofocus);this.view=new Mo(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:yr.create({doc:t,selection:e||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews();this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach((t=>{var e;return null===(e=this.capturedTransaction)||void 0===e?void 0:e.step(t)})):void(this.capturedTransaction=t);const e=this.state.apply(t),n=!this.state.selection.eq(e.selection);this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t}),n&&this.emit("selectionUpdate",{editor:this,transaction:t});const r=t.getMeta("focus"),i=t.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:t}),i&&this.emit("blur",{editor:this,event:i.event,transaction:t}),t.docChanged&&!t.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return Wa(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,r="string"==typeof t?e:t;return function(t,e,n={}){if(!e)return Va(t,null,n)||qa(t,null,n);const r=La(e,t.schema);return"node"===r?Va(t,e,n):"mark"===r&&qa(t,e,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(t,e){const n=dn.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return Sa(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...Oa(this.schema),...n}})}get isEmpty(){return function(t){var e;const n=null===(e=t.type.createAndFill())||void 0===e?void 0:e.toJSON(),r=t.toJSON();return JSON.stringify(n)===JSON.stringify(r)}(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var t;return!(null===(t=this.view)||void 0===t?void 0:t.docView)}}class sl{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ca(na(this,"addOptions",{name:this.name}))),this.storage=ca(na(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new sl(t)}configure(t={}){const e=this.extend();return e.options=xa(this.options,t),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}extend(t={}){const e=new sl(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=ca(na(e,"addOptions",{name:e.name})),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,r=t.state.selection.$from;if(r.pos===r.end()){const i=r.marks(),s=!!i.find((t=>(null==t?void 0:t.type.name)===e.name));if(!s)return!1;const o=i.find((t=>(null==t?void 0:t.type.name)===e.name));return o&&n.removeStoredMark(o),n.insertText(" ",r.pos),t.view.dispatch(n),!0}return!1}}class ol{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ca(na(this,"addOptions",{name:this.name}))),this.storage=ca(na(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ol(t)}configure(t={}){const e=this.extend();return e.options=xa(this.options,t),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}extend(t={}){const e=new ol(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=ca(na(e,"addOptions",{name:e.name})),e.storage=ca(na(e,"addStorage",{name:e.name,options:e.options})),e}}const al=ol.create({name:"doc",topNode:!0,content:"block+"}),ll=ol.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",oa(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),cl=ol.create({name:"text",group:"inline"});function hl(t={}){return new br({view:e=>new dl(e,t)})}class dl{constructor(t,e){this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=e.width||1,this.color=e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let n=t=>{this[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos);if(!e.parent.inlineContent){let n=e.nodeBefore,r=e.nodeAfter;if(n||r){let e=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(e){let i=e.getBoundingClientRect(),s=n?i.bottom:i.top;n&&r&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:i.left,right:i.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos);t={left:e.left-this.width/2,right:e.left+this.width/2,top:e.top,bottom:e.bottom}}let n,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color),!i||i==document.body&&"static"==getComputedStyle(i).position)n=-pageXOffset,r=-pageYOffset;else{let t=i.getBoundingClientRect();n=t.left-i.scrollLeft,r=t.top-i.scrollTop}this.element.style.left=t.left-n+"px",this.element.style.top=t.top-r+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,e,t):r;if(e&&!i){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice&&(t=Ln(this.editorView.state.doc,t,this.editorView.dragging.slice),null==t))return this.setCursor(null);this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const ul=ka.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[hl(this.options)]}});class pl extends tr{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return pl.valid(n)?new pl(n):tr.near(n)}content(){return ge.empty}eq(t){return t instanceof pl&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new pl(t.resolve(e.pos))}getBookmark(){return new fl(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(0!=n)for(let t=r.child(n-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n!=r.childCount)for(let t=r.child(n);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(t))return!1;let n=e.type.spec.allowGapCursor;if(null!=n)return n;let r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,e,n=!1){t:for(;;){if(!n&&pl.valid(t))return t;let r=t.pos,i=null;for(let n=t.depth;;n--){let s=t.node(n);if(e>0?t.indexAfter(n)<s.childCount:t.index(n)>0){i=s.child(e>0?t.indexAfter(n):t.index(n)-1);break}if(0==n)return null;r+=e;let o=t.doc.resolve(r);if(pl.valid(o))return o}for(;;){let s=e>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!or.isSelectable(i)){t=t.doc.resolve(r+i.nodeSize*e),n=!1;continue t}break}i=s,r+=e;let o=t.doc.resolve(r);if(pl.valid(o))return o}return null}}}pl.prototype.visible=!1,pl.findFrom=pl.findGapCursorFrom,tr.jsonID("gapcursor",pl);class fl{constructor(t){this.pos=t}map(t){return new fl(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return pl.valid(e)?new pl(e):tr.near(e)}}const ml=_o({ArrowLeft:gl("horiz",-1),ArrowRight:gl("horiz",1),ArrowUp:gl("vert",-1),ArrowDown:gl("vert",1)});function gl(t,e){const n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,r,i){let s=t.selection,o=e>0?s.$to:s.$from,a=s.empty;if(s instanceof ir){if(!i.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=t.doc.resolve(e>0?o.after():o.before())}let l=pl.findGapCursorFrom(o,e,a);return!!l&&(r&&r(t.tr.setSelection(new pl(l))),!0)}}function yl(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!pl.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&or.isSelectable(t.state.doc.nodeAt(i.inside)))&&(t.dispatch(t.state.tr.setSelection(new pl(r))),!0)}function vl(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof pl))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=he.empty;for(let t=r.length-1;t>=0;t--)i=he.from(r[t].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new ge(i,0,0));return s.setSelection(ir.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function bl(t){if(!(t.selection instanceof pl))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ro.create(t.doc,[to.widget(t.selection.head,e,{key:"gapcursor"})])}const wl=ka.create({name:"gapCursor",addProseMirrorPlugins:()=>[new br({props:{decorations:bl,createSelectionBetween:(t,e,n)=>e.pos==n.pos&&pl.valid(n)?new pl(n):null,handleClick:yl,handleKeyDown:ml,handleDOMEvents:{beforeinput:vl}}})],extendNodeSchema(t){var e;return{allowGapCursor:null!==(e=ca(na(t,"allowGapCursor",{name:t.name,options:t.options,storage:t.storage})))&&void 0!==e?e:null}}});var xl=function(){};xl.prototype.append=function(t){return t.length?(t=xl.from(t),!this.length&&t||t.length<200&&this.leafAppend(t)||this.length<200&&t.leafPrepend(this)||this.appendInner(t)):this},xl.prototype.prepend=function(t){return t.length?xl.from(t).append(this):this},xl.prototype.appendInner=function(t){return new Sl(this,t)},xl.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?xl.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},xl.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},xl.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},xl.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(e,n){return r.push(t(e,n))}),e,n),r},xl.from=function(t){return t instanceof xl?t:t&&t.length?new kl(t):xl.empty};var kl=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var i=e;i<n;i++)if(!1===t(this.values[i],r+i))return!1},e.prototype.forEachInvertedInner=function(t,e,n,r){for(var i=e-1;i>=n;i--)if(!1===t(this.values[i],r+i))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=200)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=200)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(xl);xl.empty=new kl([]);var Sl=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,r){var i=this.left.length;return!(e<i&&!1===this.left.forEachInner(t,e,Math.min(n,i),r))&&(!(n>i&&!1===this.right.forEachInner(t,Math.max(e-i,0),Math.min(this.length,n)-i,r+i))&&void 0)},e.prototype.forEachInvertedInner=function(t,e,n,r){var i=this.left.length;return!(e>i&&!1===this.right.forEachInvertedInner(t,e-i,Math.max(n,i)-i,r+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(t,Math.min(e,i),n,r))&&void 0)},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(xl),Ol=xl;class Ml{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let n,r,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}e&&(n=this.remapping(i,this.items.length),r=n.maps.length);let s,o,a=t.tr,l=[],c=[];return this.items.forEach(((t,e)=>{if(!t.step)return n||(n=this.remapping(i,e+1),r=n.maps.length),r--,void c.push(t);if(n){c.push(new Al(t.map));let e,i=t.step.map(n.slice(r));i&&a.maybeStep(i).doc&&(e=a.mapping.maps[a.mapping.maps.length-1],l.push(new Al(e,void 0,void 0,l.length+c.length))),r--,e&&n.appendMap(e,r)}else a.maybeStep(t.step);return t.selection?(s=n?t.selection.map(n.slice(r)):t.selection,o=new Ml(this.items.slice(0,i).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:a,selection:s}}addTransform(t,e,n,r){let i=[],s=this.eventCount,o=this.items,a=!r&&o.length?o.get(o.length-1):null;for(let n=0;n<t.steps.length;n++){let l,c=t.steps[n].invert(t.docs[n]),h=new Al(t.mapping.maps[n],c,e);(l=a&&a.merge(h))&&(h=l,n?i.pop():o=o.slice(0,o.length-1)),i.push(h),e&&(s++,e=void 0),r||(a=h)}let l=s-n.depth;return l>Cl&&(o=function(t,e){let n;return t.forEach(((t,r)=>{if(t.selection&&0==e--)return n=r,!1})),t.slice(n)}(o,l),s-=l),new Ml(o.append(i),s)}remapping(t,e){let n=new bn;return this.items.forEach(((e,r)=>{let i=null!=e.mirrorOffset&&r-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0;n.appendMap(e.map,i)}),t,e),n}addMaps(t){return 0==this.eventCount?this:new Ml(this.items.append(t.map((t=>new Al(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-e),i=t.mapping,s=t.steps.length,o=this.eventCount;this.items.forEach((t=>{t.selection&&o--}),r);let a=e;this.items.forEach((e=>{let r=i.getMirror(--a);if(null==r)return;s=Math.min(s,r);let l=i.maps[r];if(e.step){let s=t.steps[r].invert(t.docs[r]),c=e.selection&&e.selection.map(i.slice(a+1,r));c&&o++,n.push(new Al(l,s,c))}else n.push(new Al(l))}),r);let l=[];for(let t=e;t<s;t++)l.push(new Al(i.maps[t]));let c=this.items.slice(0,r).append(l).append(n),h=new Ml(c,o);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,r=[],i=0;return this.items.forEach(((s,o)=>{if(o>=t)r.push(s),s.selection&&i++;else if(s.step){let t=s.step.map(e.slice(n)),o=t&&t.getMap();if(n--,o&&e.appendMap(o,n),t){let a=s.selection&&s.selection.map(e.slice(n));a&&i++;let l,c=new Al(o.invert(),t,a),h=r.length-1;(l=r.length&&r[h].merge(c))?r[h]=l:r.push(c)}}else s.map&&n--}),this.items.length,0),new Ml(Ol.from(r.reverse()),i)}}Ml.empty=new Ml(Ol.empty,0);class Al{constructor(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new Al(e.getMap().invert(),e,this.selection)}}}class El{constructor(t,e,n,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=r}}const Cl=20;function Tl(t){let e=[];return t.forEach(((t,n,r,i)=>e.push(r,i))),e}function Nl(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function Dl(t,e,n,r){let i=Rl(e),s=Bl.get(e).spec.config,o=(r?t.undone:t.done).popEvent(e,i);if(!o)return;let a=o.selection.resolve(o.transform.doc),l=(r?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,i),c=new El(r?l:o.remaining,r?o.remaining:l,null,0);n(o.transform.setSelection(a).setMeta(Bl,{redo:r,historyState:c}).scrollIntoView())}let $l=!1,Il=null;function Rl(t){let e=t.plugins;if(Il!=e){$l=!1,Il=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){$l=!0;break}}return $l}const Bl=new kr("history"),Fl=new kr("closeHistory");function Pl(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new br({key:Bl,state:{init:()=>new El(Ml.empty,Ml.empty,null,0),apply:(e,n,r)=>function(t,e,n,r){let i,s=n.getMeta(Bl);if(s)return s.historyState;n.getMeta(Fl)&&(t=new El(t.done,t.undone,null,0));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(o&&o.getMeta(Bl))return o.getMeta(Bl).redo?new El(t.done.addTransform(n,void 0,r,Rl(e)),t.undone,Tl(n.mapping.maps[n.steps.length-1]),t.prevTime):new El(t.done,t.undone.addTransform(n,void 0,r,Rl(e)),null,t.prevTime);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new El(t.done.rebased(n,i),t.undone.rebased(n,i),Nl(t.prevRanges,n.mapping),t.prevTime):new El(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Nl(t.prevRanges,n.mapping),t.prevTime);{let i=0==t.prevTime||!o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach(((t,r)=>{for(let i=0;i<e.length;i+=2)t<=e[i+1]&&r>=e[i]&&(n=!0)})),n}(n,t.prevRanges)),s=o?Nl(t.prevRanges,n.mapping):Tl(n.mapping.maps[n.steps.length-1]);return new El(t.done.addTransform(n,i?e.selection.getBookmark():void 0,r,Rl(e)),Ml.empty,s,n.time)}}(n,r,e,t)},config:t,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,r="historyUndo"==n?Vl:"historyRedo"==n?Ll:null;return!!r&&(e.preventDefault(),r(t.state,t.dispatch))}}}})}const Vl=(t,e)=>{let n=Bl.getState(t);return!(!n||0==n.done.eventCount)&&(e&&Dl(n,t,e,!1),!0)},Ll=(t,e)=>{let n=Bl.getState(t);return!(!n||0==n.undone.eventCount)&&(e&&Dl(n,t,e,!0),!0)},zl=ka.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>Vl(t,e),redo:()=>({state:t,dispatch:e})=>Ll(t,e)}),addProseMirrorPlugins(){return[Pl(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});class jl extends X{connect(){for(const t of this.editorTargets){const e=new il({extensions:[ul,wl,zl,al,ll,cl],content:"",injectCSS:!1,element:t,editorProps:{attributes:{class:"ariadne-h-28 ariadne-max-h-48 ariadne-p-2 ariadne-rounded-lg ariadne-overflow-y-auto focus:ariadne-outline-none"}},parseOptions:{preserveWhitespace:!0}}),n=t.previousElementSibling;if(n){const r=t.closest("form");null==r||r.addEventListener("submit",(()=>{n.setAttribute("value",e.getText()||""),e.commands.clearContent()}))}}}}jl.targets=["editor"];class _l extends X{toggle(){this.expandableTarget.classList.toggle("ariadne-hidden");for(const t of this.slidePanelTargets)t.classList.toggle("ariadne-hidden")}}_l.targets=["expandable","expandWrapper","slidePanel","buttonWrapper"];class Kl extends X{constructor(){super(...arguments),this.SELECTED_CLASSES=["ariadne-border-slate-500","ariadne-text-slate-600"],this.UNSELECTED_CLASSES=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"]}connect(){for(const t of this.tabTargets)t.hasAttribute("aria-current")&&(t.classList.add(...this.SELECTED_CLASSES),t.classList.remove(...this.UNSELECTED_CLASSES))}toggle(t){for(const e of this.tabTargets)e===t.target?(e.setAttribute("aria-current","page"),e.classList.add(...this.SELECTED_CLASSES),e.classList.remove(...this.UNSELECTED_CLASSES)):e.hasAttribute("aria-current")&&(e.removeAttribute("aria-current"),e.classList.add(...this.UNSELECTED_CLASSES),e.classList.remove(...this.SELECTED_CLASSES))}}Kl.targets=["tab"];var Wl="top",Hl="bottom",ql="right",Jl="left",Ul=[Wl,Hl,ql,Jl],Gl=Ul.reduce((function(t,e){return t.concat([e+"-start",e+"-end"])}),[]),Yl=[].concat(Ul,["auto"]).reduce((function(t,e){return t.concat([e,e+"-start",e+"-end"])}),[]),Xl=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function Zl(t){return t?(t.nodeName||"").toLowerCase():null}function Ql(t){if(null==t)return window;if("[object Window]"!==t.toString()){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function tc(t){return t instanceof Ql(t).Element||t instanceof Element}function ec(t){return t instanceof Ql(t).HTMLElement||t instanceof HTMLElement}function nc(t){return"undefined"!=typeof ShadowRoot&&(t instanceof Ql(t).ShadowRoot||t instanceof ShadowRoot)}var rc={name:"applyStyles",enabled:!0,phase:"write",fn:function(t){var e=t.state;Object.keys(e.elements).forEach((function(t){var n=e.styles[t]||{},r=e.attributes[t]||{},i=e.elements[t];ec(i)&&Zl(i)&&(Object.assign(i.style,n),Object.keys(r).forEach((function(t){var e=r[t];!1===e?i.removeAttribute(t):i.setAttribute(t,!0===e?"":e)})))}))},effect:function(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach((function(t){var r=e.elements[t],i=e.attributes[t]||{},s=Object.keys(e.styles.hasOwnProperty(t)?e.styles[t]:n[t]).reduce((function(t,e){return t[e]="",t}),{});ec(r)&&Zl(r)&&(Object.assign(r.style,s),Object.keys(i).forEach((function(t){r.removeAttribute(t)})))}))}},requires:["computeStyles"]};function ic(t){return t.split("-")[0]}var sc=Math.max,oc=Math.min,ac=Math.round;function lc(){var t=navigator.userAgentData;return null!=t&&t.brands&&Array.isArray(t.brands)?t.brands.map((function(t){return t.brand+"/"+t.version})).join(" "):navigator.userAgent}function cc(){return!/^((?!chrome|android).)*safari/i.test(lc())}function hc(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=!1);var r=t.getBoundingClientRect(),i=1,s=1;e&&ec(t)&&(i=t.offsetWidth>0&&ac(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&ac(r.height)/t.offsetHeight||1);var o=(tc(t)?Ql(t):window).visualViewport,a=!cc()&&n,l=(r.left+(a&&o?o.offsetLeft:0))/i,c=(r.top+(a&&o?o.offsetTop:0))/s,h=r.width/i,d=r.height/s;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l,x:l,y:c}}function dc(t){var e=hc(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function uc(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&nc(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function pc(t){return Ql(t).getComputedStyle(t)}function fc(t){return["table","td","th"].indexOf(Zl(t))>=0}function mc(t){return((tc(t)?t.ownerDocument:t.document)||window.document).documentElement}function gc(t){return"html"===Zl(t)?t:t.assignedSlot||t.parentNode||(nc(t)?t.host:null)||mc(t)}function yc(t){return ec(t)&&"fixed"!==pc(t).position?t.offsetParent:null}function vc(t){for(var e=Ql(t),n=yc(t);n&&fc(n)&&"static"===pc(n).position;)n=yc(n);return n&&("html"===Zl(n)||"body"===Zl(n)&&"static"===pc(n).position)?e:n||function(t){var e=/firefox/i.test(lc());if(/Trident/i.test(lc())&&ec(t)&&"fixed"===pc(t).position)return null;var n=gc(t);for(nc(n)&&(n=n.host);ec(n)&&["html","body"].indexOf(Zl(n))<0;){var r=pc(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||e&&"filter"===r.willChange||e&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(t)||e}function bc(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function wc(t,e,n){return sc(t,oc(e,n))}function xc(t){return Object.assign({},{top:0,right:0,bottom:0,left:0},t)}function kc(t,e){return e.reduce((function(e,n){return e[n]=t,e}),{})}var Sc={name:"arrow",enabled:!0,phase:"main",fn:function(t){var e,n=t.state,r=t.name,i=t.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=ic(n.placement),l=bc(a),c=[Jl,ql].indexOf(a)>=0?"height":"width";if(s&&o){var h=function(t,e){return xc("number"!=typeof(t="function"==typeof t?t(Object.assign({},e.rects,{placement:e.placement})):t)?t:kc(t,Ul))}(i.padding,n),d=dc(s),u="y"===l?Wl:Jl,p="y"===l?Hl:ql,f=n.rects.reference[c]+n.rects.reference[l]-o[l]-n.rects.popper[c],m=o[l]-n.rects.reference[l],g=vc(s),y=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,v=f/2-m/2,b=h[u],w=y-d[c]-h[p],x=y/2-d[c]/2+v,k=wc(b,x,w),S=l;n.modifiersData[r]=((e={})[S]=k,e.centerOffset=k-x,e)}},effect:function(t){var e=t.state,n=t.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=e.elements.popper.querySelector(r)))&&uc(e.elements.popper,r)&&(e.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Oc(t){return t.split("-")[1]}var Mc={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ac(t){var e,n=t.popper,r=t.popperRect,i=t.placement,s=t.variation,o=t.offsets,a=t.position,l=t.gpuAcceleration,c=t.adaptive,h=t.roundOffsets,d=t.isFixed,u=o.x,p=void 0===u?0:u,f=o.y,m=void 0===f?0:f,g="function"==typeof h?h({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var y=o.hasOwnProperty("x"),v=o.hasOwnProperty("y"),b=Jl,w=Wl,x=window;if(c){var k=vc(n),S="clientHeight",O="clientWidth";if(k===Ql(n)&&"static"!==pc(k=mc(n)).position&&"absolute"===a&&(S="scrollHeight",O="scrollWidth"),i===Wl||(i===Jl||i===ql)&&"end"===s)w=Hl,m-=(d&&k===x&&x.visualViewport?x.visualViewport.height:k[S])-r.height,m*=l?1:-1;if(i===Jl||(i===Wl||i===Hl)&&"end"===s)b=ql,p-=(d&&k===x&&x.visualViewport?x.visualViewport.width:k[O])-r.width,p*=l?1:-1}var M,A=Object.assign({position:a},c&&Mc),E=!0===h?function(t,e){var n=t.x,r=t.y,i=e.devicePixelRatio||1;return{x:ac(n*i)/i||0,y:ac(r*i)/i||0}}({x:p,y:m},Ql(n)):{x:p,y:m};return p=E.x,m=E.y,l?Object.assign({},A,((M={})[w]=v?"0":"",M[b]=y?"0":"",M.transform=(x.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",M)):Object.assign({},A,((e={})[w]=v?m+"px":"",e[b]=y?p+"px":"",e.transform="",e))}var Ec={passive:!0};var Cc={left:"right",right:"left",bottom:"top",top:"bottom"};function Tc(t){return t.replace(/left|right|bottom|top/g,(function(t){return Cc[t]}))}var Nc={start:"end",end:"start"};function Dc(t){return t.replace(/start|end/g,(function(t){return Nc[t]}))}function $c(t){var e=Ql(t);return{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Ic(t){return hc(mc(t)).left+$c(t).scrollLeft}function Rc(t){var e=pc(t),n=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function Bc(t){return["html","body","#document"].indexOf(Zl(t))>=0?t.ownerDocument.body:ec(t)&&Rc(t)?t:Bc(gc(t))}function Fc(t,e){var n;void 0===e&&(e=[]);var r=Bc(t),i=r===(null==(n=t.ownerDocument)?void 0:n.body),s=Ql(r),o=i?[s].concat(s.visualViewport||[],Rc(r)?r:[]):r,a=e.concat(o);return i?a:a.concat(Fc(gc(o)))}function Pc(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Vc(t,e,n){return"viewport"===e?Pc(function(t,e){var n=Ql(t),r=mc(t),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var c=cc();(c||!c&&"fixed"===e)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+Ic(t),y:l}}(t,n)):tc(e)?function(t,e){var n=hc(t,!1,"fixed"===e);return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}(e,n):Pc(function(t){var e,n=mc(t),r=$c(t),i=null==(e=t.ownerDocument)?void 0:e.body,s=sc(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=sc(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+Ic(t),l=-r.scrollTop;return"rtl"===pc(i||n).direction&&(a+=sc(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}(mc(t)))}function Lc(t,e,n,r){var i="clippingParents"===e?function(t){var e=Fc(gc(t)),n=["absolute","fixed"].indexOf(pc(t).position)>=0&&ec(t)?vc(t):t;return tc(n)?e.filter((function(t){return tc(t)&&uc(t,n)&&"body"!==Zl(t)})):[]}(t):[].concat(e),s=[].concat(i,[n]),o=s[0],a=s.reduce((function(e,n){var i=Vc(t,n,r);return e.top=sc(i.top,e.top),e.right=oc(i.right,e.right),e.bottom=oc(i.bottom,e.bottom),e.left=sc(i.left,e.left),e}),Vc(t,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function zc(t){var e,n=t.reference,r=t.element,i=t.placement,s=i?ic(i):null,o=i?Oc(i):null,a=n.x+n.width/2-r.width/2,l=n.y+n.height/2-r.height/2;switch(s){case Wl:e={x:a,y:n.y-r.height};break;case Hl:e={x:a,y:n.y+n.height};break;case ql:e={x:n.x+n.width,y:l};break;case Jl:e={x:n.x-r.width,y:l};break;default:e={x:n.x,y:n.y}}var c=s?bc(s):null;if(null!=c){var h="y"===c?"height":"width";switch(o){case"start":e[c]=e[c]-(n[h]/2-r[h]/2);break;case"end":e[c]=e[c]+(n[h]/2-r[h]/2)}}return e}function jc(t,e){void 0===e&&(e={});var n=e,r=n.placement,i=void 0===r?t.placement:r,s=n.strategy,o=void 0===s?t.strategy:s,a=n.boundary,l=void 0===a?"clippingParents":a,c=n.rootBoundary,h=void 0===c?"viewport":c,d=n.elementContext,u=void 0===d?"popper":d,p=n.altBoundary,f=void 0!==p&&p,m=n.padding,g=void 0===m?0:m,y=xc("number"!=typeof g?g:kc(g,Ul)),v="popper"===u?"reference":"popper",b=t.rects.popper,w=t.elements[f?v:u],x=Lc(tc(w)?w:w.contextElement||mc(t.elements.popper),l,h,o),k=hc(t.elements.reference),S=zc({reference:k,element:b,strategy:"absolute",placement:i}),O=Pc(Object.assign({},b,S)),M="popper"===u?O:k,A={top:x.top-M.top+y.top,bottom:M.bottom-x.bottom+y.bottom,left:x.left-M.left+y.left,right:M.right-x.right+y.right},E=t.modifiersData.offset;if("popper"===u&&E){var C=E[i];Object.keys(A).forEach((function(t){var e=[ql,Hl].indexOf(t)>=0?1:-1,n=[Wl,Hl].indexOf(t)>=0?"y":"x";A[t]+=C[n]*e}))}return A}function _c(t,e){void 0===e&&(e={});var n=e,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?Yl:l,h=Oc(r),d=h?a?Gl:Gl.filter((function(t){return Oc(t)===h})):Ul,u=d.filter((function(t){return c.indexOf(t)>=0}));0===u.length&&(u=d);var p=u.reduce((function(e,n){return e[n]=jc(t,{placement:n,boundary:i,rootBoundary:s,padding:o})[ic(n)],e}),{});return Object.keys(p).sort((function(t,e){return p[t]-p[e]}))}var Kc={name:"flip",enabled:!0,phase:"main",fn:function(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0===o||o,l=n.fallbackPlacements,c=n.padding,h=n.boundary,d=n.rootBoundary,u=n.altBoundary,p=n.flipVariations,f=void 0===p||p,m=n.allowedAutoPlacements,g=e.options.placement,y=ic(g),v=l||(y===g||!f?[Tc(g)]:function(t){if("auto"===ic(t))return[];var e=Tc(t);return[Dc(t),e,Dc(e)]}(g)),b=[g].concat(v).reduce((function(t,n){return t.concat("auto"===ic(n)?_c(e,{placement:n,boundary:h,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:m}):n)}),[]),w=e.rects.reference,x=e.rects.popper,k=new Map,S=!0,O=b[0],M=0;M<b.length;M++){var A=b[M],E=ic(A),C="start"===Oc(A),T=[Wl,Hl].indexOf(E)>=0,N=T?"width":"height",D=jc(e,{placement:A,boundary:h,rootBoundary:d,altBoundary:u,padding:c}),$=T?C?ql:Jl:C?Hl:Wl;w[N]>x[N]&&($=Tc($));var I=Tc($),R=[];if(s&&R.push(D[E]<=0),a&&R.push(D[$]<=0,D[I]<=0),R.every((function(t){return t}))){O=A,S=!1;break}k.set(A,R)}if(S)for(var B=function(t){var e=b.find((function(e){var n=k.get(e);if(n)return n.slice(0,t).every((function(t){return t}))}));if(e)return O=e,"break"},F=f?3:1;F>0;F--){if("break"===B(F))break}e.placement!==O&&(e.modifiersData[r]._skip=!0,e.placement=O,e.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function Wc(t,e,n){return void 0===n&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function Hc(t){return[Wl,ql,Hl,Jl].some((function(e){return t[e]>=0}))}var qc={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(t){var e=t.state,n=t.options,r=t.name,i=n.offset,s=void 0===i?[0,0]:i,o=Yl.reduce((function(t,n){return t[n]=function(t,e,n){var r=ic(t),i=[Jl,Wl].indexOf(r)>=0?-1:1,s="function"==typeof n?n(Object.assign({},e,{placement:t})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[Jl,ql].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}(n,e.rects,s),t}),{}),a=o[e.placement],l=a.x,c=a.y;null!=e.modifiersData.popperOffsets&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=o}};var Jc={name:"preventOverflow",enabled:!0,phase:"main",fn:function(t){var e=t.state,n=t.options,r=t.name,i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0!==o&&o,l=n.boundary,c=n.rootBoundary,h=n.altBoundary,d=n.padding,u=n.tether,p=void 0===u||u,f=n.tetherOffset,m=void 0===f?0:f,g=jc(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:h}),y=ic(e.placement),v=Oc(e.placement),b=!v,w=bc(y),x="x"===w?"y":"x",k=e.modifiersData.popperOffsets,S=e.rects.reference,O=e.rects.popper,M="function"==typeof m?m(Object.assign({},e.rects,{placement:e.placement})):m,A="number"==typeof M?{mainAxis:M,altAxis:M}:Object.assign({mainAxis:0,altAxis:0},M),E=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,C={x:0,y:0};if(k){if(s){var T,N="y"===w?Wl:Jl,D="y"===w?Hl:ql,$="y"===w?"height":"width",I=k[w],R=I+g[N],B=I-g[D],F=p?-O[$]/2:0,P="start"===v?S[$]:O[$],V="start"===v?-O[$]:-S[$],L=e.elements.arrow,z=p&&L?dc(L):{width:0,height:0},j=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},_=j[N],K=j[D],W=wc(0,S[$],z[$]),H=b?S[$]/2-F-W-_-A.mainAxis:P-W-_-A.mainAxis,q=b?-S[$]/2+F+W+K+A.mainAxis:V+W+K+A.mainAxis,J=e.elements.arrow&&vc(e.elements.arrow),U=J?"y"===w?J.clientTop||0:J.clientLeft||0:0,G=null!=(T=null==E?void 0:E[w])?T:0,Y=I+q-G,X=wc(p?oc(R,I+H-G-U):R,I,p?sc(B,Y):B);k[w]=X,C[w]=X-I}if(a){var Z,Q="x"===w?Wl:Jl,tt="x"===w?Hl:ql,et=k[x],nt="y"===x?"height":"width",rt=et+g[Q],it=et-g[tt],st=-1!==[Wl,Jl].indexOf(y),ot=null!=(Z=null==E?void 0:E[x])?Z:0,at=st?rt:et-S[nt]-O[nt]-ot+A.altAxis,lt=st?et+S[nt]+O[nt]-ot-A.altAxis:it,ct=p&&st?function(t,e,n){var r=wc(t,e,n);return r>n?n:r}(at,et,lt):wc(p?at:rt,et,p?lt:it);k[x]=ct,C[x]=ct-et}e.modifiersData[r]=C}},requiresIfExists:["offset"]};function Uc(t,e,n){void 0===n&&(n=!1);var r,i,s=ec(e),o=ec(e)&&function(t){var e=t.getBoundingClientRect(),n=ac(e.width)/t.offsetWidth||1,r=ac(e.height)/t.offsetHeight||1;return 1!==n||1!==r}(e),a=mc(e),l=hc(t,o,n),c={scrollLeft:0,scrollTop:0},h={x:0,y:0};return(s||!s&&!n)&&(("body"!==Zl(e)||Rc(a))&&(c=(r=e)!==Ql(r)&&ec(r)?{scrollLeft:(i=r).scrollLeft,scrollTop:i.scrollTop}:$c(r)),ec(e)?((h=hc(e,!0)).x+=e.clientLeft,h.y+=e.clientTop):a&&(h.x=Ic(a))),{x:l.left+c.scrollLeft-h.x,y:l.top+c.scrollTop-h.y,width:l.width,height:l.height}}function Gc(t){var e=new Map,n=new Set,r=[];function i(t){n.add(t.name),[].concat(t.requires||[],t.requiresIfExists||[]).forEach((function(t){if(!n.has(t)){var r=e.get(t);r&&i(r)}})),r.push(t)}return t.forEach((function(t){e.set(t.name,t)})),t.forEach((function(t){n.has(t.name)||i(t)})),r}var Yc={placement:"bottom",modifiers:[],strategy:"absolute"};function Xc(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return!e.some((function(t){return!(t&&"function"==typeof t.getBoundingClientRect)}))}function Zc(t){void 0===t&&(t={});var e=t,n=e.defaultModifiers,r=void 0===n?[]:n,i=e.defaultOptions,s=void 0===i?Yc:i;return function(t,e,n){void 0===n&&(n=s);var i,o,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},Yc,s),modifiersData:{},elements:{reference:t,popper:e},attributes:{},styles:{}},l=[],c=!1,h={state:a,setOptions:function(n){var i="function"==typeof n?n(a.options):n;d(),a.options=Object.assign({},s,a.options,i),a.scrollParents={reference:tc(t)?Fc(t):t.contextElement?Fc(t.contextElement):[],popper:Fc(e)};var o=function(t){var e=Gc(t);return Xl.reduce((function(t,n){return t.concat(e.filter((function(t){return t.phase===n})))}),[])}(function(t){var e=t.reduce((function(t,e){var n=t[e.name];return t[e.name]=n?Object.assign({},n,e,{options:Object.assign({},n.options,e.options),data:Object.assign({},n.data,e.data)}):e,t}),{});return Object.keys(e).map((function(t){return e[t]}))}([].concat(r,a.options.modifiers)));return a.orderedModifiers=o.filter((function(t){return t.enabled})),a.orderedModifiers.forEach((function(t){var e=t.name,n=t.options,r=void 0===n?{}:n,i=t.effect;if("function"==typeof i){var s=i({state:a,name:e,instance:h,options:r}),o=function(){};l.push(s||o)}})),h.update()},forceUpdate:function(){if(!c){var t=a.elements,e=t.reference,n=t.popper;if(Xc(e,n)){a.rects={reference:Uc(e,vc(n),"fixed"===a.options.strategy),popper:dc(n)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach((function(t){return a.modifiersData[t.name]=Object.assign({},t.data)}));for(var r=0;r<a.orderedModifiers.length;r++)if(!0!==a.reset){var i=a.orderedModifiers[r],s=i.fn,o=i.options,l=void 0===o?{}:o,d=i.name;"function"==typeof s&&(a=s({state:a,options:l,name:d,instance:h})||a)}else a.reset=!1,r=-1}}},update:(i=function(){return new Promise((function(t){h.forceUpdate(),t(a)}))},function(){return o||(o=new Promise((function(t){Promise.resolve().then((function(){o=void 0,t(i())}))}))),o}),destroy:function(){d(),c=!0}};if(!Xc(t,e))return h;function d(){l.forEach((function(t){return t()})),l=[]}return h.setOptions(n).then((function(t){!c&&n.onFirstUpdate&&n.onFirstUpdate(t)})),h}}var Qc=Zc({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(t){var e=t.state,n=t.instance,r=t.options,i=r.scroll,s=void 0===i||i,o=r.resize,a=void 0===o||o,l=Ql(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach((function(t){t.addEventListener("scroll",n.update,Ec)})),a&&l.addEventListener("resize",n.update,Ec),function(){s&&c.forEach((function(t){t.removeEventListener("scroll",n.update,Ec)})),a&&l.removeEventListener("resize",n.update,Ec)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(t){var e=t.state,n=t.name;e.modifiersData[n]=zc({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(t){var e=t.state,n=t.options,r=n.gpuAcceleration,i=void 0===r||r,s=n.adaptive,o=void 0===s||s,a=n.roundOffsets,l=void 0===a||a,c={placement:ic(e.placement),variation:Oc(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:"fixed"===e.options.strategy};null!=e.modifiersData.popperOffsets&&(e.styles.popper=Object.assign({},e.styles.popper,Ac(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:l})))),null!=e.modifiersData.arrow&&(e.styles.arrow=Object.assign({},e.styles.arrow,Ac(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})},data:{}},rc,qc,Kc,Jc,Sc,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(t){var e=t.state,n=t.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=jc(e,{elementContext:"reference"}),a=jc(e,{altBoundary:!0}),l=Wc(o,r),c=Wc(a,i,s),h=Hc(l),d=Hc(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:h,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":h,"data-popper-escaped":d})}}]});class th extends X{connect(){this.popperInstance=Qc(this.triggerTarget,this.tooltipTarget,{placement:this.placementValue,modifiers:[{name:"offset",options:{offset:this.offsetValue}}]})}disconnect(){this.popperInstance&&this.popperInstance.destroy()}show(){this.tooltipTarget.setAttribute("data-tooltip-show",""),this.tooltipTarget.classList.remove("ariadne-invisible"),this.popperInstance.update(),this.dispatch("shown",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}hide(){this.tooltipTarget.removeAttribute("data-tooltip-show"),this.tooltipTarget.classList.add("ariadne-invisible"),this.dispatch("ariadne-hidden",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}}function eh(t){return Array.from(t.querySelectorAll('[role="tablist"] [role="tab"]')).filter((e=>e instanceof HTMLElement&&e.closest(t.tagName)===t))}th.targets=["trigger","tooltip"],th.values={placement:{type:String,default:"top"},offset:{type:Array,default:[0,8]}};class nh extends HTMLElement{static define(t="tab-container",e=customElements){return e.define(t,this),this}connectedCallback(){this.addEventListener("keydown",(t=>{var e;const n=t.target;if(!(n instanceof HTMLElement))return;if(n.closest(this.tagName)!==this)return;if("tab"!==n.getAttribute("role")&&!n.closest('[role="tablist"]'))return;const r=eh(this),i=r.indexOf(r.find((t=>t.matches('[aria-selected="true"]')))),[s,o]="vertical"===(null===(e=n.closest('[role="tablist"]'))||void 0===e?void 0:e.getAttribute("aria-orientation"))?[["ArrowDown","ArrowRight"],["ArrowUp","ArrowLeft"]]:[["ArrowRight"],["ArrowLeft"]];if(s.some((e=>t.code===e))){let t=i+1;t>=r.length&&(t=0),this.selectTab(t)}else if(o.some((e=>t.code===e))){let t=i-1;t<0&&(t=r.length-1),this.selectTab(t)}else"Home"===t.code?(this.selectTab(0),t.preventDefault()):"End"===t.code&&(this.selectTab(r.length-1),t.preventDefault())})),this.addEventListener("click",(t=>{const e=eh(this);if(!(t.target instanceof Element))return;if(t.target.closest(this.tagName)!==this)return;const n=t.target.closest('[role="tab"]');if(!(n instanceof HTMLElement&&n.closest('[role="tablist"]')))return;const r=e.indexOf(n);this.selectTab(r)}));for(const t of eh(this))t.hasAttribute("aria-selected")||t.setAttribute("aria-selected","false"),t.hasAttribute("tabindex")||("true"===t.getAttribute("aria-selected")?t.setAttribute("tabindex","0"):t.setAttribute("tabindex","-1"))}selectTab(t){const e=eh(this),n=Array.from(this.querySelectorAll('[role="tabpanel"]')).filter((t=>t.closest(this.tagName)===this));if(t>e.length-1)throw new RangeError(`Index "${t}" out of bounds`);const r=e[t],i=n[t];if(!!this.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:i}}))){for(const t of e)t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");for(const t of n)t.hidden=!0,t.hasAttribute("tabindex")||t.hasAttribute("data-tab-container-no-tabstop")||t.setAttribute("tabindex","0");r.setAttribute("aria-selected","true"),r.setAttribute("tabindex","0"),r.focus(),i.hidden=!1,this.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:i}}))}}}const rh="undefined"!=typeof globalThis?globalThis:window;try{rh.TabContainerElement=nh.define()}catch(et){if(!(rh.DOMException&&et instanceof DOMException&&"NotSupportedError"===et.name||et instanceof ReferenceError))throw et}const ih=["ariadne-border-slate-500","ariadne-text-slate-600"],sh=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"];for(const t of document.getElementsByTagName("tab-container"))t.addEventListener("tab-container-change",(function(t){var e;const n=t.detail.relatedTarget,r=n.closest("tab-container").firstElementChild,i=r.querySelector('[aria-selected="true"]'),s=null===(e=n.getAttribute("id"))||void 0===e?void 0:e.split("-").slice(1).join("-"),o=r.querySelector(`#${s}`);i.classList.remove(...ih),i.classList.add(...sh),o.classList.add(...ih),o.classList.remove(...sh)}));const oh=["second","minute","hour","day","month","year"];const ah=/^[-+]?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;class lh{constructor(t=0,e=0,n=0,r=0,i=0,s=0,o=0){this.years=t,this.months=e,this.weeks=n,this.days=r,this.hours=i,this.minutes=s,this.seconds=o}abs(){return new lh(Math.abs(this.years),Math.abs(this.months),Math.abs(this.weeks),Math.abs(this.days),Math.abs(this.hours),Math.abs(this.minutes),Math.abs(this.seconds))}static from(t){var e;if("string"==typeof t){const n=String(t).trim(),r=n.startsWith("-")?-1:1,i=null===(e=n.match(ah))||void 0===e?void 0:e.slice(1).map((t=>(Number(t)||0)*r));return i?new lh(...i):new lh}if("object"==typeof t){const{years:e,months:n,weeks:r,days:i,hours:s,minutes:o,seconds:a}=t;return new lh(e,n,r,i,s,o,a)}throw new RangeError("invalid duration")}}function ch(t,e,n){const r=function(t,e){const n=new Date(t);return n.setFullYear(n.getFullYear()+e.years),n.setMonth(n.getMonth()+e.months),n.setDate(n.getDate()+7*e.weeks+e.days),n.setHours(n.getHours()+e.hours),n.setMinutes(n.getMinutes()+e.minutes),n.setSeconds(n.getSeconds()+e.seconds),n}(t,lh.from(n).abs());return!r||Math.abs(Number(r)-Number(t))>Math.abs(Number(t)-Number(e))}var hh,dh,uh,ph,fh,mh,gh,yh=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)},vh=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n};const bh=("undefined"!=typeof globalThis?globalThis:window).HTMLElement||null;class wh extends Event{constructor(t,e,n,r){super("relative-time-updated",{bubbles:!0,composed:!0}),this.oldText=t,this.newText=e,this.oldTitle=n,this.newTitle=r}}function xh(t){if(!t.date)return 1/0;if("elapsed"===t.format){const e=t.precision;if("second"===e)return 1e3;if("minute"===e)return 6e4}const e=Math.abs(Date.now()-t.date.getTime());return e<6e4?1e3:e<36e5?6e4:36e5}const kh=new class{constructor(){this.elements=new Set,this.time=1/0,this.timer=-1}observe(t){if(this.elements.has(t))return;this.elements.add(t);const e=t.date;if(e&&e.getTime()){const e=xh(t),n=Date.now()+e;n<this.time&&(clearTimeout(this.timer),this.timer=setTimeout((()=>this.update()),e),this.time=n)}}unobserve(t){this.elements.has(t)&&this.elements.delete(t)}update(){if(clearTimeout(this.timer),!this.elements.size)return;let t=1/0;for(const e of this.elements)t=Math.min(t,xh(e)),e.update();this.time=Math.min(36e5,t),this.timer=setTimeout((()=>this.update()),this.time),this.time+=Date.now()}};class Sh extends bh{constructor(){super(...arguments),hh.add(this),dh.set(this,!1),uh.set(this,!1),fh.set(this,this.shadowRoot?this.shadowRoot:this.attachShadow?this.attachShadow({mode:"open"}):this)}static get observedAttributes(){return["second","minute","hour","weekday","day","month","year","time-zone-name","prefix","threshold","tense","precision","format","datetime","lang","title"]}get second(){const t=this.getAttribute("second");if("numeric"===t||"2-digit"===t)return t}set second(t){this.setAttribute("second",t||"")}get minute(){const t=this.getAttribute("minute");if("numeric"===t||"2-digit"===t)return t}set minute(t){this.setAttribute("minute",t||"")}get hour(){const t=this.getAttribute("hour");if("numeric"===t||"2-digit"===t)return t}set hour(t){this.setAttribute("hour",t||"")}get weekday(){const t=this.getAttribute("weekday");if("long"===t||"short"===t||"narrow"===t)return t}set weekday(t){this.setAttribute("weekday",t||"")}get day(){var t;const e=null!==(t=this.getAttribute("day"))&&void 0!==t?t:"numeric";if("numeric"===e||"2-digit"===e)return e}set day(t){this.setAttribute("day",t||"")}get month(){var t;const e=null!==(t=this.getAttribute("month"))&&void 0!==t?t:"short";if("numeric"===e||"2-digit"===e||"short"===e||"long"===e||"narrow"===e)return e}set month(t){this.setAttribute("month",t||"")}get year(){var t;const e=this.getAttribute("year");return"numeric"===e||"2-digit"===e?e:this.hasAttribute("year")||(new Date).getUTCFullYear()===(null===(t=this.date)||void 0===t?void 0:t.getUTCFullYear())?void 0:"numeric"}set year(t){this.setAttribute("day",t||"")}get timeZoneName(){const t=this.getAttribute("time-zone-name");if("long"===t||"short"===t||"shortOffset"===t||"longOffset"===t||"shortGeneric"===t||"longGeneric"===t)return t}set timeZoneName(t){this.setAttribute("time-zone-name",t||"")}get prefix(){var t;return null!==(t=this.getAttribute("prefix"))&&void 0!==t?t:"on"}set prefix(t){this.setAttribute("prefix",t)}get threshold(){const t=this.getAttribute("threshold");return t&&(e=t,ah.test(e))?t:"P30D";var e}set threshold(t){this.setAttribute("threshold",t)}get tense(){const t=this.getAttribute("tense");return"past"===t?"past":"future"===t?"future":"auto"}set tense(t){this.setAttribute("tense",t)}get precision(){const t=this.getAttribute("precision");return oh.includes(t)?t:"second"}set precision(t){this.setAttribute("precision",t)}get format(){const t=this.getAttribute("format");return"micro"===t?"micro":"elapsed"===t?"elapsed":"auto"}set format(t){this.setAttribute("format",t)}get datetime(){return this.getAttribute("datetime")||""}set datetime(t){this.setAttribute("datetime",t)}get date(){const t=Date.parse(this.datetime);return Number.isNaN(t)?null:new Date(t)}set date(t){this.datetime=(null==t?void 0:t.toISOString())||""}connectedCallback(){this.update()}disconnectedCallback(){kh.unobserve(this)}attributeChangedCallback(t,e,n){e!==n&&("title"===t&&vh(this,dh,null!==n&&yh(this,hh,"m",mh).call(this)!==n,"f"),yh(this,uh,"f")||"title"===t&&yh(this,dh,"f")||vh(this,uh,(async()=>{await Promise.resolve(),this.update()})(),"f"))}update(){const t=yh(this,fh,"f").textContent||"",e=this.getAttribute("title")||"";let n=e,r=t;const i=new Date;yh(this,dh,"f")||(n=yh(this,hh,"m",mh).call(this)||"",n&&this.setAttribute("title",n)),r=yh(this,hh,"m",gh).call(this,i)||"",r?yh(this,fh,"f").textContent=r:this.shadowRoot===yh(this,fh,"f")&&this.textContent&&(yh(this,fh,"f").textContent=this.textContent),r===t&&n===e||this.dispatchEvent(new wh(t,r,e,n));const s=this.date,o=this.format,a=("auto"===o||"micro"===o)&&s&&ch(i,s,this.threshold);"elapsed"===o||a?kh.observe(this):kh.unobserve(this),vh(this,uh,!1,"f")}}dh=new WeakMap,uh=new WeakMap,fh=new WeakMap,hh=new WeakSet,ph=function(){var t,e;return null!==(e=null===(t=this.closest("[lang]"))||void 0===t?void 0:t.getAttribute("lang"))&&void 0!==e?e:"default"},mh=function(){const t=this.date;if(t&&"undefined"!=typeof Intl&&Intl.DateTimeFormat)return new Intl.DateTimeFormat(yh(this,hh,"a",ph),{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)},gh=function(t=new Date){const e=this.date;if(!e)return;const n=this.format;if("elapsed"===n){const t=oh.indexOf(this.precision)||0,n=function(t){const e=Math.abs(t.getTime()-(new Date).getTime()),n=Math.floor(e/1e3),r=Math.floor(n/60),i=Math.floor(r/60),s=Math.floor(i/24),o=Math.floor(s/30),a=Math.floor(o/12),l=[];return a&&l.push([a,"year"]),o-12*a&&l.push([o-12*a,"month"]),s-30*o&&l.push([s-30*o,"day"]),i-24*s&&l.push([i-24*s,"hour"]),r-60*i&&l.push([r-60*i,"minute"]),n-60*r&&l.push([n-60*r,"second"]),l}(e).filter((e=>oh.indexOf(e[1])>=t));return n.map((([t,e])=>`${t}${e[0]}`)).join(" ")||`0${this.precision[0]}`}const r=this.tense,i="micro"===n,s=t.getTime()<e.getTime(),o=ch(t,e,this.threshold),a=yh(this,hh,"a",ph);if("undefined"!=typeof Intl&&Intl.RelativeTimeFormat){const t=new Intl.RelativeTimeFormat(a,{numeric:"auto"});if("past"===r||"auto"===r&&!s&&o){const[n,r]=i?function(t){const e=(new Date).getTime()-t.getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return r<1?[1,"minute"]:r<60?[r,"minute"]:i<24?[i,"hour"]:s<365?[s,"day"]:[a,"year"]}(e):function(t){const e=(new Date).getTime()-t.getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return e<0||n<10?[0,"second"]:n<45?[-n,"second"]:n<90||r<45?[-r,"minute"]:r<90||i<24?[-i,"hour"]:i<36||s<30?[-s,"day"]:o<18?[-o,"month"]:[-a,"year"]}(e);return i?`${n}${r[0]}`:t.format(n,r)}if("future"===r||"auto"===r&&s&&o){const[n,r]=i?function(t){const e=t.getTime()-(new Date).getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return s>=365?[a,"year"]:i>=24?[s,"day"]:r>=60?[i,"hour"]:r>1?[r,"minute"]:[1,"minute"]}(e):function(t){const e=t.getTime()-(new Date).getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return o>=18||o>=12?[a,"year"]:s>=45||s>=30?[o,"month"]:i>=36||i>=24?[s,"day"]:r>=90||r>=45?[i,"hour"]:n>=90||n>=45?[r,"minute"]:n>=10?[n,"second"]:[0,"second"]}(e);return i?`${n}${r[0]}`:t.format(n,r)}}if("undefined"==typeof Intl||!Intl.DateTimeFormat)return;const l=new Intl.DateTimeFormat(a,{second:this.second,minute:this.minute,hour:this.hour,weekday:this.weekday,day:this.day,month:this.month,year:this.year,timeZoneName:this.timeZoneName});return`${this.prefix} ${l.format(e)}`.trim()};const Oh="undefined"!=typeof globalThis?globalThis:window;try{customElements.define("relative-time",Sh),Oh.RelativeTimeElement=Sh}catch(et){if(!(Oh.DOMException&&et instanceof DOMException&&"NotSupportedError"===et.name||et instanceof ReferenceError))throw et}const Mh=class{constructor(t=document.documentElement,r=_){this.logger=console,this.debug=!1,this.logDebugActivity=(t,e,n={})=>{this.debug&&this.logFormattedMessage(t,e,n)},this.element=t,this.schema=r,this.dispatcher=new e(this),this.router=new j(this),this.actionDescriptorFilters=Object.assign({},n)}static start(t,e){const n=new this(t,e);return n.start(),n}async start(){await new Promise((t=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",(()=>t())):t()})),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(t,e){this.load({identifier:t,controllerConstructor:e})}registerActionOption(t,e){this.actionDescriptorFilters[t]=e}load(t,...e){(Array.isArray(t)?t:[t,...e]).forEach((t=>{t.controllerConstructor.shouldLoad&&this.router.loadDefinition(t)}))}unload(t,...e){(Array.isArray(t)?t:[t,...e]).forEach((t=>this.router.unloadIdentifier(t)))}get controllers(){return this.router.contexts.map((t=>t.controller))}getControllerForElementAndIdentifier(t,e){const n=this.router.getContextForElementAndIdentifier(t,e);return n?n.controller:null}handleError(t,e,n){var r;this.logger.error("%s\n\n%o\n\n%o",e,t,n),null===(r=window.onerror)||void 0===r||r.call(window,e,"",0,0,t)}logFormattedMessage(t,e,n={}){n=Object.assign({application:this},n),this.logger.groupCollapsed(`${t} #${e}`),this.logger.log("details:",Object.assign({},n)),this.logger.groupEnd()}}.start();Mh.register("clipboard-copy-component",class extends X{copy(){const t=this.element.attributes.getNamedItem("value"),e=this.element.attributes.getNamedItem("for");if(t)navigator.clipboard.writeText(t.value);else if(e){const t=document.getElementById(e.value);navigator.clipboard.writeText((null==t?void 0:t.textContent)||"")}else navigator.clipboard.writeText(this.element.textContent||"")}}),Mh.register("ariadne-form",Bt),Mh.register("rich-text-area-component",jl),Mh.register("slideover-component",_l),Mh.register("tab-nav-component",Kl),Mh.register("tooltip-component",th),Mh.register("toggleable",oe),Mh.register("accumulator",re),Mh.register("options",ne),Mh.register("string-match",ee),Mh.register("events",class extends X{stopPropagation(t){t.stopPropagation()}});
8
8
  //# sourceMappingURL=ariadne_view_components.js.map