rhino-editor
Version:
A custom element wrapped rich text editor
1,848 lines • 512 kB
JavaScript
var rd=Object.defineProperty;var Jm=(n,t,e)=>t in n?rd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Gm=(n,t)=>{for(var e in t)rd(n,e,{get:t[e],enumerable:!0})};var tt=(n,t,e)=>Jm(n,typeof t!="symbol"?t+"":t,e);var hr=globalThis,go=hr.trustedTypes,od=go?go.createPolicy("lit-html",{createHTML:n=>n}):void 0,Zs="$lit$",ye=`lit$${Math.random().toFixed(9).slice(2)}$`,ta="?"+ye,Xm=`<${ta}>`,Ye=document,fr=()=>Ye.createComment(""),pr=n=>n===null||typeof n!="object"&&typeof n!="function",ea=Array.isArray,dd=n=>ea(n)||typeof n?.[Symbol.iterator]=="function",Qs=`[
\f\r]`,ur=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,id=/-->/g,sd=/>/g,Ge=RegExp(`>|${Qs}(?:([^\\s"'>=/]+)(${Qs}*=${Qs}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),ad=/'/g,ld=/"/g,ud=/^(?:script|style|textarea|title)$/i,na=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),T=na(1),it=na(2),ok=na(3),qt=Symbol.for("lit-noChange"),K=Symbol.for("lit-nothing"),cd=new WeakMap,Xe=Ye.createTreeWalker(Ye,129);function hd(n,t){if(!ea(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return od!==void 0?od.createHTML(t):t}var fd=(n,t)=>{let e=n.length-1,r=[],o,i=t===2?"<svg>":t===3?"<math>":"",s=ur;for(let a=0;a<e;a++){let l=n[a],c,d,u=-1,h=0;for(;h<l.length&&(s.lastIndex=h,d=s.exec(l),d!==null);)h=s.lastIndex,s===ur?d[1]==="!--"?s=id:d[1]!==void 0?s=sd:d[2]!==void 0?(ud.test(d[2])&&(o=RegExp("</"+d[2],"g")),s=Ge):d[3]!==void 0&&(s=Ge):s===Ge?d[0]===">"?(s=o??ur,u=-1):d[1]===void 0?u=-2:(u=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?Ge:d[3]==='"'?ld:ad):s===ld||s===ad?s=Ge:s===id||s===sd?s=ur:(s=Ge,o=void 0);let f=s===Ge&&n[a+1].startsWith("/>")?" ":"";i+=s===ur?l+Xm:u>=0?(r.push(c),l.slice(0,u)+Zs+l.slice(u)+ye+f):l+ye+(u===-2?a:f)}return[hd(n,i+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},mr=class n{constructor({strings:t,_$litType$:e},r){let o;this.parts=[];let i=0,s=0,a=t.length-1,l=this.parts,[c,d]=fd(t,e);if(this.el=n.createElement(c,r),Xe.currentNode=this.el.content,e===2||e===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(o=Xe.nextNode())!==null&&l.length<a;){if(o.nodeType===1){if(o.hasAttributes())for(let u of o.getAttributeNames())if(u.endsWith(Zs)){let h=d[s++],f=o.getAttribute(u).split(ye),p=/([.?@])?(.*)/.exec(h);l.push({type:1,index:i,name:p[2],strings:f,ctor:p[1]==="."?yo:p[1]==="?"?vo:p[1]==="@"?xo:Ze}),o.removeAttribute(u)}else u.startsWith(ye)&&(l.push({type:6,index:i}),o.removeAttribute(u));if(ud.test(o.tagName)){let u=o.textContent.split(ye),h=u.length-1;if(h>0){o.textContent=go?go.emptyScript:"";for(let f=0;f<h;f++)o.append(u[f],fr()),Xe.nextNode(),l.push({type:2,index:++i});o.append(u[h],fr())}}}else if(o.nodeType===8)if(o.data===ta)l.push({type:2,index:i});else{let u=-1;for(;(u=o.data.indexOf(ye,u+1))!==-1;)l.push({type:7,index:i}),u+=ye.length-1}i++}}static createElement(t,e){let r=Ye.createElement("template");return r.innerHTML=t,r}};function Qe(n,t,e=n,r){if(t===qt)return t;let o=r!==void 0?e._$Co?.[r]:e._$Cl,i=pr(t)?void 0:t._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),i===void 0?o=void 0:(o=new i(n),o._$AT(n,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=o:e._$Cl=o),o!==void 0&&(t=Qe(n,o._$AS(n,t.values),o,r)),t}var bo=class{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){let{el:{content:e},parts:r}=this._$AD,o=(t?.creationScope??Ye).importNode(e,!0);Xe.currentNode=o;let i=Xe.nextNode(),s=0,a=0,l=r[0];for(;l!==void 0;){if(s===l.index){let c;l.type===2?c=new On(i,i.nextSibling,this,t):l.type===1?c=new l.ctor(i,l.name,l.strings,this,t):l.type===6&&(c=new ko(i,this,t)),this._$AV.push(c),l=r[++a]}s!==l?.index&&(i=Xe.nextNode(),s++)}return Xe.currentNode=Ye,o}p(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},On=class n{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,o){this.type=2,this._$AH=K,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Qe(this,t,e),pr(t)?t===K||t==null||t===""?(this._$AH!==K&&this._$AR(),this._$AH=K):t!==this._$AH&&t!==qt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):dd(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==K&&pr(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ye.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:r}=t,o=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=mr.createElement(hd(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===o)this._$AH.p(e);else{let i=new bo(o,this),s=i.u(this.options);i.p(e),this.T(s),this._$AH=i}}_$AC(t){let e=cd.get(t.strings);return e===void 0&&cd.set(t.strings,e=new mr(t)),e}k(t){ea(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,o=0;for(let i of t)o===e.length?e.push(r=new n(this.O(fr()),this.O(fr()),this,this.options)):r=e[o],r._$AI(i),o++;o<e.length&&(this._$AR(r&&r._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){let r=t.nextSibling;t.remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},Ze=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,o,i){this.type=1,this._$AH=K,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=K}_$AI(t,e=this,r,o){let i=this.strings,s=!1;if(i===void 0)t=Qe(this,t,e,0),s=!pr(t)||t!==this._$AH&&t!==qt,s&&(this._$AH=t);else{let a=t,l,c;for(t=i[0],l=0;l<i.length-1;l++)c=Qe(this,a[r+l],e,l),c===qt&&(c=this._$AH[l]),s||(s=!pr(c)||c!==this._$AH[l]),c===K?t=K:t!==K&&(t+=(c??"")+i[l+1]),this._$AH[l]=c}s&&!o&&this.j(t)}j(t){t===K?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},yo=class extends Ze{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===K?void 0:t}},vo=class extends Ze{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==K)}},xo=class extends Ze{constructor(t,e,r,o,i){super(t,e,r,o,i),this.type=5}_$AI(t,e=this){if((t=Qe(this,t,e,0)??K)===qt)return;let r=this._$AH,o=t===K&&r!==K||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,i=t!==K&&(r===K||o);o&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},ko=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Qe(this,t)}},pd={M:Zs,P:ye,A:ta,C:1,L:fd,R:bo,D:dd,V:Qe,I:On,H:Ze,N:vo,U:xo,B:yo,F:ko},Ym=hr.litHtmlPolyfillSupport;Ym?.(mr,On),(hr.litHtmlVersions??(hr.litHtmlVersions=[])).push("3.3.1");var So=(n,t,e)=>{let r=e?.renderBefore??t,o=r._$litPart$;if(o===void 0){let i=e?.renderBefore??null;r._$litPart$=o=new On(t.insertBefore(fr(),i),i,void 0,e??{})}return o._$AI(n),o};var{I:ak}=pd;var md=n=>n.strings===void 0;var Nn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},tn=n=>(...t)=>({_$litDirective$:n,values:t}),De=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var gr=(n,t)=>{let e=n._$AN;if(e===void 0)return!1;for(let r of e)r._$AO?.(t,!1),gr(r,t);return!0},wo=n=>{let t,e;do{if((t=n._$AM)===void 0)break;e=t._$AN,e.delete(n),n=t}while(e?.size===0)},gd=n=>{for(let t;t=n._$AM;n=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(n))break;e.add(n),tg(t)}};function Qm(n){this._$AN!==void 0?(wo(this),this._$AM=n,gd(this)):this._$AM=n}function Zm(n,t=!1,e=0){let r=this._$AH,o=this._$AN;if(o!==void 0&&o.size!==0)if(t)if(Array.isArray(r))for(let i=e;i<r.length;i++)gr(r[i],!1),wo(r[i]);else r!=null&&(gr(r,!1),wo(r));else gr(this,n)}var tg=n=>{n.type==Nn.CHILD&&(n._$AP??(n._$AP=Zm),n._$AQ??(n._$AQ=Qm))},Eo=class extends De{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),gd(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(gr(this,t),wo(this))}setValue(t){if(md(this._$Ct))this._$Ct._$AI(t,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var bd=()=>new oa,oa=class{},ra=new WeakMap,yd=tn(class extends Eo{render(n){return K}update(n,[t]){let e=t!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=n.options?.host,this.rt(this.ct=n.element)),K}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){let t=this.ht??globalThis,e=ra.get(t);e===void 0&&(e=new WeakMap,ra.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){return typeof this.G=="function"?ra.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Mo=globalThis,Ao=Mo.ShadowRoot&&(Mo.ShadyCSS===void 0||Mo.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ia=Symbol(),vd=new WeakMap,br=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==ia)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(Ao&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=vd.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&vd.set(e,t))}return t}toString(){return this.cssText}},xd=n=>new br(typeof n=="string"?n:n+"",void 0,ia),Y=(n,...t)=>{let e=n.length===1?n[0]:t.reduce((r,o,i)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+n[i+1],n[0]);return new br(e,n,ia)},kd=(n,t)=>{if(Ao)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),o=Mo.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,n.appendChild(r)}},sa=Ao?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return xd(e)})(n):n;var{is:eg,defineProperty:ng,getOwnPropertyDescriptor:rg,getOwnPropertyNames:og,getOwnPropertySymbols:ig,getPrototypeOf:sg}=Object,$e=globalThis,Sd=$e.trustedTypes,ag=Sd?Sd.emptyScript:"",lg=$e.reactiveElementPolyfillSupport,yr=(n,t)=>n,aa={toAttribute(n,t){switch(t){case Boolean:n=n?ag:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},Ed=(n,t)=>!eg(n,t),wd={attribute:!0,type:String,converter:aa,reflect:!1,useDefault:!1,hasChanged:Ed};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),$e.litPropertyMetadata??($e.litPropertyMetadata=new WeakMap);var ve=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=wd){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),o=this.getPropertyDescriptor(t,r,e);o!==void 0&&ng(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:i}=rg(this.prototype,t)??{get(){return this[e]},set(s){this[e]=s}};return{get:o,set(s){let a=o?.call(this);i?.call(this,s),this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??wd}static _$Ei(){if(this.hasOwnProperty(yr("elementProperties")))return;let t=sg(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(yr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(yr("properties"))){let e=this.properties,r=[...og(e),...ig(e)];for(let o of r)this.createProperty(o,e[o])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,o]of e)this.elementProperties.set(r,o)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let o=this._$Eu(e,r);o!==void 0&&this._$Eh.set(o,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let o of r)e.unshift(sa(o))}else t!==void 0&&e.push(sa(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return kd(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$ET(t,e){let r=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,r);if(o!==void 0&&r.reflect===!0){let i=(r.converter?.toAttribute!==void 0?r.converter:aa).toAttribute(e,r.type);this._$Em=t,i==null?this.removeAttribute(o):this.setAttribute(o,i),this._$Em=null}}_$AK(t,e){let r=this.constructor,o=r._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let i=r.getPropertyOptions(o),s=typeof i.converter=="function"?{fromAttribute:i.converter}:i.converter?.fromAttribute!==void 0?i.converter:aa;this._$Em=o;let a=s.fromAttribute(e,i.type);this[o]=a??this._$Ej?.get(o)??a,this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){let o=this.constructor,i=this[t];if(r??(r=o.getPropertyOptions(t)),!((r.hasChanged??Ed)(i,e)||r.useDefault&&r.reflect&&i===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:o,wrapped:i},s){r&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,s??e??this[t]),i!==!0||s!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),o===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[o,i]of this._$Ep)this[o]=i;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[o,i]of r){let{wrapped:s}=i,a=this[o];s!==!0||this._$AL.has(o)||a===void 0||this.C(o,void 0,i,a)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(t){}firstUpdated(t){}};ve.elementStyles=[],ve.shadowRootOptions={mode:"open"},ve[yr("elementProperties")]=new Map,ve[yr("finalized")]=new Map,lg?.({ReactiveElement:ve}),($e.reactiveElementVersions??($e.reactiveElementVersions=[])).push("2.1.1");var vr=globalThis,te=class extends ve{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;let t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=So(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return qt}};te._$litElement$=!0,te.finalized=!0,vr.litElementHydrateSupport?.({LitElement:te});var cg=vr.litElementPolyfillSupport;cg?.({LitElement:te});(vr.litElementVersions??(vr.litElementVersions=[])).push("4.2.1");var dg=Y`
:host,
.trix-content {
/* General tokens */
--rhino-focus-ring: 0px 0px 1px 1px var(--rhino-button-active-border-color);
--rhino-border-radius: 4px;
--rhino-danger-border-color: red;
--rhino-danger-background-color: #ffdddd;
/* Editor tokens */
--rhino-text-color: #374151;
--rhino-dark-text-color: white;
--rhino-border-color: #cecece;
--rhino-placeholder-text-color: #cecece;
--rhino-dark-placeholder-text-color: gray;
/* Regular buttons */
--rhino-button-text-color: #889;
--rhino-button-dark-text-color: #eee;
--rhino-button-border-color: #cecece;
/** Disabled Buttons */
--rhino-button-disabled-text-color: #d1d5db;
--rhino-button-disabled-border-color: #d1d5db;
--rhino-button-disabled-background-color: #d1d5db;
/** Active buttons */
--rhino-button-active-border-color: #005a9c;
--rhino-button-active-background-color: rgb(226 239 255);
--rhino-toolbar-text-color: hsl(219, 6%, 43%);
--rhino-toolbar-icon-size: 1em;
--rhino-dialog-border-color: hsl(
var(--rhino-button-focus-background-color-hsl) / 50%
);
/** Focus buttons */
--rhino-button-focus-background-color: hsl(
var(--rhino-button-focus-background-color-hsl)
);
--rhino-button-focus-background-color-hsl: 219 26% 95%;
/**
* Override "--rhino-fake-selection-color" to change the color of .rhino-selection when the editor is not focused.
*/
--rhino-fake-selection-color: rgb(220, 220, 220);
display: block;
color: var(--rhino-text-color);
color: light-dark(var(--rhino-text-color), var(--rhino-dark-text-color));
}
`,Lk=Y`
/**
* Cursor styles that are useful for providing a more "pleasant" editor experience.
*/
/**
* https://github.com/curvenote/editor/blob/main/packages/prosemirror-codemark/src/codemark.css
*/
@keyframes rhino-blink {
49% {
border-color: unset;
}
50% {
border-color: Canvas;
}
99% {
border-color: Canvas;
}
}
.rhino-editor .no-cursor {
caret-color: transparent;
}
:where(.rhino-editor) .fake-cursor {
margin: 0;
padding: 0;
margin-right: -1px;
border-left-width: 1px;
border-left-style: solid;
animation: rhino-blink 1s;
animation-iteration-count: infinite;
position: relative;
z-index: 1;
}
/** This is for actual "selection" which are highlighting more than 1 character. */
:where(.rhino-editor .ProseMirror):not(:focus-within) .rhino-selection {
background: var(--rhino-fake-selection-color);
}
.ProseMirror-separator {
display: none !important;
}
`,Md=Y`
.rhino-toolbar-button {
appearance: none;
-webkit-appearance: none;
border: 1px solid var(--rhino-border-color);
border-radius: var(--rhino-border-radius);
padding: 0.4em;
color: var(--rhino-button-text-color);
color: light-dark(
var(--rhino-button-text-color),
var(--rhino-button-dark-text-color)
);
background: Canvas;
font-size: inherit;
display: inline-grid;
}
.rhino-toolbar-button:is([aria-disabled="true"], :disabled) {
color: var(--rhino-button-disabled-text-color);
border-color: var(--rhino-button-disabled-border-color);
}
.rhino-toolbar-button[aria-disabled="true"]:focus {
border-color: var(--rhino-button-disabled-border-color);
}
.rhino-toolbar-button svg {
min-height: var(--rhino-toolbar-icon-size);
min-width: var(--rhino-toolbar-icon-size);
/* max-height / max-width needs to be set for safari */
max-height: var(--rhino-toolbar-icon-size);
max-width: var(--rhino-toolbar-icon-size);
}
.rhino-toolbar-button:is(:focus, :hover):not(
[aria-disabled="true"],
:disabled
) {
outline: transparent;
border-color: var(--rhino-button-active-border-color);
}
.rhino-toolbar-button:is(:focus):not([aria-disabled="true"], :disabled) {
box-shadow: var(--rhino-focus-ring);
}
/* Only change the background color in certain scenarios */
.rhino-toolbar-button:is(:hover):not(
[aria-disabled="true"],
:disabled,
[aria-pressed="true"],
[part~="toolbar__button--active"]
) {
background-color: var(--rhino-button-focus-background-color);
background-color: light-dark(
var(--rhino-button-focus-background-color),
gray
);
}
.rhino-toolbar-button:is([aria-disabled="true"], :disabled):not(
[part~="toolbar__button--active"]
) {
color: var(--rhino-button-disabled-text-color);
color: light-dark(var(--rhino-button-disabled-text-color), gray);
border-color: var(--rhino-button-disabled-border-color);
}
.rhino-toolbar-button:is(:focus, :hover):is(
[aria-disabled="true"],
:disabled
):not([part~="toolbar__button--active"]) {
outline: transparent;
color: var(--rhino-button-disabled-text-color);
color: light-dark(var(--rhino-button-disabled-text-color), gray);
border-color: var(--rhino-button-disabled-border-color);
box-shadow: 0 0 0 1px var(--rhino-button-disabled-border-color);
box-shadow: 0 0 0 1px
light-dark(var(--rhino-button-disabled-border-color), transparent);
}
`,Ad=Y`
${dg}
[part~="toolbar"] {
color: var(--rhino-toolbar-text-color);
}
[part~="toolbar"]::part(base) {
border-color: var(--rhino-border-color);
border-bottom-color: transparent;
border-width: 1px;
border-radius: 4px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
display: flex;
align-items: center;
overflow: auto;
}
[part~="toolbar"][part~="bubble-menu__toolbar"]::part(base) {
border: 1px solid var(--rhino-border-color);
border-radius: 4px;
padding: 4px;
background: Canvas;
}
[part~="toolbar"]::part(base):is(:focus-visible, :focus-within) {
border-color: var(--rhino-button-active-border-color);
outline: transparent;
}
.rhino-toolbar-button[part~="toolbar__button--active"],
.rhino-toolbar-button[part~="toolbar__button--active"]:is(
:hover,
:focus-within
) {
background-color: var(--rhino-button-active-background-color);
}
slot[name="toolbar"]
:is(
[part~="toolbar__button--link"],
[part~="toolbar__button--increase-indentation"]
) {
margin-inline-end: 1rem;
}
[part~="toolbar__button--attach-files"] {
margin-inline-end: auto;
}
role-anchored-region {
font-size: 0.8em;
--background: transparent;
--border-color: transparent;
}
role-anchored-region::part(popover) {
border: none;
}
.link-dialog__container {
display: flex;
align-items: center;
max-width: 600px;
border: 1px solid gray;
padding: 0.4em;
background: Canvas;
border-radius: 8px;
}
.link-dialog__input {
border: 1px solid var(--rhino-border-color);
border-radius: var(--rhino-border-radius);
padding: 0.4em 0.6em;
flex: 1 1 auto;
}
.link-dialog__input:is(:focus) {
outline: transparent;
border-color: var(--rhino-button-active-border-color);
}
.link-validate:invalid {
outline: transparent;
background-color: var(--rhino-danger-background-color);
border-color: var(--rhino-danger-border-color);
box-shadow: none;
}
.rhino-toolbar-button.link-dialog__button {
padding: 0.4em 0.6em;
border: 1px solid var(--rhino-button-border-color);
border-radius: var(--rhino-border-radius);
}
.link-dialog__buttons {
margin-inline-start: 0.5em;
}
.editor-wrapper {
position: relative;
}
.trix-content {
border: 1px solid var(--rhino-border-color);
border-radius: 0px 0px var(--rhino-border-radius) var(--rhino-border-radius);
margin: 0;
padding: 0.4em 0.6em;
min-height: 200px;
outline: transparent;
white-space: pre-wrap;
}
role-tooltip {
position: fixed;
top: 0;
left: 0;
font-size: 0.75em;
--background: CanvasText;
color: Canvas;
--border-color: CanvasText;
}
role-tooltip::part(popover) {
padding: 0.4em 0.6em;
}
svg,
::slotted(svg) {
height: var(--rhino-toolbar-icon-size);
width: var(--rhino-toolbar-icon-size);
}
`;var en=class extends te{static define(t,e,r){t==null&&(t=this.baseName),e==null&&(e=this),!this.customElementRegistry.get(t)&&this.customElementRegistry.define(t,ug(e),r)}constructor(){super();try{this.internals=this.attachInternals()}catch(t){console.error(t)}}addCustomState(t){try{this.internals?.states.add(t)}catch{}}deleteCustomState(t){try{this.internals?.states.delete(t)}catch{}}hasCustomState(t){try{return this.internals?.states.has(t)}catch{return!1}}toggleCustomState(t,e){if(e==null){this.hasCustomState(t)?this.deleteCustomState(t):this.addCustomState(t);return}e===!0?this.addCustomState(t):this.deleteCustomState(t)}};en.customElementRegistry=window.customElements;function ug(n){return class extends n{}}function ft(n){this.content=n}ft.prototype={constructor:ft,find:function(n){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===n)return t;return-1},get:function(n){var t=this.find(n);return t==-1?void 0:this.content[t+1]},update:function(n,t,e){var r=e&&e!=n?this.remove(e):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(e||n,t):(i[o+1]=t,e&&(i[o]=e)),new ft(i)},remove:function(n){var t=this.find(n);if(t==-1)return this;var e=this.content.slice();return e.splice(t,2),new ft(e)},addToStart:function(n,t){return new ft([n,t].concat(this.remove(n).content))},addToEnd:function(n,t){var e=this.remove(n).content.slice();return e.push(n,t),new ft(e)},addBefore:function(n,t,e){var r=this.remove(t),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,t,e),new ft(o)},forEach:function(n){for(var t=0;t<this.content.length;t+=2)n(this.content[t],this.content[t+1])},prepend:function(n){return n=ft.from(n),n.size?new ft(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ft.from(n),n.size?new ft(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var t=this;n=ft.from(n);for(var e=0;e<n.content.length;e+=2)t=t.remove(n.content[e]);return t},toObject:function(){var n={};return this.forEach(function(t,e){n[t]=e}),n},get size(){return this.content.length>>1}};ft.from=function(n){if(n instanceof ft)return n;var t=[];if(n)for(var e in n)t.push(e,n[e]);return new ft(t)};var la=ft;function Id(n,t,e){for(let r=0;;r++){if(r==n.childCount||r==t.childCount)return n.childCount==t.childCount?null:e;let o=n.child(r),i=t.child(r);if(o==i){e+=o.nodeSize;continue}if(!o.sameMarkup(i))return e;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)e++;return e}if(o.content.size||i.content.size){let s=Id(o.content,i.content,e+1);if(s!=null)return s}e+=o.nodeSize}}function Ld(n,t,e,r){for(let o=n.childCount,i=t.childCount;;){if(o==0||i==0)return o==i?null:{a:e,b:r};let s=n.child(--o),a=t.child(--i),l=s.nodeSize;if(s==a){e-=l,r-=l;continue}if(!s.sameMarkup(a))return{a:e,b:r};if(s.isText&&s.text!=a.text){let c=0,d=Math.min(s.text.length,a.text.length);for(;c<d&&s.text[s.text.length-c-1]==a.text[a.text.length-c-1];)c++,e--,r--;return{a:e,b:r}}if(s.content.size||a.content.size){let c=Ld(s.content,a.content,e-1,r-1);if(c)return c}e-=l,r-=l}}var w=class n{constructor(t,e){if(this.content=t,this.size=e||0,e==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,e,r,o=0,i){for(let s=0,a=0;a<e;s++){let l=this.content[s],c=a+l.nodeSize;if(c>t&&r(l,o+a,i||null,s)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,t-d),Math.min(l.content.size,e-d),r,o+d)}a=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,o){let i="",s=!0;return this.nodesBetween(t,e,(a,l)=>{let c=a.isText?a.text.slice(Math.max(t,l)-l,e-l):a.isLeaf?o?typeof o=="function"?o(a):o:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,o=this.content.slice(),i=0;for(e.isText&&e.sameMarkup(r)&&(o[o.length-1]=e.withText(e.text+r.text),i=1);i<t.content.length;i++)o.push(t.content[i]);return new n(o,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],o=0;if(e>t)for(let i=0,s=0;s<e;i++){let a=this.content[i],l=s+a.nodeSize;l>t&&((s<t||l>e)&&(a.isText?a=a.cut(Math.max(0,t-s),Math.min(a.text.length,e-s)):a=a.cut(Math.max(0,t-s-1),Math.min(a.content.size,e-s-1))),r.push(a),o+=a.nodeSize),s=l}return new n(r,o)}cutByIndex(t,e){return t==e?n.empty:t==0&&e==this.content.length?this:new n(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let o=this.content.slice(),i=this.size+e.nodeSize-r.nodeSize;return o[t]=e,new n(o,i)}addToStart(t){return new n([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new n(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,r=0;e<this.content.length;e++){let o=this.content[e];t(o,r,e),r+=o.nodeSize}}findDiffStart(t,e=0){return Id(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return Ld(this,t,e,r)}findIndex(t){if(t==0)return To(0,t);if(t==this.size)return To(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,r=0;;e++){let o=this.child(e),i=r+o.nodeSize;if(i>=t)return i==t?To(e+1,i):To(e,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 n.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return n.empty;let e,r=0;for(let o=0;o<t.length;o++){let i=t[o];r+=i.nodeSize,o&&i.isText&&t[o-1].sameMarkup(i)?(e||(e=t.slice(0,o)),e[e.length-1]=i.withText(e[e.length-1].text+i.text)):e&&e.push(i)}return new n(e||t,r)}static from(t){if(!t)return n.empty;if(t instanceof n)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new n([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};w.empty=new w([],0);var ca={index:0,offset:0};function To(n,t){return ca.index=n,ca.offset=t,ca}function Co(n,t){if(n===t)return!0;if(!(n&&typeof n=="object")||!(t&&typeof t=="object"))return!1;let e=Array.isArray(n);if(Array.isArray(t)!=e)return!1;if(e){if(n.length!=t.length)return!1;for(let r=0;r<n.length;r++)if(!Co(n[r],t[r]))return!1}else{for(let r in n)if(!(r in t)||!Co(n[r],t[r]))return!1;for(let r in t)if(!(r in n))return!1}return!0}var z=class n{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,r=!1;for(let o=0;o<t.length;o++){let i=t[o];if(this.eq(i))return t;if(this.type.excludes(i.type))e||(e=t.slice(0,o));else{if(i.type.excludes(this.type))return t;!r&&i.type.rank>this.type.rank&&(e||(e=t.slice(0,o)),e.push(this),r=!0),e&&e.push(i)}}return e||(e=t.slice()),r||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&&Co(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 r=t.marks[e.type];if(!r)throw new RangeError(`There is no mark type ${e.type} in this schema`);let o=r.create(e.attrs);return r.checkAttrs(o.attrs),o}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return n.none;if(t instanceof n)return[t];let e=t.slice();return e.sort((r,o)=>r.type.rank-o.type.rank),e}};z.none=[];var on=class extends Error{},A=class n{constructor(t,e,r){this.content=t,this.openStart=e,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=zd(this.content,t+this.openStart,e);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(t,e){return new n(Bd(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 n.empty;let r=e.openStart||0,o=e.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(w.fromJSON(t,e.content),r,o)}static maxOpen(t,e=!0){let r=0,o=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)o++;return new n(t,r,o)}};A.empty=new A(w.empty,0,0);function Bd(n,t,e){let{index:r,offset:o}=n.findIndex(t),i=n.maybeChild(r),{index:s,offset:a}=n.findIndex(e);if(o==t||i.isText){if(a!=e&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,t).append(n.cut(e))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Bd(i.content,t-o-1,e-o-1)))}function zd(n,t,e,r){let{index:o,offset:i}=n.findIndex(t),s=n.maybeChild(o);if(i==t||s.isText)return r&&!r.canReplace(o,o,e)?null:n.cut(0,t).append(e).append(n.cut(t));let a=zd(s.content,t-i-1,e,s);return a&&n.replaceChild(o,s.copy(a))}function hg(n,t,e){if(e.openStart>n.depth)throw new on("Inserted content deeper than insertion position");if(n.depth-e.openStart!=t.depth-e.openEnd)throw new on("Inconsistent open depths");return Hd(n,t,e,0)}function Hd(n,t,e,r){let o=n.index(r),i=n.node(r);if(o==t.index(r)&&r<n.depth-e.openStart){let s=Hd(n,t,e,r+1);return i.copy(i.content.replaceChild(o,s))}else if(e.content.size)if(!e.openStart&&!e.openEnd&&n.depth==r&&t.depth==r){let s=n.parent,a=s.content;return rn(s,a.cut(0,n.parentOffset).append(e.content).append(a.cut(t.parentOffset)))}else{let{start:s,end:a}=fg(e,n);return rn(i,Vd(n,s,a,t,r))}else return rn(i,Oo(n,t,r))}function Fd(n,t){if(!t.type.compatibleContent(n.type))throw new on("Cannot join "+t.type.name+" onto "+n.type.name)}function ua(n,t,e){let r=n.node(e);return Fd(r,t.node(e)),r}function nn(n,t){let e=t.length-1;e>=0&&n.isText&&n.sameMarkup(t[e])?t[e]=n.withText(t[e].text+n.text):t.push(n)}function xr(n,t,e,r){let o=(t||n).node(e),i=0,s=t?t.index(e):o.childCount;n&&(i=n.index(e),n.depth>e?i++:n.textOffset&&(nn(n.nodeAfter,r),i++));for(let a=i;a<s;a++)nn(o.child(a),r);t&&t.depth==e&&t.textOffset&&nn(t.nodeBefore,r)}function rn(n,t){return n.type.checkContent(t),n.copy(t)}function Vd(n,t,e,r,o){let i=n.depth>o&&ua(n,t,o+1),s=r.depth>o&&ua(e,r,o+1),a=[];return xr(null,n,o,a),i&&s&&t.index(o)==e.index(o)?(Fd(i,s),nn(rn(i,Vd(n,t,e,r,o+1)),a)):(i&&nn(rn(i,Oo(n,t,o+1)),a),xr(t,e,o,a),s&&nn(rn(s,Oo(e,r,o+1)),a)),xr(r,null,o,a),new w(a)}function Oo(n,t,e){let r=[];if(xr(null,n,e,r),n.depth>e){let o=ua(n,t,e+1);nn(rn(o,Oo(n,t,e+1)),r)}return xr(t,null,e,r),new w(r)}function fg(n,t){let e=t.depth-n.openStart,o=t.node(e).copy(n.content);for(let i=e-1;i>=0;i--)o=t.node(i).copy(w.from(o));return{start:o.resolveNoCache(n.openStart+e),end:o.resolveNoCache(o.content.size-n.openEnd-e)}}var No=class n{constructor(t,e,r){this.pos=t,this.path=e,this.parentOffset=r,this.depth=e.length/3-1}resolveDepth(t){return t==null?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[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].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 r=this.pos-this.path[this.path.length-1],o=t.child(e);return r?t.child(e).cut(r):o}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):t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[e*3],o=e==0?0:this.path[e*3-1]+1;for(let i=0;i<t;i++)o+=r.child(i).nodeSize;return o}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return z.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),o=t.maybeChild(e);if(!r){let a=r;r=o,o=a}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,o=t.parent.maybeChild(t.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new sn(this,t,r);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 r=[],o=0,i=e;for(let s=t;;){let{index:a,offset:l}=s.content.findIndex(i),c=i-l;if(r.push(s,a,o+l),!c||(s=s.child(a),s.isText))break;i=c-1,o+=l+1}return new n(e,r,i)}static resolveCached(t,e){let r=Td.get(t);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==e)return s}else Td.set(t,r=new ha);let o=r.elts[r.i]=n.resolve(t,e);return r.i=(r.i+1)%pg,o}},ha=class{constructor(){this.elts=[],this.i=0}},pg=12,Td=new WeakMap,sn=class{constructor(t,e,r){this.$from=t,this.$to=e,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},mg=Object.create(null),Mt=class n{constructor(t,e,r,o=z.none){this.type=t,this.attrs=e,this.marks=o,this.content=r||w.empty}get children(){return this.content.content}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,r,o=0){this.content.nodesBetween(t,e,r,o,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,r,o){return this.content.textBetween(t,e,r,o)}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,r){return this.type==t&&Co(this.attrs,e||t.defaultAttrs||mg)&&z.sameSet(this.marks,r||z.none)}copy(t=null){return t==this.content?this:new n(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new n(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return t==0&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=!1){if(t==e)return A.empty;let o=this.resolve(t),i=this.resolve(e),s=r?0:o.sharedDepth(e),a=o.start(s),c=o.node(s).content.cut(o.pos-a,i.pos-a);return new A(c,o.depth-s,i.depth-s)}replace(t,e,r){return hg(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:o}=e.content.findIndex(t);if(e=e.maybeChild(r),!e)return null;if(o==t||e.isText)return e;t-=o+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let o=this.content.child(e-1);return{node:o,index:e-1,offset:r-o.nodeSize}}resolve(t){return No.resolveCached(this,t)}resolveNoCache(t){return No.resolve(this,t)}rangeHasMark(t,e,r){let o=!1;return e>t&&this.nodesBetween(t,e,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}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()+")"),Ud(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,r=w.empty,o=0,i=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,o,i),a=s&&s.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(let l=o;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(t,e,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(t).matchType(r),s=i&&i.matchFragment(this.content,e);return s?s.validEnd:!1}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),this.type.checkAttrs(this.attrs);let t=z.none;for(let e=0;e<this.marks.length;e++){let r=this.marks[e];r.type.checkAttrs(r.attrs),t=r.addToSet(t)}if(!z.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.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(e=>e.toJSON())),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let o=w.fromJSON(t,e.content),i=t.nodeType(e.type).create(e.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};Mt.prototype.text=void 0;var fa=class n extends Mt{constructor(t,e,r,o){if(super(t,e,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ud(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 n(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new n(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return t==0&&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 Ud(n,t){for(let e=n.length-1;e>=0;e--)t=n[e].type.name+"("+t+")";return t}var an=class n{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let r=new pa(t,e);if(r.next==null)return n.empty;let o=Kd(r);r.next&&r.err("Unexpected trailing text");let i=Sg(kg(o));return wg(i,r),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,r=t.childCount){let o=this;for(let i=e;o&&i<r;i++)o=o.matchType(t.child(i).type);return o}get inlineContent(){return this.next.length!=0&&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 r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return!0;return!1}fillBefore(t,e=!1,r=0){let o=[this];function i(s,a){let l=s.matchFragment(t,r);if(l&&(!e||l.validEnd))return w.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:u}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let h=i(u,a.concat(d));if(h)return h}}return null}return i(this,[])}findWrapping(t){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==t)return this.wrapCache[r+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(t)){let s=[];for(let a=o;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:a,next:l}=i.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in e)&&(!o.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:o}),e[a.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=[];function e(r){t.push(r);for(let o=0;o<r.next.length;o++)t.indexOf(r.next[o].next)==-1&&e(r.next[o].next)}return e(this),t.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+t.indexOf(r.next[s].next);return i}).join(`
`)}};an.empty=new an(!0);var pa=class{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 Kd(n){let t=[];do t.push(gg(n));while(n.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function gg(n){let t=[];do t.push(bg(n));while(n.next&&n.next!=")"&&n.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function bg(n){let t=xg(n);for(;;)if(n.eat("+"))t={type:"plus",expr:t};else if(n.eat("*"))t={type:"star",expr:t};else if(n.eat("?"))t={type:"opt",expr:t};else if(n.eat("{"))t=yg(n,t);else break;return t}function _d(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let t=Number(n.next);return n.pos++,t}function yg(n,t){let e=_d(n),r=e;return n.eat(",")&&(n.next!="}"?r=_d(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:e,max:r,expr:t}}function vg(n,t){let e=n.nodeTypes,r=e[t];if(r)return[r];let o=[];for(let i in e){let s=e[i];s.isInGroup(t)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+t+"' found"),o}function xg(n){if(n.eat("(")){let t=Kd(n);return n.eat(")")||n.err("Missing closing paren"),t}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let t=vg(n,n.next).map(e=>(n.inline==null?n.inline=e.isInline:n.inline!=e.isInline&&n.err("Mixing inline and block content"),{type:"name",value:e}));return n.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function kg(n){let t=[[]];return o(i(n,0),e()),t;function e(){return t.push([])-1}function r(s,a,l){let c={term:l,to:a};return t[s].push(c),c}function o(s,a){s.forEach(l=>l.to=a)}function i(s,a){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(i(c,a)),[]);if(s.type=="seq")for(let l=0;;l++){let c=i(s.exprs[l],a);if(l==s.exprs.length-1)return c;o(c,a=e())}else if(s.type=="star"){let l=e();return r(a,l),o(i(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=e();return o(i(s.expr,a),l),o(i(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(a)].concat(i(s.expr,a));if(s.type=="range"){let l=a;for(let c=0;c<s.min;c++){let d=e();o(i(s.expr,l),d),l=d}if(s.max==-1)o(i(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let d=e();r(l,d),o(i(s.expr,l),d),l=d}return[r(l)]}else{if(s.type=="name")return[r(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function jd(n,t){return t-n}function Cd(n,t){let e=[];return r(t),e.sort(jd);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);e.push(o);for(let s=0;s<i.length;s++){let{term:a,to:l}=i[s];!a&&e.indexOf(l)==-1&&r(l)}}}function Sg(n){let t=Object.create(null);return e(Cd(n,0));function e(r){let o=[];r.forEach(s=>{n[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<o.length;d++)o[d][0]==a&&(c=o[d][1]);Cd(n,l).forEach(d=>{c||o.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=t[r.join(",")]=new an(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let a=o[s][1].sort(jd);i.next.push({type:o[s][0],next:t[a.join(",")]||e(a)})}return i}}function wg(n,t){for(let e=0,r=[n];e<r.length;e++){let o=r[e],i=!o.validEnd,s=[];for(let a=0;a<o.next.length;a++){let{type:l,next:c}=o.next[a];s.push(l.name),i&&!(l.isText||l.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Wd(n){let t=Object.create(null);for(let e in n){let r=n[e];if(!r.hasDefault)return null;t[e]=r.default}return t}function qd(n,t){let e=Object.create(null);for(let r in n){let o=t&&t[r];if(o===void 0){let i=n[r];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r)}e[r]=o}return e}function Jd(n,t,e,r){for(let o in t)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${e} of type ${o}`);for(let o in n){let i=n[o];i.validate&&i.validate(t[o])}}function Gd(n,t){let e=Object.create(null);if(t)for(let r in t)e[r]=new ma(n,r,t[r]);return e}var Po=class n{constructor(t,e,r){this.name=t,this.schema=e,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Gd(t,r.attrs),this.defaultAttrs=Wd(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==an.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}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:qd(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Mt(this,this.computeAttrs(t),w.from(e),z.setFrom(r))}createChecked(t=null,e,r){return e=w.from(e),this.checkContent(e),new Mt(this,this.computeAttrs(t),e,z.setFrom(r))}createAndFill(t=null,e,r){if(t=this.computeAttrs(t),e=w.from(e),e.size){let s=this.contentMatch.fillBefore(e);if(!s)return null;e=s.append(e)}let o=this.contentMatch.matchFragment(e),i=o&&o.fillBefore(w.empty,!0);return i?new Mt(this,t,e.append(i),z.setFrom(r)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let r=0;r<t.childCount;r++)if(!this.allowsMarks(t.child(r).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)}`)}checkAttrs(t){Jd(this.attrs,t,"node",this.name)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let e;for(let r=0;r<t.length;r++)this.allowsMarkType(t[r].type)?e&&e.push(t[r]):e||(e=t.slice(0,r));return e?e.length?e:z.none:t}static compile(t,e){let r=Object.create(null);t.forEach((i,s)=>r[i]=new n(i,e,s));let o=e.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Eg(n,t,e){let r=e.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${n}, got ${i}`)}}var ma=class{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Eg(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Sr=class n{constructor(t,e,r,o){this.name=t,this.rank=e,this.schema=r,this.spec=o,this.attrs=Gd(t,o.attrs),this.excluded=null;let i=Wd(this.attrs);this.instance=i?new z(this,i):null}create(t=null){return!t&&this.instance?this.instance:new z(this,qd(this.attrs,t))}static compile(t,e){let r=Object.create(null),o=0;return t.forEach((i,s)=>r[i]=new n(i,o++,e,s)),r}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]}checkAttrs(t){Jd(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}},Rn=class{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let o in t)e[o]=t[o];e.nodes=la.from(t.nodes),e.marks=la.from(t.marks||{}),this.nodes=Po.compile(this.spec.nodes,this),this.marks=Sr.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",a=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=an.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=a=="_"?null:a?Od(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Od(this,s.split(" "))}this.nodeFromJSON=o=>Mt.fromJSON(this,o),this.markFromJSON=o=>z.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,r,o){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof Po){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(e,r,o)}text(t,e){let r=this.nodes.text;return new fa(r,r.defaultAttrs,t,z.setFrom(e))}mark(t,e){return typeof t=="string"&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}};function Od(n,t){let e=[];for(let r=0;r<t.length;r++){let o=t[r],i=n.marks[o],s=i;if(i)e.push(i);else for(let a in n.marks){let l=n.marks[a];(o=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(o)>-1)&&e.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return e}function Mg(n){return n.tag!=null}function Ag(n){return n.style!=null}var ee=class n{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let r=this.matchedStyles=[];e.forEach(o=>{if(Mg(o))this.tags.push(o);else if(Ag(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=t.nodes[o.node];return i.contentMatch.matchType(i)})}parse(t,e={}){let r=new Ro(this,e,!1);return r.addAll(t,z.none,e.from,e.to),r.finish()}parseSlice(t,e={}){let r=new Ro(this,e,!0);return r.addAll(t,z.none,e.from,e.to),A.maxOpen(r.finish())}matchTag(t,e,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Cg(t,i.tag)&&(i.namespace===void 0||t.namespaceURI==i.namespace)&&(!i.context||e.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(t);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(t,e,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],a=s.style;if(!(a.indexOf(t)!=0||s.context&&!r.matchesContext(s.context)||a.length>t.length&&(a.charCodeAt(t.length)!=61||a.slice(t.length+1)!=e))){if(s.getAttrs){let l=s.getAttrs(e);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(t){let e=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<e.length;s++){let a=e[s];if((a.priority==null?50:a.priority)<i)break}e.splice(s,0,o)}for(let o in t.marks){let i=t.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Pd(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in t.nodes){let i=t.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Pd(s)),s.node||s.ignore||s.mark||(s.node=o)})}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new n(t,n.schemaRules(t)))}},Xd={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},Tg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Yd={ol:!0,ul:!0},wr=1,ga=2,kr=4;function Nd(n,t,e){return t!=null?(t?wr:0)|(t==="full"?ga:0):n&&n.whitespace=="pre"?wr|ga:e&~kr}var Pn=class{constructor(t,e,r,o,i,s){this.type=t,this.attrs=e,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=z.none,this.match=i||(s&kr?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(w.from(t));if(e)this.match=this.type.contentMatch.matchFragment(e);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(t.type))?(this.match=r,o):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&wr)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let e=w.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(w.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Xd.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}},Ro=class{constructor(t,e,r){this.parser=t,this.options=e,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=e.topNode,i,s=Nd(null,e.preserveWhitespace,0)|(r?kr:0);o?i=new Pn(o.type,o.attrs,z.none,!0,e.topMatch||o.type.contentMatch,s):r?i=new Pn(null,null,z.none,!0,null,s):i=new Pn(t.schema.topNodeType,null,z.none,!0,null,s),this.nodes=[i],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){t.nodeType==3?this.addTextNode(t,e):t.nodeType==1&&this.addElement(t,e)}addTextNode(t,e){let r=t.nodeValue,o=this.top,i=o.options&ga?"full":this.localPreserveWS||(o.options&wr)>0;if(i==="full"||o.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=o.content[o.content.length-1],a=t.previousSibling;(!s||a&&a.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),e,!/\S/.test(r)),this.findInText(t)}else this.findInside(t)}addElement(t,e,r){let o=this.localPreserveWS,i=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let s=t.nodeName.toLowerCase(),a;Yd.hasOwnProperty(s)&&this.parser.normalizeLists&&_g(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(a=this.parser.matchTag(t,this,r));t:if(l?l.ignore:Tg.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t,e);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let c,d=this.needsBlock;if(Xd.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let u=l&&l.skip?e:this.readStyles(t,e);u&&this.addAll(t,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(t,e);c&&this.addElementByRule(t,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=o}leafFallback(t,e){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
`),e)}ignoreFallback(t,e){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),e,!0)}readStyles(t,e){let r=t.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let a=void 0;;){let l=this.parser.matchStyle(i,s,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?e=e.filter(c=>!l.clearMark(c)):e=e.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return e}addElementByRule(t,e,r,o){let i,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let l=this.enter(s,e.attrs||null,r,e.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[e.mark];r=r.concat(l.create(e.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(t);else if(o)this.addElement(t,r,o);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=t;typeof e.contentElement=="string"?l=t.querySelector(e.contentElement):typeof e.contentElement=="function"?l=e.contentElement(t):e.contentElement&&(l=e.contentElement),this.findAround(t,l,!0),this.addAll(l,r),this.findAround(t,l,!1)}i&&this.sync(a)&&this.open--}addAll(t,e,r,o){let i=r||0;for(let s=r?t.childNodes[r]:t.firstChild,a=o==null?null:t.childNodes[o];s!=a;s=s.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(s,e);this.findAtPoint(t,i)}findPlace(t,e,r){let o,i;for(let s=this.open,a=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(t);if(c&&(!o||o.length>c.length+a)&&(o=c,i=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)e=this.enterInner(o[s],null,e,!1);return e}insertNode(t,e,r){if(t.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(e=this.enterInner(i,null,e))}let o=this.findPlace(t,e,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(t.type));let s=z.none;for(let a of o.concat(t.marks))(i.type?i.type.allowsMarkType(a.type):Rd(a.type,t.type))&&(s=a.addToSet(s));return i.content.push(t.mark(s)),!0}return!1}enter(t,e,r,o){let i=this.findPlace(t.create(e),r,!1);return i&&(i=this.enterInner(t,e,r,!0,o)),i}enterInner(t,e,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let a=Nd(t,i,s.options);s.options&kr&&s.content.length==0&&(a|=kr);let l=z.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Rd(c.type,t))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Pn(t,e,l,o,null,a)),this.open++,r}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;this.localPreserveWS&&(this.nodes[e].options|=wr)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let o=r.length-1;o>=0;o--)t+=r[o].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==e&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,r){if(t!=e&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&t.nodeType==1&&t.contains(this.find[o].node)&&e.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].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("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(a,l)=>{for(;a>=0;a--){let c=e[a];if(c==""){if(a==e.length-1||a==0)continue;for(;l>=i;l--)if(s(a-1,l))return!0;return!1}else{let d=l>0||l==0&&o?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let e in this.parser.schema.nodes){let r=this.parser.schema.nodes[e];if(r.isTextblock&&r.defaultAttrs)return r}}};function _g(n){for(let t=n.firstChild,e=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&Yd.hasOwnProperty(r)&&e?(e.appendChild(t),t=e):r=="li"?e=t:r&&(e=null)}}function Cg(n,t){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,t)}function Pd(n){let t={};for(let e in n)t[e]=n[e];return t}function Rd(n,t){let e=t.schema.nodes;for(let r in e){let o=e[r];if(!o.allowsMarkType(n))continue;let i=[],s=a=>{i.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==t||i.indexOf(d)<0&&s(d))return!0}};if(s(o.contentMatch))return!0}}var At=class n{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},r){r||(r=da(e).createDocumentFragment());let o=r,i=[];return t.forEach(s=>{if(i.length||s.marks.length){let a=0,l=0;for(;a<i.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(i[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<i.length;)o=i.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],d=this.serializeMark(c,s.isInline,e);d&&(i.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(s,e))}),r}serializeNodeInner(t,e){let{dom:r,contentDOM:o}=_o(da(e),this.nodes[t.type.name](t),null,t.attrs);if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,o)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let o=t.marks.length-1;o>=0;o--){let i=this.serializeMark(t.marks[o],t.isInline,e);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(t,e,r={}){let o=this.marks[t.type.name];return o&&_o(da(r),o(t,e),null,t.attrs)}static renderSpec(t,e,r=null,o){return _o(t,e,r,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new n(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Dd(t.nodes);return e.text||(e.text=r=>r.text),e}static marksFromSchema(t){return Dd(t.marks)}};function Dd(n){let t={};for(let e in n){let r=n[e].spec.toDOM;r&&(t[e]=r)}return t}function da(n){return n.document||window.document}var $d=new WeakMap;function Og(n){let t=$d.get(n);return t===void 0&&$d.set(n,t=Ng(n)),t}function Ng(n){let t=null;function e(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let o=0;o<r.length;o++)e(r[o]);else for(let o in r)e(r[o])}return e(n),t}function _o(n,t,e,r){if(typeof t=="string")return{dom:n.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let o=t[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Og(r))&&i.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(e=o.slice(0,s),o=o.slice(s+1));let a,l=e?n.createElementNS(e,o):n.createElement(o),c=t[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?l.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):u=="style"&&l.style?l.style.cssText=c[u]:l.setAttribute(u,c[u])}}for(let u=d;u<t.length;u++){let h=t[u];if(h===0){if(u<t.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:p}=_o(n,h,e,r);if(l.appendChild(f),p){if(a)throw new RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}var tu=65535,eu=Math.pow(2,16);function Pg(n,t){return n+t*eu}function Qd(n){return n&tu}function Rg(n){return(n-(n&tu))/eu}var nu=1,ru=2,Do=4,ou=8,Ar=class{constructor(t,e,r){this.pos=t,this.delInfo=e,this.recover=r}get deleted(){return(this.delInfo&ou)>0}get deletedBefore(){return(this.delInfo&(nu|Do))>0}get deletedAfter(){return(this.delInfo&(ru|Do))>0}get deletedAcross(){return(this.delInfo&Do)>0}},xe=class n{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&n.empty)return n.empty}recover(t){let e=0,r=Qd(t);if(!this.inverted)for(let o=0;o<r;o++)e+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+e+Rg(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?o:0);if(l>t)break;let c=this.ranges[a+i],d=this.ranges[a+s],u=l+c;if(t<=u){let h=c?t==l?-1:t==u?1:e:e,f=l+o+(h<0?0:d);if(r)return f;let p=t==(e<0?l:u)?null:Pg(a/3,t-l),y=t==l?ru:t==u?nu:Do;return(e<0?t!=l:t!=u)&&(y|=ou),new Ar(f,y,p)}o+=d-c}return r?t+o:new Ar(t+o,0,null)}touches(t,e){let r=0,o=Qd(e),i=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>t)break;let c=this.ranges[a+i],d=l+c;if(t<=d&&a==o*3)return!0;r+=this.ranges[a+s]-c}return!1}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],a=s-(this.inverted?i:0),l=s+(this.inverted?0:i),c=this.ranges[o+e],d=this.ranges[o+r];t(a,a+c,l,l+d),i+=d-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?n.empty:new n(t<0?[0,-t,0]:[0,0,t])}};xe.empty=new xe([]);var Tr=class n{constructor(t,e,r=0,o=t?t.length:0){this.mirror=e,this.from=r,this.to=o,this._maps=t||[],this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new n(this._maps,this.mirror,t,e)}appendMap(t,e){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),e!=null&&this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,r=this._maps.length;e<t._maps.length;e++){let o=t.getMirror(e);this.appendMap(t._maps[e],o!=null&&o<e?r+o: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,r=this._maps.length+t._maps.length;e>=0;e--){let o=t.getMirror(e);this.appendMap(t._maps[e].invert(),o!=null&&o>e?r-o-1:void 0)}}invert(){let t=new n;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],a=s.mapResult(t,e);if(a.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,t=this._maps[l].recover(a.recover);continue}}o|=a.delInfo,t=a.pos}return r?t:new Ar(t,o,null)}},ba=Object.create(null),st=class{getMap(){return xe.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ba[e.stepType];if(!r)throw new RangeError(`No step type ${e.stepType} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in ba)throw new RangeError("Duplicate use of step JSON ID "+t);return ba[t]=e,e.prototype.jsonID=t,e}},ct=class n{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new n(t,null)}static fail(t){return new n(null,t)}static fromReplace(t,e,r,o){try{return n.ok(t.replace(e,r,o))}catch(i){if(i instanceof on)return n.fail(i.message);throw i}}};function Sa(n,t,e){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(Sa(i.content,t,i))),i.isInline&&(i=t(i,e,o)),r.push(i)}return w.fromArray(r)}var _r=class n extends st{constructor(t,e,r){super(),this.from=t,this.to=e,this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new A(Sa(e.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),e.openStart,e.openEnd);return ct.fromReplace(t,this.from,this.to,i)}invert(){return new ke(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new n(e.pos,r.pos,this.mark)}merge(t){return t instanceof n&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new n(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(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(e.from,e.to,t.markFromJSON(e.mark))}};st.jsonID("addMark",_r);var ke=class n extends st{constructor(t,e,r){super(),this.from=t,this.to=e,this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=new A(Sa(e.content,o=>o.mark(this.mark.removeFromSet(o.marks)),t),e.openStart,e.openEnd);return ct.fromReplace(t,this.from,this.to,r)}invert(){return new _r(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new n(e.pos,r.pos,this.mark)}merge(t){return t instanceof n&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new n(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(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(e.from,e.to,t.markFromJSON(e.mark))}};st.jsonID("removeMark",ke);var Cr=class n extends st{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return ct.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return ct.fromReplace(t,this.pos,this.pos+1,new A(w.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let r=this.mark.addToSet(e.marks);if(r.length==e.marks.length){for(let o=0;o<e.marks.length;o++)if(!e.marks[o].isInSet(r))return new n(this.pos,e.marks[o]);return new n(this.pos,this.mark)}}return new Dn(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new n(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(e.pos,t.markFromJSON(e.mark))}};st.jsonID("addNodeMark",Cr);var Dn=class n extends st{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return ct.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return ct.fromReplace(t,this.pos,this.pos+1,new A(w.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return!e||!this.mark.isInSet(e.marks)?this:new Cr(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new n(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(e.pos,t.markFromJSON(e.mark))}};st.jsonID("removeNodeMark",Dn);var at=class n extends st{constructor(t,e,r,o=!1){super(),this.from=t,this.to=e,this.slice=r,this.structure=o}apply(t){return this.structure&&xa(t,this.from,this.to)?ct.fail("Structure replace would overwrite content"):ct.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new xe([this.from,this.to-this.from,this.slice.size])}invert(t){return new n(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deletedAcross&&r.deletedAcross?null:new n(e.pos,Math.max(e.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof n)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let e=this.slice.size+t.slice.size==0?A.empty:new A(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new n(this.from,this.to+(t.to-t.from),e,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let e=this.slice.size+t.slice.size==0?A.empty:new A(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new n(t.from,this.to,e,this.structure)}else return null}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(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(e.from,e.to,A.fromJSON(t,e.slice),!!e.structure)}};st.jsonID("replace",at);var J=class n extends st{constructor(t,e,r,o,i,s,a=!1){super(),this.from=t,this.to=e,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=a}apply(t){if(this.structure&&(xa(t,this.from,this.gapFrom)||xa(t,this.gapTo,this.to)))return ct.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return ct.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);return r?ct.fromReplace(t,this.from,this.to,r):ct.fail("Content does not fit in gap")}getMap(){return new xe([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 n(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),r=t.mapResult(this.to,-1),o=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return e.deletedAcross&&r.deletedAcross||o<e.pos||i>r.pos?null:new n(e.pos,r.pos,o,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(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(e.from,e.to,e.gapFrom,e.gapTo,A.fromJSON(t,e.slice),e.insert,!!e.structure)}};st.jsonID("replaceAround",J);function xa(n,t,e){let r=n.resolve(t),o=e-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function Dg(n,t,e,r){let o=[],i=[],s,a;n.doc.nodesBetween(t,e,(l,c,d)=>{if(!l.isInline)return;let u=l.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,t),f=Math.min(c+l.nodeSize,e),p=r.addToSet(u);for(let y=0;y<u.length;y++)u[y].isInSet(p)||(s&&s.to==h&&s.mark.eq(u[y])?s.to=f:o.push(s=new ke(h,f,u[y])));a&&a.to==h?a.to=f:i.push(a=new _r(h,f,r))}}),o.forEach(l=>n.step(l)),i.forEach(l=>n.step(l))}function $g(n,t,e,r){let o=[],i=0;n.doc.nodesBetween(t,e,(s,a)=>{if(!s.isInline)return;i++;let l=null;if(r instanceof Sr){let c=s.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,e);for(let d=0;d<l.length;d++){let u=l[d],h;for(let f=0;f<o.length;f++){let p=o[f];p.step==i-1&&u.eq(o[f].style)&&(h=p)}h?(h.to=c,h.step=i):o.push({style:u,from:Math.max(a,t),to:c,step:i})}}}),o.forEach(s=>n.step(new ke(s.from,s.to,s.style)))}function wa(n,t,e,r=e.contentMatch,o=!0){let i=n.doc.nodeAt(t),s=[],a=t+1;for(let l=0;l<i.childCount;l++){let c=i.child(l),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)s.push(new at(a,d,A.empty));else{r=u;for(let h=0;h<c.marks.length;h++)e.allowsMarkType(c.marks[h].type)||n.step(new ke(a,d,c.marks[h]));if(o&&c.isText&&e.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new A(w.from(e.schema.text(" ",e.allowedMarks(c.marks))),0,0)),s.push(new at(a+h.index,a+h.index+h[0].length,p))}}a=d}if(!r.validEnd){let l=r.fillBefore(w.empty,!0);n.replace(a,a,new A(l,0,0))}for(let l=s.length-1;l>=0;l--)n.step(s[l])}function Ig(n,t,e){return(t==0||n.canReplace(t,n.childCount))&&(e==n.childCount||n.canReplace(0,e))}function Se(n){let e=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),i=n.$from.index(r),s=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(i,s,e))return r;if(r==0||o.type.spec.isolating||!Ig(o,i,s))break}return null}function Lg(n,t,e){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),a=o.after(i+1),l=s,c=a,d=w.empty,u=0;for(let p=i,y=!1;p>e;p--)y||r.index(p)>0?(y=!0,d=w.from(r.node(p).copy(d)),u++):l--;let h=w.empty,f=0;for(let p=i,y=!1;p>e;p--)y||o.after(p+1)<o.end(p)?(y=!0,h=w.from(o.node(p).copy(h)),f++):c++;n.step(new J(l,c,s,a,new A(d.append(h),u,f),d.size-u,!0))}function Ln(n,t,e=null,r=n){let o=Bg(n,t),i=o&&zg(r,t);return i?o.map(Zd).concat({type:t,attrs:e}).concat(i.map(Zd)):null}function Zd(n){return{type:n,attrs:null}}function Bg(n,t){let{parent:e,startIndex:r,endIndex:o}=n,i=e.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return e.canReplaceWith(r,o,s)?i:null}function zg(n,t){let{parent:e,startIndex:r,endIndex:o}=n,i=e.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let c=r;l&&c<o;c++)l=l.matchType(e.child(c).type);return!l||!l.validEnd?null:s}function Hg(n,t,e){let r=w.empty;for(let s=e.length-1;s>=0;s--){if(r.size){let a=e[s].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=w.from(e[s].type.create(e[s].attrs,r))}let o=t.start,i=t.end;n.step(new J(o,i,o,i,new A(r,0,0),e.length,!0))}function Fg(n,t,e,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(t,e,(s,a)=>{let l=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,l)&&Vg(n.doc,n.mapping.slice(i).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&su(n,s,a,i),wa(n,n.mapping.slice(i).map(a,1),r,void 0,c===null);let d=n.mapping.slice(i),u=d.map(a,1),h=d.map(a+s.nodeSize,1);return n.step(new J(u,h,u+1,h-1,new A(w.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&iu(n,s,a,i),!1}})}function iu(n,t,e,r){t.forEach((o,i)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let l=n.mapping.slice(r).map(e+1+i+s.index);n.replaceWith(l,l+1,t.type.schema.linebreakReplacement.create())}}})}function su(n,t,e,r){t.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(e+1+i);n.replaceWith(s,s+1,t.type.schema.text(`
`))}})}function Vg(n,t,e){let r=n.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,e)}function Ug(n,t,e,r,o){let i=n.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");e||(e=i.type);let s=e.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(t,t+i.nodeSize,s);if(!e.validContent(i.content))throw new RangeError("Invalid content for node type "+e.name);n.step(new J(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new A(w.from(s),0,0),1,!0))}function Rt(n,t,e=1,r){let o=n.resolve(t),i=o.depth-e,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=e-2;c>i;c--,d--){let u=o.node(c),h=o.index(c);if(u.type.spec.isolating)return!1;let f=u.content.cutByIndex(h,u.childCount),p=r&&r[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let y=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!y.type.validContent(f))return!1}let a=o.indexAfter(i),l=r&&r[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function Kg(n,t,e=1,r){let o=n.doc.resolve(t),i=w.empty,s=w.empty;for(let a=o.depth,l=o.depth-e,c=e-1;a>l;a--,c--){i=w.from(o.node(a).copy(i));let d=r&&r[c];s=w.from(d?d.type.create(d.attrs,s):o.node(a).copy(s))}n.step(new at(t,t,new A(i.append(s),e,e),!0))}function Bt(n,t){let e=n.resolve(t),r=e.index();return au(e.nodeBefore,e.nodeAfter)&&e.parent.canReplace(r,r+1)}function jg(n,t){t.content.size||n.type.compatibleContent(t.type);let e=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?n.type.schema.nodes.text:i.type;if(e=e.matchType(s),!e||!n.type.allowsMarks(i.marks))return!1}return e.validEnd}function au(n,t){return!!(n&&t&&!n.isLeaf&&jg(n,t))}function ln(n,t,e=-1){let r=n.resolve(t);for(let o=r.depth;;o--){let i,s,a=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):e>0?(i=r.node(o+1),a++,s=r.node(o).maybeChild(a)):(i=r.node(o).maybeChild(a-1),s=r.node(o+1)),i&&!i.isTextblock&&au(i,s)&&r.node(o).canReplace(a,a+1))return t;if(o==0)break;t=e<0?r.before(o):r.after(o)}}function Wg(n,t,e){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(t-e),s=i.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let a=n.steps.length;if(r===!1){let d=n.doc.resolve(t+e);su(n,d.node(),d.before(),a)}s.inlineContent&&wa(n,t+e-1,s,i.node().contentMatchAt(i.index()),r==null);let l=n.mapping.slice(a),c=l.map(t-e);if(n.step(new at(c,l.map(t+e,-1),A.empty,!0)),r===!0){let d=n.doc.resolve(c);iu(n,d.node(),d.before(),n.steps.length)}return n}function qg(n,t,e){let r=n.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),e))return t;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,e))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,e))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Lo(n,t,e){let r=n.resolve(t);if(!e.content.size)return t;let o=e.content;for(let i=0;i<e.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(e.openStart==0&&e.size?2:1);i++)for(let s=r.depth;s>=0;s--){let a=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.index(s)+(a>0?1:0),c=r.node(s),d=!1;if(i==1)d=c.canReplace(l,l,o);else{let u=c.contentMatchAt(l).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(l,l,u[0])}if(d)return a==0?r.pos:a<0?r.before(s+1):r.after(s+1)}return null}function Or(n,t,e=t,r=A.empty){if(t==e&&!r.size)return null;let o=n.resolve(t),i=n.resolve(e);return lu(o,i,r)?new at(t,e,r):new ka(o,i,r).fit()}function lu(n,t,e){return!e.openStart&&!e.openEnd&&n.start()==t.start()&&n.parent.canReplace(n.index(),t.index(),e.content)}var ka=class{constructor(t,e,r){this.$from=t,this.$to=e,this.unplaced=r,this.frontier=[],this.placed=w.empty;for(let o=0;o<=t.depth;o++){let i=t.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(o))})}for(let o=t.depth;o>0;o--)this.placed=w.from(t.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(t<0?this.$to:r.doc.resolve(t));if(!o)return null;let i=this.placed,s=r.depth,a=o.depth;for(;s&&a&&i.childCount==1;)i=i.firstChild.content,s--,a--;let l=new A(i,s,a);return t>-1?new J(r.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||r.pos!=this.$to.pos?new at(r.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<t;r++){let i=e.firstChild;if(e.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){t=r;break}e=i.content}for(let e=1;e<=2;e++)for(let r=e==1?t:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=ya(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,u=null;if(e==1&&(s?c.matchType(s.type)||(u=c.fillBefore(w.from(s),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:a,parent:i,inject:u};if(e==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:a,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced,o=ya(t,e);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new A(t,e+1,Math.max(r,o.size+e>=t.size-r?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced,o=ya(t,e);if(o.childCount<=1&&e>0){let i=t.size-e<=e+o.size;this.unplaced=new A(Er(t,e-1,1),e-1,i?e-1:r)}else this.unplaced=new A(Er(t,e,1),e,r)}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:o,wrap:i}){for(;this.depth>e;)this.closeFrontierNode();if(i)for(let y=0;y<i.length;y++)this.openFrontierNode(i[y]);let s=this.unplaced,a=r?r.content:s.content,l=s.openStart-t,c=0,d=[],{match:u,type:h}=this.frontier[e];if(o){for(let y=0;y<o.childCount;y++)d.push(o.child(y));u=u.matchFragment(o)}let f=a.size+t-(s.content.size-s.openEnd);for(;c<a.childCount;){let y=a.child(c),x=u.matchType(y.type);if(!x)break;c++,(c>1||l==0||y.content.size)&&(u=x,d.push(cu(y.mark(h.allowedMarks(y.marks)),c==1?l:0,c==a.childCount?f:-1)))}let p=c==a.childCount;p||(f=-1),this.placed=Mr(this.placed,e,w.from(d)),this.frontier[e].match=u,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,x=a;y<f;y++){let b=x.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),x=b.content}this.unplaced=p?t==0?A.empty:new A(Er(s.content,t-1,1),t-1,f<0?s.openEnd:t-1):new A(Er(s.content,t,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!va(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:o}=this.frontier[e],i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=va(t,e,o,r,i);if(s){for(let a=e-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=va(t,a,c,l,!0);if(!d||d.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=Mr(this.placed,e.depth,e.fit)),t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let o=t.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,t.index(r));this.openFrontierNode(o.type,o.attrs,i)}return t}openFrontierNode(t,e=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=Mr(this.placed,this.depth,w.from(t.create(e,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(w.empty,!0);e.childCount&&(this.placed=Mr(this.placed,this.frontier.length,e))}};function Er(n,t,e){return t==0?n.cutByIndex(e,n.childCount):n.replaceChild(0,n.firstChild.copy(Er(n.firstChild.content,t-1,e)))}function Mr(n,t,e){return t==0?n.append(e):n.replaceChild(n.childCount-1,n.lastChild.copy(Mr(n.lastChild.content,t-1,e)))}function ya(n,t){for(let e=0;e<t;e++)n=n.firstChild.content;return n}function cu(n,t,e){if(t<=0)return n;let r=n.content;return t>1&&(r=r.replaceChild(0,cu(r.firstChild,t-1,r.childCount==1?e-1:0))),t>0&&(r=n.type.contentMatch.fillBefore(r).append(r),e<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(w.empty,!0)))),n.copy(r)}function va(n,t,e,r,o){let i=n.node(t),s=o?n.indexAfter(t):n.index(t);if(s==i.childCount&&!e.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,s);return a&&!Jg(e,i.content,s)?a:null}function Jg(n,t,e){for(let r=e;r<t.childCount;r++)if(!n.allowsMarks(t.child(r).marks))return!0;return!1}function Gg(n){return n.spec.defining||n.spec.definingForContent}function Xg(n,t,e,r){if(!r.size)return n.deleteRange(t,e);let o=n.doc.resolve(t),i=n.doc.resolve(e);if(lu(o,i,r))return n.step(new at(t,e,r));let s=uu(o,n.doc.resolve(e));s[s.length-1]==0&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let h=o.depth,f=o.pos-1;h>0;h--,f--){let p=o.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(h)>-1?a=h:o.before(h)==f&&s.splice(1,0,-h)}let l=s.indexOf(a),c=[],d=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=d-1;h>=0;h--){let f=c[h],p=Gg(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(a)-1)))d=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+d+1)%(r.openStart+1),p=c[f];if(p)for(let y=0;y<s.length;y++){let x=s[(y+l)%s.length],b=!0;x<0&&(b=!1,x=-x);let k=o.node(x-1),m=o.index(x-1);if(k.canReplaceWith(m,m,p.type,p.marks))return n.replace(o.before(x),b?i.after(x):e,new A(du(r.content,0,r.openStart,f),f,r.openEnd))}}let u=n.steps.length;for(let h=s.length-1;h>=0&&(n.replace(t,e,r),!(n.steps.length>u));h--){let f=s[h];f<0||(t=o.before(f),e=i.after(f))}}function du(n,t,e,r,o){if(t<e){let i=n.firstChild;n=n.replaceChild(0,i.copy(du(i.content,t+1,e,r,i)))}if(t>r){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(w.empty,!0))}return n}function Yg(n,t,e,r){if(!r.isInline&&t==e&&n.doc.resolve(t).parent.content.size){let o=qg(n.doc,t,r.type);o!=null&&(t=e=o)}n.replaceRange(t,e,new A(w.from(r),0,0))}function Qg(n,t,e){let r=n.doc.resolve(t),o=n.doc.resolve(e),i=uu(r,o);for(let s=0;s<i.length;s++){let a=i[s],l=s==i.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),o.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),o.indexAfter(a-1))))return n.delete(r.before(a),o.after(a))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(t-r.start(s)==r.depth-s&&e>r.end(s)&&o.end(s)-e!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),e);n.delete(t,e)}function uu(n,t){let e=[],r=Math.min(n.depth,t.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||t.end(o)>t.pos+(t.depth-o)||n.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(i==t.start(o)||o==n.depth&&o==t.depth&&n.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==i-1)&&e.push(o)}return e}var $o=class n extends st{constructor(t,e,r){super(),this.pos=t,this.attr=e,this.value=r}apply(t){let e=t.nodeAt(this.pos);if(!e)return ct.fail("No node at attribute step's position");let r=Object.create(null);for(let i in e.attrs)r[i]=e.attrs[i];r[this.attr]=this.value;let o=e.type.create(r,null,e.marks);return ct.fromReplace(t,this.pos,this.pos+1,new A(w.from(o),0,e.isLeaf?0:1))}getMap(){return xe.empty}invert(t){return new n(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 n(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(e.pos,e.attr,e.value)}};st.jsonID("attr",$o);var Io=class n extends st{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let o in t.attrs)e[o]=t.attrs[o];e[this.attr]=this.value;let r=t.type.create(e,t.content,t.marks);return ct.ok(r)}getMap(){return xe.empty}invert(t){return new n(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(e.attr,e.value)}};st.jsonID("docAttr",Io);var $n=class extends Error{};$n=function n(t){let e=Error.call(this,t);return e.__proto__=n.prototype,e};$n.prototype=Object.create(Error.prototype);$n.prototype.constructor=$n;$n.prototype.name="TransformError";var In=class{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Tr}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new $n(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,r=A.empty){let o=Or(this.doc,t,e,r);return o&&this.step(o),this}replaceWith(t,e,r){return this.replace(t,e,new A(w.from(r),0,0))}delete(t,e){return this.replace(t,e,A.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){return Xg(this,t,e,r),this}replaceRangeWith(t,e,r){return Yg(this,t,e,r),this}deleteRange(t,e){return Qg(this,t,e),this}lift(t,e){return Lg(this,t,e),this}join(t,e=1){return Wg(this,t,e),this}wrap(t,e){return Hg(this,t,e),this}setBlockType(t,e=t,r,o=null){return Fg(this,t,e,r,o),this}setNodeMarkup(t,e,r=null,o){return Ug(this,t,e,r,o),this}setNodeAttribute(t,e,r){return this.step(new $o(t,e,r)),this}setDocAttribute(t,e){return this.step(new Io(t,e)),this}addNodeMark(t,e){return this.step(new Cr(t,e)),this}removeNodeMark(t,e){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(e instanceof z)e.isInSet(r.marks)&&this.step(new Dn(t,e));else{let o=r.marks,i,s=[];for(;i=e.isInSet(o);)s.push(new Dn(t,i)),o=i.removeFromSet(o);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(t,e=1,r){return Kg(this,t,e,r),this}addMark(t,e,r){return Dg(this,t,e,r),this}removeMark(t,e,r){return $g(this,t,e,r),this}clearIncompatible(t,e,r){return wa(this,t,e,r),this}};var Ea=Object.create(null),R=class{constructor(t,e,r){this.$anchor=t,this.$head=e,this.ranges=r||[new zo(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=A.empty){let r=e.content.lastChild,o=null;for(let a=0;a<e.openEnd;a++)o=r,r=r.lastChild;let i=t.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:l,$to:c}=s[a],d=t.mapping.slice(i);t.replaceRange(d.map(l.pos),d.map(c.pos),a?A.empty:e),a==0&&pu(t,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:a}=o[i],l=t.mapping.slice(r),c=l.map(s.pos),d=l.map(a.pos);i?t.deleteRange(c,d):(t.replaceRangeWith(c,d,e),pu(t,r,e.isInline?-1:1))}}static findFrom(t,e,r=!1){let o=t.parent.inlineContent?new _(t):Bn(t.node(0),t.parent,t.pos,t.index(),e,r);if(o)return o;for(let i=t.depth-1;i>=0;i--){let s=e<0?Bn(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):Bn(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,r);if(s)return s}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new yt(t.node(0))}static atStart(t){return Bn(t,t,0,0,1)||new yt(t)}static atEnd(t){return Bn(t,t,t.content.size,t.childCount,-1)||new yt(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ea[e.type];if(!r)throw new RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Ea)throw new RangeError("Duplicate use of selection JSON ID "+t);return Ea[t]=e,e.prototype.jsonID=t,e}getBookmark(){return _.between(this.$anchor,this.$head).getBookmark()}};R.prototype.visible=!0;var zo=class{constructor(t,e){this.$from=t,this.$to=e}},hu=!1;function fu(n){!hu&&!n.parent.inlineContent&&(hu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var _=class n extends R{constructor(t,e=t){fu(t),fu(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let r=t.resolve(e.map(this.head));if(!r.parent.inlineContent)return R.near(r);let o=t.resolve(e.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(t,e=A.empty){if(super.replace(t,e),e==A.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof n&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Ho(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let o=t.resolve(e);return new this(o,r==e?o:t.resolve(r))}static between(t,e,r){let o=t.pos-e.pos;if((!r||o)&&(r=o>=0?1:-1),!e.parent.inlineContent){let i=R.findFrom(e,r,!0)||R.findFrom(e,-r,!0);if(i)e=i.$head;else return R.near(e,r)}return t.parent.inlineContent||(o==0?t=e:(t=(R.findFrom(t,-r,!0)||R.findFrom(t,r,!0)).$anchor,t.pos<e.pos!=o<0&&(t=e))),new n(t,e)}};R.jsonID("text",_);var Ho=class n{constructor(t,e){this.anchor=t,this.head=e}map(t){return new n(t.map(this.anchor),t.map(this.head))}resolve(t){return _.between(t.resolve(this.anchor),t.resolve(this.head))}},N=class n extends R{constructor(t){let e=t.nodeAfter,r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r),this.node=e}map(t,e){let{deleted:r,pos:o}=e.mapResult(this.anchor),i=t.resolve(o);return r?R.near(i):new n(i)}content(){return new A(w.from(this.node),0,0)}eq(t){return t instanceof n&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Aa(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(t.resolve(e.anchor))}static create(t,e){return new n(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}};N.prototype.visible=!1;R.jsonID("node",N);var Aa=class n{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new Ho(r,r):new n(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;return r&&N.isSelectable(r)?new N(e):R.near(e)}},yt=class n extends R{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=A.empty){if(e==A.empty){t.delete(0,t.doc.content.size);let r=R.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new n(t)}map(t){return new n(t)}eq(t){return t instanceof n}getBookmark(){return Zg}};R.jsonID("all",yt);var Zg={map(){return this},resolve(n){return new yt(n)}};function Bn(n,t,e,r,o,i=!1){if(t.inlineContent)return _.create(n,e);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let a=t.child(s);if(a.isAtom){if(!i&&N.isSelectable(a))return N.create(n,e-(o<0?a.nodeSize:0))}else{let l=Bn(n,a,e+o,o<0?a.childCount:0,o,i);if(l)return l}e+=a.nodeSize*o}return null}function pu(n,t,e){let r=n.steps.length-1;if(r<t)return;let o=n.steps[r];if(!(o instanceof at||o instanceof J))return;let i=n.mapping.maps[r],s;i.forEach((a,l,c,d)=>{s==null&&(s=d)}),n.setSelection(R.near(n.doc.resolve(s),e))}var mu=1,Bo=2,gu=4,Ta=class extends In{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=(this.updated|mu)&~Bo,this.storedMarks=null,this}get selectionSet(){return(this.updated&mu)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=Bo,this}ensureMarks(t){return z.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(this.updated&Bo)>0}addStep(t,e){super.addStep(t,e),this.updated=this.updated&~Bo,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let r=this.selection;return e&&(t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||z.none))),r.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,r){let o=this.doc.type.schema;if(e==null)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(r==null&&(r=e),r=r??e,!t)return this.deleteRange(e,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(e);i=r==e?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(e,r,o.text(t,i)),this.selection.empty||this.setSelection(R.near(this.selection.$to)),this}}setMeta(t,e){return this.meta[typeof t=="string"?t:t.key]=e,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=gu,this}get scrolledIntoView(){return(this.updated&gu)>0}};function bu(n,t){return!t||!n?n:n.bind(t)}var cn=class{constructor(t,e,r){this.name=t,this.init=bu(e.init,r),this.apply=bu(e.apply,r)}},tb=[new cn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new cn("selection",{init(n,t){return n.selection||R.atStart(t.doc)},apply(n){return n.selection}}),new cn("storedMarks",{init(n){return n.storedMarks||null},apply(n,t,e,r){return r.selection.$cursor?n.storedMarks:null}}),new cn("scrollToSelection",{init(){return 0},apply(n,t){return n.scrolledIntoView?t+1:t}})],Nr=class{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=tb.slice(),e&&e.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new cn(r.key,r.spec.state,r))})}},Fo=class n{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 r=0;r<this.config.plugins.length;r++)if(r!=e){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let a=this.config.plugins[s];if(a.spec.appendTransaction){let l=o?o[s].n:0,c=o?o[s].state:this,d=l<e.length&&a.spec.appendTransaction.call(a,l?e.slice(l):e,c,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",t),!o){o=[];for(let u=0;u<this.config.plugins.length;u++)o.push(u<s?{state:r,n:e.length}:{state:this,n:0})}e.push(d),r=r.applyInner(d),i=!0}o&&(o[s]={state:r,n:e.length})}}if(!i)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new n(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];e[i.name]=i.apply(t,this[i.name],this,e)}return e}get tr(){return new Ta(this)}static create(t){let e=new Nr(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new n(e);for(let o=0;o<e.fields.length;o++)r[e.fields[o].name]=e.fields[o].init(t,r);return r}reconfigure(t){let e=new Nr(this.schema,t.plugins),r=e.fields,o=new n(e);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(t,o)}return o}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map(r=>r.toJSON())),t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=t[r],i=o.spec.state;i&&i.toJSON&&(e[r]=i.toJSON.call(o,this[o.key]))}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let o=new Nr(t.schema,t.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Mt.fromJSON(t.schema,e.doc);else if(s.name=="selection")i.selection=R.fromJSON(i.doc,e.selection);else if(s.name=="storedMarks")e.storedMarks&&(i.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(e,a)){i[s.name]=c.fromJSON.call(l,t,e[a],i);return}}i[s.name]=s.init(t,i)}}),i}};function yu(n,t,e){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(t):r=="handleDOMEvents"&&(o=yu(o,t,{})),e[r]=o}return e}var O=class{constructor(t){this.spec=t,this.props={},t.props&&yu(t.props,this,this.props),this.key=t.key?t.key.key:vu("plugin")}getState(t){return t[this.key]}},Ma=Object.create(null);function vu(n){return n in Ma?n+"$"+ ++Ma[n]:(Ma[n]=0,n+"$")}var D=class{constructor(t="key"){this.key=vu(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}};var Dt=function(n){for(var t=0;;t++)if(n=n.previousSibling,!n)return t},$r=function(n){let t=n.assignedSlot||n.parentNode;return t&&t.nodeType==11?t.host:t},xu=null,we=function(n,t,e){let r=xu||(xu=document.createRange());return r.setEnd(n,e??n.nodeValue.length),r.setStart(n,t||0),r},mn=function(n,t,e,r){return e&&(ku(n,t,e,r,-1)||ku(n,t,e,r,1))},eb=/^(img|br|input|textarea|hr)$/i;function ku(n,t,e,r,o){for(;;){if(n==e&&t==r)return!0;if(t==(o<0?0:ne(n))){let i=n.parentNode;if(!i||i.nodeType!=1||rb(n)||eb.test(n.nodeName)||n.contentEditable=="false")return!1;t=Dt(n)+(o<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[t+(o<0?-1:0)],n.contentEditable=="false")return!1;t=o<0?ne(n):0}else return!1}}function ne(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function nb(n,t,e){for(let r=t==0,o=t==ne(n);r||o;){if(n==e)return!0;let i=Dt(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==ne(n)}}function rb(n){let t;for(let e=n;e&&!(t=e.pmViewDesc);e=e.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==n||t.contentDOM==n)}var Xo=function(n){return n.focusNode&&mn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Fn(n,t){let e=document.createEvent("Event");return e.initEvent("keydown",!0,!0),e.keyCode=n,e.key=e.code=t,e}function ob(n){let t=n.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}var He=typeof navigator<"u"?navigator:null,Su=typeof document<"u"?document:null,Fe=He&&He.userAgent||"",Da=/Edge\/(\d+)/.exec(Fe),Xu=/MSIE \d/.exec(Fe),$a=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fe),_t=!!(Xu||$a||Da),ze=Xu?document.documentMode:$a?+$a[1]:Da?+Da[1]:0,Gt=!_t&&/gecko\/(\d+)/i.test(Fe);Gt&&+(/Firefox\/(\d+)/.exec(Fe)||[0,0])[1];var Ia=!_t&&/Chrome\/(\d+)/.exec(Fe),Tt=!!Ia,ib=Ia?+Ia[1]:0,vt=!_t&&!!He&&/Apple Computer/.test(He.vendor),Kn=vt&&(/Mobile\/\w+/.test(Fe)||!!He&&He.maxTouchPoints>2),zt=Kn||(He?/Mac/.test(He.platform):!1),re=/Android \d/.test(Fe),Yo=!!Su&&"webkitFontSmoothing"in Su.documentElement.style,sb=Yo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ab(n){return{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ie(n,t){return typeof n=="number"?n:n[t]}function lb(n){let t=n.getBoundingClientRect(),e=t.width/n.offsetWidth||1,r=t.height/n.offsetHeight||1;return{left:t.left,right:t.left+n.clientWidth*e,top:t.top,bottom:t.top+n.clientHeight*r}}function wu(n,t,e){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=e||n.dom;s;s=$r(s)){if(s.nodeType!=1)continue;let a=s,l=a==i.body,c=l?ab(i):lb(a),d=0,u=0;if(t.top<c.top+Ie(r,"top")?u=-(c.top-t.top+Ie(o,"top")):t.bottom>c.bottom-Ie(r,"bottom")&&(u=t.bottom-c.bottom+Ie(o,"bottom")),t.left<c.left+Ie(r,"left")?d=-(c.left-t.left+Ie(o,"left")):t.right>c.right-Ie(r,"right")&&(d=t.right-c.right+Ie(o,"right")),d||u)if(l)i.defaultView.scrollBy(d,u);else{let h=a.scrollLeft,f=a.scrollTop;u&&(a.scrollTop+=u),d&&(a.scrollLeft+=d);let p=a.scrollLeft-h,y=a.scrollTop-f;t={left:t.left-p,top:t.top-y,right:t.right-p,bottom:t.bottom-y}}if(l)break}}function cb(n){let t=n.dom.getBoundingClientRect(),e=Math.max(0,t.top),r,o;for(let i=(t.left+t.right)/2,s=e+1;s<Math.min(innerHeight,t.bottom);s+=5){let a=n.root.elementFromPoint(i,s);if(!a||a==n.dom||!n.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=e-20){r=a,o=l.top;break}}return{refDOM:r,refTop:o,stack:Yu(n.dom)}}function Yu(n){let t=[],e=n.ownerDocument;for(let r=n;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=e);r=$r(r));return t}function db({refDOM:n,refTop:t,stack:e}){let r=n?n.getBoundingClientRect().top:0;Qu(e,r==0?0:r-t)}function Qu(n,t){for(let e=0;e<n.length;e++){let{dom:r,top:o,left:i}=n[e];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}var zn=null;function ub(n){if(n.setActive)return n.setActive();if(zn)return n.focus(zn);let t=Yu(n);n.focus(zn==null?{get preventScroll(){return zn={preventScroll:!0},!0}}:void 0),zn||(zn=!1,Qu(t,0))}function Zu(n,t){let e,r=2e8,o,i=0,s=t.top,a=t.top;for(let l=n.firstChild,c=0;l;l=l.nextSibling,c++){let d;if(l.nodeType==1)d=l.getClientRects();else if(l.nodeType==3)d=we(l).getClientRects();else continue;for(let u=0;u<d.length;u++){let h=d[u];if(h.top<=s&&h.bottom>=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);let f=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(f<r){e=l,r=f,o=f&&e.nodeType==3?{left:h.right<t.left?h.right:h.left,top:t.top}:t,l.nodeType==1&&f&&(i=c+(t.left>=(h.left+h.right)/2?1:0));continue}}!e&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(i=c+1)}}return e&&e.nodeType==3?hb(e,o):!e||r&&e.nodeType==1?{node:n,offset:i}:Zu(e,o)}function hb(n,t){let e=n.nodeValue.length,r=document.createRange();for(let o=0;o<e;o++){r.setEnd(n,o+1),r.setStart(n,o);let i=Le(r,1);if(i.top!=i.bottom&&el(t,i))return{node:n,offset:o+(t.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function el(n,t){return n.left>=t.left-1&&n.left<=t.right+1&&n.top>=t.top-1&&n.top<=t.bottom+1}function fb(n,t){let e=n.parentNode;return e&&/^li$/i.test(e.nodeName)&&t.left<n.getBoundingClientRect().left?e:n}function pb(n,t,e){let{node:r,offset:o}=Zu(t,e),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&e.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function mb(n,t,e,r){let o=-1;for(let i=t;i!=n.dom;){let s=n.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){let a=s.dom.getBoundingClientRect();if(a.left>r.left||a.top>r.top)o=s.posBefore;else if(a.right<r.left||a.bottom<r.top)o=s.posAfter;else break}i=s.dom.parentNode}return o>-1?o:n.docView.posFromDOM(t,e,1)}function th(n,t,e){let r=n.childNodes.length;if(r&&e.top<e.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-e.top)/(e.bottom-e.top))-2)),i=o;;){let s=n.childNodes[i];if(s.nodeType==1){let a=s.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(el(t,c))return th(s,t,c)}}if((i=(i+1)%r)==o)break}return n}function gb(n,t){let e=n.dom.ownerDocument,r,o=0;if(e.caretPositionFromPoint)try{let l=e.caretPositionFromPoint(t.left,t.top);l&&({offsetNode:r,offset:o}=l)}catch{}if(!r&&e.caretRangeFromPoint){let l=e.caretRangeFromPoint(t.left,t.top);l&&({startContainer:r,startOffset:o}=l)}let i=(n.root.elementFromPoint?n.root:e).elementFromPoint(t.left,t.top),s;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let l=n.dom.getBoundingClientRect();if(!el(t,l)||(i=th(n.dom,t,l),!i))return null}if(vt)for(let l=i;r&&l;l=$r(l))l.draggable&&(r=void 0);if(i=fb(i,t),r){if(Gt&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let l=r.childNodes[o],c;l.nodeName=="IMG"&&(c=l.getBoundingClientRect()).right<=t.left&&c.bottom>t.top&&o++}r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(s=mb(n,r,o,t))}s==null&&(s=pb(n,i,t));let a=n.docView.nearestDesc(i,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Le(n,t){let e=n.getClientRects();return e.length?e[t<0?0:e.length-1]:n.getBoundingClientRect()}var bb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function eh(n,t,e){let{node:r,offset:o,atom:i}=n.docView.domFromPos(t,e<0?-1:1),s=Yo||Gt;if(r.nodeType==3)if(s&&(bb.test(r.nodeValue)||(e<0?!o:o==r.nodeValue.length))){let l=Le(we(r,o,o),e);if(Gt&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Le(we(r,o-1,o-1),-1);if(c.top==l.top){let d=Le(we(r,o,o+1),-1);if(d.top!=l.top)return Pr(d,d.left<c.left)}}return l}else{let l=o,c=o,d=e<0?1:-1;return e<0&&!o?(c++,d=-1):e>=0&&o==r.nodeValue.length?(l--,d=1):e<0?l--:c++,Pr(Le(we(r,l,c),1),d<0)}if(!n.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(e<0||o==ne(r))){let l=r.childNodes[o-1];if(l.nodeType==1)return _a(l.getBoundingClientRect(),!1)}if(i==null&&o<ne(r)){let l=r.childNodes[o];if(l.nodeType==1)return _a(l.getBoundingClientRect(),!0)}return _a(r.getBoundingClientRect(),e>=0)}if(i==null&&o&&(e<0||o==ne(r))){let l=r.childNodes[o-1],c=l.nodeType==3?we(l,ne(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Pr(Le(c,1),!1)}if(i==null&&o<ne(r)){let l=r.childNodes[o];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?we(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return Pr(Le(c,-1),!0)}return Pr(Le(r.nodeType==3?we(r):r,-e),e>=0)}function Pr(n,t){if(n.width==0)return n;let e=t?n.left:n.right;return{top:n.top,bottom:n.bottom,left:e,right:e}}function _a(n,t){if(n.height==0)return n;let e=t?n.top:n.bottom;return{top:e,bottom:e,left:n.left,right:n.right}}function nh(n,t,e){let r=n.state,o=n.root.activeElement;r!=t&&n.updateState(t),o!=n.dom&&n.focus();try{return e()}finally{r!=t&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function yb(n,t,e){let r=t.selection,o=e=="up"?r.$from:r.$to;return nh(n,t,()=>{let{node:i}=n.docView.domFromPos(o.pos,e=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.dom;break}i=a.dom.parentNode}let s=eh(n,o.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=we(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(e=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}var vb=/[\u0590-\u08ac]/;function xb(n,t,e){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=n.domSelection();return!vb.test(r.parent.textContent)||!a.modify?e=="left"||e=="backward"?i:s:nh(n,t,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",e,"character");let f=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:y}=n.domSelectionRange(),x=p&&!f.contains(p.nodeType==1?p:p.parentNode)||l==p&&c==y;try{a.collapse(d,u),l&&(l!=d||c!=u)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),x})}var Eu=null,Mu=null,Au=!1;function kb(n,t,e){return Eu==t&&Mu==e?Au:(Eu=t,Mu=e,Au=e=="up"||e=="down"?yb(n,t,e):xb(n,t,e))}var Jt=0,Tu=1,Vn=2,oe=3,gn=class{constructor(t,e,r,o){this.parent=t,this.children=e,this.dom=r,this.contentDOM=o,this.dirty=Jt,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,r){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,r=this.posAtStart;;e++){let o=this.children[e];if(o==t)return r;r+=o.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,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode))if(r<0){let i,s;if(t==this.contentDOM)i=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(t==this.dom&&this.contentDOM)o=e>Dt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(e==0)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&e==t.childNodes.length)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let r=!0,o=t;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!e||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))r=!1;else return i}}getDesc(t){let e=t.pmViewDesc;for(let r=e;r;r=r.parent)if(r==this)return e}posFromDOM(t,e,r){for(let o=t;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;e<this.children.length;e++){let o=this.children[e],i=r+o.size;if(r==t&&i!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(t<i)return o.descAt(t-r-o.border);r=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],a=i+s.size;if(a>t||s instanceof Ko){o=t-i;break}i=a}if(o)return this.children[r].domFromPos(o-this.children[r].border,e);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Vo&&i.side>=0;r--);if(e<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&e&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,e):{node:this.contentDOM,offset:i?Dt(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,e):{node:this.contentDOM,offset:i?Dt(i.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,a=0;;a++){let l=this.children[a],c=s+l.size;if(o==-1&&t<=c){let d=s+l.border;if(t>=d&&e<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(t,e,d);t=s;for(let u=a;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=Dt(h.dom)+1;break}t-=h.size}o==-1&&(o=0)}if(o>-1&&(c>e||a==this.children.length-1)){e=c;for(let d=a+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=Dt(u.dom);break}e+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:t,to:e,fromOffset:o,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 e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(e.nodeType!=1||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,o=!1){let i=Math.min(t,e),s=Math.max(t,e);for(let h=0,f=0;h<this.children.length;h++){let p=this.children[h],y=f+p.size;if(i>f&&s<y)return p.setSelection(t-f-p.border,e-f-p.border,r,o);f=y}let a=this.domFromPos(t,t?-1:1),l=e==t?a:this.domFromPos(e,e?-1:1),c=r.getSelection(),d=!1;if((Gt||vt)&&t==e){let{node:h,offset:f}=a;if(h.nodeType==3){if(d=!!(f&&h.nodeValue[f-1]==`
`),d&&f==h.nodeValue.length)for(let p=h,y;p;p=p.parentNode){if(y=p.nextSibling){y.nodeName=="BR"&&(a=l={node:y.parentNode,offset:Dt(y)+1});break}let x=p.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let p=h.childNodes[f-1];d=p&&(p.nodeName=="BR"||p.contentEditable=="false")}}if(Gt&&c.focusNode&&c.focusNode!=l.node&&c.focusNode.nodeType==1){let h=c.focusNode.childNodes[c.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||d&&vt)&&mn(a.node,a.offset,c.anchorNode,c.anchorOffset)&&mn(l.node,l.offset,c.focusNode,c.focusOffset))return;let u=!1;if((c.extend||t==e)&&!d){c.collapse(a.node,a.offset);try{t!=e&&c.extend(l.node,l.offset),u=!0}catch{}}if(!u){if(t>e){let f=a;a=l,l=f}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?t<=s&&e>=r:t<s&&e>r){let a=r+i.border,l=s-i.border;if(t>=a&&e<=l){this.dirty=t==r||e==s?Vn:Tu,t==a&&e==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=oe:i.markDirty(t-a,e-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Vn:oe}r=s}this.dirty=Vn}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=t==1?Vn:Tu;e.dirty<r&&(e.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}},Vo=class extends gn{constructor(t,e,r,o){let i,s=e.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!e.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,i=this}matchesWidget(t){return this.dirty==Jt&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},La=class extends gn{constructor(t,e,r,o){super(t,[],e,null),this.textDOM=r,this.text=o}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 t.type==="characterData"&&t.target.nodeValue==t.oldValue}},jn=class n extends gn{constructor(t,e,r,o){super(t,[],r,o),this.mark=e}static create(t,e,r,o){let i=o.nodeViews[e.type.name],s=i&&i(e,o,r);return(!s||!s.dom)&&(s=At.renderSpec(document,e.type.spec.toDOM(e,r))),new n(t,e,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&oe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(t){return this.dirty!=oe&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),this.dirty!=Jt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Jt}}slice(t,e,r){let o=n.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;e<s&&(i=Va(i,e,s,r)),t>0&&(i=Va(i,0,t,r));for(let a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o}},bn=class n extends gn{constructor(t,e,r,o,i,s,a,l,c){super(t,[],i,s),this.node=e,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=a,s&&this.updateChildren(l,c)}static create(t,e,r,o,i,s){let a=i.nodeViews[e.type.name],l,c=a&&a(e,i,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(e.isText){if(!d)d=document.createTextNode(e.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=At.renderSpec(document,e.type.spec.toDOM(e)));!u&&!e.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),e.type.spec.draggable&&(d.draggable=!0));let h=d;return d=ih(d,r,e),c?l=new Ba(t,e,r,o,d,u||null,h,c,i,s+1):e.isText?new Uo(t,e,r,o,d,h,i):new n(t,e,r,o,d,u||null,h,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}t.contentElement||(t.getContent=()=>w.empty)}return t}matchesNode(t,e,r){return this.dirty==Jt&&t.eq(this.node)&&Ha(e,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let r=this.node.inlineContent,o=e,i=t.composing?this.localCompositionInfo(t,e):null,s=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new Fa(this,s&&s.node,t);Mb(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,t):c.type.side>=0&&!u&&l.syncToMarks(d==this.node.childCount?z.none:this.node.child(d).marks,r,t),l.placeWidget(c,t,o)},(c,d,u,h)=>{l.syncToMarks(c.marks,r,t);let f;l.findNodeMatch(c,d,u,h)||a&&t.state.selection.from>o&&t.state.selection.to<o+c.nodeSize&&(f=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(c,d,u,f,t)||l.updateNextNode(c,d,u,t,h)||l.addNode(c,d,u,t,o),o+=c.nodeSize}),l.syncToMarks([],r,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Vn)&&(s&&this.protectLocalComposition(t,s),rh(this.contentDOM,this.children,t),Kn&&Ab(this.dom))}localCompositionInfo(t,e){let{from:r,to:o}=t.state.selection;if(!(t.state.selection instanceof _)||r<e||o>e+this.node.content.size)return null;let i=t.domSelectionRange(),s=Tb(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,l=_b(this.node.content,a,r-e,o-e);return l<0?null:{node:s,pos:l,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:r,text:o}){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 La(this,i,e,o);t.input.compositionNodes.push(s),this.children=Va(this.children,r,r+o.length,t,s)}update(t,e,r,o){return this.dirty==oe||!t.sameMarkup(this.node)?!1:(this.updateInner(t,e,r,o),!0)}updateInner(t,e,r,o){this.updateOuterDeco(e),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Jt}updateOuterDeco(t){if(Ha(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=oh(this.dom,this.nodeDOM,za(this.outerDeco,this.node,e),za(t,this.node,e)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}};function _u(n,t,e,r,o){return ih(r,t,n),new bn(void 0,n,t,e,r,r,r,o,0)}var Uo=class n extends bn{constructor(t,e,r,o,i,s,a){super(t,e,r,o,i,null,s,a,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,r,o){return this.dirty==oe||this.dirty!=Jt&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(e),(this.dirty!=Jt||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=Jt,!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,r){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,r){let o=this.node.cut(t,e),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(t,e){super.markDirty(t,e),this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length)&&(this.dirty=oe)}get domAtom(){return!1}},Ko=class extends gn{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==Jt&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Ba=class extends bn{constructor(t,e,r,o,i,s,a,l,c,d){super(t,e,r,o,i,s,a,c,d),this.spec=l}update(t,e,r,o){if(this.dirty==oe)return!1;if(this.spec.update){let i=this.spec.update(t,e,r);return i&&this.updateInner(t,e,r,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,e,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,o){this.spec.setSelection?this.spec.setSelection(t,e,r):super.setSelection(t,e,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}};function rh(n,t,e){let r=n.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],a=s.dom;if(a.parentNode==n){for(;a!=r;)r=Cu(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(a,r);if(s instanceof jn){let l=r?r.previousSibling:n.lastChild;rh(s.contentDOM,s.children,e),r=l?l.nextSibling:n.firstChild}}for(;r;)r=Cu(r),o=!0;o&&e.trackWrites==n&&(e.trackWrites=null)}var Rr=function(n){n&&(this.nodeName=n)};Rr.prototype=Object.create(null);var un=[new Rr];function za(n,t,e){if(n.length==0)return un;let r=e?un[0]:new Rr,o=[r];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&o.push(r=new Rr(s.nodeName));for(let a in s){let l=s[a];l!=null&&(e&&o.length==1&&o.push(r=new Rr(t.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return o}function oh(n,t,e,r){if(e==un&&r==un)return t;let o=t;for(let i=0;i<r.length;i++){let s=r[i],a=e[i];if(i){let l;a&&a.nodeName==s.nodeName&&o!=n&&(l=o.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(o),a=un[0]),o=l}Sb(o,a||un[0],s)}return o}function Sb(n,t,e){for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&!(r in e)&&n.removeAttribute(r);for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&e[r]!=t[r]&&n.setAttribute(r,e[r]);if(t.class!=e.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=e.class?e.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(t.style!=e.style){if(t.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(t.style);)n.style.removeProperty(o[1])}e.style&&(n.style.cssText+=e.style)}}function ih(n,t,e){return oh(n,n,un,za(t,e,n.nodeType!=1))}function Ha(n,t){if(n.length!=t.length)return!1;for(let e=0;e<n.length;e++)if(!n[e].type.eq(t[e].type))return!1;return!0}function Cu(n){let t=n.nextSibling;return n.parentNode.removeChild(n),t}var Fa=class{constructor(t,e,r){this.lock=e,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=wb(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let o=0,i=this.stack.length>>1,s=Math.min(i,t.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(t[o])&&t[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=Jt,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<t.length;){this.stack.push(this.top,this.index+1);let a=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++)if(this.top.children[l].matchesMark(t[i])){a=l;break}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=jn.create(this.top,t[i],e,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,i++}}findNodeMatch(t,e,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,r))i=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(t,e,r)&&!this.preMatch.matched.has(c)){i=a;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(t,e,r,o,i){let s=this.top.children[o];return s.dirty==oe&&s.dom==s.contentDOM&&(s.dirty=Vn),s.update(t,e,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let r=t.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}t=e}}updateNextNode(t,e,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof bn){let l=this.preMatch.matched.get(a);if(l!=null&&l!=i)return!1;let c=a.dom;if(!(this.lock&&(c==this.lock||c.nodeType==1&&c.contains(this.lock.parentNode))&&!(t.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==t.text&&a.dirty!=oe&&Ha(e,a.outerDeco)))&&a.update(t,e,r,o))return this.destroyBetween(this.index,s),a.dom!=c&&(this.changed=!0),this.index++,!0;break}}return!1}addNode(t,e,r,o,i){this.top.children.splice(this.index++,0,bn.create(this.top,t,e,r,o,i)),this.changed=!0}placeWidget(t,e,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(t)&&(t==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Vo(this.top,t,e,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof jn;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Uo)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((vt||Tt)&&t&&t.dom.contentEditable=="false"&&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 r=document.createElement(t);t=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),t=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Ko(this.top,[],r,null);e!=this.top?e.children.push(o):e.children.splice(this.index++,0,o),this.changed=!0}}};function wb(n,t){let e=t,r=e.children.length,o=n.childCount,i=new Map,s=[];t:for(;o>0;){let a;for(;;)if(r){let c=e.children[r-1];if(c instanceof jn)e=c,r=c.children.length;else{a=c,r--;break}}else{if(e==t)break t;r=e.parent.children.indexOf(e),e=e.parent}let l=a.node;if(l){if(l!=n.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}function Eb(n,t){return n.type.side-t.type.side}function Mb(n,t,e,r){let o=t.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,o,t.forChild(i,d),c),i+=d.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){if(s<o.length&&o[s].to==i){let p=o[s++],y;for(;s<o.length&&o[s].to==i;)(y||(y=[p])).push(o[s++]);if(y){y.sort(Eb);for(let x=0;x<y.length;x++)e(y[x],c,!!l)}else e(p,c,!!l)}let d,u;if(l)u=-1,d=l,l=null;else if(c<n.childCount)u=c,d=n.child(c++);else break;for(let p=0;p<a.length;p++)a[p].to<=i&&a.splice(p--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);let h=i+d.nodeSize;if(d.isText){let p=h;s<o.length&&o[s].from<p&&(p=o[s].from);for(let y=0;y<a.length;y++)a[y].to<p&&(p=a[y].to);p<h&&(l=d.cut(p-i),d=d.cut(0,p-i),h=p,u=-1)}let f=d.isInline&&!d.isLeaf?a.filter(p=>!p.inline):a.slice();r(d,f,t.forChild(i,d),u),i=h}}function Ab(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let t=n.style.cssText;n.style.cssText=t+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=t}}function Tb(n,t){for(;;){if(n.nodeType==3)return n;if(n.nodeType==1&&t>0){if(n.childNodes.length>t&&n.childNodes[t].nodeType==3)return n.childNodes[t];n=n.childNodes[t-1],t=ne(n)}else if(n.nodeType==1&&t<n.childNodes.length)n=n.childNodes[t],t=0;else return null}}function _b(n,t,e,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let s=n.child(o++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;l+=c.text}if(i>=e){let c=a<r?l.lastIndexOf(t,r-a-1):-1;if(c>=0&&c+t.length+a>=e)return a+c;if(e==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}function Va(n,t,e,r,o){let i=[];for(let s=0,a=0;s<n.length;s++){let l=n[s],c=a,d=a+=l.size;c>=e||d<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,r)),o&&(i.push(o),o=void 0),d>e&&i.push(l.slice(e-c,l.size,r)))}return i}function nl(n,t=null){let e=n.domSelectionRange(),r=n.state.doc;if(!e.focusNode)return null;let o=n.docView.nearestDesc(e.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(Xo(e)){for(l=a;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&N.isSelectable(d)&&o.parent&&!(d.isInline&&nb(e.focusNode,e.focusOffset,o.dom))){let u=o.posBefore;c=new N(s==u?a:r.resolve(u))}}else{let d=n.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(d<0)return null;l=r.resolve(d)}if(!c){let d=t=="pointer"||n.state.selection.head<a.pos&&!i?1:-1;c=rl(n,l,a,d)}return c}function sh(n){return n.editable?n.hasFocus():lh(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ee(n,t=!1){let e=n.state.selection;if(ah(n,e),!!sh(n)){if(!t&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Tt){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&mn(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Ob(n);else{let{anchor:r,head:o}=e,i,s;Ou&&!(e instanceof _)&&(e.$from.parent.inlineContent||(i=Nu(n,e.from)),!e.empty&&!e.$from.parent.inlineContent&&(s=Nu(n,e.to))),n.docView.setSelection(r,o,n.root,t),Ou&&(i&&Pu(i),s&&Pu(s)),e.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Cb(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}var Ou=vt||Tt&&ib<63;function Nu(n,t){let{node:e,offset:r}=n.docView.domFromPos(t,0),o=r<e.childNodes.length?e.childNodes[r]:null,i=r?e.childNodes[r-1]:null;if(vt&&o&&o.contentEditable=="false")return Ca(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Ca(o);if(i)return Ca(i)}}function Ca(n){return n.contentEditable="true",vt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Pu(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Cb(n){let t=n.dom.ownerDocument;t.removeEventListener("selectionchange",n.input.hideSelectionGuard);let e=n.domSelectionRange(),r=e.anchorNode,o=e.anchorOffset;t.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(e.anchorNode!=r||e.anchorOffset!=o)&&(t.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!sh(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ob(n){let t=n.domSelection(),e=document.createRange(),r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?e.setEnd(r.parentNode,Dt(r)+1):e.setEnd(r,0),e.collapse(!1),t.removeAllRanges(),t.addRange(e),!o&&!n.state.selection.visible&&_t&&ze<=11&&(r.disabled=!0,r.disabled=!1)}function ah(n,t){if(t instanceof N){let e=n.docView.descAt(t.from);e!=n.lastSelectedViewDesc&&(Ru(n),e&&e.selectNode(),n.lastSelectedViewDesc=e)}else Ru(n)}function Ru(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function rl(n,t,e,r){return n.someProp("createSelectionBetween",o=>o(n,t,e))||_.between(t,e,r)}function Du(n){return n.editable&&!n.hasFocus()?!1:lh(n)}function lh(n){let t=n.domSelectionRange();if(!t.anchorNode)return!1;try{return n.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(n.editable||n.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Nb(n){let t=n.docView.domFromPos(n.state.selection.anchor,0),e=n.domSelectionRange();return mn(t.node,t.offset,e.anchorNode,e.anchorOffset)}function Ua(n,t){let{$anchor:e,$head:r}=n.selection,o=t>0?e.max(r):e.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(t>0?o.after():o.before()):null:o;return i&&R.findFrom(i,t)}function dn(n,t){return n.dispatch(n.state.tr.setSelection(t).scrollIntoView()),!0}function $u(n,t,e){let r=n.state.selection;if(r instanceof _){if(!r.empty||e.indexOf("s")>-1)return!1;if(n.endOfTextblock(t>0?"right":"left")){let o=Ua(n.state,t);return o&&o instanceof N?dn(n,o):!1}else if(!(zt&&e.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let a=t<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(a))&&!s.contentDOM?N.isSelectable(i)?dn(n,new N(t<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):Yo?dn(n,new _(n.state.doc.resolve(t<0?a:a+i.nodeSize))):!1:!1}}else{if(r instanceof N&&r.node.isInline)return dn(n,new _(t>0?r.$to:r.$from));{let o=Ua(n.state,t);return o?dn(n,o):!1}}}function jo(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Dr(n){let t=n.pmViewDesc;return t&&t.size==0&&(n.nextSibling||n.nodeName!="BR")}function Oa(n){let t=n.domSelectionRange(),e=t.focusNode,r=t.focusOffset;if(!e)return;let o,i,s=!1;for(Gt&&e.nodeType==1&&r<jo(e)&&Dr(e.childNodes[r])&&(s=!0);;)if(r>0){if(e.nodeType!=1)break;{let a=e.childNodes[r-1];if(Dr(a))o=e,i=--r;else if(a.nodeType==3)e=a,r=e.nodeValue.length;else break}}else{if(ch(e))break;{let a=e.previousSibling;for(;a&&Dr(a);)o=e.parentNode,i=Dt(a),a=a.previousSibling;if(a)e=a,r=jo(e);else{if(e=e.parentNode,e==n.dom)break;r=0}}}s?Ka(n,e,r):o&&Ka(n,o,i)}function Na(n){let t=n.domSelectionRange(),e=t.focusNode,r=t.focusOffset;if(!e)return;let o=jo(e),i,s;for(;;)if(r<o){if(e.nodeType!=1)break;let a=e.childNodes[r];if(Dr(a))i=e,s=++r;else break}else{if(ch(e))break;{let a=e.nextSibling;for(;a&&Dr(a);)i=a.parentNode,s=Dt(a)+1,a=a.nextSibling;if(a)e=a,r=0,o=jo(e);else{if(e=e.parentNode,e==n.dom)break;r=o=0}}}i&&Ka(n,i,s)}function ch(n){let t=n.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ka(n,t,e){let r=n.domSelection();if(Xo(r)){let i=document.createRange();i.setEnd(t,e),i.setStart(t,e),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,e);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&Ee(n)},50)}function Iu(n,t,e){let r=n.state.selection;if(r instanceof _&&!r.empty||e.indexOf("s")>-1||zt&&e.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(t<0?"up":"down")){let s=Ua(n.state,t);if(s&&s instanceof N)return dn(n,s)}if(!o.parent.inlineContent){let s=t<0?o:i,a=r instanceof yt?R.near(s,t):R.findFrom(s,t);return a?dn(n,a):!1}return!1}function Lu(n,t){if(!(n.state.selection instanceof _))return!0;let{$head:e,$anchor:r,empty:o}=n.state.selection;if(!e.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!e.textOffset&&(t<0?e.nodeBefore:e.nodeAfter);if(i&&!i.isText){let s=n.state.tr;return t<0?s.delete(e.pos-i.nodeSize,e.pos):s.delete(e.pos,e.pos+i.nodeSize),n.dispatch(s),!0}return!1}function Bu(n,t,e){n.domObserver.stop(),t.contentEditable=e,n.domObserver.start()}function Pb(n){if(!vt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:e}=n.domSelectionRange();if(t&&t.nodeType==1&&e==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;Bu(n,r,"true"),setTimeout(()=>Bu(n,r,"false"),20)}return!1}function Rb(n){let t="";return n.ctrlKey&&(t+="c"),n.metaKey&&(t+="m"),n.altKey&&(t+="a"),n.shiftKey&&(t+="s"),t}function Db(n,t){let e=t.keyCode,r=Rb(t);return e==8||zt&&e==72&&r=="c"?Lu(n,-1)||Oa(n):e==46||zt&&e==68&&r=="c"?Lu(n,1)||Na(n):e==13||e==27?!0:e==37||zt&&e==66&&r=="c"?$u(n,-1,r)||Oa(n):e==39||zt&&e==70&&r=="c"?$u(n,1,r)||Na(n):e==38||zt&&e==80&&r=="c"?Iu(n,-1,r)||Oa(n):e==40||zt&&e==78&&r=="c"?Pb(n)||Iu(n,1,r)||Na(n):r==(zt?"m":"c")&&(e==66||e==73||e==89||e==90)}function dh(n,t){n.someProp("transformCopied",f=>{t=f(t)});let e=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let f=r.firstChild;e.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=n.someProp("clipboardSerializer")||At.fromSchema(n.state.schema),a=gh(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=mh[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let p=a.createElement(d[f]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),u++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(e)}`);let h=n.someProp("clipboardTextSerializer",f=>f(t))||t.content.textBetween(0,t.content.size,`
`);return{dom:l,text:h}}function uh(n,t,e,r,o){let i=o.parent.type.spec.code,s,a;if(!e&&!t)return null;let l=t&&(r||i||!e);if(l){if(n.someProp("transformPastedText",h=>{t=h(t,i||r)}),i)return t?new A(w.from(n.state.schema.text(t.replace(/\r\n?/g,`
`))),0,0):A.empty;let u=n.someProp("clipboardTextParser",h=>h(t,o,r));if(u)a=u;else{let h=o.marks(),{schema:f}=n.state,p=At.fromSchema(f);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(y=>{let x=s.appendChild(document.createElement("p"));y&&x.appendChild(p.serializeNode(f.text(y,h)))})}}else n.someProp("transformPastedHTML",u=>{e=u(e)}),s=Lb(e),Yo&&Bb(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0&&s.firstChild;u--)s=s.firstChild;if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||ee.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||d),context:o,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!$b.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)a=zb(zu(a,+d[1],+d[2]),d[4]);else if(a=A.maxOpen(Ib(a.content,o),!0),a.openStart||a.openEnd){let u=0,h=0;for(let f=a.content.firstChild;u<a.openStart&&!f.type.spec.isolating;u++,f=f.firstChild);for(let f=a.content.lastChild;h<a.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);a=zu(a,u,h)}return n.someProp("transformPasted",u=>{a=u(a)}),a}var $b=/^(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 Ib(n,t){if(n.childCount<2)return n;for(let e=t.depth;e>=0;e--){let o=t.node(e).contentMatchAt(t.index(e)),i,s=[];if(n.forEach(a=>{if(!s)return;let l=o.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&i.length&&fh(l,i,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=ph(s[s.length-1],i.length));let d=hh(a,l);s.push(d),o=o.matchType(d.type),i=l}}),s)return w.from(s)}return n}function hh(n,t,e=0){for(let r=t.length-1;r>=e;r--)n=t[r].create(null,w.from(n));return n}function fh(n,t,e,r,o){if(o<n.length&&o<t.length&&n[o]==t[o]){let i=fh(n,t,e,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?e.type:n[o+1]))return r.copy(r.content.append(w.from(hh(e,n,o+1))))}}function ph(n,t){if(t==0)return n;let e=n.content.replaceChild(n.childCount-1,ph(n.lastChild,t-1)),r=n.contentMatchAt(n.childCount).fillBefore(w.empty,!0);return n.copy(e.append(r))}function ja(n,t,e,r,o,i){let s=t<0?n.firstChild:n.lastChild,a=s.content;return o<r-1&&(a=ja(a,t,e,r,o+1,i)),o>=e&&(a=t<0?s.contentMatchAt(0).fillBefore(a,n.childCount>1||i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(w.empty,!0))),n.replaceChild(t<0?0:n.childCount-1,s.copy(a))}function zu(n,t,e){return t<n.openStart&&(n=new A(ja(n.content,-1,t,n.openStart,0,n.openEnd),t,n.openEnd)),e<n.openEnd&&(n=new A(ja(n.content,1,e,n.openEnd,0,0),n.openStart,e)),n}var mh={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Hu=null;function gh(){return Hu||(Hu=document.implementation.createHTMLDocument("title"))}function Lb(n){let t=/^(\s*<meta [^>]*>)*/.exec(n);t&&(n=n.slice(t[0].length));let e=gh().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&mh[r[1].toLowerCase()])&&(n=o.map(i=>"<"+i+">").join("")+n+o.map(i=>"</"+i+">").reverse().join("")),e.innerHTML=n,o)for(let i=0;i<o.length;i++)e=e.querySelector(o[i])||e;return e}function Bb(n){let t=n.querySelectorAll(Tt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let e=0;e<t.length;e++){let r=t[e];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function zb(n,t){if(!n.size)return n;let e=n.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return n}let{content:o,openStart:i,openEnd:s}=n;for(let a=r.length-2;a>=0;a-=2){let l=e.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;o=w.from(l.create(r[a+1],o)),i++,s++}return new A(o,i,s)}var xt={},kt={},Hb={touchstart:!0,touchmove:!0},Wa=class{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 Fb(n){for(let t in xt){let e=xt[t];n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>{Ub(n,r)&&!ol(n,r)&&(n.editable||!(r.type in kt))&&e(n,r)},Hb[t]?{passive:!0}:void 0)}vt&&n.dom.addEventListener("input",()=>null),qa(n)}function Be(n,t){n.input.lastSelectionOrigin=t,n.input.lastSelectionTime=Date.now()}function Vb(n){n.domObserver.stop();for(let t in n.input.eventHandlers)n.dom.removeEventListener(t,n.input.eventHandlers[t]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function qa(n){n.someProp("handleDOMEvents",t=>{for(let e in t)n.input.eventHandlers[e]||n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>ol(n,r))})}function ol(n,t){return n.someProp("handleDOMEvents",e=>{let r=e[t.type];return r?r(n,t)||t.defaultPrevented:!1})}function Ub(n,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target;e!=n.dom;e=e.parentNode)if(!e||e.nodeType==11||e.pmViewDesc&&e.pmViewDesc.stopEvent(t))return!1;return!0}function Kb(n,t){!ol(n,t)&&xt[t.type]&&(n.editable||!(t.type in kt))&&xt[t.type](n,t)}kt.keydown=(n,t)=>{let e=t;if(n.input.shiftKey=e.keyCode==16||e.shiftKey,!yh(n,e)&&(n.input.lastKeyCode=e.keyCode,n.input.lastKeyCodeTime=Date.now(),!(re&&Tt&&e.keyCode==13)))if(e.keyCode!=229&&n.domObserver.forceFlush(),Kn&&e.keyCode==13&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Fn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,e))||Db(n,e)?e.preventDefault():Be(n,"key")};kt.keyup=(n,t)=>{t.keyCode==16&&(n.input.shiftKey=!1)};kt.keypress=(n,t)=>{let e=t;if(yh(n,e)||!e.charCode||e.ctrlKey&&!e.altKey||zt&&e.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,e))){e.preventDefault();return}let r=n.state.selection;if(!(r instanceof _)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(e.charCode);n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,o))||n.dispatch(n.state.tr.insertText(o).scrollIntoView()),e.preventDefault()}};function Qo(n){return{left:n.clientX,top:n.clientY}}function jb(n,t){let e=t.x-n.clientX,r=t.y-n.clientY;return e*e+r*r<100}function il(n,t,e,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(t,a=>s>i.depth?a(n,e,i.nodeAfter,i.before(s),o,!0):a(n,e,i.node(s),i.before(s),o,!1)))return!0;return!1}function Un(n,t,e){n.focused||n.focus();let r=n.state.tr.setSelection(t);e=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function Wb(n,t){if(t==-1)return!1;let e=n.state.doc.resolve(t),r=e.nodeAfter;return r&&r.isAtom&&N.isSelectable(r)?(Un(n,new N(e),"pointer"),!0):!1}function qb(n,t){if(t==-1)return!1;let e=n.state.selection,r,o;e instanceof N&&(r=e.node);let i=n.state.doc.resolve(t);for(let s=i.depth+1;s>0;s--){let a=s>i.depth?i.nodeAfter:i.node(s);if(N.isSelectable(a)){r&&e.$from.depth>0&&s>=e.$from.depth&&i.before(e.$from.depth+1)==e.$from.pos?o=i.before(e.$from.depth):o=i.before(s);break}}return o!=null?(Un(n,N.create(n.state.doc,o),"pointer"),!0):!1}function Jb(n,t,e,r,o){return il(n,"handleClickOn",t,e,r)||n.someProp("handleClick",i=>i(n,t,r))||(o?qb(n,e):Wb(n,e))}function Gb(n,t,e,r){return il(n,"handleDoubleClickOn",t,e,r)||n.someProp("handleDoubleClick",o=>o(n,t,r))}function Xb(n,t,e,r){return il(n,"handleTripleClickOn",t,e,r)||n.someProp("handleTripleClick",o=>o(n,t,r))||Yb(n,e,r)}function Yb(n,t,e){if(e.button!=0)return!1;let r=n.state.doc;if(t==-1)return r.inlineContent?(Un(n,_.create(r,0,r.content.size),"pointer"),!0):!1;let o=r.resolve(t);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),a=o.before(i);if(s.inlineContent)Un(n,_.create(r,a+1,a+1+s.content.size),"pointer");else if(N.isSelectable(s))Un(n,N.create(r,a),"pointer");else continue;return!0}}function sl(n){return Wo(n)}var bh=zt?"metaKey":"ctrlKey";xt.mousedown=(n,t)=>{let e=t;n.input.shiftKey=e.shiftKey;let r=sl(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&jb(e,n.input.lastClick)&&!e[bh]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:e.clientX,y:e.clientY,type:i};let s=n.posAtCoords(Qo(e));s&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Ja(n,s,e,!!r)):(i=="doubleClick"?Gb:Xb)(n,s.pos,s.inside,e)?e.preventDefault():Be(n,"pointer"))};var Ja=class{constructor(t,e,r,o){this.view=t,this.pos=e,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[bh],this.allowDefault=r.shiftKey;let i,s;if(e.inside>-1)i=t.state.doc.nodeAt(e.inside),s=e.inside;else{let d=t.state.doc.resolve(e.pos);i=d.parent,s=d.depth?d.before():0}let a=o?null:r.target,l=a?t.docView.nearestDesc(a,!0):null;this.target=l?l.dom:null;let{selection:c}=t.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof N&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Gt&&!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)),Be(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(()=>Ee(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(Qo(t))),this.updateAllowDefault(t),this.allowDefault||!e?Be(this.view,"pointer"):Jb(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||vt&&this.mightDrag&&!this.mightDrag.node.isAtom||Tt&&!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)?(Un(this.view,R.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):Be(this.view,"pointer")}move(t){this.updateAllowDefault(t),Be(this.view,"pointer"),t.buttons==0&&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)}};xt.touchstart=n=>{n.input.lastTouch=Date.now(),sl(n),Be(n,"pointer")};xt.touchmove=n=>{n.input.lastTouch=Date.now(),Be(n,"pointer")};xt.contextmenu=n=>sl(n);function yh(n,t){return n.composing?!0:vt&&Math.abs(t.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Qb=re?5e3:-1;kt.compositionstart=kt.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:t}=n,e=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!e.textOffset&&e.parentOffset&&e.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||e.marks(),Wo(n,!0),n.markCursor=null;else if(Wo(n),Gt&&t.selection.empty&&e.parentOffset&&!e.textOffset&&e.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){n.domSelection().collapse(s,s.nodeValue.length);break}else o=s,i=-1}}n.input.composing=!0}vh(n,Qb)};kt.compositionend=(n,t)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=t.timeStamp,vh(n,20))};function vh(n,t){clearTimeout(n.input.composingTimeout),t>-1&&(n.input.composingTimeout=setTimeout(()=>Wo(n),t))}function xh(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Zb());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Zb(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Wo(n,t=!1){if(!(re&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),xh(n),t||n.docView&&n.docView.dirty){let e=nl(n);return e&&!e.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(e)):n.updateState(n.state),!0}return!1}}function t0(n,t){if(!n.dom.parentNode)return;let e=n.dom.parentNode.appendChild(document.createElement("div"));e.appendChild(t),e.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e),n.focus()},50)}var Wn=_t&&ze<15||Kn&&sb<604;xt.copy=kt.cut=(n,t)=>{let e=t,r=n.state.selection,o=e.type=="cut";if(r.empty)return;let i=Wn?null:e.clipboardData,s=r.content(),{dom:a,text:l}=dh(n,s);i?(e.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):t0(n,a),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function e0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function n0(n,t){if(!n.dom.parentNode)return;let e=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(e?"textarea":"div"));e||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),e?Ga(n,r.value,null,t):Ga(n,r.textContent,r.innerHTML,t)},50)}function Ga(n,t,e,r){let o=uh(n,t,e,n.input.shiftKey,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,r,o||A.empty)))return!0;if(!o)return!1;let i=e0(o),s=i?n.state.tr.replaceSelectionWith(i,n.input.shiftKey):n.state.tr.replaceSelection(o);return n.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}kt.paste=(n,t)=>{let e=t;if(n.composing&&!re)return;let r=Wn?null:e.clipboardData;r&&Ga(n,r.getData("text/plain"),r.getData("text/html"),e)?e.preventDefault():n0(n,e)};var Xa=class{constructor(t,e){this.slice=t,this.move=e}},kh=zt?"altKey":"ctrlKey";xt.dragstart=(n,t)=>{let e=t,r=n.input.mouseDown;if(r&&r.done(),!e.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(Qo(e));if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof N?o.to-1:o.to))){if(r&&r.mightDrag)n.dispatch(n.state.tr.setSelection(N.create(n.state.doc,r.mightDrag.pos)));else if(e.target&&e.target.nodeType==1){let c=n.docView.nearestDesc(e.target,!0);c&&c.node.type.spec.draggable&&c!=n.docView&&n.dispatch(n.state.tr.setSelection(N.create(n.state.doc,c.posBefore)))}}let s=n.state.selection.content(),{dom:a,text:l}=dh(n,s);e.dataTransfer.clearData(),e.dataTransfer.setData(Wn?"Text":"text/html",a.innerHTML),e.dataTransfer.effectAllowed="copyMove",Wn||e.dataTransfer.setData("text/plain",l),n.dragging=new Xa(s,!e[kh])};xt.dragend=n=>{let t=n.dragging;window.setTimeout(()=>{n.dragging==t&&(n.dragging=null)},50)};kt.dragover=kt.dragenter=(n,t)=>t.preventDefault();kt.drop=(n,t)=>{let e=t,r=n.dragging;if(n.dragging=null,!e.dataTransfer)return;let o=n.posAtCoords(Qo(e));if(!o)return;let i=n.state.doc.resolve(o.pos),s=r&&r.slice;s?n.someProp("transformPasted",p=>{s=p(s)}):s=uh(n,e.dataTransfer.getData(Wn?"Text":"text/plain"),Wn?null:e.dataTransfer.getData("text/html"),!1,i);let a=!!(r&&!e[kh]);if(n.someProp("handleDrop",p=>p(n,e,s||A.empty,a))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Lo(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let c=n.state.tr;a&&c.deleteSelection();let d=c.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(h))return;let f=c.doc.resolve(d);if(u&&N.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new N(f));else{let p=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((y,x,b,k)=>p=k),c.setSelection(rl(n,f,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};xt.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ee(n)},20))};xt.blur=(n,t)=>{let e=t;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),e.relatedTarget&&n.dom.contains(e.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};xt.beforeinput=(n,t)=>{if(Tt&&re&&t.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Fn(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in kt)xt[n]=kt[n];function Ir(n,t){if(n==t)return!0;for(let e in n)if(n[e]!==t[e])return!1;for(let e in t)if(!(e in n))return!1;return!0}var Ya=class n{constructor(t,e){this.toDOM=t,this.spec=e||fn,this.side=this.spec.side||0}map(t,e,r,o){let{pos:i,deleted:s}=t.mapResult(e.from+o,this.side<0?-1:1);return s?null:new et(i-r,i-r,this)}valid(){return!0}eq(t){return this==t||t instanceof n&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ir(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},hn=class n{constructor(t,e){this.attrs=t,this.spec=e||fn}map(t,e,r,o){let i=t.map(e.from+o,this.spec.inclusiveStart?-1:1)-r,s=t.map(e.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new et(i,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof n&&Ir(this.attrs,t.attrs)&&Ir(this.spec,t.spec)}static is(t){return t.type instanceof n}destroy(){}},Qa=class n{constructor(t,e){this.attrs=t,this.spec=e||fn}map(t,e,r,o){let i=t.mapResult(e.from+o,1);if(i.deleted)return null;let s=t.mapResult(e.to+o,-1);return s.deleted||s.pos<=i.pos?null:new et(i.pos-r,s.pos-r,this)}valid(t,e){let{index:r,offset:o}=t.content.findIndex(e.from),i;return o==e.from&&!(i=t.child(r)).isText&&o+i.nodeSize==e.to}eq(t){return this==t||t instanceof n&&Ir(this.attrs,t.attrs)&&Ir(this.spec,t.spec)}destroy(){}},et=class n{constructor(t,e,r){this.from=t,this.to=e,this.type=r}copy(t,e){return new n(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,r){return this.type.map(t,this,e,r)}static widget(t,e,r){return new n(t,t,new Ya(e,r))}static inline(t,e,r,o){return new n(t,e,new hn(r,o))}static node(t,e,r,o){return new n(t,e,new Qa(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof hn}},Hn=[],fn={},W=class n{constructor(t,e){this.local=t.length?t:Hn,this.children=e.length?e:Hn}static create(t,e){return e.length?Jo(e,t,0,fn):pt}find(t,e,r){let o=[];return this.findInner(t??0,e??1e9,o,0,r),o}findInner(t,e,r,o,i){for(let s=0;s<this.local.length;s++){let a=this.local[s];a.from<=e&&a.to>=t&&(!i||i(a.spec))&&r.push(a.copy(a.from+o,a.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<e&&this.children[s+1]>t){let a=this.children[s]+1;this.children[s+2].findInner(t-a,e-a,r,o+a,i)}}map(t,e,r){return this==pt||t.maps.length==0?this:this.mapInner(t,e,0,0,r||fn)}mapInner(t,e,r,o,i){let s;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(t,r,o);l&&l.type.valid(e,l)?(s||(s=[])).push(l):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?r0(this.children,s||[],t,e,r,o,i):s?new n(s.sort(pn),Hn):pt}add(t,e){return e.length?this==pt?n.create(t,e):this.addInner(t,e,0):this}addInner(t,e,r){let o,i=0;t.forEach((a,l)=>{let c=l+r,d;if(d=wh(e,a,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<l;)i+=3;o[i]==l?o[i+2]=o[i+2].addInner(a,d,c+1):o.splice(i,0,l,l+a.nodeSize,Jo(d,a,c+1,fn)),i+=3}});let s=Sh(i?Eh(e):e,-r);for(let a=0;a<s.length;a++)s[a].type.valid(t,s[a])||s.splice(a--,1);return new n(s.length?this.local.concat(s).sort(pn):this.local,o||this.children)}remove(t){return t.length==0||this==pt?this:this.removeInner(t,0)}removeInner(t,e){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,a=r[i]+e,l=r[i+1]+e;for(let d=0,u;d<t.length;d++)(u=t[d])&&u.from>a&&u.to<l&&(t[d]=null,(s||(s=[])).push(u));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,a+1);c!=pt?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<t.length;i++)if(s=t[i])for(let a=0;a<o.length;a++)o[a].eq(s,e)&&(o==this.local&&(o=this.local.slice()),o.splice(a--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new n(o,r):pt}forChild(t,e){if(this==pt)return this;if(e.isLeaf)return n.empty;let r,o;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=t){this.children[a]==t&&(r=this.children[a+2]);break}let i=t+1,s=i+e.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<s&&l.to>i&&l.type instanceof hn){let c=Math.max(i,l.from)-i,d=Math.min(s,l.to)-i;c<d&&(o||(o=[])).push(l.copy(c,d))}}if(o){let a=new n(o.sort(pn),Hn);return r?new qo([a,r]):a}return r||pt}eq(t){if(this==t)return!0;if(!(t instanceof n)||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 al(this.localsInner(t))}localsInner(t){if(this==pt)return Hn;if(t.inlineContent||!this.local.some(hn.is))return this.local;let e=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof hn||e.push(this.local[r]);return e}};W.empty=new W([],[]);W.removeOverlap=al;var pt=W.empty,qo=class n{constructor(t){this.members=t}map(t,e){let r=this.members.map(o=>o.map(t,e,fn));return n.from(r)}forChild(t,e){if(e.isLeaf)return W.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(t,e);i!=pt&&(i instanceof n?r=r.concat(i.members):r.push(i))}return n.from(r)}eq(t){if(!(t instanceof n)||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,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(t);if(i.length)if(!e)e=i;else{r&&(e=e.slice(),r=!1);for(let s=0;s<i.length;s++)e.push(i[s])}}return e?al(r?e:e.sort(pn)):Hn}static from(t){switch(t.length){case 0:return pt;case 1:return t[0];default:return new n(t)}}};function r0(n,t,e,r,o,i,s){let a=n.slice();for(let c=0,d=i;c<e.maps.length;c++){let u=0;e.maps[c].forEach((h,f,p,y)=>{let x=y-p-(f-h);for(let b=0;b<a.length;b+=3){let k=a[b+1];if(k<0||h>k+d-u)continue;let m=a[b]+d-u;f>=m?a[b+1]=h<=m?-2:-1:p>=o&&x&&(a[b]+=x,a[b+1]+=x)}u+=x}),d=e.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=e.map(n[c]+i),u=d-o;if(u<0||u>=r.content.size){l=!0;continue}let h=e.map(n[c+1]+i,-1),f=h-o,{index:p,offset:y}=r.content.findIndex(u),x=r.maybeChild(p);if(x&&y==u&&y+x.nodeSize==f){let b=a[c+2].mapInner(e,x,d+1,n[c]+i+1,s);b!=pt?(a[c]=u,a[c+1]=f,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=o0(a,n,t,e,o,i,s),d=Jo(c,r,0,s);t=d.local;for(let u=0;u<a.length;u+=3)a[u+1]<0&&(a.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let f=d.children[u];for(;h<a.length&&a[h]<f;)h+=3;a.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new W(t.sort(pn),a)}function Sh(n,t){if(!t||!n.length)return n;let e=[];for(let r=0;r<n.length;r++){let o=n[r];e.push(new et(o.from+t,o.to+t,o.type))}return e}function o0(n,t,e,r,o,i,s){function a(l,c){for(let d=0;d<l.local.length;d++){let u=l.local[d].map(r,o,c);u?e.push(u):s.onRemove&&s.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<n.length;l+=3)n[l+1]==-1&&a(n[l+2],t[l]+i+1);return e}function wh(n,t,e){if(t.isLeaf)return null;let r=e+t.nodeSize,o=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>e&&s.to<r&&((o||(o=[])).push(s),n[i]=null);return o}function Eh(n){let t=[];for(let e=0;e<n.length;e++)n[e]!=null&&t.push(n[e]);return t}function Jo(n,t,e,r){let o=[],i=!1;t.forEach((a,l)=>{let c=wh(n,a,l+e);if(c){i=!0;let d=Jo(c,a,e+l+1,r);d!=pt&&o.push(l,l+a.nodeSize,d)}});let s=Sh(i?Eh(n):n,-e).sort(pn);for(let a=0;a<s.length;a++)s[a].type.valid(t,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new W(s,o):pt}function pn(n,t){return n.from-t.from||n.to-t.to}function al(n){let t=n;for(let e=0;e<t.length-1;e++){let r=t[e];if(r.from!=r.to)for(let o=e+1;o<t.length;o++){let i=t[o];if(i.from==r.from){i.to!=r.to&&(t==n&&(t=n.slice()),t[o]=i.copy(i.from,r.to),Fu(t,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(t==n&&(t=n.slice()),t[e]=r.copy(r.from,i.from),Fu(t,o,r.copy(i.from,r.to)));break}}}return t}function Fu(n,t,e){for(;t<n.length&&pn(e,n[t])>0;)t++;n.splice(t,0,e)}function Pa(n){let t=[];return n.someProp("decorations",e=>{let r=e(n.state);r&&r!=pt&&t.push(r)}),n.cursorWrapper&&t.push(W.create(n.state.doc,[n.cursorWrapper.deco])),qo.from(t)}var i0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},s0=_t&&ze<=11,Za=class{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}},tl=class{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Za,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);_t&&ze<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),s0&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,i0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let 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(Du(this.view)){if(this.suppressingSelectionUpdates)return Ee(this.view);if(_t&&ze<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&mn(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=new Set,r;for(let i=t.focusNode;i;i=$r(i))e.add(i);for(let i=t.anchorNode;i;i=$r(i))if(e.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!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 r=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Du(t)&&!this.ignoreSelectionChange(r),i=-1,s=-1,a=!1,l=[];if(t.editable)for(let d=0;d<e.length;d++){let u=this.registerMutation(e[d],l);u&&(i=i<0?u.from:Math.min(u.from,i),s=s<0?u.to:Math.max(u.to,s),u.typeOver&&(a=!0))}if(Gt&&l.length>1){let d=l.filter(u=>u.nodeName=="BR");if(d.length==2){let u=d[0],h=d[1];u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}}let c=null;i<0&&o&&t.input.lastFocus>Date.now()-200&&t.input.lastTouch<Date.now()-300&&Xo(r)&&(c=nl(t))&&c.eq(R.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Ee(t),this.currentSelection.set(r),t.scrollToSelection()):(i>-1||o)&&(i>-1&&(t.docView.markDirty(i,s),a0(t)),this.handleDOMChange(i,s,a,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||Ee(t),this.currentSelection.set(r))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let d=0;d<t.addedNodes.length;d++)e.push(t.addedNodes[d]);if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let o=t.previousSibling,i=t.nextSibling;if(_t&&ze<=11&&t.addedNodes.length)for(let d=0;d<t.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=t.addedNodes[d];(!u||Array.prototype.indexOf.call(t.addedNodes,u)<0)&&(o=u),(!h||Array.prototype.indexOf.call(t.addedNodes,h)<0)&&(i=h)}let s=o&&o.parentNode==t.target?Dt(o)+1:0,a=r.localPosFromDOM(t.target,s,-1),l=i&&i.parentNode==t.target?Dt(i):t.target.childNodes.length,c=r.localPosFromDOM(t.target,l,1);return{from:a,to:c}}else return t.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}},Vu=new WeakMap,Uu=!1;function a0(n){if(!Vu.has(n)&&(Vu.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Gt,Uu)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."),Uu=!0}}function l0(n){let t;function e(l){l.preventDefault(),l.stopImmediatePropagation(),t=l.getTargetRanges()[0]}n.dom.addEventListener("beforeinput",e,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",e,!0);let r=t.startContainer,o=t.startOffset,i=t.endContainer,s=t.endOffset,a=n.domAtPos(n.state.selection.anchor);return mn(a.node,a.offset,i,s)&&([r,o,i,s]=[i,s,r,o]),{anchorNode:r,anchorOffset:o,focusNode:i,focusOffset:s}}function c0(n,t,e){let{node:r,fromOffset:o,toOffset:i,from:s,to:a}=n.docView.parseRange(t,e),l=n.domSelectionRange(),c,d=l.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],Xo(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Tt&&n.input.lastKeyCode===8)for(let x=i;x>o;x--){let b=r.childNodes[x-1],k=b.pmViewDesc;if(b.nodeName=="BR"&&!k){i=x;break}if(!k||k.size)break}let u=n.state.doc,h=n.someProp("domParser")||ee.fromSchema(n.state.schema),f=u.resolve(s),p=null,y=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:d0,context:f});if(c&&c[0].pos!=null){let x=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=x),p={anchor:x+s,head:b+s}}return{doc:y,sel:p,from:s,to:a}}function d0(n){let t=n.pmViewDesc;if(t)return t.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(vt&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}else if(n.parentNode.lastChild==n||vt&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}function u0(n,t,e,r,o){if(t<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,B=nl(n,M);if(B&&!n.state.selection.eq(B)){let V=n.state.tr.setSelection(B);M=="pointer"?V.setMeta("pointer",!0):M=="key"&&V.scrollIntoView(),n.dispatch(V)}return}let i=n.state.doc.resolve(t),s=i.sharedDepth(e);t=i.before(s+1),e=n.state.doc.resolve(e).after(s+1);let a=n.state.selection,l=c0(n,t,e),c=n.state.doc,d=c.slice(l.from,l.to),u,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,h="end"):(u=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=p0(d.content,l.doc.content,l.from,u,h);if((Kn&&n.input.lastIOSEnter>Date.now()-225||re)&&o.some(M=>M.nodeName=="DIV"||M.nodeName=="P")&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",M=>M(n,Fn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(r&&a instanceof _&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(l.sel){let M=Ku(n,n.state.doc,l.sel);M&&!M.eq(n.state.selection)&&n.dispatch(n.state.tr.setSelection(M))}return}if(Tt&&n.cursorWrapper&&l.sel&&l.sel.anchor==n.cursorWrapper.deco.from&&l.sel.head==l.sel.anchor){let M=f.endB-f.start;l.sel={anchor:l.sel.anchor+M,head:l.sel.anchor+M}}n.input.domChangeCount++,n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof _&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=l.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=l.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),_t&&ze<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>l.from&&l.doc.textBetween(f.start-l.from-1,f.start-l.from+1)==" \xA0"&&(f.start--,f.endA--,f.endB--);let p=l.doc.resolveNoCache(f.start-l.from),y=l.doc.resolveNoCache(f.endB-l.from),x=c.resolve(f.start),b=p.sameParent(y)&&p.parent.inlineContent&&x.end()>=f.endA,k;if((Kn&&n.input.lastIOSEnter>Date.now()-225&&(!b||o.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!b&&p.pos<l.doc.content.size&&(k=R.findFrom(l.doc.resolve(p.pos+1),1,!0))&&k.head==y.pos)&&n.someProp("handleKeyDown",M=>M(n,Fn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&f0(c,f.start,f.endA,p,y)&&n.someProp("handleKeyDown",M=>M(n,Fn(8,"Backspace")))){re&&Tt&&n.domObserver.suppressSelectionUpdates();return}Tt&&re&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),re&&!b&&p.start()!=y.start()&&y.parentOffset==0&&p.depth==y.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==f.endA&&(f.endB-=2,y=l.doc.resolveNoCache(f.endB-l.from),setTimeout(()=>{n.someProp("handleKeyDown",function(M){return M(n,Fn(13,"Enter"))})},20));let m=f.start,g=f.endA,v,S,C;if(b){if(p.pos==y.pos)_t&&ze<=11&&p.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ee(n),20)),v=n.state.tr.delete(m,g),S=c.resolve(f.start).marksAcross(c.resolve(f.endA));else if(f.endA==f.endB&&(C=h0(p.parent.content.cut(p.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,f.endA-x.start()))))v=n.state.tr,C.type=="add"?v.addMark(m,g,C.mark):v.removeMark(m,g,C.mark);else if(p.parent.child(p.index()).isText&&p.index()==y.index()-(y.textOffset?0:1)){let M=p.parent.textBetween(p.parentOffset,y.parentOffset);if(n.someProp("handleTextInput",B=>B(n,m,g,M)))return;v=n.state.tr.insertText(M,m,g)}}if(v||(v=n.state.tr.replace(m,g,l.doc.slice(f.start-l.from,f.endB-l.from))),l.sel){let M=Ku(n,v.doc,l.sel);M&&!(Tt&&re&&n.composing&&M.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(M.head==m||M.head==v.mapping.map(g)-1)||_t&&M.empty&&M.head==m)&&v.setSelection(M)}S&&v.ensureMarks(S),n.dispatch(v.scrollIntoView())}function Ku(n,t,e){return Math.max(e.anchor,e.head)>t.content.size?null:rl(n,t.resolve(e.anchor),t.resolve(e.head))}function h0(n,t){let e=n.firstChild.marks,r=t.firstChild.marks,o=e,i=r,s,a,l;for(let d=0;d<r.length;d++)o=r[d].removeFromSet(o);for(let d=0;d<e.length;d++)i=e[d].removeFromSet(i);if(o.length==1&&i.length==0)a=o[0],s="add",l=d=>d.mark(a.addToSet(d.marks));else if(o.length==0&&i.length==1)a=i[0],s="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<t.childCount;d++)c.push(l(t.child(d)));if(w.from(c).eq(n))return{mark:a,type:s}}function f0(n,t,e,r,o){if(!r.parent.isTextblock||e-t<=o.pos-r.pos||Ra(r,!0,!1)<o.pos)return!1;let i=n.resolve(t);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=n.resolve(Ra(i,!0,!0));return!s.parent.isTextblock||s.pos>e||Ra(s,!0,!1)<e?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Ra(n,t,e){let r=n.depth,o=t?n.end():n.pos;for(;r>0&&(t||n.indexAfter(r)==n.node(r).childCount);)r--,o++,t=!1;if(e){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function p0(n,t,e,r,o){let i=n.findDiffStart(t,e);if(i==null)return null;let{a:s,b:a}=n.findDiffEnd(t,e+n.size,e+t.size);if(o=="end"){let l=Math.max(0,i-Math.min(s,a));r-=s+l-i}if(s<i&&n.size<t.size){let l=r<=i&&r>=s?i-r:0;i-=l,a=i+(a-s),s=i}else if(a<i){let l=r<=i&&r>=a?i-r:0;i-=l,s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}var Go=class{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 Wa,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Gu),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=qu(this),Wu(this),this.nodeViews=Ju(this),this.docView=_u(this.state.doc,ju(this),Pa(this),this.dom,this),this.domObserver=new tl(this,(r,o,i,s)=>u0(this,r,o,i,s)),this.domObserver.start(),Fb(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&&qa(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Gu),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let r in this._props)e[r]=this._props[r];e.state=this.state;for(let r in t)e[r]=t[r];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){let r=this.state,o=!1,i=!1;t.storedMarks&&this.composing&&(xh(this),i=!0),this.state=t;let s=r.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let h=Ju(this);g0(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&qa(this),this.editable=qu(this),Wu(this);let a=Pa(this),l=ju(this),c=r.plugins!=t.plugins&&!r.doc.eq(t.doc)?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(t.doc,l,a);(d||!t.selection.eq(r.selection))&&(i=!0);let u=c=="preserve"&&i&&this.dom.style.overflowAnchor==null&&cb(this);if(i){this.domObserver.stop();let h=d&&(_t||Tt)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&m0(r.selection,t.selection);if(d){let f=Tt?this.trackWrites=this.domSelectionRange().focusNode:null;(o||!this.docView.update(t.doc,l,a,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=_u(t.doc,l,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Nb(this))?Ee(this,h):(ah(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():u&&db(u)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",e=>e(this)))if(this.state.selection instanceof N){let e=this.docView.domAfterPos(this.state.selection.from);e.nodeType==1&&wu(this,e.getBoundingClientRect(),t)}else wu(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){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let r=this.directPlugins[e];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let r=this.state.plugins[e];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];r.update&&r.update(this,t)}}someProp(t,e){let r=this._props&&this._props[t],o;if(r!=null&&(o=e?e(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let a=this.directPlugins[s].props[t];if(a!=null&&(o=e?e(a):a))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let a=i[s].props[t];if(a!=null&&(o=e?e(a):a))return o}}hasFocus(){if(_t){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(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&ub(this.dom),Ee(this),this.domObserver.start()}get root(){let t=this._root;if(t==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return t||document}posAtCoords(t){return gb(this,t)}coordsAtPos(t,e=1){return eh(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,r=-1){let o=this.docView.posFromDOM(t,e,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,e){return kb(this,e||this.state,t)}destroy(){this.docView&&(Vb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Pa(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Kb(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){return vt&&this.root.nodeType===11&&ob(this.dom.ownerDocument)==this.dom?l0(this):this.domSelection()}domSelection(){return this.root.getSelection()}};function ju(n){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(n.editable),t.translate="no",n.someProp("attributes",e=>{if(typeof e=="function"&&(e=e(n.state)),e)for(let r in e)r=="class"&&(t.class+=" "+e[r]),r=="style"?t.style=(t.style?t.style+";":"")+e[r]:!t[r]&&r!="contenteditable"&&r!="nodeName"&&(t[r]=String(e[r]))}),[et.node(0,n.state.doc.content.size,t)]}function Wu(n){if(n.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),n.cursorWrapper={dom:t,deco:et.widget(n.state.selection.head,t,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function qu(n){return!n.someProp("editable",t=>t(n.state)===!1)}function m0(n,t){let e=Math.min(n.$anchor.sharedDepth(n.head),t.$anchor.sharedDepth(t.head));return n.$anchor.start(e)!=t.$anchor.start(e)}function Ju(n){let t=Object.create(null);function e(r){for(let o in r)Object.prototype.hasOwnProperty.call(t,o)||(t[o]=r[o])}return n.someProp("nodeViews",e),n.someProp("markViews",e),t}function g0(n,t){let e=0,r=0;for(let o in n){if(n[o]!=t[o])return!0;e++}for(let o in t)r++;return e!=r}function Gu(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Me={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:"'"},ti={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},b0=typeof navigator<"u"&&/Mac/.test(navigator.platform),y0=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(nt=0;nt<10;nt++)Me[48+nt]=Me[96+nt]=String(nt);var nt;for(nt=1;nt<=24;nt++)Me[nt+111]="F"+nt;var nt;for(nt=65;nt<=90;nt++)Me[nt]=String.fromCharCode(nt+32),ti[nt]=String.fromCharCode(nt);var nt;for(Zo in Me)ti.hasOwnProperty(Zo)||(ti[Zo]=Me[Zo]);var Zo;function Mh(n){var t=b0&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||y0&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",e=!t&&n.key||(n.shiftKey?ti:Me)[n.keyCode]||n.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}var v0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),x0=typeof navigator<"u"&&/Win/.test(navigator.platform);function k0(n){let t=n.split(/-(?!$)/),e=t[t.length-1];e=="Space"&&(e=" ");let r,o,i,s;for(let a=0;a<t.length-1;a++){let l=t[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))v0?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(e="Alt-"+e),o&&(e="Ctrl-"+e),s&&(e="Meta-"+e),i&&(e="Shift-"+e),e}function S0(n){let t=Object.create(null);for(let e in n)t[k0(e)]=n[e];return t}function ll(n,t,e=!0){return t.altKey&&(n="Alt-"+n),t.ctrlKey&&(n="Ctrl-"+n),t.metaKey&&(n="Meta-"+n),e&&t.shiftKey&&(n="Shift-"+n),n}function Ah(n){return new O({props:{handleKeyDown:cl(n)}})}function cl(n){let t=S0(n);return function(e,r){let o=Mh(r),i,s=t[ll(o,r)];if(s&&s(e.state,e.dispatch,e))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let a=t[ll(o,r,!1)];if(a&&a(e.state,e.dispatch,e))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(x0&&r.ctrlKey&&r.altKey)&&(i=Me[r.keyCode])&&i!=o){let a=t[ll(i,r)];if(a&&a(e.state,e.dispatch,e))return!0}}return!1}}var ei=(n,t)=>n.selection.empty?!1:(t&&t(n.tr.deleteSelection().scrollIntoView()),!0);function _h(n,t){let{$cursor:e}=n.selection;return!e||(t?!t.endOfTextblock("backward",n):e.parentOffset>0)?null:e}var ul=(n,t,e)=>{let r=_h(n,e);if(!r)return!1;let o=fl(r);if(!o){let s=r.blockRange(),a=s&&Se(s);return a==null?!1:(t&&t(n.tr.lift(s,a).scrollIntoView()),!0)}let i=o.nodeBefore;if(Lh(n,o,t,-1))return!0;if(r.parent.content.size==0&&(qn(i,"end")||N.isSelectable(i)))for(let s=r.depth;;s--){let a=Or(n.doc,r.before(s),r.after(s),A.empty);if(a&&a.slice.size<a.to-a.from){if(t){let l=n.tr.step(a);l.setSelection(qn(i,"end")?R.findFrom(l.doc.resolve(l.mapping.map(o.pos,-1)),-1):N.create(l.doc,o.pos-i.nodeSize)),t(l.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(t&&t(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},Ch=(n,t,e)=>{let r=_h(n,e);if(!r)return!1;let o=fl(r);return o?Nh(n,o,t):!1},Oh=(n,t,e)=>{let r=Ph(n,e);if(!r)return!1;let o=gl(r);return o?Nh(n,o,t):!1};function Nh(n,t,e){let r=t.nodeBefore,o=r,i=t.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let s=t.nodeAfter,a=s,l=t.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=Or(n.doc,i,l,A.empty);if(!c||c.from!=i||c instanceof at&&c.slice.size>=l-i)return!1;if(e){let d=n.tr.step(c);d.setSelection(_.create(d.doc,i)),e(d.scrollIntoView())}return!0}function qn(n,t,e=!1){for(let r=n;r;r=t=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(e&&r.childCount!=1)return!1}return!1}var hl=(n,t,e)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(e?!e.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=fl(r)}let s=i&&i.nodeBefore;return!s||!N.isSelectable(s)?!1:(t&&t(n.tr.setSelection(N.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function fl(n){if(!n.parent.type.spec.isolating)for(let t=n.depth-1;t>=0;t--){if(n.index(t)>0)return n.doc.resolve(n.before(t+1));if(n.node(t).type.spec.isolating)break}return null}function Ph(n,t){let{$cursor:e}=n.selection;return!e||(t?!t.endOfTextblock("forward",n):e.parentOffset<e.parent.content.size)?null:e}var pl=(n,t,e)=>{let r=Ph(n,e);if(!r)return!1;let o=gl(r);if(!o)return!1;let i=o.nodeAfter;if(Lh(n,o,t,1))return!0;if(r.parent.content.size==0&&(qn(i,"start")||N.isSelectable(i))){let s=Or(n.doc,r.before(),r.after(),A.empty);if(s&&s.slice.size<s.to-s.from){if(t){let a=n.tr.step(s);a.setSelection(qn(i,"start")?R.findFrom(a.doc.resolve(a.mapping.map(o.pos)),1):N.create(a.doc,a.mapping.map(o.pos))),t(a.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(t&&t(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},ml=(n,t,e)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(e?!e.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=gl(r)}let s=i&&i.nodeAfter;return!s||!N.isSelectable(s)?!1:(t&&t(n.tr.setSelection(N.create(n.doc,i.pos)).scrollIntoView()),!0)};function gl(n){if(!n.parent.type.spec.isolating)for(let t=n.depth-1;t>=0;t--){let e=n.node(t);if(n.index(t)+1<e.childCount)return n.doc.resolve(n.after(t+1));if(e.type.spec.isolating)break}return null}var Rh=(n,t)=>{let e=n.selection,r=e instanceof N,o;if(r){if(e.node.isTextblock||!Bt(n.doc,e.from))return!1;o=e.from}else if(o=ln(n.doc,e.from,-1),o==null)return!1;if(t){let i=n.tr.join(o);r&&i.setSelection(N.create(i.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),t(i.scrollIntoView())}return!0},Dh=(n,t)=>{let e=n.selection,r;if(e instanceof N){if(e.node.isTextblock||!Bt(n.doc,e.to))return!1;r=e.to}else if(r=ln(n.doc,e.to,1),r==null)return!1;return t&&t(n.tr.join(r).scrollIntoView()),!0},$h=(n,t)=>{let{$from:e,$to:r}=n.selection,o=e.blockRange(r),i=o&&Se(o);return i==null?!1:(t&&t(n.tr.lift(o,i).scrollIntoView()),!0)},bl=(n,t)=>{let{$head:e,$anchor:r}=n.selection;return!e.parent.type.spec.code||!e.sameParent(r)?!1:(t&&t(n.tr.insertText(`
`).scrollIntoView()),!0)};function yl(n){for(let t=0;t<n.edgeCount;t++){let{type:e}=n.edge(t);if(e.isTextblock&&!e.hasRequiredAttrs())return e}return null}var vl=(n,t)=>{let{$head:e,$anchor:r}=n.selection;if(!e.parent.type.spec.code||!e.sameParent(r))return!1;let o=e.node(-1),i=e.indexAfter(-1),s=yl(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let a=e.after(),l=n.tr.replaceWith(a,a,s.createAndFill());l.setSelection(R.near(l.doc.resolve(a),1)),t(l.scrollIntoView())}return!0},Jn=(n,t)=>{let e=n.selection,{$from:r,$to:o}=e;if(e instanceof yt||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=yl(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,a=n.tr.insert(s,i.createAndFill());a.setSelection(_.create(a.doc,s+1)),t(a.scrollIntoView())}return!0},xl=(n,t)=>{let{$cursor:e}=n.selection;if(!e||e.parent.content.size)return!1;if(e.depth>1&&e.after()!=e.end(-1)){let i=e.before();if(Rt(n.doc,i))return t&&t(n.tr.split(i).scrollIntoView()),!0}let r=e.blockRange(),o=r&&Se(r);return o==null?!1:(t&&t(n.tr.lift(r,o).scrollIntoView()),!0)};function w0(n){return(t,e)=>{let{$from:r,$to:o}=t.selection;if(t.selection instanceof N&&t.selection.node.isBlock)return!r.parentOffset||!Rt(t.doc,r.pos)?!1:(e&&e(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,a,l=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){l=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),a=yl(r.node(f-1).contentMatchAt(r.indexAfter(f-1)));let y=n&&n(o.parent,l,r);i.unshift(y||(l&&a?{type:a}:null)),s=f;break}else{if(f==1)return!1;i.unshift(null)}let d=t.tr;(t.selection instanceof _||t.selection instanceof yt)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=Rt(d.doc,u,i.length,i);if(h||(i[0]=a?{type:a}:null,h=Rt(d.doc,u,i.length,i)),!h)return!1;if(d.split(u,i.length,i),!l&&c&&r.node(s).type!=a){let f=d.mapping.map(r.before(s)),p=d.doc.resolve(f);a&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(s)),a)}return e&&e(d.scrollIntoView()),!0}}var E0=w0();var Ih=(n,t)=>{let{$from:e,to:r}=n.selection,o,i=e.sharedDepth(r);return i==0?!1:(o=e.before(i),t&&t(n.tr.setSelection(N.create(n.doc,o))),!0)},M0=(n,t)=>(t&&t(n.tr.setSelection(new yt(n.doc))),!0);function A0(n,t,e){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&t.parent.canReplace(i-1,i)?(e&&e(n.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(i,i+1)||!(o.isTextblock||Bt(n.doc,t.pos))?!1:(e&&e(n.tr.join(t.pos).scrollIntoView()),!0)}function Lh(n,t,e,r){let o=t.nodeBefore,i=t.nodeAfter,s,a,l=o.type.spec.isolating||i.type.spec.isolating;if(!l&&A0(n,t,e))return!0;let c=!l&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(s=(a=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&a.matchType(s[0]||i.type).validEnd){if(e){let f=t.pos+i.nodeSize,p=w.empty;for(let b=s.length-1;b>=0;b--)p=w.from(s[b].create(null,p));p=w.from(o.copy(p));let y=n.tr.step(new J(t.pos-1,f,t.pos,f,new A(p,1,0),s.length,!0)),x=y.doc.resolve(f+2*s.length);x.nodeAfter&&x.nodeAfter.type==o.type&&Bt(y.doc,x.pos)&&y.join(x.pos),e(y.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&l?null:R.findFrom(t,1),u=d&&d.$from.blockRange(d.$to),h=u&&Se(u);if(h!=null&&h>=t.depth)return e&&e(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&qn(i,"start",!0)&&qn(o,"end")){let f=o,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let y=i,x=1;for(;!y.isTextblock;y=y.firstChild)x++;if(f.canReplace(f.childCount,f.childCount,y.content)){if(e){let b=w.empty;for(let m=p.length-1;m>=0;m--)b=w.from(p[m].copy(b));let k=n.tr.step(new J(t.pos-p.length,t.pos+i.nodeSize,t.pos+x,t.pos+i.nodeSize-x,new A(b,p.length,0),0,!0));e(k.scrollIntoView())}return!0}}return!1}function Bh(n){return function(t,e){let r=t.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(e&&e(t.tr.setSelection(_.create(t.doc,n<0?o.start(i):o.end(i)))),!0):!1}}var kl=Bh(-1),Sl=Bh(1);function zh(n,t=null){return function(e,r){let{$from:o,$to:i}=e.selection,s=o.blockRange(i),a=s&&Ln(s,n,t);return a?(r&&r(e.tr.wrap(s,a).scrollIntoView()),!0):!1}}function wl(n,t=null){return function(e,r){let o=!1;for(let i=0;i<e.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:a}}=e.selection.ranges[i];e.doc.nodesBetween(s,a,(l,c)=>{if(o)return!1;if(!(!l.isTextblock||l.hasMarkup(n,t)))if(l.type==n)o=!0;else{let d=e.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,n)}})}if(!o)return!1;if(r){let i=e.tr;for(let s=0;s<e.selection.ranges.length;s++){let{$from:{pos:a},$to:{pos:l}}=e.selection.ranges[s];i.setBlockType(a,l,n,t)}r(i.scrollIntoView())}return!0}}function Gn(...n){return function(t,e,r){for(let o=0;o<n.length;o++)if(n[o](t,e,r))return!0;return!1}}var dl=Gn(ei,ul,hl),Th=Gn(ei,pl,ml),Ve={Enter:Gn(bl,Jn,xl,E0),"Mod-Enter":vl,Backspace:dl,"Mod-Backspace":dl,"Shift-Backspace":dl,Delete:Th,"Mod-Delete":Th,"Mod-a":M0},T0={"Ctrl-h":Ve.Backspace,"Alt-Backspace":Ve["Mod-Backspace"],"Ctrl-d":Ve.Delete,"Ctrl-Alt-Backspace":Ve["Mod-Delete"],"Alt-Delete":Ve["Mod-Delete"],"Alt-d":Ve["Mod-Delete"],"Ctrl-a":kl,"Ctrl-e":Sl};for(let n in Ve)T0[n]=Ve[n];var yS=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function Hh(n,t=null){return function(e,r){let{$from:o,$to:i}=e.selection,s=o.blockRange(i);if(!s)return!1;let a=r?e.tr:null;return _0(a,s,n,t)?(r&&r(a.scrollIntoView()),!0):!1}}function _0(n,t,e,r=null){let o=!1,i=t,s=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(e)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let l=s.resolve(t.start-2);i=new sn(l,l,t.depth),t.endIndex<t.parent.childCount&&(t=new sn(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let a=Ln(i,e,r,t);return a?(n&&C0(n,t,a,o,e),!0):!1}function C0(n,t,e,r,o){let i=w.empty;for(let d=e.length-1;d>=0;d--)i=w.from(e[d].type.create(e[d].attrs,i));n.step(new J(t.start-(r?2:0),t.end,t.start,t.end,new A(i,0,0),e.length,!0));let s=0;for(let d=0;d<e.length;d++)e[d].type==o&&(s=d+1);let a=e.length-s,l=t.start+e.length-(r?2:0),c=t.parent;for(let d=t.startIndex,u=t.endIndex,h=!0;d<u;d++,h=!1)!h&&Rt(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return n}function Fh(n){return function(t,e){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==n);return i?e?r.node(i.depth-1).type==n?O0(t,e,n,i):N0(t,e,i):!0:!1}}function O0(n,t,e,r){let o=n.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new J(i-1,s,i,s,new A(w.from(e.create(null,r.parent.copy())),1,0),1,!0)),r=new sn(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let a=Se(r);if(a==null)return!1;o.lift(r,a);let l=o.doc.resolve(o.mapping.map(i,-1)-1);return Bt(o.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&o.join(l.pos),t(o.scrollIntoView()),!0}function N0(n,t,e){let r=n.tr,o=e.parent;for(let f=e.end,p=e.endIndex-1,y=e.startIndex;p>y;p--)f-=o.child(p).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(e.start),s=i.nodeAfter;if(r.mapping.map(e.end)!=e.start+i.nodeAfter.nodeSize)return!1;let a=e.startIndex==0,l=e.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?w.empty:w.from(o))))return!1;let u=i.pos,h=u+s.nodeSize;return r.step(new J(u-(a?1:0),h+(l?1:0),u+1,h-1,new A((a?w.empty:w.from(o.copy(w.empty))).append(l?w.empty:w.from(o.copy(w.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}function Vh(n){return function(t,e){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let a=i.parent,l=a.child(s-1);if(l.type!=n)return!1;if(e){let c=l.lastChild&&l.lastChild.type==a.type,d=w.from(c?n.create():null),u=new A(w.from(n.create(null,w.from(a.type.create(null,d)))),c?3:1,0),h=i.start,f=i.end;e(t.tr.step(new J(h-(c?3:1),f,h,f,u,1,!0)).scrollIntoView())}return!0}}var P0=Object.defineProperty,Xh=(n,t)=>{for(var e in t)P0(n,e,{get:t[e],enumerable:!0})};function li(n){let{state:t,transaction:e}=n,{selection:r}=e,{doc:o}=e,{storedMarks:i}=e;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=e.selection,o=e.doc,i=e.storedMarks,e}}}var ci=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:n,editor:t,state:e}=this,{view:r}=t,{tr:o}=e,i=this.buildProps(o);return Object.fromEntries(Object.entries(n).map(([s,a])=>[s,(...c)=>{let d=a(...c)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,t=!0){let{rawCommands:e,editor:r,state:o}=this,{view:i}=r,s=[],a=!!n,l=n||o.tr,c=()=>(!a&&t&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),s.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(e).map(([u,h])=>[u,(...p)=>{let y=this.buildProps(l,t),x=h(...p)(y);return s.push(x),d}])),run:c};return d}createCan(n){let{rawCommands:t,state:e}=this,r=!1,o=n||e.tr,i=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(t).map(([a,l])=>[a,(...c)=>l(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(n,t=!0){let{rawCommands:e,editor:r,state:o}=this,{view:i}=r,s={tr:n,editor:r,view:i,state:li({state:o,transaction:n}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(n,t),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>l(...c)(s)]))}};return s}},R0=class{constructor(){this.callbacks={}}on(n,t){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(t),this}emit(n,...t){let e=this.callbacks[n];return e&&e.forEach(r=>r.apply(this,t)),this}off(n,t){let e=this.callbacks[n];return e&&(t?this.callbacks[n]=e.filter(r=>r!==t):delete this.callbacks[n]),this}once(n,t){let e=(...r)=>{this.off(n,e),t.apply(this,r)};return this.on(n,e)}removeAllListeners(){this.callbacks={}}};function Cl(n,t){let e=new In(n);return t.forEach(r=>{r.steps.forEach(o=>{e.step(o)})}),e}var Yh=n=>{let t=n.childNodes;for(let e=t.length-1;e>=0;e-=1){let r=t[e];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Yh(r)}return n};function ni(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let t=`<body>${n}</body>`,e=new window.DOMParser().parseFromString(t,"text/html").body;return Yh(e)}function Lr(n,t,e){if(n instanceof Mt||n instanceof w)return n;e={slice:!0,parseOptions:{},...e};let r=typeof n=="object"&&n!==null,o=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return w.fromArray(n.map(a=>t.nodeFromJSON(a)));let s=t.nodeFromJSON(n);return e.errorOnInvalidContent&&s.check(),s}catch(i){if(e.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),Lr("",t,e)}if(o){if(e.errorOnInvalidContent){let s=!1,a="",l=new Rn({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(e.slice?ee.fromSchema(l).parseSlice(ni(n),e.parseOptions):ee.fromSchema(l).parse(ni(n),e.parseOptions),e.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}let i=ee.fromSchema(t);return e.slice?i.parseSlice(ni(n),e.parseOptions).content:i.parse(ni(n),e.parseOptions)}return Lr("",t,e)}function Tl(n,t,e={},r={}){return Lr(n,t,{slice:!1,parseOptions:e,errorOnInvalidContent:r.errorOnInvalidContent})}function D0(n){for(let t=0;t<n.edgeCount;t+=1){let{type:e}=n.edge(t);if(e.isTextblock&&!e.hasRequiredAttrs())return e}return null}function Qh(n,t,e){let r=[];return n.nodesBetween(t.from,t.to,(o,i)=>{e(o)&&r.push({node:o,pos:i})}),r}function $0(n,t){for(let e=n.depth;e>0;e-=1){let r=n.node(e);if(t(r))return{pos:e>0?n.before(e):0,start:n.start(e),depth:e,node:r}}}function di(n){return t=>$0(t.$from,n)}function P(n,t,e){return n.config[t]===void 0&&n.parent?P(n.parent,t,e):typeof n.config[t]=="function"?n.config[t].bind({...e,parent:n.parent?P(n.parent,t,e):null}):n.config[t]}function Ol(n){return n.map(t=>{let e={name:t.name,options:t.options,storage:t.storage},r=P(t,"addExtensions",e);return r?[t,...Ol(r())]:t}).flat(10)}function Nl(n,t){let e=At.fromSchema(t).serializeFragment(n),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(e),o.innerHTML}function Zh(n){return typeof n=="function"}function H(n,t=void 0,...e){return Zh(n)?t?n.bind(t)(...e):n(...e):n}function I0(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Br(n){let t=n.filter(o=>o.type==="extension"),e=n.filter(o=>o.type==="node"),r=n.filter(o=>o.type==="mark");return{baseExtensions:t,nodeExtensions:e,markExtensions:r}}function tf(n){let t=[],{nodeExtensions:e,markExtensions:r}=Br(n),o=[...e,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(s=>{let a={name:s.name,options:s.options,storage:s.storage,extensions:o},l=P(s,"addGlobalAttributes",a);if(!l)return;l().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([h,f])=>{t.push({type:u,name:h,attribute:{...i,...f}})})})})}),o.forEach(s=>{let a={name:s.name,options:s.options,storage:s.storage},l=P(s,"addAttributes",a);if(!l)return;let c=l();Object.entries(c).forEach(([d,u])=>{let h={...i,...u};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,t.push({type:s.name,name:d,attribute:h})})}),t}function $(...n){return n.filter(t=>!!t).reduce((t,e)=>{let r={...t};return Object.entries(e).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){let a=i?String(i).split(" "):[],l=r[o]?r[o].split(" "):[],c=a.filter(d=>!l.includes(d));r[o]=[...l,...c].join(" ")}else if(o==="style"){let a=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[o]?r[o].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;l.forEach(d=>{let[u,h]=d.split(":").map(f=>f.trim());c.set(u,h)}),a.forEach(d=>{let[u,h]=d.split(":").map(f=>f.trim());c.set(u,h)}),r[o]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[o]=i}),r},{})}function ai(n,t){return t.filter(e=>e.type===n.type.name).filter(e=>e.attribute.rendered).map(e=>e.attribute.renderHTML?e.attribute.renderHTML(n.attrs)||{}:{[e.name]:n.attrs[e.name]}).reduce((e,r)=>$(e,r),{})}function L0(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Uh(n,t){return"style"in n?n:{...n,getAttrs:e=>{let r=n.getAttrs?n.getAttrs(e):n.attrs;if(r===!1)return!1;let o=t.reduce((i,s)=>{let a=s.attribute.parseHTML?s.attribute.parseHTML(e):L0(e.getAttribute(s.name));return a==null?i:{...i,[s.name]:a}},{});return{...r,...o}}}}function Kh(n){return Object.fromEntries(Object.entries(n).filter(([t,e])=>t==="attrs"&&I0(e)?!1:e!=null))}function B0(n,t){var e;let r=tf(n),{nodeExtensions:o,markExtensions:i}=Br(n),s=(e=o.find(c=>P(c,"topNode")))==null?void 0:e.name,a=Object.fromEntries(o.map(c=>{let d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:t},h=n.reduce((b,k)=>{let m=P(k,"extendNodeSchema",u);return{...b,...m?m(c):{}}},{}),f=Kh({...h,content:H(P(c,"content",u)),marks:H(P(c,"marks",u)),group:H(P(c,"group",u)),inline:H(P(c,"inline",u)),atom:H(P(c,"atom",u)),selectable:H(P(c,"selectable",u)),draggable:H(P(c,"draggable",u)),code:H(P(c,"code",u)),whitespace:H(P(c,"whitespace",u)),linebreakReplacement:H(P(c,"linebreakReplacement",u)),defining:H(P(c,"defining",u)),isolating:H(P(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var k,m;return[b.name,{default:(k=b?.attribute)==null?void 0:k.default,validate:(m=b?.attribute)==null?void 0:m.validate}]}))}),p=H(P(c,"parseHTML",u));p&&(f.parseDOM=p.map(b=>Uh(b,d)));let y=P(c,"renderHTML",u);y&&(f.toDOM=b=>y({node:b,HTMLAttributes:ai(b,d)}));let x=P(c,"renderText",u);return x&&(f.toText=x),[c.name,f]})),l=Object.fromEntries(i.map(c=>{let d=r.filter(x=>x.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:t},h=n.reduce((x,b)=>{let k=P(b,"extendMarkSchema",u);return{...x,...k?k(c):{}}},{}),f=Kh({...h,inclusive:H(P(c,"inclusive",u)),excludes:H(P(c,"excludes",u)),group:H(P(c,"group",u)),spanning:H(P(c,"spanning",u)),code:H(P(c,"code",u)),attrs:Object.fromEntries(d.map(x=>{var b,k;return[x.name,{default:(b=x?.attribute)==null?void 0:b.default,validate:(k=x?.attribute)==null?void 0:k.validate}]}))}),p=H(P(c,"parseHTML",u));p&&(f.parseDOM=p.map(x=>Uh(x,d)));let y=P(c,"renderHTML",u);return y&&(f.toDOM=x=>y({mark:x,HTMLAttributes:ai(x,d)})),[c.name,f]}));return new Rn({topNode:s,nodes:a,marks:l})}function z0(n){let t=n.filter((e,r)=>n.indexOf(e)!==r);return Array.from(new Set(t))}function Pl(n){return n.sort((e,r)=>{let o=P(e,"priority")||100,i=P(r,"priority")||100;return o>i?-1:o<i?1:0})}function ef(n){let t=Pl(Ol(n)),e=z0(t.map(r=>r.name));return e.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${e.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),t}function nf(n,t,e){let{from:r,to:o}=t,{blockSeparator:i=`
`,textSerializers:s={}}=e||{},a="";return n.nodesBetween(r,o,(l,c,d,u)=>{var h;l.isBlock&&c>r&&(a+=i);let f=s?.[l.type.name];if(f)return d&&(a+=f({node:l,pos:c,parent:d,index:u,range:t})),!1;l.isText&&(a+=(h=l?.text)==null?void 0:h.slice(Math.max(r,c)-c,o-c))}),a}function H0(n,t){let e={from:0,to:n.content.size};return nf(n,e,t)}function rf(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,t])=>t.spec.toText).map(([t,e])=>[t,e.spec.toText]))}function Te(n,t){if(typeof n=="string"){if(!t.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return t.marks[n]}return n}function of(n,t){let e=Te(t,n.schema),{from:r,to:o,empty:i}=n.selection,s=[];i?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,l=>{s.push(...l.marks)});let a=s.find(l=>l.type.name===e.name);return a?{...a.attrs}:{}}function q(n,t){if(typeof n=="string"){if(!t.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return t.nodes[n]}return n}function F0(n,t){let e=q(t,n.schema),{from:r,to:o}=n.selection,i=[];n.doc.nodesBetween(r,o,a=>{i.push(a)});let s=i.reverse().find(a=>a.type.name===e.name);return s?{...s.attrs}:{}}function ui(n,t){return t.nodes[n]?"node":t.marks[n]?"mark":null}function Rl(n,t){let e=ui(typeof t=="string"?t:t.name,n.schema);return e==="node"?F0(n,t):e==="mark"?of(n,t):{}}function V0(n,t=JSON.stringify){let e={};return n.filter(r=>{let o=t(r);return Object.prototype.hasOwnProperty.call(e,o)?!1:e[o]=!0})}function U0(n){let t=V0(n);return t.length===1?t:t.filter((e,r)=>!t.filter((i,s)=>s!==r).some(i=>e.oldRange.from>=i.oldRange.from&&e.oldRange.to<=i.oldRange.to&&e.newRange.from>=i.newRange.from&&e.newRange.to<=i.newRange.to))}function Dl(n){let{mapping:t,steps:e}=n,r=[];return t.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((a,l)=>{s.push({from:a,to:l})});else{let{from:a,to:l}=e[i];if(a===void 0||l===void 0)return;s.push({from:a,to:l})}s.forEach(({from:a,to:l})=>{let c=t.slice(i).map(a,-1),d=t.slice(i).map(l),u=t.invert().map(c,-1),h=t.invert().map(d);r.push({oldRange:{from:u,to:h},newRange:{from:c,to:d}})})}),U0(r)}function $l(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Yn(n,t,e={strict:!0}){let r=Object.keys(t);return r.length?r.every(o=>e.strict?t[o]===n[o]:$l(t[o])?t[o].test(n[o]):t[o]===n[o]):!0}function sf(n,t,e={}){return n.find(r=>r.type===t&&Yn(Object.fromEntries(Object.keys(e).map(o=>[o,r.attrs[o]])),e))}function jh(n,t,e={}){return!!sf(n,t,e)}function Il(n,t,e){var r;if(!n||!t)return;let o=n.parent.childAfter(n.parentOffset);if((!o.node||!o.node.marks.some(d=>d.type===t))&&(o=n.parent.childBefore(n.parentOffset)),!o.node||!o.node.marks.some(d=>d.type===t)||(e=e||((r=o.node.marks[0])==null?void 0:r.attrs),!sf([...o.node.marks],t,e)))return;let s=o.index,a=n.start()+o.offset,l=s+1,c=a+o.node.nodeSize;for(;s>0&&jh([...n.parent.child(s-1).marks],t,e);)s-=1,a-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&jh([...n.parent.child(l).marks],t,e);)c+=n.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function hi(n,t,e){let r=[];return n===t?e.resolve(n).marks().forEach(o=>{let i=e.resolve(n),s=Il(i,o.type);s&&r.push({mark:o,...s})}):e.nodesBetween(n,t,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var af=(n,t,e,r=20)=>{let o=n.doc.resolve(e),i=r,s=null;for(;i>0&&s===null;){let a=o.node(i);a?.type.name===t?s=a:i-=1}return[s,i]};function El(n,t){return t.nodes[n]||t.marks[n]||null}function si(n,t,e){return Object.fromEntries(Object.entries(e).filter(([r])=>{let o=n.find(i=>i.type===t&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var K0=(n,t=500)=>{let e="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-t),r,(o,i,s,a)=>{var l,c;let d=((c=(l=o.type.spec).toText)==null?void 0:c.call(l,{node:o,pos:i,parent:s,index:a}))||o.textContent||"%leaf%";e+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-i))}),e};function _l(n,t,e={}){let{empty:r,ranges:o}=n.selection,i=t?Te(t,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>Yn(u.attrs,e,{strict:!1}));let s=0,a=[];if(o.forEach(({$from:u,$to:h})=>{let f=u.pos,p=h.pos;n.doc.nodesBetween(f,p,(y,x)=>{if(!y.isText&&!y.marks.length)return;let b=Math.max(f,x),k=Math.min(p,x+y.nodeSize),m=k-b;s+=m,a.push(...y.marks.map(g=>({mark:g,from:b,to:k})))})}),s===0)return!1;let l=a.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>Yn(u.mark.attrs,e,{strict:!1})).reduce((u,h)=>u+h.to-h.from,0),c=a.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,h)=>u+h.to-h.from,0);return(l>0?l+c:l)>=s}function ie(n,t,e={}){let{from:r,to:o,empty:i}=n.selection,s=t?q(t,n.schema):null,a=[];n.doc.nodesBetween(r,o,(u,h)=>{if(u.isText)return;let f=Math.max(r,h),p=Math.min(o,h+u.nodeSize);a.push({node:u,from:f,to:p})});let l=o-r,c=a.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>Yn(u.node.attrs,e,{strict:!1}));return i?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=l}function j0(n,t,e={}){if(!t)return ie(n,null,e)||_l(n,null,e);let r=ui(t,n.schema);return r==="node"?ie(n,t,e):r==="mark"?_l(n,t,e):!1}var lf=(n,t)=>{let{$from:e,$to:r,$anchor:o}=n.selection;if(t){let i=di(a=>a.type.name===t)(n.selection);if(!i)return!1;let s=n.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||e.pos!==r.pos)},cf=n=>{let{$from:t,$to:e}=n.selection;return!(t.parentOffset>0||t.pos!==e.pos)};function Wh(n,t){return Array.isArray(t)?t.some(e=>(typeof e=="string"?e:e.name)===n.name):t}function qh(n,t){let{nodeExtensions:e}=Br(t),r=e.find(s=>s.name===n);if(!r)return!1;let o={name:r.name,options:r.options,storage:r.storage},i=H(P(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function zr(n,{checkChildren:t=!0,ignoreWhitespace:e=!1}={}){var r;if(e){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(t){let o=!0;return n.content.forEach(i=>{o!==!1&&(zr(i,{ignoreWhitespace:e,checkChildren:t})||(o=!1))}),o}return!1}function Ue(n){return n instanceof N}function fi(n){return n instanceof _}function Ae(n=0,t=0,e=0){return Math.min(Math.max(n,t),e)}function pi(n,t,e){let o=n.state.doc.content.size,i=Ae(t,0,o),s=Ae(e,0,o),a=n.coordsAtPos(i),l=n.coordsAtPos(s,-1),c=Math.min(a.top,l.top),d=Math.max(a.bottom,l.bottom),u=Math.min(a.left,l.left),h=Math.max(a.right,l.right),f=h-u,p=d-c,b={top:c,bottom:d,left:u,right:h,width:f,height:p,x:u,y:c};return{...b,toJSON:()=>b}}function df(n,t=null){if(!t)return null;let e=R.atStart(n),r=R.atEnd(n);if(t==="start"||t===!0)return e;if(t==="end")return r;let o=e.from,i=r.to;return t==="all"?_.create(n,Ae(0,o,i),Ae(n.content.size,o,i)):_.create(n,Ae(t,o,i),Ae(t,o,i))}function Ll(n,t,e){let r=n.steps.length-1;if(r<t)return;let o=n.steps[r];if(!(o instanceof at||o instanceof J))return;let i=n.mapping.maps[r],s=0;i.forEach((a,l,c,d)=>{s===0&&(s=d)}),n.setSelection(R.near(n.doc.resolve(s),e))}var mi=class{constructor(n){this.find=n.find,this.handler=n.handler}},W0=(n,t)=>{if($l(t))return t.exec(n);let e=t(n);if(!e)return null;let r=[e.text];return r.index=e.index,r.input=n,r.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(e.replaceWith)),r};function ri(n){var t;let{editor:e,from:r,to:o,text:i,rules:s,plugin:a}=n,{view:l}=e;if(l.composing)return!1;let c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(t=c.nodeBefore||c.nodeAfter)!=null&&t.marks.find(h=>h.type.spec.code))return!1;let d=!1,u=K0(c)+i;return s.forEach(h=>{if(d)return;let f=W0(u,h.find);if(!f)return;let p=l.state.tr,y=li({state:l.state,transaction:p}),x={from:r-(f[0].length-i.length),to:o},{commands:b,chain:k,can:m}=new ci({editor:e,state:y});h.handler({state:y,range:x,match:f,commands:b,chain:k,can:m})===null||!p.steps.length||(p.setMeta(a,{transform:p,from:r,to:o,text:i}),l.dispatch(p),d=!0)}),d}function q0(n){let{editor:t,rules:e}=n,r=new O({state:{init(){return null},apply(o,i,s){let a=o.getMeta(r);if(a)return a;let l=o.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=Nl(w.from(d),s.schema);let{from:u}=l,h=u+d.length;ri({editor:t,from:u,to:h,text:d,rules:e,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,a){return ri({editor:t,from:i,to:s,text:a,rules:e,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&ri({editor:t,from:i.pos,to:i.pos,text:"",rules:e,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?ri({editor:t,from:s.pos,to:s.pos,text:`
`,rules:e,plugin:r}):!1}},isInputRules:!0});return r}function J0(n){return Object.prototype.toString.call(n).slice(8,-1)}function oi(n){return J0(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function uf(n,t){let e={...n};return oi(n)&&oi(t)&&Object.keys(t).forEach(r=>{oi(t[r])&&oi(n[r])?e[r]=uf(n[r],t[r]):e[r]=t[r]}),e}var Bl=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...H(P(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...H(P(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){let t=this.extend({...this.config,addOptions:()=>uf(this.options,n)});return t.name=this.name,t.parent=this.parent,t}extend(n={}){let t=new this.constructor({...this.config,...n});return t.parent=this,this.child=t,t.name="name"in n?n.name:t.parent.name,t}},$t=class hf extends Bl{constructor(){super(...arguments),this.type="mark"}static create(t={}){let e=typeof t=="function"?t():t;return new hf(e)}static handleExit({editor:t,mark:e}){let{tr:r}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){let s=o.marks();if(!!!s.find(c=>c?.type.name===e.name))return!1;let l=s.find(c=>c?.type.name===e.name);return l&&r.removeStoredMark(l),r.insertText(" ",o.pos),t.view.dispatch(r),!0}return!1}configure(t){return super.configure(t)}extend(t){let e=typeof t=="function"?t():t;return super.extend(e)}};function G0(n){return typeof n=="number"}var X0=class{constructor(n){this.find=n.find,this.handler=n.handler}},Y0=(n,t,e)=>{if($l(t))return[...n.matchAll(t)];let r=t(n,e);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=n,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function Q0(n){let{editor:t,state:e,from:r,to:o,rule:i,pasteEvent:s,dropEvent:a}=n,{commands:l,chain:c,can:d}=new ci({editor:t,state:e}),u=[];return e.doc.nodesBetween(r,o,(f,p)=>{var y,x,b,k,m;if((x=(y=f.type)==null?void 0:y.spec)!=null&&x.code||!(f.isText||f.isTextblock||f.isInline))return;let g=(m=(k=(b=f.content)==null?void 0:b.size)!=null?k:f.nodeSize)!=null?m:0,v=Math.max(r,p),S=Math.min(o,p+g);if(v>=S)return;let C=f.isText?f.text||"":f.textBetween(v-p,S-p,void 0,"\uFFFC");Y0(C,i.find,s).forEach(B=>{if(B.index===void 0)return;let V=v+B.index+1,gt=V+B[0].length,ot={from:e.tr.mapping.map(V),to:e.tr.mapping.map(gt)},bt=i.handler({state:e,range:ot,match:B,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});u.push(bt)})}),u.every(f=>f!==null)}var ii=null,Z0=n=>{var t;let e=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=e.clipboardData)==null||t.setData("text/html",n),e};function ty(n){let{editor:t,rules:e}=n,r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}let l=({state:d,from:u,to:h,rule:f,pasteEvt:p})=>{let y=d.tr,x=li({state:d,transaction:y});if(!(!Q0({editor:t,state:x,from:Math.max(u-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:a})||!y.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return e.map(d=>new O({view(u){let h=p=>{var y;r=(y=u.dom.parentElement)!=null&&y.contains(p.target)?u.dom.parentElement:null,r&&(ii=t)},f=()=>{ii&&(ii=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,h)=>{if(i=r===u.dom.parentElement,a=h,!i){let f=ii;f?.isEditable&&setTimeout(()=>{let p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,h)=>{var f;let p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return s=h,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,h,f)=>{let p=u[0],y=p.getMeta("uiEvent")==="paste"&&!o,x=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),k=!!b;if(!y&&!x&&!k)return;if(k){let{text:v}=b;typeof v=="string"?v=v:v=Nl(w.from(v),f.schema);let{from:S}=b,C=S+v.length,M=Z0(v);return l({rule:d,state:f,from:S,to:{b:C},pasteEvt:M})}let m=h.doc.content.findDiffStart(f.doc.content),g=h.doc.content.findDiffEnd(f.doc.content);if(!(!G0(m)||!g||m===g.b))return l({rule:d,state:f,from:m,to:g,pasteEvt:s})}}))}var gi=class{constructor(n,t){this.splittableMarks=[],this.editor=t,this.extensions=ef(n),this.schema=B0(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((n,t)=>{let e={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:El(t.name,this.schema)},r=P(t,"addCommands",e);return r?{...n,...r()}:n},{})}get plugins(){let{editor:n}=this;return Pl([...this.extensions].reverse()).map(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:El(r.name,this.schema)},i=[],s=P(r,"addKeyboardShortcuts",o),a={};if(r.type==="mark"&&P(r,"exitable",o)&&(a.ArrowRight=()=>$t.handleExit({editor:n,mark:r})),s){let h=Object.fromEntries(Object.entries(s()).map(([f,p])=>[f,()=>p({editor:n})]));a={...a,...h}}let l=Ah(a);i.push(l);let c=P(r,"addInputRules",o);if(Wh(r,n.options.enableInputRules)&&c){let h=c();if(h&&h.length){let f=q0({editor:n,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}let d=P(r,"addPasteRules",o);if(Wh(r,n.options.enablePasteRules)&&d){let h=d();if(h&&h.length){let f=ty({editor:n,rules:h});i.push(...f)}}let u=P(r,"addProseMirrorPlugins",o);if(u){let h=u();i.push(...h)}return i}).flat()}get attributes(){return tf(this.extensions)}get nodeViews(){let{editor:n}=this,{nodeExtensions:t}=Br(this.extensions);return Object.fromEntries(t.filter(e=>!!P(e,"addNodeView")).map(e=>{let r=this.attributes.filter(a=>a.type===e.name),o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:n,type:q(e.name,this.schema)},i=P(e,"addNodeView",o);if(!i)return[];let s=(a,l,c,d,u)=>{let h=ai(a,r);return i()({node:a,view:l,getPos:c,decorations:d,innerDecorations:u,editor:n,extension:e,HTMLAttributes:h})};return[e.name,s]}))}get markViews(){let{editor:n}=this,{markExtensions:t}=Br(this.extensions);return Object.fromEntries(t.filter(e=>!!P(e,"addMarkView")).map(e=>{let r=this.attributes.filter(a=>a.type===e.name),o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:n,type:Te(e.name,this.schema)},i=P(e,"addMarkView",o);if(!i)return[];let s=(a,l,c)=>{let d=ai(a,r);return i()({mark:a,view:l,inline:c,editor:n,extension:e,HTMLAttributes:d,updateAttributes:u=>{f1(a,n,u)}})};return[e.name,s]}))}setupExtensions(){let n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(t=>[t.name,t.storage])),n.forEach(t=>{var e;let r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:El(t.name,this.schema)};t.type==="mark"&&((e=H(P(t,"keepOnSplit",r)))==null||e)&&this.splittableMarks.push(t.name);let o=P(t,"onBeforeCreate",r),i=P(t,"onCreate",r),s=P(t,"onUpdate",r),a=P(t,"onSelectionUpdate",r),l=P(t,"onTransaction",r),c=P(t,"onFocus",r),d=P(t,"onBlur",r),u=P(t,"onDestroy",r);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),s&&this.editor.on("update",s),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};gi.resolve=ef;gi.sort=Pl;gi.flatten=Ol;var ey={};Xh(ey,{ClipboardTextSerializer:()=>pf,Commands:()=>bf,Delete:()=>yf,Drop:()=>vf,Editable:()=>xf,FocusEvents:()=>Sf,Keymap:()=>wf,Paste:()=>Ef,Tabindex:()=>Mf,focusEventsPluginKey:()=>kf});var L=class ff extends Bl{constructor(){super(...arguments),this.type="extension"}static create(t={}){let e=typeof t=="function"?t():t;return new ff(e)}configure(t){return super.configure(t)}extend(t){let e=typeof t=="function"?t():t;return super.extend(e)}},pf=L.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new O({key:new D("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:t,schema:e}=n,{doc:r,selection:o}=t,{ranges:i}=o,s=Math.min(...i.map(d=>d.$from.pos)),a=Math.max(...i.map(d=>d.$to.pos)),l=rf(e);return nf(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),mf={};Xh(mf,{blur:()=>ny,clearContent:()=>ry,clearNodes:()=>oy,command:()=>iy,createParagraphNear:()=>sy,cut:()=>ay,deleteCurrentNode:()=>ly,deleteNode:()=>cy,deleteRange:()=>dy,deleteSelection:()=>uy,enter:()=>hy,exitCode:()=>fy,extendMarkRange:()=>py,first:()=>my,focus:()=>by,forEach:()=>yy,insertContent:()=>vy,insertContentAt:()=>ky,joinBackward:()=>Ey,joinDown:()=>wy,joinForward:()=>My,joinItemBackward:()=>Ay,joinItemForward:()=>Ty,joinTextblockBackward:()=>_y,joinTextblockForward:()=>Cy,joinUp:()=>Sy,keyboardShortcut:()=>Ny,lift:()=>Py,liftEmptyBlock:()=>Ry,liftListItem:()=>Dy,newlineInCode:()=>$y,resetAttributes:()=>Iy,scrollIntoView:()=>Ly,selectAll:()=>By,selectNodeBackward:()=>zy,selectNodeForward:()=>Hy,selectParentNode:()=>Fy,selectTextblockEnd:()=>Vy,selectTextblockStart:()=>Uy,setContent:()=>Ky,setMark:()=>Wy,setMeta:()=>qy,setNode:()=>Jy,setNodeSelection:()=>Gy,setTextSelection:()=>Xy,sinkListItem:()=>Yy,splitBlock:()=>Qy,splitListItem:()=>Zy,toggleList:()=>t1,toggleMark:()=>e1,toggleNode:()=>n1,toggleWrap:()=>r1,undoInputRule:()=>o1,unsetAllMarks:()=>i1,unsetMark:()=>s1,updateAttributes:()=>a1,wrapIn:()=>l1,wrapInList:()=>c1});var ny=()=>({editor:n,view:t})=>(requestAnimationFrame(()=>{var e;n.isDestroyed||(t.dom.blur(),(e=window?.getSelection())==null||e.removeAllRanges())}),!0),ry=(n=!0)=>({commands:t})=>t.setContent("",{emitUpdate:n}),oy=()=>({state:n,tr:t,dispatch:e})=>{let{selection:r}=t,{ranges:o}=r;return e&&o.forEach(({$from:i,$to:s})=>{n.doc.nodesBetween(i.pos,s.pos,(a,l)=>{if(a.type.isText)return;let{doc:c,mapping:d}=t,u=c.resolve(d.map(l)),h=c.resolve(d.map(l+a.nodeSize)),f=u.blockRange(h);if(!f)return;let p=Se(f);if(a.type.isTextblock){let{defaultType:y}=u.parent.contentMatchAt(u.index());t.setNodeMarkup(f.start,y)}(p||p===0)&&t.lift(f,p)})}),!0},iy=n=>t=>n(t),sy=()=>({state:n,dispatch:t})=>Jn(n,t),ay=(n,t)=>({editor:e,tr:r})=>{let{state:o}=e,i=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let s=r.mapping.map(t);return r.insert(s,i.content),r.setSelection(new _(r.doc.resolve(Math.max(s-1,0)))),!0},ly=()=>({tr:n,dispatch:t})=>{let{selection:e}=n,r=e.$anchor.node();if(r.content.size>0)return!1;let o=n.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(t){let a=o.before(i),l=o.after(i);n.delete(a,l).scrollIntoView()}return!0}return!1},cy=n=>({tr:t,state:e,dispatch:r})=>{let o=q(n,e.schema),i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let l=i.before(s),c=i.after(s);t.delete(l,c).scrollIntoView()}return!0}return!1},dy=n=>({tr:t,dispatch:e})=>{let{from:r,to:o}=n;return e&&t.delete(r,o),!0},uy=()=>({state:n,dispatch:t})=>ei(n,t),hy=()=>({commands:n})=>n.keyboardShortcut("Enter"),fy=()=>({state:n,dispatch:t})=>vl(n,t),py=(n,t={})=>({tr:e,state:r,dispatch:o})=>{let i=Te(n,r.schema),{doc:s,selection:a}=e,{$from:l,from:c,to:d}=a;if(o){let u=Il(l,i,t);if(u&&u.from<=c&&u.to>=d){let h=_.create(s,u.from,u.to);e.setSelection(h)}}return!0},my=n=>t=>{let e=typeof n=="function"?n(t):n;for(let r=0;r<e.length;r+=1)if(e[r](t))return!0;return!1};function gy(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function zl(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var by=(n=null,t={})=>({editor:e,view:r,tr:o,dispatch:i})=>{t={scrollIntoView:!0,...t};let s=()=>{(zl()||gy())&&r.dom.focus(),requestAnimationFrame(()=>{e.isDestroyed||(r.focus(),t?.scrollIntoView&&e.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!fi(e.state.selection))return s(),!0;let a=df(o.doc,n)||e.state.selection,l=e.state.selection.eq(a);return i&&(l||o.setSelection(a),l&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},yy=(n,t)=>e=>n.every((r,o)=>t(r,{...e,index:o})),vy=(n,t)=>({tr:e,commands:r})=>r.insertContentAt({from:e.selection.from,to:e.selection.to},n,t),xy=n=>!("type"in n),ky=(n,t,e)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){e={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...e};let a,l=x=>{i.emit("contentError",{editor:i,error:x,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...e.parseOptions};if(!e.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Lr(t,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(x){l(x)}try{a=Lr(t,i.schema,{parseOptions:c,errorOnInvalidContent:(s=e.errorOnInvalidContent)!=null?s:i.options.enableContentCheck})}catch(x){return l(x),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,f=!0;if((xy(a)?a:[a]).forEach(x=>{x.check(),h=h?x.isText&&x.marks.length===0:!1,f=f?x.isBlock:!1}),d===u&&f){let{parent:x}=r.doc.resolve(d);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(d-=1,u+=1)}let y;if(h){if(Array.isArray(t))y=t.map(x=>x.text||"").join("");else if(t instanceof w){let x="";t.forEach(b=>{b.text&&(x+=b.text)}),y=x}else typeof t=="object"&&t&&t.text?y=t.text:y=t;r.insertText(y,d,u)}else{y=a;let x=r.doc.resolve(d),b=x.node(),k=x.parentOffset===0,m=b.isText||b.isTextblock,g=b.content.size>0;k&&m&&g&&(d=Math.max(0,d-1)),r.replaceWith(d,u,y)}e.updateSelection&&Ll(r,r.steps.length-1,-1),e.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),e.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},Sy=()=>({state:n,dispatch:t})=>Rh(n,t),wy=()=>({state:n,dispatch:t})=>Dh(n,t),Ey=()=>({state:n,dispatch:t})=>ul(n,t),My=()=>({state:n,dispatch:t})=>pl(n,t),Ay=()=>({state:n,dispatch:t,tr:e})=>{try{let r=ln(n.doc,n.selection.$from.pos,-1);return r==null?!1:(e.join(r,2),t&&t(e),!0)}catch{return!1}},Ty=()=>({state:n,dispatch:t,tr:e})=>{try{let r=ln(n.doc,n.selection.$from.pos,1);return r==null?!1:(e.join(r,2),t&&t(e),!0)}catch{return!1}},_y=()=>({state:n,dispatch:t})=>Ch(n,t),Cy=()=>({state:n,dispatch:t})=>Oh(n,t);function gf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Oy(n){let t=n.split(/-(?!$)/),e=t[t.length-1];e==="Space"&&(e=" ");let r,o,i,s;for(let a=0;a<t.length-1;a+=1){let l=t[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))zl()||gf()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(e=`Alt-${e}`),o&&(e=`Ctrl-${e}`),s&&(e=`Meta-${e}`),i&&(e=`Shift-${e}`),e}var Ny=n=>({editor:t,view:e,tr:r,dispatch:o})=>{let i=Oy(n).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{e.someProp("handleKeyDown",c=>c(e,a))});return l?.steps.forEach(c=>{let d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0},Py=(n,t={})=>({state:e,dispatch:r})=>{let o=q(n,e.schema);return ie(e,o,t)?$h(e,r):!1},Ry=()=>({state:n,dispatch:t})=>xl(n,t),Dy=n=>({state:t,dispatch:e})=>{let r=q(n,t.schema);return Fh(r)(t,e)},$y=()=>({state:n,dispatch:t})=>bl(n,t);function Jh(n,t){let e=typeof t=="string"?[t]:t;return Object.keys(n).reduce((r,o)=>(e.includes(o)||(r[o]=n[o]),r),{})}var Iy=(n,t)=>({tr:e,state:r,dispatch:o})=>{let i=null,s=null,a=ui(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(i=q(n,r.schema)),a==="mark"&&(s=Te(n,r.schema)),o&&e.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,d)=>{i&&i===c.type&&e.setNodeMarkup(d,void 0,Jh(c.attrs,t)),s&&c.marks.length&&c.marks.forEach(u=>{s===u.type&&e.addMark(d,d+c.nodeSize,s.create(Jh(u.attrs,t)))})})}),!0):!1},Ly=()=>({tr:n,dispatch:t})=>(t&&n.scrollIntoView(),!0),By=()=>({tr:n,dispatch:t})=>{if(t){let e=new yt(n.doc);n.setSelection(e)}return!0},zy=()=>({state:n,dispatch:t})=>hl(n,t),Hy=()=>({state:n,dispatch:t})=>ml(n,t),Fy=()=>({state:n,dispatch:t})=>Ih(n,t),Vy=()=>({state:n,dispatch:t})=>Sl(n,t),Uy=()=>({state:n,dispatch:t})=>kl(n,t),Ky=(n,{errorOnInvalidContent:t,emitUpdate:e=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:a})=>{let{doc:l}=i;if(r.preserveWhitespace!=="full"){let c=Tl(n,o.schema,r,{errorOnInvalidContent:t??o.options.enableContentCheck});return s&&i.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!e),!0}return s&&i.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:l.content.size},n,{parseOptions:r,errorOnInvalidContent:t??o.options.enableContentCheck})};function jy(n,t,e){var r;let{selection:o}=t,i=null;if(fi(o)&&(i=o.$cursor),i){let a=(r=n.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(e)&&(!!e.isInSet(a)||!a.some(c=>c.type.excludes(e)))}let{ranges:s}=o;return s.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(e):!1;return n.doc.nodesBetween(a.pos,l.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){let f=!h||h.type.allowsMarkType(e),p=!!e.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(e));c=f&&p}return!c}),c})}var Wy=(n,t={})=>({tr:e,state:r,dispatch:o})=>{let{selection:i}=e,{empty:s,ranges:a}=i,l=Te(n,r.schema);if(o)if(s){let c=of(r,l);e.addStoredMark(l.create({...c,...t}))}else a.forEach(c=>{let d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,f)=>{let p=Math.max(f,d),y=Math.min(f+h.nodeSize,u);h.marks.find(b=>b.type===l)?h.marks.forEach(b=>{l===b.type&&e.addMark(p,y,l.create({...b.attrs,...t}))}):e.addMark(p,y,l.create(t))})});return jy(r,e,l)},qy=(n,t)=>({tr:e})=>(e.setMeta(n,t),!0),Jy=(n,t={})=>({state:e,dispatch:r,chain:o})=>{let i=q(n,e.schema),s;return e.selection.$anchor.sameParent(e.selection.$head)&&(s=e.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:a})=>wl(i,{...s,...t})(e)?!0:a.clearNodes()).command(({state:a})=>wl(i,{...s,...t})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Gy=n=>({tr:t,dispatch:e})=>{if(e){let{doc:r}=t,o=Ae(n,0,r.content.size),i=N.create(r,o);t.setSelection(i)}return!0},Xy=n=>({tr:t,dispatch:e})=>{if(e){let{doc:r}=t,{from:o,to:i}=typeof n=="number"?{from:n,to:n}:n,s=_.atStart(r).from,a=_.atEnd(r).to,l=Ae(o,s,a),c=Ae(i,s,a),d=_.create(r,l,c);t.setSelection(d)}return!0},Yy=n=>({state:t,dispatch:e})=>{let r=q(n,t.schema);return Vh(r)(t,e)};function Gh(n,t){let e=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(e){let r=e.filter(o=>t?.includes(o.type.name));n.tr.ensureMarks(r)}}var Qy=({keepMarks:n=!0}={})=>({tr:t,state:e,dispatch:r,editor:o})=>{let{selection:i,doc:s}=t,{$from:a,$to:l}=i,c=o.extensionManager.attributes,d=si(c,a.node().type.name,a.node().attrs);if(i instanceof N&&i.node.isBlock)return!a.parentOffset||!Rt(s,a.pos)?!1:(r&&(n&&Gh(e,o.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;let u=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:D0(a.node(-1).contentMatchAt(a.indexAfter(-1))),f=u&&h?[{type:h,attrs:d}]:void 0,p=Rt(t.doc,t.mapping.map(a.pos),1,f);if(!f&&!p&&Rt(t.doc,t.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:d}]:void 0),r){if(p&&(i instanceof _&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,f),h&&!u&&!a.parentOffset&&a.parent.type!==h)){let y=t.mapping.map(a.before()),x=t.doc.resolve(y);a.node(-1).canReplaceWith(x.index(),x.index()+1,h)&&t.setNodeMarkup(t.mapping.map(a.before()),h)}n&&Gh(e,o.extensionManager.splittableMarks),t.scrollIntoView()}return p},Zy=(n,t={})=>({tr:e,state:r,dispatch:o,editor:i})=>{var s;let a=q(n,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;let u=l.node(-1);if(u.type!==a)return!1;let h=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){let b=w.empty,k=l.index(-1)?1:l.index(-2)?2:3;for(let M=l.depth-k;M>=l.depth-3;M-=1)b=w.from(l.node(M).copy(b));let m=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,g={...si(h,l.node().type.name,l.node().attrs),...t},v=((s=a.contentMatch.defaultType)==null?void 0:s.createAndFill(g))||void 0;b=b.append(w.from(a.createAndFill(null,v)||void 0));let S=l.before(l.depth-(k-1));e.replace(S,l.after(-m),new A(b,4-k,0));let C=-1;e.doc.nodesBetween(S,e.doc.content.size,(M,B)=>{if(C>-1)return!1;M.isTextblock&&M.content.size===0&&(C=B+1)}),C>-1&&e.setSelection(_.near(e.doc.resolve(C))),e.scrollIntoView()}return!0}let f=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,p={...si(h,u.type.name,u.attrs),...t},y={...si(h,l.node().type.name,l.node().attrs),...t};e.delete(l.pos,c.pos);let x=f?[{type:a,attrs:p},{type:f,attrs:y}]:[{type:a,attrs:p}];if(!Rt(e.doc,l.pos,2))return!1;if(o){let{selection:b,storedMarks:k}=r,{splittableMarks:m}=i.extensionManager,g=k||b.$to.parentOffset&&b.$from.marks();if(e.split(l.pos,2,x).scrollIntoView(),!g||!o)return!0;let v=g.filter(S=>m.includes(S.type.name));e.ensureMarks(v)}return!0},Ml=(n,t)=>{let e=di(s=>s.type===t)(n.selection);if(!e)return!0;let r=n.doc.resolve(Math.max(0,e.pos-1)).before(e.depth);if(r===void 0)return!0;let o=n.doc.nodeAt(r);return e.node.type===o?.type&&Bt(n.doc,e.pos)&&n.join(e.pos),!0},Al=(n,t)=>{let e=di(s=>s.type===t)(n.selection);if(!e)return!0;let r=n.doc.resolve(e.start).after(e.depth);if(r===void 0)return!0;let o=n.doc.nodeAt(r);return e.node.type===o?.type&&Bt(n.doc,r)&&n.join(r),!0},t1=(n,t,e,r={})=>({editor:o,tr:i,state:s,dispatch:a,chain:l,commands:c,can:d})=>{let{extensions:u,splittableMarks:h}=o.extensionManager,f=q(n,s.schema),p=q(t,s.schema),{selection:y,storedMarks:x}=s,{$from:b,$to:k}=y,m=b.blockRange(k),g=x||y.$to.parentOffset&&y.$from.marks();if(!m)return!1;let v=di(S=>qh(S.type.name,u))(y);if(m.depth>=1&&v&&m.depth-v.depth<=1){if(v.node.type===f)return c.liftListItem(p);if(qh(v.node.type.name,u)&&f.validContent(v.node.content)&&a)return l().command(()=>(i.setNodeMarkup(v.pos,f),!0)).command(()=>Ml(i,f)).command(()=>Al(i,f)).run()}return!e||!g||!a?l().command(()=>d().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>Ml(i,f)).command(()=>Al(i,f)).run():l().command(()=>{let S=d().wrapInList(f,r),C=g.filter(M=>h.includes(M.type.name));return i.ensureMarks(C),S?!0:c.clearNodes()}).wrapInList(f,r).command(()=>Ml(i,f)).command(()=>Al(i,f)).run()},e1=(n,t={},e={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=e,s=Te(n,r.schema);return _l(r,s,t)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,t)},n1=(n,t,e={})=>({state:r,commands:o})=>{let i=q(n,r.schema),s=q(t,r.schema),a=ie(r,i,e),l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?o.setNode(s,l):o.setNode(i,{...l,...e})},r1=(n,t={})=>({state:e,commands:r})=>{let o=q(n,e.schema);return ie(e,o,t)?r.lift(o):r.wrapIn(o,t)},o1=()=>({state:n,dispatch:t})=>{let e=n.plugins;for(let r=0;r<e.length;r+=1){let o=e[r],i;if(o.spec.isInputRules&&(i=o.getState(n))){if(t){let s=n.tr,a=i.transform;for(let l=a.steps.length-1;l>=0;l-=1)s.step(a.steps[l].invert(a.docs[l]));if(i.text){let l=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,l))}else s.delete(i.from,i.to)}return!0}}return!1},i1=()=>({tr:n,dispatch:t})=>{let{selection:e}=n,{empty:r,ranges:o}=e;return r||t&&o.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},s1=(n,t={})=>({tr:e,state:r,dispatch:o})=>{var i;let{extendEmptyMarkRange:s=!1}=t,{selection:a}=e,l=Te(n,r.schema),{$from:c,empty:d,ranges:u}=a;if(!o)return!0;if(d&&s){let{from:h,to:f}=a,p=(i=c.marks().find(x=>x.type===l))==null?void 0:i.attrs,y=Il(c,l,p);y&&(h=y.from,f=y.to),e.removeMark(h,f,l)}else u.forEach(h=>{e.removeMark(h.$from.pos,h.$to.pos,l)});return e.removeStoredMark(l),!0},a1=(n,t={})=>({tr:e,state:r,dispatch:o})=>{let i=null,s=null,a=ui(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(i=q(n,r.schema)),a==="mark"&&(s=Te(n,r.schema)),o&&e.selection.ranges.forEach(l=>{let c=l.$from.pos,d=l.$to.pos,u,h,f,p;e.selection.empty?r.doc.nodesBetween(c,d,(y,x)=>{i&&i===y.type&&(f=Math.max(x,c),p=Math.min(x+y.nodeSize,d),u=x,h=y)}):r.doc.nodesBetween(c,d,(y,x)=>{x<c&&i&&i===y.type&&(f=Math.max(x,c),p=Math.min(x+y.nodeSize,d),u=x,h=y),x>=c&&x<=d&&(i&&i===y.type&&e.setNodeMarkup(x,void 0,{...y.attrs,...t}),s&&y.marks.length&&y.marks.forEach(b=>{if(s===b.type){let k=Math.max(x,c),m=Math.min(x+y.nodeSize,d);e.addMark(k,m,s.create({...b.attrs,...t}))}}))}),h&&(u!==void 0&&e.setNodeMarkup(u,void 0,{...h.attrs,...t}),s&&h.marks.length&&h.marks.forEach(y=>{s===y.type&&e.addMark(f,p,s.create({...y.attrs,...t}))}))}),!0):!1},l1=(n,t={})=>({state:e,dispatch:r})=>{let o=q(n,e.schema);return zh(o,t)(e,r)},c1=(n,t={})=>({state:e,dispatch:r})=>{let o=q(n,e.schema);return Hh(o,t)(e,r)},bf=L.create({name:"commands",addCommands(){return{...mf}}}),yf=L.create({name:"delete",onUpdate({transaction:n,appendedTransactions:t}){var e,r,o;let i=()=>{var s,a,l,c;if((c=(l=(a=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,n))!=null?c:n.getMeta("y-sync$"))return;let d=Cl(n.before,[n,...t]);Dl(d).forEach(f=>{d.mapping.mapResult(f.oldRange.from).deletedAfter&&d.mapping.mapResult(f.oldRange.to).deletedBefore&&d.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,y)=>{let x=y+p.nodeSize-2,b=f.oldRange.from<=y&&x<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:y,to:x,newFrom:d.mapping.map(y),newTo:d.mapping.map(x),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:n,combinedTransform:d})})});let h=d.mapping;d.steps.forEach((f,p)=>{var y,x;if(f instanceof ke){let b=h.slice(p).map(f.from,-1),k=h.slice(p).map(f.to),m=h.invert().map(b,-1),g=h.invert().map(k),v=(y=d.doc.nodeAt(b-1))==null?void 0:y.marks.some(C=>C.eq(f.mark)),S=(x=d.doc.nodeAt(k))==null?void 0:x.marks.some(C=>C.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:m,to:g},newRange:{from:b,to:k},partial:!!(S||v),editor:this.editor,transaction:n,combinedTransform:d})}})};(o=(r=(e=this.editor.options.coreExtensionOptions)==null?void 0:e.delete)==null?void 0:r.async)==null||o?setTimeout(i,0):i()}}),vf=L.create({name:"drop",addProseMirrorPlugins(){return[new O({key:new D("tiptapDrop"),props:{handleDrop:(n,t,e,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:e,moved:r})}}})]}}),xf=L.create({name:"editable",addProseMirrorPlugins(){return[new O({key:new D("editable"),props:{editable:()=>this.editor.options.editable}})]}}),kf=new D("focusEvents"),Sf=L.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new O({key:kf,props:{handleDOMEvents:{focus:(t,e)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:e}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,e)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:e}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),wf=L.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{let{selection:l,doc:c}=a,{empty:d,$anchor:u}=l,{pos:h,parent:f}=u,p=u.parent.isTextblock&&h>0?a.doc.resolve(h-1):u,y=p.parent.type.spec.isolating,x=u.pos-u.parentOffset,b=y&&p.parent.childCount===1?x===u.pos:R.atStart(c).from===h;return!d||!f.type.isTextblock||f.textContent.length||!b||b&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return zl()||gf()?i:o},addProseMirrorPlugins(){return[new O({key:new D("clearDocument"),appendTransaction:(n,t,e)=>{if(n.some(y=>y.getMeta("composition")))return;let r=n.some(y=>y.docChanged)&&!t.doc.eq(e.doc),o=n.some(y=>y.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:a}=t.selection,l=R.atStart(t.doc).from,c=R.atEnd(t.doc).to;if(i||!(s===l&&a===c)||!zr(e.doc))return;let h=e.tr,f=li({state:e,transaction:h}),{commands:p}=new ci({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),Ef=L.create({name:"paste",addProseMirrorPlugins(){return[new O({key:new D("tiptapPaste"),props:{handlePaste:(n,t,e)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:e})}}})]}}),Mf=L.create({name:"tabindex",addProseMirrorPlugins(){return[new O({key:new D("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),d1=class Xn{constructor(t,e,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=e,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!=null?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}e=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:e,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),e=this.resolvedPos.doc.resolve(t);return new Xn(e,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new Xn(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new Xn(t,this.editor)}get children(){let t=[];return this.node.content.forEach((e,r)=>{let o=e.isBlock&&!e.isTextblock,i=e.isAtom&&!e.isText,s=this.pos+r+(i?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(s);if(!o&&a.depth<=this.depth)return;let l=new Xn(a,this.editor,o,o?e:null);o&&(l.actualDepth=this.depth+1),t.push(new Xn(a,this.editor,o,o?e:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){let t=this.children;return t[t.length-1]||null}closest(t,e={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===t)if(Object.keys(e).length>0){let i=o.node.attrs,s=Object.keys(e);for(let a=0;a<s.length;a+=1){let l=s[a];if(i[l]!==e[l])break}}else r=o;o=o.parent}return r}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;let i=Object.keys(e);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===t&&i.every(l=>e[l]===s.node.attrs[l])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(t,e,r))))}),o}setAttribute(t){let{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(e)}},u1=`.ProseMirror {
position: relative;
}
.ProseMirror {
word-wrap: break-word;
white-space: pre-wrap;
white-space: break-spaces;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}
.ProseMirror [contenteditable="false"] {
white-space: normal;
}
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
white-space: pre-wrap;
}
.ProseMirror pre {
white-space: pre-wrap;
}
img.ProseMirror-separator {
display: inline !important;
border: none !important;
margin: 0 !important;
width: 0 !important;
height: 0 !important;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
margin: 0;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-hideselection *::selection {
background: transparent;
}
.ProseMirror-hideselection *::-moz-selection {
background: transparent;
}
.ProseMirror-hideselection * {
caret-color: transparent;
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}`;function h1(n,t,e){let r=document.querySelector(`style[data-tiptap-style${e?`-${e}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return t&&o.setAttribute("nonce",t),o.setAttribute(`data-tiptap-style${e?`-${e}`:""}`,""),o.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(o),o}var Af=class extends R0{constructor(n={}){super(),this.css=null,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:o,moved:i})=>this.options.onDrop(r,o,i)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);let t=this.createDoc(),e=df(t,this.options.autofocus);this.editorState=Fo.create({doc:t,schema:this.schema,selection:e||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=h1(u1,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,t=!0){this.setOptions({editable:n}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.editorState=this.state.apply(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,t)=>{if(t==="state")return this.editorState;if(t in n)return Reflect.get(n,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,t){let e=Zh(t)?t(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:e});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;let t=this.state.plugins,e=t;if([].concat(n).forEach(o=>{let i=typeof o=="string"?`${o}$`:o.key;e=e.filter(s=>!s.key.startsWith(i))}),t.length===e.length)return;let r=this.state.reconfigure({plugins:e});return this.view.updateState(r),r}createExtensionManager(){var n,t;let r=[...this.options.enableCoreExtensions?[xf,pf.configure({blockSeparator:(t=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:t.blockSeparator}),bf,Sf,wf,Mf,vf,Ef,yf].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new gi(r,this)}createCommandManager(){this.commandManager=new ci({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=Tl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!=="collaboration"),this.createExtensionManager()}}),n=Tl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){var t;this.editorView=new Go(n,{...this.options.editorProps,attributes:{role:"textbox",...(t=this.options.editorProps)==null?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let e=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(e),this.prependClass(),this.injectCSS();let r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}let{state:t,transactions:e}=this.state.applyTransaction(n),r=!this.state.selection.eq(t.selection),o=e.includes(n),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:t}),!o)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:e.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});let s=e.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=s?.getMeta("focus"),l=s?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:s}),l&&this.emit("blur",{editor:this,event:l.event,transaction:s}),!(n.getMeta("preventUpdate")||!e.some(c=>c.docChanged)||i.doc.eq(t.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:e.slice(1)})}getAttributes(n){return Rl(this.state,n)}isActive(n,t){let e=typeof n=="string"?n:null,r=typeof n=="string"?t:n;return j0(this.state,e,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Nl(this.state.doc.content,this.schema)}getText(n){let{blockSeparator:t=`
`,textSerializers:e={}}=n||{};return H0(this.state.doc,{blockSeparator:t,textSerializers:{...rf(this.schema),...e}})}get isEmpty(){return zr(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,t;return(t=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?t:!0}$node(n,t){var e;return((e=this.$doc)==null?void 0:e.querySelector(n,t))||null}$nodes(n,t){var e;return((e=this.$doc)==null?void 0:e.querySelectorAll(n,t))||null}$pos(n){let t=this.state.doc.resolve(n);return new d1(t,this)}get $doc(){return this.$pos(0)}};function se(n){return new mi({find:n.find,handler:({state:t,range:e,match:r})=>{let o=H(n.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=t,s=r[r.length-1],a=r[0];if(s){let l=a.search(/\S/),c=e.from+a.indexOf(s),d=c+s.length;if(hi(e.from,e.to,t.doc).filter(f=>f.mark.type.excluded.find(y=>y===n.type&&y!==f.mark.type)).filter(f=>f.to>c).length)return null;d<e.to&&i.delete(d,e.to),c>e.from&&i.delete(e.from+l,c);let h=e.from+l+s.length;i.addMark(e.from+l,h,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}function Tf(n){return new mi({find:n.find,handler:({state:t,range:e,match:r})=>{let o=H(n.getAttributes,void 0,r)||{},{tr:i}=t,s=e.from,a=e.to,l=n.type.create(o);if(r[1]){let c=r[0].lastIndexOf(r[1]),d=s+c;d>a?d=a:a=d+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(d,a,l)}else if(r[0]){let c=n.type.isInline?s:s-1;i.insert(c,n.type.create(o)).delete(i.mapping.map(s),i.mapping.map(a))}i.scrollIntoView()}})}function Hr(n){return new mi({find:n.find,handler:({state:t,range:e,match:r})=>{let o=t.doc.resolve(e.from),i=H(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;t.tr.delete(e.from,e.to).setBlockType(e.from,e.from,n.type,i)}})}function ae(n){return new mi({find:n.find,handler:({state:t,range:e,match:r,chain:o})=>{let i=H(n.getAttributes,void 0,r)||{},s=t.tr.delete(e.from,e.to),l=s.doc.resolve(e.from).blockRange(),c=l&&Ln(l,n.type,i);if(!c)return null;if(s.wrap(l,c),n.keepMarks&&n.editor){let{selection:u,storedMarks:h}=t,{splittableMarks:f}=n.editor.extensionManager,p=h||u.$to.parentOffset&&u.$from.marks();if(p){let y=p.filter(x=>f.includes(x.type.name));s.ensureMarks(y)}}if(n.keepAttributes){let u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(u,i).run()}let d=s.doc.resolve(e.from-1).nodeBefore;d&&d.type===n.type&&Bt(s.doc,e.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&s.join(e.from-1)}})}function _f(n,t){let{selection:e}=n,{$from:r}=e;if(e instanceof N){let i=r.index();return r.parent.canReplaceWith(i,i+1,t)}let o=r.depth;for(;o>=0;){let i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(t))return!0;o-=1}return!1}function f1(n,t,e={}){let{state:r}=t,{doc:o,tr:i}=r,s=n;o.descendants((a,l)=>{let c=i.mapping.map(l),d=i.mapping.map(l)+a.nodeSize,u=null;if(a.marks.forEach(f=>{if(f!==s)return!1;u=f}),!u)return;let h=!1;if(Object.keys(e).forEach(f=>{e[f]!==u.attrs[f]&&(h=!0)}),h){let f=n.type.create({...n.attrs,...e});i.removeMark(c,d,n.type),i.addMark(c,d,f)}}),i.docChanged&&t.view.dispatch(i)}var F=class Cf extends Bl{constructor(){super(...arguments),this.type="node"}static create(t={}){let e=typeof t=="function"?t():t;return new Cf(e)}configure(t){return super.configure(t)}extend(t){let e=typeof t=="function"?t():t;return super.extend(e)}};function Ht(n){return new X0({find:n.find,handler:({state:t,range:e,match:r,pasteEvent:o})=>{let i=H(n.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=t,a=r[r.length-1],l=r[0],c=e.to;if(a){let d=l.search(/\S/),u=e.from+l.indexOf(a),h=u+a.length;if(hi(e.from,e.to,t.doc).filter(p=>p.mark.type.excluded.find(x=>x===n.type&&x!==p.mark.type)).filter(p=>p.to>u).length)return null;h<e.to&&s.delete(h,e.to),u>e.from&&s.delete(e.from+d,u),c=e.from+d+a.length,s.addMark(e.from+d,c,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}var Of=Y`
.ProseMirror {
position: relative;
word-wrap: break-word;
white-space: pre-wrap;
white-space: break-spaces;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
font-feature-settings: "liga" 0;
}
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
white-space: pre-wrap;
}
.ProseMirror pre {
white-space: pre-wrap;
}
img.ProseMirror-separator {
display: inline !important;
border: none !important;
margin: 0 !important;
width: 1px !important;
height: 1px !important;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
margin: 0;
min-width: 1px;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-hideselection *::selection {
background: transparent;
}
.ProseMirror-hideselection *::-moz-selection {
background: transparent;
}
.ProseMirror-hideselection * {
caret-color: transparent;
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}
.tippy-box[data-animation="fade"][data-state="hidden"] {
opacity: 0;
}
`;var Qn=(n,t)=>{if(n==="slot")return 0;if(n instanceof Function)return n(t);let{children:e,...r}=t??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,e]};var p1=/^\s*>\s$/,Nf=F.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return Qn("blockquote",{...$(this.options.HTMLAttributes,n),children:Qn("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[ae({find:p1,type:this.type})]}});var m1=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,g1=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,b1=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,y1=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Pf=$t.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return Qn("strong",{...$(this.options.HTMLAttributes,n),children:Qn("slot",{})})},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[se({find:m1,type:this.type}),se({find:b1,type:this.type})]},addPasteRules(){return[Ht({find:g1,type:this.type}),Ht({find:y1,type:this.type})]}});var v1=/(^|[^`])`([^`]+)`(?!`)$/,x1=/(^|[^`])`([^`]+)`(?!`)/g,Rf=$t.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[se({find:v1,type:this.type})]},addPasteRules(){return[Ht({find:x1,type:this.type})]}});var k1=/^```([a-z]+)?[\s\n]$/,S1=/^~~~([a-z]+)?[\s\n]$/,Df=F.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var t;let{languageClassPrefix:e}=this.options,i=[...((t=n.firstElementChild)==null?void 0:t.classList)||[]].filter(s=>s.startsWith(e)).map(s=>s.replace(e,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:t}){return["pre",$(this.options.HTMLAttributes,t),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:t})=>t.setNode(this.name,n),toggleCodeBlock:n=>({commands:t})=>t.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:n,$anchor:t}=this.editor.state.selection,e=t.pos===1;return!n||t.parent.type.name!==this.name?!1:e||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{if(!this.options.enableTabIndentation)return!1;let{state:t}=n,{selection:e}=t,{$from:r,empty:o}=e;if(r.parent.type!==this.type)return!1;let i=" ".repeat(this.options.tabSize);return o?n.commands.insertContent(i):n.commands.command(({tr:s})=>{let{from:a,to:l}=e,u=t.doc.textBetween(a,l,`
`,`
`).split(`
`).map(h=>i+h).join(`
`);return s.replaceWith(a,l,t.schema.text(u)),!0})},"Shift-Tab":({editor:n})=>{if(!this.options.enableTabIndentation)return!1;let{state:t}=n,{selection:e}=t,{$from:r,empty:o}=e;return r.parent.type!==this.type?!1:o?n.commands.command(({tr:i})=>{var s;let{pos:a}=r,l=r.start(),c=r.end(),u=t.doc.textBetween(l,c,`
`,`
`).split(`
`),h=0,f=0,p=a-l;for(let g=0;g<u.length;g+=1){if(f+u[g].length>=p){h=g;break}f+=u[g].length+1}let x=((s=u[h].match(/^ */))==null?void 0:s[0])||"",b=Math.min(x.length,this.options.tabSize);if(b===0)return!0;let k=l;for(let g=0;g<h;g+=1)k+=u[g].length+1;return i.delete(k,k+b),a-k<=b&&i.setSelection(_.create(i.doc,k)),!0}):n.commands.command(({tr:i})=>{let{from:s,to:a}=e,d=t.doc.textBetween(s,a,`
`,`
`).split(`
`).map(u=>{var h;let f=((h=u.match(/^ */))==null?void 0:h[0])||"",p=Math.min(f.length,this.options.tabSize);return u.slice(p)}).join(`
`);return i.replaceWith(s,a,t.schema.text(d)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=n,{selection:e}=t,{$from:r,empty:o}=e;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
`);return!i||!s?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=n,{selection:e,doc:r}=t,{$from:o,empty:i}=e;if(!i||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;let a=o.after();return a===void 0?!1:r.nodeAt(a)?n.commands.command(({tr:c})=>(c.setSelection(R.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[Hr({find:k1,type:this.type,getAttributes:n=>({language:n[1]})}),Hr({find:S1,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new O({key:new D("codeBlockVSCodeHandler"),props:{handlePaste:(n,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let e=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!e||!i)return!1;let{tr:s,schema:a}=n.state,l=a.text(e.replace(/\r\n?/g,`
`));return s.replaceSelectionWith(this.type.create({language:i},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(_.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}});var $f=F.create({name:"doc",topNode:!0,content:"block+"});var If=F.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",$(this.options.HTMLAttributes,n)]},renderText(){return`
`},addCommands(){return{setHardBreak:()=>({commands:n,chain:t,state:e,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:o,storedMarks:i}=e;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:a}=r.extensionManager,l=i||o.$to.parentOffset&&o.$from.marks();return t().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&s){let u=l.filter(h=>a.includes(h.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Lf=F.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:t}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,$(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:n=>({commands:t})=>this.options.levels.includes(n.level)?t.setNode(this.name,n):!1,toggleHeading:n=>({commands:t})=>this.options.levels.includes(n.level)?t.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,t)=>({...n,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(n=>Hr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Bf=F.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",$(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:t})=>{if(!_f(t,t.schema.nodes[this.name]))return!1;let{selection:e}=t,{$to:r}=e,o=n();return Ue(e)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:i,dispatch:s})=>{var a;if(s){let{$to:l}=i.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?i.setSelection(_.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(N.create(i.doc,l.pos)):i.setSelection(_.create(i.doc,l.pos));else{let d=(a=l.parent.type.contentMatch.defaultType)==null?void 0:a.create();d&&(i.insert(c,d),i.setSelection(_.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Tf({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var w1=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,E1=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,M1=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,A1=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,zf=$t.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[se({find:w1,type:this.type}),se({find:M1,type:this.type})]},addPasteRules(){return[Ht({find:E1,type:this.type}),Ht({find:A1,type:this.type})]}});var T1="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",_1="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Wl="numeric",ql="ascii",Jl="alpha",Ur="asciinumeric",Vr="alphanumeric",Gl="domain",Wf="emoji",C1="scheme",O1="slashscheme",Hl="whitespace";function N1(n,t){return n in t||(t[n]=[]),t[n]}function yn(n,t,e){t[Wl]&&(t[Ur]=!0,t[Vr]=!0),t[ql]&&(t[Ur]=!0,t[Jl]=!0),t[Ur]&&(t[Vr]=!0),t[Jl]&&(t[Vr]=!0),t[Vr]&&(t[Gl]=!0),t[Wf]&&(t[Gl]=!0);for(let r in t){let o=N1(r,e);o.indexOf(n)<0&&o.push(n)}}function P1(n,t){let e={};for(let r in t)t[r].indexOf(n)>=0&&(e[r]=!0);return e}function Ct(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Ct.groups={};Ct.prototype={accepts(){return!!this.t},go(n){let t=this,e=t.j[n];if(e)return e;for(let r=0;r<t.jr.length;r++){let o=t.jr[r][0],i=t.jr[r][1];if(i&&o.test(n))return i}return t.jd},has(n,t=!1){return t?n in this.j:!!this.go(n)},ta(n,t,e,r){for(let o=0;o<n.length;o++)this.tt(n[o],t,e,r)},tr(n,t,e,r){r=r||Ct.groups;let o;return t&&t.j?o=t:(o=new Ct(t),e&&r&&yn(t,e,r)),this.jr.push([n,o]),o},ts(n,t,e,r){let o=this,i=n.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(n[s]);return o.tt(n[i-1],t,e,r)},tt(n,t,e,r){r=r||Ct.groups;let o=this;if(t&&t.j)return o.j[n]=t,t;let i=t,s,a=o.go(n);if(a?(s=new Ct,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new Ct,i){if(r)if(s.t&&typeof s.t=="string"){let l=Object.assign(P1(s.t,r),e);yn(i,l,r)}else e&&yn(i,e,r);s.t=i}return o.j[n]=s,s}};var I=(n,t,e,r,o)=>n.ta(t,e,r,o),G=(n,t,e,r,o)=>n.tr(t,e,r,o),Hf=(n,t,e,r,o)=>n.ts(t,e,r,o),E=(n,t,e,r,o)=>n.tt(t,e,r,o),Oe="WORD",Xl="UWORD",qf="ASCIINUMERICAL",Jf="ALPHANUMERICAL",Gr="LOCALHOST",Yl="TLD",Ql="UTLD",xi="SCHEME",Zn="SLASH_SCHEME",tc="NUM",Zl="WS",ec="NL",Kr="OPENBRACE",jr="CLOSEBRACE",ki="OPENBRACKET",Si="CLOSEBRACKET",wi="OPENPAREN",Ei="CLOSEPAREN",Mi="OPENANGLEBRACKET",Ai="CLOSEANGLEBRACKET",Ti="FULLWIDTHLEFTPAREN",_i="FULLWIDTHRIGHTPAREN",Ci="LEFTCORNERBRACKET",Oi="RIGHTCORNERBRACKET",Ni="LEFTWHITECORNERBRACKET",Pi="RIGHTWHITECORNERBRACKET",Ri="FULLWIDTHLESSTHAN",Di="FULLWIDTHGREATERTHAN",$i="AMPERSAND",Ii="APOSTROPHE",Li="ASTERISK",je="AT",Bi="BACKSLASH",zi="BACKTICK",Hi="CARET",We="COLON",nc="COMMA",Fi="DOLLAR",le="DOT",Vi="EQUALS",rc="EXCLAMATION",Vt="HYPHEN",Wr="PERCENT",Ui="PIPE",Ki="PLUS",ji="POUND",qr="QUERY",oc="QUOTE",Gf="FULLWIDTHMIDDLEDOT",ic="SEMI",ce="SLASH",Jr="TILDE",Wi="UNDERSCORE",Xf="EMOJI",qi="SYM",Yf=Object.freeze({__proto__:null,ALPHANUMERICAL:Jf,AMPERSAND:$i,APOSTROPHE:Ii,ASCIINUMERICAL:qf,ASTERISK:Li,AT:je,BACKSLASH:Bi,BACKTICK:zi,CARET:Hi,CLOSEANGLEBRACKET:Ai,CLOSEBRACE:jr,CLOSEBRACKET:Si,CLOSEPAREN:Ei,COLON:We,COMMA:nc,DOLLAR:Fi,DOT:le,EMOJI:Xf,EQUALS:Vi,EXCLAMATION:rc,FULLWIDTHGREATERTHAN:Di,FULLWIDTHLEFTPAREN:Ti,FULLWIDTHLESSTHAN:Ri,FULLWIDTHMIDDLEDOT:Gf,FULLWIDTHRIGHTPAREN:_i,HYPHEN:Vt,LEFTCORNERBRACKET:Ci,LEFTWHITECORNERBRACKET:Ni,LOCALHOST:Gr,NL:ec,NUM:tc,OPENANGLEBRACKET:Mi,OPENBRACE:Kr,OPENBRACKET:ki,OPENPAREN:wi,PERCENT:Wr,PIPE:Ui,PLUS:Ki,POUND:ji,QUERY:qr,QUOTE:oc,RIGHTCORNERBRACKET:Oi,RIGHTWHITECORNERBRACKET:Pi,SCHEME:xi,SEMI:ic,SLASH:ce,SLASH_SCHEME:Zn,SYM:qi,TILDE:Jr,TLD:Yl,UNDERSCORE:Wi,UTLD:Ql,UWORD:Xl,WORD:Oe,WS:Zl}),_e=/[a-z]/,Fr=/\p{L}/u,Fl=/\p{Emoji}/u;var Ce=/\d/,Vl=/\s/;var Ff="\r",Ul=`
`,R1="\uFE0F",D1="\u200D",Kl="\uFFFC",bi=null,yi=null;function $1(n=[]){let t={};Ct.groups=t;let e=new Ct;bi==null&&(bi=Vf(T1)),yi==null&&(yi=Vf(_1)),E(e,"'",Ii),E(e,"{",Kr),E(e,"}",jr),E(e,"[",ki),E(e,"]",Si),E(e,"(",wi),E(e,")",Ei),E(e,"<",Mi),E(e,">",Ai),E(e,"\uFF08",Ti),E(e,"\uFF09",_i),E(e,"\u300C",Ci),E(e,"\u300D",Oi),E(e,"\u300E",Ni),E(e,"\u300F",Pi),E(e,"\uFF1C",Ri),E(e,"\uFF1E",Di),E(e,"&",$i),E(e,"*",Li),E(e,"@",je),E(e,"`",zi),E(e,"^",Hi),E(e,":",We),E(e,",",nc),E(e,"$",Fi),E(e,".",le),E(e,"=",Vi),E(e,"!",rc),E(e,"-",Vt),E(e,"%",Wr),E(e,"|",Ui),E(e,"+",Ki),E(e,"#",ji),E(e,"?",qr),E(e,'"',oc),E(e,"/",ce),E(e,";",ic),E(e,"~",Jr),E(e,"_",Wi),E(e,"\\",Bi),E(e,"\u30FB",Gf);let r=G(e,Ce,tc,{[Wl]:!0});G(r,Ce,r);let o=G(r,_e,qf,{[Ur]:!0}),i=G(r,Fr,Jf,{[Vr]:!0}),s=G(e,_e,Oe,{[ql]:!0});G(s,Ce,o),G(s,_e,s),G(o,Ce,o),G(o,_e,o);let a=G(e,Fr,Xl,{[Jl]:!0});G(a,_e),G(a,Ce,i),G(a,Fr,a),G(i,Ce,i),G(i,_e),G(i,Fr,i);let l=E(e,Ul,ec,{[Hl]:!0}),c=E(e,Ff,Zl,{[Hl]:!0}),d=G(e,Vl,Zl,{[Hl]:!0});E(e,Kl,d),E(c,Ul,l),E(c,Kl,d),G(c,Vl,d),E(d,Ff),E(d,Ul),G(d,Vl,d),E(d,Kl,d);let u=G(e,Fl,Xf,{[Wf]:!0});E(u,"#"),G(u,Fl,u),E(u,R1,u);let h=E(u,D1);E(h,"#"),G(h,Fl,u);let f=[[_e,s],[Ce,o]],p=[[_e,null],[Fr,a],[Ce,i]];for(let y=0;y<bi.length;y++)Ke(e,bi[y],Yl,Oe,f);for(let y=0;y<yi.length;y++)Ke(e,yi[y],Ql,Xl,p);yn(Yl,{tld:!0,ascii:!0},t),yn(Ql,{utld:!0,alpha:!0},t),Ke(e,"file",xi,Oe,f),Ke(e,"mailto",xi,Oe,f),Ke(e,"http",Zn,Oe,f),Ke(e,"https",Zn,Oe,f),Ke(e,"ftp",Zn,Oe,f),Ke(e,"ftps",Zn,Oe,f),yn(xi,{scheme:!0,ascii:!0},t),yn(Zn,{slashscheme:!0,ascii:!0},t),n=n.sort((y,x)=>y[0]>x[0]?1:-1);for(let y=0;y<n.length;y++){let x=n[y][0],k=n[y][1]?{[C1]:!0}:{[O1]:!0};x.indexOf("-")>=0?k[Gl]=!0:_e.test(x)?Ce.test(x)?k[Ur]=!0:k[ql]=!0:k[Wl]=!0,Hf(e,x,x,k)}return Hf(e,"localhost",Gr,{ascii:!0}),e.jd=new Ct(qi),{start:e,tokens:Object.assign({groups:t},Yf)}}function Qf(n,t){let e=I1(t.replace(/[A-Z]/g,a=>a.toLowerCase())),r=e.length,o=[],i=0,s=0;for(;s<r;){let a=n,l=null,c=0,d=null,u=-1,h=-1;for(;s<r&&(l=a.go(e[s]));)a=l,a.accepts()?(u=0,h=0,d=a):u>=0&&(u+=e[s].length,h++),c+=e[s].length,i+=e[s].length,s++;i-=u,s-=h,c-=u,o.push({t:d.t,v:t.slice(i-c,i),s:i-c,e:i})}return o}function I1(n){let t=[],e=n.length,r=0;for(;r<e;){let o=n.charCodeAt(r),i,s=o<55296||o>56319||r+1===e||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);t.push(s),r+=s.length}return t}function Ke(n,t,e,r,o){let i,s=t.length;for(let a=0;a<s-1;a++){let l=t[a];n.j[l]?i=n.j[l]:(i=new Ct(r),i.jr=o.slice(),n.j[l]=i),n=i}return i=new Ct(e),i.jr=o.slice(),n.j[t[s-1]]=i,i}function Vf(n){let t=[],e=[],r=0,o="0123456789";for(;r<n.length;){let i=0;for(;o.indexOf(n[r+i])>=0;)i++;if(i>0){t.push(e.join(""));for(let s=parseInt(n.substring(r,r+i),10);s>0;s--)e.pop();r+=i}else e.push(n[r]),r++}return t}var Xr={defaultProtocol:"http",events:null,format:Uf,formatHref:Uf,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function sc(n,t=null){let e=Object.assign({},Xr);n&&(e=Object.assign(e,n instanceof sc?n.o:n));let r=e.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=e,t&&(this.defaultRender=t),this.ignoreTags=o}sc.prototype={o:Xr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,t,e){let r=t!=null,o=this.o[n];return o&&(typeof o=="object"?(o=e.t in o?o[e.t]:Xr[n],typeof o=="function"&&r&&(o=o(t,e))):typeof o=="function"&&r&&(o=o(t,e.t,e)),o)},getObj(n,t,e){let r=this.o[n];return typeof r=="function"&&t!=null&&(r=r(t,e.t,e)),r},render(n){let t=n.render(this);return(this.get("render",null,n)||this.defaultRender)(t,n.t,n)}};function Uf(n){return n}function Zf(n,t){this.t="token",this.v=n,this.tk=t}Zf.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){let t=this.toString(),e=n.get("truncate",t,this),r=n.get("format",t,this);return e&&r.length>e?r.substring(0,e)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Xr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){let t=this,e=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",e,this),o=n.get("tagName",e,t),i=this.toFormattedString(n),s={},a=n.get("className",e,t),l=n.get("target",e,t),c=n.get("rel",e,t),d=n.getObj("attributes",e,t),u=n.getObj("events",e,t);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:o,attributes:s,content:i,eventListeners:u}}};function Ji(n,t){class e extends Zf{constructor(o,i){super(o,i),this.t=n}}for(let r in t)e.prototype[r]=t[r];return e.t=n,e}var Kf=Ji("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),jf=Ji("text"),L1=Ji("nl"),vi=Ji("url",{isLink:!0,toHref(n=Xr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){let n=this.tk;return n.length>=2&&n[0].t!==Gr&&n[1].t===We}});var Ft=n=>new Ct(n);function B1({groups:n}){let t=n.domain.concat([$i,Li,je,Bi,zi,Hi,Fi,Vi,Vt,tc,Wr,Ui,Ki,ji,ce,qi,Jr,Wi]),e=[Ii,We,nc,le,rc,Wr,qr,oc,ic,Mi,Ai,Kr,jr,Si,ki,wi,Ei,Ti,_i,Ci,Oi,Ni,Pi,Ri,Di],r=[$i,Ii,Li,Bi,zi,Hi,Fi,Vi,Vt,Kr,jr,Wr,Ui,Ki,ji,qr,ce,qi,Jr,Wi],o=Ft(),i=E(o,Jr);I(i,r,i),I(i,n.domain,i);let s=Ft(),a=Ft(),l=Ft();I(o,n.domain,s),I(o,n.scheme,a),I(o,n.slashscheme,l),I(s,r,i),I(s,n.domain,s);let c=E(s,je);E(i,je,c),E(a,je,c),E(l,je,c);let d=E(i,le);I(d,r,i),I(d,n.domain,i);let u=Ft();I(c,n.domain,u),I(u,n.domain,u);let h=E(u,le);I(h,n.domain,u);let f=Ft(Kf);I(h,n.tld,f),I(h,n.utld,f),E(c,Gr,f);let p=E(u,Vt);E(p,Vt,p),I(p,n.domain,u),I(f,n.domain,u),E(f,le,h),E(f,Vt,p);let y=E(f,We);I(y,n.numeric,Kf);let x=E(s,Vt),b=E(s,le);E(x,Vt,x),I(x,n.domain,s),I(b,r,i),I(b,n.domain,s);let k=Ft(vi);I(b,n.tld,k),I(b,n.utld,k),I(k,n.domain,s),I(k,r,i),E(k,le,b),E(k,Vt,x),E(k,je,c);let m=E(k,We),g=Ft(vi);I(m,n.numeric,g);let v=Ft(vi),S=Ft();I(v,t,v),I(v,e,S),I(S,t,v),I(S,e,S),E(k,ce,v),E(g,ce,v);let C=E(a,We),M=E(l,We),B=E(M,ce),V=E(B,ce);I(a,n.domain,s),E(a,le,b),E(a,Vt,x),I(l,n.domain,s),E(l,le,b),E(l,Vt,x),I(C,n.domain,v),E(C,ce,v),E(C,qr,v),I(V,n.domain,v),I(V,t,v),E(V,ce,v);let gt=[[Kr,jr],[ki,Si],[wi,Ei],[Mi,Ai],[Ti,_i],[Ci,Oi],[Ni,Pi],[Ri,Di]];for(let ot=0;ot<gt.length;ot++){let[bt,X]=gt[ot],Et=E(v,bt);E(S,bt,Et),E(Et,X,v);let rt=Ft(vi);I(Et,t,rt);let Z=Ft();I(Et,e),I(rt,t,rt),I(rt,e,Z),I(Z,t,rt),I(Z,e,Z),E(rt,X,v),E(Z,X,v)}return E(o,Gr,k),E(o,ec,L1),{start:o,tokens:Yf}}function z1(n,t,e){let r=e.length,o=0,i=[],s=[];for(;o<r;){let a=n,l=null,c=null,d=0,u=null,h=-1;for(;o<r&&!(l=a.go(e[o].t));)s.push(e[o++]);for(;o<r&&(c=l||a.go(e[o].t));)l=null,a=c,a.accepts()?(h=0,u=a):h>=0&&h++,o++,d++;if(h<0)o-=d,o<r&&(s.push(e[o]),o++);else{s.length>0&&(i.push(jl(jf,t,s)),s=[]),o-=h,d-=h;let f=u.t,p=e.slice(o-d,o);i.push(jl(f,t,p))}}return s.length>0&&i.push(jl(jf,t,s)),i}function jl(n,t,e){let r=e[0].s,o=e[e.length-1].e,i=t.slice(r,o);return new n(i,e)}var H1=typeof console<"u"&&console&&console.warn||(()=>{}),F1="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",j={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function tp(){return Ct.groups={},j.scanner=null,j.parser=null,j.tokenQueue=[],j.pluginQueue=[],j.customSchemes=[],j.initialized=!1,j}function ac(n,t=!1){if(j.initialized&&H1(`linkifyjs: already initialized - will not register custom scheme "${n}" ${F1}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
1. Must only contain digits, lowercase ASCII letters or "-"
2. Cannot start or end with "-"
3. "-" cannot repeat`);j.customSchemes.push([n,t])}function V1(){j.scanner=$1(j.customSchemes);for(let n=0;n<j.tokenQueue.length;n++)j.tokenQueue[n][1]({scanner:j.scanner});j.parser=B1(j.scanner.tokens);for(let n=0;n<j.pluginQueue.length;n++)j.pluginQueue[n][1]({scanner:j.scanner,parser:j.parser});return j.initialized=!0,j}function Gi(n){return j.initialized||V1(),z1(j.parser.start,n,Qf(j.scanner.start,n))}Gi.scan=Qf;function Xi(n,t=null,e=null){if(t&&typeof t=="object"){if(e)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);e=t,t=null}let r=new sc(e),o=Gi(n),i=[];for(let s=0;s<o.length;s++){let a=o[s];a.isLink&&(!t||a.t===t)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}var lc="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",U1=new RegExp(lc),K1=new RegExp(`${lc}$`),j1=new RegExp(lc,"g");function W1(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function q1(n){return new O({key:new D("autolink"),appendTransaction:(t,e,r)=>{let o=t.some(c=>c.docChanged)&&!e.doc.eq(r.doc),i=t.some(c=>c.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,a=Cl(e.doc,[...t]);if(Dl(a).forEach(({newRange:c})=>{let d=Qh(r.doc,c,f=>f.isTextblock),u,h;if(d.length>1)u=d[0],h=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){let f=r.doc.textBetween(c.from,c.to," "," ");if(!K1.test(f))return;u=d[0],h=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&h){let f=h.split(U1).filter(Boolean);if(f.length<=0)return!1;let p=f[f.length-1],y=u.pos+h.lastIndexOf(p);if(!p)return!1;let x=Gi(p).map(b=>b.toObject(n.defaultProtocol));if(!W1(x))return!1;x.filter(b=>b.isLink).map(b=>({...b,from:y+b.start+1,to:y+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{hi(b.from,b.to,r.doc).some(k=>k.mark.type===n.type)||s.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function J1(n){return new O({key:new D("handleClickLink"),props:{handleClick:(t,e,r)=>{var o,i;if(r.button!==0||!t.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let d=r.target,u=[];for(;d.nodeName!=="DIV";)u.push(d),d=d.parentNode;s=u.find(h=>h.nodeName==="A")}if(!s)return!1;let a=Rl(t.state,n.type.name),l=(o=s?.href)!=null?o:a.href,c=(i=s?.target)!=null?i:a.target;return n.enableClickSelection&&n.editor.commands.extendMarkRange(n.type.name),s&&l?(window.open(l,c),!0):!1}}})}function G1(n){return new O({key:new D("handlePasteLink"),props:{handlePaste:(t,e,r)=>{let{state:o}=t,{selection:i}=o,{empty:s}=i;if(s)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});let l=Xi(a,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!l?!1:n.editor.commands.setMark(n.type,{href:l.href})}}})}function vn(n,t){let e=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&e.push(o)}),!n||n.replace(j1,"").match(new RegExp(`^(?:(?:${e.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var cc=$t.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){ac(n);return}ac(n.scheme,n.optionalSlashes)})},onDestroy(){tp()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,t)=>!!vn(n,t.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{let t=n.getAttribute("href");return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!vn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:t=>!!vn(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",$(this.options.HTMLAttributes,n),0]:["a",$(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:t})=>{let{href:e}=n;return this.options.isAllowedUri(e,{defaultValidate:r=>!!vn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:t})=>{let{href:e}=n||{};return e&&!this.options.isAllowedUri(e,{defaultValidate:r=>!!vn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ht({find:n=>{let t=[];if(n){let{protocols:e,defaultProtocol:r}=this.options,o=Xi(n).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!vn(s,e),protocols:e,defaultProtocol:r}));o.length&&o.forEach(i=>t.push({text:i.value,data:{href:i.href},index:i.start}))}return t},type:this.type,getAttributes:n=>{var t;return{href:(t=n.data)==null?void 0:t.href}}})]},addProseMirrorPlugins(){let n=[],{protocols:t,defaultProtocol:e}=this.options;return this.options.autolink&&n.push(q1({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!vn(o,t),protocols:t,defaultProtocol:e}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(J1({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(G1({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),ep=cc;var X1=Object.defineProperty,Y1=(n,t)=>{for(var e in t)X1(n,e,{get:t[e],enumerable:!0})},Q1="listItem",np="textStyle",rp=/^\s*([-+*])\s$/,hc=F.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",$(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Q1,this.editor.getAttributes(np)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=ae({find:rp,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=ae({find:rp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(np),editor:this.editor})),[n]}}),fc=F.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",$(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Z1={};Y1(Z1,{findListItemPos:()=>Yr,getNextListDepth:()=>pc,handleBackspace:()=>dc,handleDelete:()=>uc,hasListBefore:()=>sp,hasListItemAfter:()=>tv,hasListItemBefore:()=>ap,listItemHasSubList:()=>lp,nextListIsDeeper:()=>cp,nextListIsHigher:()=>dp});var Yr=(n,t)=>{let{$from:e}=t.selection,r=q(n,t.schema),o=null,i=e.depth,s=e.pos,a=null;for(;i>0&&a===null;)o=e.node(i),o.type===r?a=i:(i-=1,s-=1);return a===null?null:{$pos:t.doc.resolve(s),depth:a}},pc=(n,t)=>{let e=Yr(n,t);if(!e)return!1;let[,r]=af(t,n,e.$pos.pos+4);return r},sp=(n,t,e)=>{let{$anchor:r}=n.selection,o=Math.max(0,r.pos-2),i=n.doc.resolve(o).node();return!(!i||!e.includes(i.type.name))},ap=(n,t)=>{var e;let{$anchor:r}=t.selection,o=t.doc.resolve(r.pos-2);return!(o.index()===0||((e=o.nodeBefore)==null?void 0:e.type.name)!==n)},lp=(n,t,e)=>{if(!e)return!1;let r=q(n,t.schema),o=!1;return e.descendants(i=>{i.type===r&&(o=!0)}),o},dc=(n,t,e)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!ie(n.state,t)&&sp(n.state,t,e)){let{$anchor:a}=n.state.selection,l=n.state.doc.resolve(a.before()-1),c=[];l.node().descendants((h,f)=>{h.type.name===t&&c.push({node:h,pos:f})});let d=c.at(-1);if(!d)return!1;let u=n.state.doc.resolve(l.start()+d.pos+1);return n.chain().cut({from:a.start()-1,to:a.end()+1},u.end()).joinForward().run()}if(!ie(n.state,t)||!cf(n.state))return!1;let r=Yr(t,n.state);if(!r)return!1;let i=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=lp(t,n.state,i);return ap(t,n.state)&&!s?n.commands.joinItemBackward():n.chain().liftListItem(t).run()},cp=(n,t)=>{let e=pc(n,t),r=Yr(n,t);return!r||!e?!1:e>r.depth},dp=(n,t)=>{let e=pc(n,t),r=Yr(n,t);return!r||!e?!1:e<r.depth},uc=(n,t)=>{if(!ie(n.state,t)||!lf(n.state,t))return!1;let{selection:e}=n.state,{$from:r,$to:o}=e;return!e.empty&&r.sameParent(o)?!1:cp(t,n.state)?n.chain().focus(n.state.selection.from+4).lift(t).joinBackward().run():dp(t,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},tv=(n,t)=>{var e;let{$anchor:r}=t.selection,o=t.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((e=o.nodeAfter)==null?void 0:e.type.name)!==n)},mc=L.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let t=!1;return this.options.listTypes.forEach(({itemName:e})=>{n.state.schema.nodes[e]!==void 0&&uc(n,e)&&(t=!0)}),t},"Mod-Delete":({editor:n})=>{let t=!1;return this.options.listTypes.forEach(({itemName:e})=>{n.state.schema.nodes[e]!==void 0&&uc(n,e)&&(t=!0)}),t},Backspace:({editor:n})=>{let t=!1;return this.options.listTypes.forEach(({itemName:e,wrapperNames:r})=>{n.state.schema.nodes[e]!==void 0&&dc(n,e,r)&&(t=!0)}),t},"Mod-Backspace":({editor:n})=>{let t=!1;return this.options.listTypes.forEach(({itemName:e,wrapperNames:r})=>{n.state.schema.nodes[e]!==void 0&&dc(n,e,r)&&(t=!0)}),t}}}}),ev="listItem",op="textStyle",ip=/^(\d+)\.\s$/,gc=F.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let{start:t,...e}=n;return t===1?["ol",$(this.options.HTMLAttributes,e),0]:["ol",$(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ev,this.editor.getAttributes(op)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=ae({find:ip,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=ae({find:ip,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(op)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[n]}}),nv=/^\s*(\[([( |x])?\])\s$/,rv=F.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{let t=n.getAttribute("data-checked");return t===""||t==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:t}){return["li",$(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){let n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:t,getPos:e,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=d=>{var u,h;a.ariaLabel=((h=(u=this.options.a11y)==null?void 0:u.checkboxLabel)==null?void 0:h.call(u,d,a.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return c(n),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",d=>d.preventDefault()),a.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}let{checked:u}=d.target;r.isEditable&&typeof e=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let f=e();if(typeof f!="number")return!1;let p=h.doc.nodeAt(f);return h.setNodeMarkup(f,void 0,{...p?.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,u])=>{o.setAttribute(d,u)}),o.dataset.checked=n.attrs.checked,a.checked=n.attrs.checked,i.append(a,s),o.append(i,l),Object.entries(t).forEach(([d,u])=>{o.setAttribute(d,u)}),{dom:o,contentDOM:l,update:d=>d.type!==this.type?!1:(o.dataset.checked=d.attrs.checked,a.checked=d.attrs.checked,c(d),!0)}}},addInputRules(){return[ae({find:nv,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),ov=F.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",$(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),zE=L.create({name:"listKit",addExtensions(){let n=[];return this.options.bulletList!==!1&&n.push(hc.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(fc.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(mc.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(gc.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(rv.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(ov.configure(this.options.taskList)),n}});var up=F.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var iv=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,sv=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,bc=$t.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[se({find:iv,type:this.type})]},addPasteRules(){return[Ht({find:sv,type:this.type})]}}),hp=bc;var fp=F.create({name:"text",group:"inline"});var pp=$t.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function mp(n={}){return new O({view(t){return new yc(t,n)}})}var yc=class{constructor(t,e){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=e.width)!==null&&r!==void 0?r:1,this.color=e.color===!1?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return t.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e))}update(t,e){this.cursorPos!=null&&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,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),e=!t.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,a=i.height/o.offsetHeight;if(e){let u=t.nodeBefore,h=t.nodeAfter;if(u||h){let f=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(f){let p=f.getBoundingClientRect(),y=u?p.bottom:p.top;u&&h&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*a;r={left:p.left,right:p.right,top:y-x,bottom:y+x}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",e),this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=l.getBoundingClientRect(),h=u.width/l.offsetWidth,f=u.height/l.offsetHeight;c=u.left-l.scrollLeft*h,d=u.top-l.scrollTop*f}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/a+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/a+"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}),r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,e,t):o;if(e&&!i){let s=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Lo(this.editorView.state.doc,s,this.editorView.dragging.slice);a!=null&&(s=a)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}};var mt=class n extends R{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return n.valid(r)?new n(r):R.near(r)}content(){return A.empty}eq(t){return t instanceof n&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(t.resolve(e.pos))}getBookmark(){return new vc(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!av(t)||!lv(t))return!1;let r=e.type.spec.allowGapCursor;if(r!=null)return r;let o=e.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,e,r=!1){t:for(;;){if(!r&&n.valid(t))return t;let o=t.pos,i=null;for(let s=t.depth;;s--){let a=t.node(s);if(e>0?t.indexAfter(s)<a.childCount:t.index(s)>0){i=a.child(e>0?t.indexAfter(s):t.index(s)-1);break}else if(s==0)return null;o+=e;let l=t.doc.resolve(o);if(n.valid(l))return l}for(;;){let s=e>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!N.isSelectable(i)){t=t.doc.resolve(o+i.nodeSize*e),r=!1;continue t}break}i=s,o+=e;let a=t.doc.resolve(o);if(n.valid(a))return a}return null}}};mt.prototype.visible=!1;mt.findFrom=mt.findGapCursorFrom;R.jsonID("gapcursor",mt);var vc=class n{constructor(t){this.pos=t}map(t){return new n(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return mt.valid(e)?new mt(e):R.near(e)}};function av(n){for(let t=n.depth;t>=0;t--){let e=n.index(t),r=n.node(t);if(e==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(e-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function lv(n){for(let t=n.depth;t>=0;t--){let e=n.indexAfter(t),r=n.node(t);if(e==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(e);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function gp(){return new O({props:{decorations:hv,createSelectionBetween(n,t,e){return t.pos==e.pos&&mt.valid(e)?new mt(e):null},handleClick:dv,handleKeyDown:cv,handleDOMEvents:{beforeinput:uv}}})}var cv=cl({ArrowLeft:Yi("horiz",-1),ArrowRight:Yi("horiz",1),ArrowUp:Yi("vert",-1),ArrowDown:Yi("vert",1)});function Yi(n,t){let e=n=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,o,i){let s=r.selection,a=t>0?s.$to:s.$from,l=s.empty;if(s instanceof _){if(!i.endOfTextblock(e)||a.depth==0)return!1;l=!1,a=r.doc.resolve(t>0?a.after():a.before())}let c=mt.findGapCursorFrom(a,t,l);return c?(o&&o(r.tr.setSelection(new mt(c))),!0):!1}}function dv(n,t,e){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(t);if(!mt.valid(r))return!1;let o=n.posAtCoords({left:e.clientX,top:e.clientY});return o&&o.inside>-1&&N.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new mt(r))),!0)}function uv(n,t){if(t.inputType!="insertCompositionText"||!(n.state.selection instanceof mt))return!1;let{$from:e}=n.state.selection,r=e.parent.contentMatchAt(e.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=w.empty;for(let s=r.length-1;s>=0;s--)o=w.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(e.pos,e.pos,new A(o,0,0));return i.setSelection(_.near(i.doc.resolve(e.pos+1))),n.dispatch(i),!1}function hv(n){if(!(n.selection instanceof mt))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",W.create(n.doc,[et.widget(n.selection.head,t,{key:"gapcursor"})])}var Qi=200,dt=function(){};dt.prototype.append=function(t){return t.length?(t=dt.from(t),!this.length&&t||t.length<Qi&&this.leafAppend(t)||this.length<Qi&&t.leafPrepend(this)||this.appendInner(t)):this};dt.prototype.prepend=function(t){return t.length?dt.from(t).append(this):this};dt.prototype.appendInner=function(t){return new fv(this,t)};dt.prototype.slice=function(t,e){return t===void 0&&(t=0),e===void 0&&(e=this.length),t>=e?dt.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))};dt.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};dt.prototype.forEach=function(t,e,r){e===void 0&&(e=0),r===void 0&&(r=this.length),e<=r?this.forEachInner(t,e,r,0):this.forEachInvertedInner(t,e,r,0)};dt.prototype.map=function(t,e,r){e===void 0&&(e=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(t(i,s))},e,r),o};dt.from=function(t){return t instanceof dt?t:t&&t.length?new bp(t):dt.empty};var bp=function(n){function t(r){n.call(this),this.values=r}n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t;var e={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new t(this.values.slice(o,i))},t.prototype.getInner=function(o){return this.values[o]},t.prototype.forEachInner=function(o,i,s,a){for(var l=i;l<s;l++)if(o(this.values[l],a+l)===!1)return!1},t.prototype.forEachInvertedInner=function(o,i,s,a){for(var l=i-1;l>=s;l--)if(o(this.values[l],a+l)===!1)return!1},t.prototype.leafAppend=function(o){if(this.length+o.length<=Qi)return new t(this.values.concat(o.flatten()))},t.prototype.leafPrepend=function(o){if(this.length+o.length<=Qi)return new t(o.flatten().concat(this.values))},e.length.get=function(){return this.values.length},e.depth.get=function(){return 0},Object.defineProperties(t.prototype,e),t}(dt);dt.empty=new bp([]);var fv=function(n){function t(e,r){n.call(this),this.left=e,this.right=r,this.length=e.length+r.length,this.depth=Math.max(e.depth,r.depth)+1}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,o,i,s){var a=this.left.length;if(o<a&&this.left.forEachInner(r,o,Math.min(i,a),s)===!1||i>a&&this.right.forEachInner(r,Math.max(o-a,0),Math.min(this.length,i)-a,s+a)===!1)return!1},t.prototype.forEachInvertedInner=function(r,o,i,s){var a=this.left.length;if(o>a&&this.right.forEachInvertedInner(r,o-a,Math.max(i,a)-a,s+a)===!1||i<a&&this.left.forEachInvertedInner(r,Math.min(o,a),i,s)===!1)return!1},t.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},t.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new t(this.left,o)},t.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new t(o,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t}(dt),xc=dt;var pv=500,kn=class n{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;e&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=t.tr,a,l,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){o||(o=this.remapping(r,h+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new de(u.map));let f=u.step.map(o.slice(i)),p;f&&s.maybeStep(f).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new de(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(u.step);if(u.selection)return a=o?u.selection.map(o.slice(i)):u.selection,l=new n(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(t,e,r,o){let i=[],s=this.eventCount,a=this.items,l=!o&&a.length?a.get(a.length-1):null;for(let d=0;d<t.steps.length;d++){let u=t.steps[d].invert(t.docs[d]),h=new de(t.mapping.maps[d],u,e),f;(f=l&&l.merge(h))&&(h=f,d?i.pop():a=a.slice(0,a.length-1)),i.push(h),e&&(s++,e=void 0),o||(l=h)}let c=s-r.depth;return c>gv&&(a=mv(a,c),s-=c),new n(a.append(i),s)}remapping(t,e){let r=new Tr;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=t?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},t,e),r}addMaps(t){return this.eventCount==0?this:new n(this.items.append(t.map(e=>new de(e))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-e),i=t.mapping,s=t.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},o);let l=e;this.items.forEach(h=>{let f=i.getMirror(--l);if(f==null)return;s=Math.min(s,f);let p=i.maps[f];if(h.step){let y=t.steps[f].invert(t.docs[f]),x=h.selection&&h.selection.map(i.slice(l+1,f));x&&a++,r.push(new de(p,y,x))}else r.push(new de(p))},o);let c=[];for(let h=e;h<s;h++)c.push(new de(i.maps[h]));let d=this.items.slice(0,o).append(c).append(r),u=new n(d,a);return u.emptyItemCount()>pv&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let t=0;return this.items.forEach(e=>{e.step||t++}),t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length,o=[],i=0;return this.items.forEach((s,a)=>{if(a>=t)o.push(s),s.selection&&i++;else if(s.step){let l=s.step.map(e.slice(r)),c=l&&l.getMap();if(r--,c&&e.appendMap(c,r),l){let d=s.selection&&s.selection.map(e.slice(r));d&&i++;let u=new de(c.invert(),l,d),h,f=o.length-1;(h=o.length&&o[f].merge(u))?o[f]=h:o.push(u)}}else s.map&&r--},this.items.length,0),new n(xc.from(o.reverse()),i)}};kn.empty=new kn(xc.empty,0);function mv(n,t){let e;return n.forEach((r,o)=>{if(r.selection&&t--==0)return e=o,!1}),n.slice(e)}var de=class n{constructor(t,e,r,o){this.map=t,this.step=e,this.selection=r,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new n(e.getMap().invert(),e,this.selection)}}},ue=class{constructor(t,e,r,o,i){this.done=t,this.undone=e,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},gv=20;function bv(n,t,e,r){let o=e.getMeta(xn),i;if(o)return o.historyState;e.getMeta(xv)&&(n=new ue(n.done,n.undone,null,0,-1));let s=e.getMeta("appendedTransaction");if(e.steps.length==0)return n;if(s&&s.getMeta(xn))return s.getMeta(xn).redo?new ue(n.done.addTransform(e,void 0,r,Zi(t)),n.undone,yp(e.mapping.maps),n.prevTime,n.prevComposition):new ue(n.done,n.undone.addTransform(e,void 0,r,Zi(t)),null,n.prevTime,n.prevComposition);if(e.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=e.getMeta("composition"),l=n.prevTime==0||!s&&n.prevComposition!=a&&(n.prevTime<(e.time||0)-r.newGroupDelay||!yv(e,n.prevRanges)),c=s?kc(n.prevRanges,e.mapping):yp(e.mapping.maps);return new ue(n.done.addTransform(e,l?t.selection.getBookmark():void 0,r,Zi(t)),kn.empty,c,e.time,a??n.prevComposition)}else return(i=e.getMeta("rebased"))?new ue(n.done.rebased(e,i),n.undone.rebased(e,i),kc(n.prevRanges,e.mapping),n.prevTime,n.prevComposition):new ue(n.done.addMaps(e.mapping.maps),n.undone.addMaps(e.mapping.maps),kc(n.prevRanges,e.mapping),n.prevTime,n.prevComposition)}function yv(n,t){if(!t)return!1;if(!n.docChanged)return!0;let e=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<t.length;i+=2)r<=t[i+1]&&o>=t[i]&&(e=!0)}),e}function yp(n){let t=[];for(let e=n.length-1;e>=0&&t.length==0;e--)n[e].forEach((r,o,i,s)=>t.push(i,s));return t}function kc(n,t){if(!n)return null;let e=[];for(let r=0;r<n.length;r+=2){let o=t.map(n[r],1),i=t.map(n[r+1],-1);o<=i&&e.push(o,i)}return e}function vv(n,t,e){let r=Zi(t),o=xn.get(t).spec.config,i=(e?n.undone:n.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),a=(e?n.done:n.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),l=new ue(e?a:i.remaining,e?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(xn,{redo:e,historyState:l})}var Sc=!1,vp=null;function Zi(n){let t=n.plugins;if(vp!=t){Sc=!1,vp=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Sc=!0;break}}return Sc}var xn=new D("history"),xv=new D("closeHistory");function xp(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new O({key:xn,state:{init(){return new ue(kn.empty,kn.empty,null,0,-1)},apply(t,e,r){return bv(e,r,t,n)}},config:n,props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType,o=r=="historyUndo"?wc:r=="historyRedo"?Ec:null;return o?(e.preventDefault(),o(t.state,t.dispatch)):!1}}}})}function ts(n,t){return(e,r)=>{let o=xn.getState(e);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=vv(o,e,n);i&&r(t?i.scrollIntoView():i)}return!0}}var wc=ts(!1,!0),Ec=ts(!0,!0),uM=ts(!1,!1),hM=ts(!0,!1);var yM=L.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{let t=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){let r=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(r)}return t.nodeSize},this.storage.words=n=>{let t=n?.node||this.editor.state.doc,e=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(e)}},addProseMirrorPlugins(){let n=!1;return[new O({key:new D("characterCount"),appendTransaction:(t,e,r)=>{if(n)return;let o=this.options.limit;if(o==null||o===0){n=!0;return}let i=this.storage.characters({node:r.doc});if(i>o){let s=i-o,a=0,l=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let c=r.tr.deleteRange(a,l);return n=!0,c}n=!0},filterTransaction:(t,e)=>{let r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:e.doc}),i=this.storage.characters({node:t.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!t.getMeta("paste"))return!1;let a=t.selection.$head.pos,l=i-r,c=a-l,d=a;return t.deleteRange(c,d),!(this.storage.characters({node:t.doc})>r)}})]}}),Sp=L.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[mp(this.options)]}}),Mc=L.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new O({key:new D("focus"),props:{decorations:({doc:n,selection:t})=>{let{isEditable:e,isFocused:r}=this.editor,{anchor:o}=t,i=[];if(!e||!r)return W.create(n,[]);let s=0;this.options.mode==="deepest"&&n.descendants((l,c)=>{if(l.isText)return;if(!(o>=c&&o<=c+l.nodeSize-1))return!1;s+=1});let a=0;return n.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&s-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";i.push(et.node(c,c+l.nodeSize,{class:this.options.className}))}),W.create(n,i)}}})]}}),wp=L.create({name:"gapCursor",addProseMirrorPlugins(){return[gp()]},extendNodeSchema(n){var t;let e={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(t=H(P(n,"allowGapCursor",e)))!=null?t:null}}}),Ac=L.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new O({key:new D("placeholder"),props:{decorations:({doc:n,selection:t})=>{let e=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,o=[];if(!e)return null;let i=this.editor.isEmpty;return n.descendants((s,a)=>{let l=r>=a&&r<=a+s.nodeSize,c=!s.isLeaf&&zr(s);if((l||!this.options.showOnlyCurrent)&&c){let d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);let u=et.node(a,a+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});o.push(u)}return this.options.includeChildren}),W.create(n,o)}}})]}}),PM=L.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:n,options:t}=this;return[new O({key:new D("selection"),props:{decorations(e){return e.selection.empty||n.isFocused||!n.isEditable||Ue(e.selection)||n.view.dragging?null:W.create(e.doc,[et.inline(e.selection.from,e.selection.to,{class:t.className})])}}})]}});function kp({types:n,node:t}){return t&&Array.isArray(n)&&n.includes(t.type)||t?.type===n}var Ep=L.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){let n=new D(this.name),t=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(this.options.node).includes(e.name));return[new O({key:n,appendTransaction:(e,r,o)=>{let{doc:i,tr:s,schema:a}=o,l=n.getState(o),c=i.content.size,d=a.nodes[this.options.node];if(l)return s.insert(c,d.create())},state:{init:(e,r)=>{let o=r.tr.doc.lastChild;return!kp({node:o,types:t})},apply:(e,r)=>{if(!e.docChanged)return r;let o=e.doc.lastChild;return!kp({node:o,types:t})}}})]}}),Mp=L.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:t})=>wc(n,t),redo:()=>({state:n,dispatch:t})=>Ec(n,t)}},addProseMirrorPlugins(){return[xp(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var kv=L.create({name:"starterKit",addExtensions(){var n,t,e,r;let o=[];return this.options.bold!==!1&&o.push(Pf.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(Nf.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(hc.configure(this.options.bulletList)),this.options.code!==!1&&o.push(Rf.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(Df.configure(this.options.codeBlock)),this.options.document!==!1&&o.push($f.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(Sp.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(wp.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(If.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(Lf.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(Mp.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(Bf.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(zf.configure(this.options.italic)),this.options.listItem!==!1&&o.push(fc.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(mc.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&o.push(cc.configure((t=this.options)==null?void 0:t.link)),this.options.orderedList!==!1&&o.push(gc.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(up.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(bc.configure(this.options.strike)),this.options.text!==!1&&o.push(fp.configure(this.options.text)),this.options.underline!==!1&&o.push(pp.configure((e=this.options)==null?void 0:e.underline)),this.options.trailingNode!==!1&&o.push(Ep.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),Ap=kv;function Tc(){let n=window.crypto||window.msCrypto;return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(t^n.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}var _c={};Gm(_c,{attachFiles:()=>Pv,blockQuote:()=>Tv,bold:()=>Sv,bulletList:()=>Ov,close:()=>$v,closeSvgPath:()=>es,code:()=>_v,codeBlock:()=>Cv,decreaseIndentation:()=>Lv,heading:()=>Av,increaseIndentation:()=>Iv,italics:()=>wv,link:()=>Mv,orderedList:()=>Nv,redo:()=>Dv,strike:()=>Ev,toSvg:()=>Q,undo:()=>Rv,warning:()=>Bv,warningSvgPath:()=>ns});function Q(n,t=24,e=["toolbar__icon"]){return T`<svg
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
fill="currentColor"
viewBox="0 0 ${t} ${t}"
width="${t}"
height="${t}"
part="${e.join(" ")}"
>
${n}
</svg>`}var Sv=Q(it`<path fill-rule="evenodd" d="M6 4.75c0-.69.56-1.25 1.25-1.25h5a4.75 4.75 0 013.888 7.479A5 5 0 0114 20.5H7.25c-.69 0-1.25-.56-1.25-1.25V4.75zM8.5 13v5H14a2.5 2.5 0 000-5H8.5zm0-2.5h3.751A2.25 2.25 0 0012.25 6H8.5v4.5z"></path>`),wv=Q(it`<path fill-rule="evenodd" d="M10 4.75a.75.75 0 01.75-.75h8.5a.75.75 0 010 1.5h-3.514l-5.828 13h3.342a.75.75 0 010 1.5h-8.5a.75.75 0 010-1.5h3.514l5.828-13H10.75a.75.75 0 01-.75-.75z"></path>`),Ev=Q(it`<path fill-rule="evenodd" d="M12.36 5C9.37 5 8.105 6.613 8.105 7.848c0 .411.072.744.193 1.02a.75.75 0 01-1.373.603 3.993 3.993 0 01-.32-1.623c0-2.363 2.271-4.348 5.755-4.348 1.931 0 3.722.794 4.814 1.5a.75.75 0 11-.814 1.26c-.94-.607-2.448-1.26-4-1.26zm4.173 7.5h3.717a.75.75 0 000-1.5H3.75a.75.75 0 000 1.5h9.136c1.162.28 2.111.688 2.76 1.211.642.518.979 1.134.979 1.898a2.63 2.63 0 01-.954 2.036c-.703.601-1.934 1.105-3.999 1.105-2.018 0-3.529-.723-4.276-1.445a.75.75 0 10-1.042 1.08c1.066 1.028 2.968 1.865 5.318 1.865 2.295 0 3.916-.56 4.974-1.464a4.131 4.131 0 001.479-3.177c0-1.296-.608-2.316-1.538-3.066a5.77 5.77 0 00-.054-.043z"></path>`),Mv=Q(it`<path d="M14.78 3.653a3.936 3.936 0 115.567 5.567l-3.627 3.627a3.936 3.936 0 01-5.88-.353.75.75 0 00-1.18.928 5.436 5.436 0 008.12.486l3.628-3.628a5.436 5.436 0 10-7.688-7.688l-3 3a.75.75 0 001.06 1.061l3-3z"></path> <path d="M7.28 11.153a3.936 3.936 0 015.88.353.75.75 0 001.18-.928 5.436 5.436 0 00-8.12-.486L2.592 13.72a5.436 5.436 0 107.688 7.688l3-3a.75.75 0 10-1.06-1.06l-3 3a3.936 3.936 0 01-5.567-5.568l3.627-3.627z"></path>`),Av=Q(it`<path fill-rule="evenodd" d="M6.25 4a.75.75 0 01.75.75V11h10V4.75a.75.75 0 011.5 0v14.5a.75.75 0 01-1.5 0V12.5H7v6.75a.75.75 0 01-1.5 0V4.75A.75.75 0 016.25 4z"></path>`),Tv=Q(it`<path d="M2.678 11.894a1 1 0 0 1 .287.801 10.97 10.97 0 0 1-.398 2c1.395-.323 2.247-.697 2.634-.893a1 1 0 0 1 .71-.074A8.06 8.06 0 0 0 8 14c3.996 0 7-2.807 7-6 0-3.192-3.004-6-7-6S1 4.808 1 8c0 1.468.617 2.83 1.678 3.894zm-.493 3.905a21.682 21.682 0 0 1-.713.129c-.2.032-.352-.176-.273-.362a9.68 9.68 0 0 0 .244-.637l.003-.01c.248-.72.45-1.548.524-2.319C.743 11.37 0 9.76 0 8c0-3.866 3.582-7 8-7s8 3.134 8 7-3.582 7-8 7a9.06 9.06 0 0 1-2.347-.306c-.52.263-1.639.742-3.468 1.105z" /> <path d="M7.066 6.76A1.665 1.665 0 0 0 4 7.668a1.667 1.667 0 0 0 2.561 1.406c-.131.389-.375.804-.777 1.22a.417.417 0 0 0 .6.58c1.486-1.54 1.293-3.214.682-4.112zm4 0A1.665 1.665 0 0 0 8 7.668a1.667 1.667 0 0 0 2.561 1.406c-.131.389-.375.804-.777 1.22a.417.417 0 0 0 .6.58c1.486-1.54 1.293-3.214.682-4.112z" />`,16),_v=Q(it`
<path d="M10.478 1.647a.5.5 0 1 0-.956-.294l-4 13a.5.5 0 0 0 .956.294zM4.854 4.146a.5.5 0 0 1 0 .708L1.707 8l3.147 3.146a.5.5 0 0 1-.708.708l-3.5-3.5a.5.5 0 0 1 0-.708l3.5-3.5a.5.5 0 0 1 .708 0m6.292 0a.5.5 0 0 0 0 .708L14.293 8l-3.147 3.146a.5.5 0 0 0 .708.708l3.5-3.5a.5.5 0 0 0 0-.708l-3.5-3.5a.5.5 0 0 0-.708 0"/>`,16),Cv=Q(it`
<path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
<path d="M6.854 4.646a.5.5 0 0 1 0 .708L4.207 8l2.647 2.646a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 0 1 .708 0m2.292 0a.5.5 0 0 0 0 .708L11.793 8l-2.647 2.646a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708 0"/>
`,16),Ov=Q(it`<path fill-rule="evenodd" d="M4 7a1 1 0 100-2 1 1 0 000 2zm4.75-1.5a.75.75 0 000 1.5h11.5a.75.75 0 000-1.5H8.75zm0 6a.75.75 0 000 1.5h11.5a.75.75 0 000-1.5H8.75zm0 6a.75.75 0 000 1.5h11.5a.75.75 0 000-1.5H8.75zM5 12a1 1 0 11-2 0 1 1 0 012 0zm-1 7a1 1 0 100-2 1 1 0 000 2z"></path>`),Nv=Q(it`<path
d="M3.604 3.089A.75.75 0 014 3.75V8.5h.75a.75.75 0 010 1.5h-3a.75.75 0 110-1.5h.75V5.151l-.334.223a.75.75 0 01-.832-1.248l1.5-1a.75.75 0 01.77-.037zM8.75 5.5a.75.75 0 000 1.5h11.5a.75.75 0 000-1.5H8.75zm0 6a.75.75 0 000 1.5h11.5a.75.75 0 000-1.5H8.75zm0 6a.75.75 0 000 1.5h11.5a.75.75 0 000-1.5H8.75zM5.5 15.75c0-.704-.271-1.286-.72-1.686a2.302 2.302 0 00-1.53-.564c-.535 0-1.094.178-1.53.565-.449.399-.72.982-.72 1.685a.75.75 0 001.5 0c0-.296.104-.464.217-.564A.805.805 0 013.25 15c.215 0 .406.072.533.185.113.101.217.268.217.565 0 .332-.069.48-.21.657-.092.113-.216.24-.403.419l-.147.14c-.152.144-.33.313-.52.504l-1.5 1.5a.75.75 0 00-.22.53v.25c0 .414.336.75.75.75H5A.75.75 0 005 19H3.31l.47-.47c.176-.176.333-.324.48-.465l.165-.156a5.98 5.98 0 00.536-.566c.358-.447.539-.925.539-1.593z"></path>`),Pv=Q(it`<path d="M4.5 3a2.5 2.5 0 0 1 5 0v9a1.5 1.5 0 0 1-3 0V5a.5.5 0 0 1 1 0v7a.5.5 0 0 0 1 0V3a1.5 1.5 0 1 0-3 0v9a2.5 2.5 0 0 0 5 0V5a.5.5 0 0 1 1 0v7a3.5 3.5 0 1 1-7 0V3z" />`,16),Rv=Q(it`<path fill-rule="evenodd" d="M14.5 1.5a.5.5 0 0 1 .5.5v4.8a2.5 2.5 0 0 1-2.5 2.5H2.707l3.347 3.346a.5.5 0 0 1-.708.708l-4.2-4.2a.5.5 0 0 1 0-.708l4-4a.5.5 0 1 1 .708.708L2.707 8.3H12.5A1.5 1.5 0 0 0 14 6.8V2a.5.5 0 0 1 .5-.5z" />`,16),Dv=Q(it`<path fill-rule="evenodd" d="M1.5 1.5A.5.5 0 0 0 1 2v4.8a2.5 2.5 0 0 0 2.5 2.5h9.793l-3.347 3.346a.5.5 0 0 0 .708.708l4.2-4.2a.5.5 0 0 0 0-.708l-4-4a.5.5 0 0 0-.708.708L13.293 8.3H3.5A1.5 1.5 0 0 1 2 6.8V2a.5.5 0 0 0-.5-.5z" />`,16),es=it`<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z" />`,$v=Q(es,16),Iv=Q(it`<path d="M2 3.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm.646 2.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1 0 .708l-2 2a.5.5 0 0 1-.708-.708L4.293 8 2.646 6.354a.5.5 0 0 1 0-.708zM7 6.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 3a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm-5 3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/>`,16),Lv=Q(it`<path d="M2 3.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm10.646 2.146a.5.5 0 0 1 .708.708L11.707 8l1.647 1.646a.5.5 0 0 1-.708.708l-2-2a.5.5 0 0 1 0-.708l2-2zM2 6.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 3a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/>`,16),ns=it`
<path d="M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016.15.15 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.2.2 0 0 1-.054.06.1.1 0 0 1-.066.017H1.146a.1.1 0 0 1-.066-.017.2.2 0 0 1-.054-.06.18.18 0 0 1 .002-.183L7.884 2.073a.15.15 0 0 1 .054-.057m1.044-.45a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767z"/>
<path d="M7.002 12a1 1 0 1 1 2 0 1 1 0 0 1-2 0M7.1 5.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0z"/>`,Bv=Q(ns,16,[]);function rs(n){let t=n/1024;if(t<1)return n.toString()+"B";let e=t/1024;return e<1?t.toFixed(0).toString()+" KB":e.toFixed(0).toString()+" MB"}var is=Y`
[hidden] {
display: none !important;
}
*,
*::after,
*::before {
box-sizing: border-box;
}
button {
background-color: inherit;
border: none;
color: inherit;
cursor: pointer;
}
`;var ss=/Mac|iOS|iPhone|iPad|iPod/i.test(window.navigator.platform),Ut=ss?"cmd":"ctrl",Tp=ss?"option":"alt",Qr="Unable to upload this file.",Cc="Add a caption...",_p={attachFiles:"Attach Files",bold:`Bold <${Ut}+b>`,italics:`Italicize <${Ut}+i>`,strike:`Strikethrough <${Ut}+shift+x>`,link:`Link <${Ut}+k>`,heading:`Heading <${Ut}+${Tp}+1>`,blockQuote:`Blockquote <${Ut}+shift+b>`,code:`Inline code <${Ut}+e>`,codeBlock:`Codeblock <${Ut}+${Tp}+c>`,bulletList:`Bullet List <${Ut}+shift+7>`,orderedList:`Ordered List <${Ut}+shift+8>`,undo:`Undo <${Ut}+z>`,redo:`Redo <${Ut}+shift+z>`,linkDialogLink:"Link",linkDialogUnlink:"Unlink",placeholder:"Write something...",increaseIndentation:"Increase indentation",decreaseIndentation:"Decrease indentation",fileUploadErrorMessage:Qr,captionPlaceholder:Cc};function Zr(n,t,e){return n?t(n):e?.(n)}var Xt=Object.freeze({notStarted:"not-started",loading:"loading",error:"error",success:"success"}),to=class extends en{constructor(){super();this.altTextEditor=!1;this.altTextDialogOpen=!1;this.altText="";this.imgSrc="";this.editorValue=null;this.handleClick=e=>{if(e.defaultPrevented)return;let r=e.composedPath(),o=this.shadowRoot?.querySelector("[part~='alt-text-button']");if(o&&r.includes(o)){e.preventDefault(),this.setNodeAttributes({altTextDialogOpen:this.altTextDialogOpen}),this.altTextDialogOpen=!0;return}if(!this.altTextDialogOpen||this.waitForDialogOpen)return;let i=this.shadowRoot?.querySelector("dialog");i&&i&&!r.includes(i)&&(this.altTextDialogOpen=!1,this.setNodeAttributes({altTextDialogOpen:this.altTextDialogOpen}))};this.handleKeydown=e=>{this.altTextDialogOpen&&e.key==="Escape"&&(this.altTextDialogOpen=!1,this.setNodeAttributes({altTextDialogOpen:this.altTextDialogOpen}))};this.loadingState="not-started",this.fileUploadErrorMessage=Qr,this.waitForDialogOpen=!1,this.altTextMaxLength=2e3,this.altTextMinLength=1,this.removeFigure=()=>{},this.setNodeAttributes=e=>{}}closeIcon(e=["icon","close-icon"]){return T`${Q(es,16,e)}`}warningIcon(){return T`${Q(ns,16,["icon","warning-icon"])}`}static get properties(){return{fileName:{attribute:"file-name",type:String},fileSize:{attribute:"file-size",type:Number},progress:{type:Number},class:{attribute:"class",type:String},loadingState:{attribute:"loading-state"},fileUploadErrorMessage:{state:!0},altTextDialogOpen:{attribute:"show-alt-text-dialog",type:Boolean},altTextMaxLength:{type:Number},imgSrc:{attribute:"img-src"},showMetadata:{attribute:"show-metadata",reflect:!0,type:Boolean},editorValue:{},altText:{attribute:"alt-text"},previewable:{reflect:!0,type:Boolean}}}connectedCallback(){super.connectedCallback(),this.classList.add("rhino-attachment-editor"),document.addEventListener("click",this.handleClick),document.addEventListener("keydown",this.handleKeydown)}firstUpdated(e){this.editorValue=this.altText}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.handleClick),document.removeEventListener("keydown",this.handleKeydown)}static get styles(){return Y`
${is}
:host {
/* Set to none because we need height / width set. */
pointer-events: none;
position: absolute;
width: 100%;
top: 0;
left: 0;
height: 100%;
z-index: 0;
--rhino-error-background-color: hsl(0 100% 89%);
--rhino-error-text-color: hsl(0 66% 30%);
--rhino-error-border-color: hsl(0 66% 30%);
}
* {
pointer-events: initial;
}
button {
background: Canvas;
border: 2px solid var(--rhino-button-border-color);
display: flex;
align-items: center;
pointer-events: all;
padding: 0.4em 0.6em;
}
button:is(:focus-within) {
border-color: var(--rhino-button-active-border-color);
}
button[part~="alt-text-save-button"] {
display: block;
margin: 0 auto;
margin-top: 1rem;
width: 50%;
font-size: 1.15rem;
text-align: center;
border-radius: 8px;
}
button[part~="delete-button"] {
position: absolute;
top: 0;
right: 50%;
transform: translate(50%, -20px);
border-radius: 9999px;
padding: 0.15rem;
border-color: Highlight;
}
:host(:not([previewable])) button[part~="alt-text-button"] {
display: none;
}
:host(:state(image-error)) button[part~="alt-text-button"] {
display: none;
}
button[part~="alt-text-button"] {
position: absolute;
top: 4px;
left: 14px;
background: rgba(0, 0, 0, 0.8);
color: white;
border: 2px solid white;
border-radius: 4px;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 4px;
}
button[part~="alt-text-button"]:is(:focus-within, :focus, :hover):not(
[aria-disabled="true"],
:disabled
) {
border-color: var(--rhino-button-active-border-color);
background-color: rgba(0, 0, 0, 0.74);
}
:host(:state(invalid-alt-text)) [part~="alt-text-button"] {
color: orange;
border-color: orange;
}
button svg {
flex: 1 1 auto;
height: 1em;
width: 1em;
}
button:is([part~="delete-button"], [part~="dialog-close-button"]) svg {
height: 1.5rem;
width: 1.5rem;
}
button:is(:disabled, [aria-disabled="true"]) {
border-color: var(--rhino-button-border-color);
color: var(--rhino-button-disabled-text-color);
}
button[part~="dialog-close-button"] {
border-color: transparent;
border-radius: 50%;
outline-offset: 0 !important;
padding: 0.1em;
}
button:is(:focus, :focus-within):not([aria-disabled="true"], :disabled) {
outline: 2px solid var(--rhino-button-active-border-color);
outline-offset: 3px;
}
button:is(:hover):not([aria-disabled="true"], :disabled) {
background-color: var(--rhino-button-active-background-color);
}
.file-metadata {
position: absolute;
left: 50%;
top: 2em;
transform: translate(-50%, 0);
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
text-align: center;
max-width: 90%;
padding: 0.4rem 0.6rem;
outline: 1px solid white;
font-size: 0.8rem;
color: #fff;
background-color: hsla(0 0% 0% / 70%);
border-radius: 3px;
}
.file-name {
display: inline-block;
max-width: 100%;
vertical-align: bottom;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.file-size {
margin-left: 0.2em;
white-space: nowrap;
}
.file-progress-container {
top: 50%;
transform: translate(0px, -50%);
left: 5%;
width: 90%;
position: absolute;
z-index: 1;
pointer-events: none;
}
.file-progress {
--border-radius: 8px;
--progress-value-color: blue;
--progress-background-color: #eee;
height: 10px;
padding: 0;
margin: 0;
opacity: 0.9;
width: 100%;
transition: opacity 200ms ease-out visibility 200ms ease-out;
border-radius: var(--border-radius);
background-color: var(--progress-background-color);
border: 1px solid gray;
}
progress::-webkit-progress-bar {
background-color: var(--progress-background-color);
border-radius: var(--border-radius);
}
progress::-webkit-progress-value {
background-color: var(--progress-value-color);
border-radius: var(--border-radius);
}
progress::-moz-progress-bar {
/* style rules */
border-radius: var(--border-radius);
background-color: var(--progress-value-color);
}
:host([loading-state="error"]) .file-progress-error {
background-color: var(--rhino-error-background-color);
color: var(--rhino-error-text-color);
border: 1px solid var(--rhino-error-border-color);
padding: 0.4em 0.6em;
margin-top: 0.25rem;
display: inline-block;
border-radius: 8px;
}
:host([loading-state="error"]) .file-progress {
background-color: var(--rhino-error-background-color);
border-color: var(--rhino-error-border-color);
}
.file-progress[value="100"] {
opacity: 0;
visibility: hidden;
}
dialog::backdrop {
background: rgba(0, 0, 0, 0.8);
}
dialog[open]::backdrop {
pointer-events: none;
}
dialog {
border: 1px solid gray;
border-radius: 4px;
width: clamp(200px, 75vw, 800px);
}
img {
display: block;
height: auto;
width: 100%;
/* Image is scaled to fit within the container. */
/* Aspect ratio IS maintained */
object-fit: contain;
aspect-ratio: 16 / 9;
background: lightgray;
border: 2px solid gray;
border-radius: 8px;
}
textarea {
width: 100%;
resize: none;
height: 100px;
font-size: 1.25em;
border: 1px solid var(--rhino-border-color);
padding: 8px;
border-radius: 8px;
}
label {
margin-top: 1rem;
display: block;
text-align: start;
}
textarea:focus {
border-color: dodgerblue;
outline: 2px solid var(--rhino-button-active-border-color);
outline-offset: 3px;
}
[part~="dialog-heading"] {
font-size: 1.5rem;
margin: 0;
}
[part~="dialog-heading-wrapper"] {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-bottom: 8px;
}
[part~="alt-text-editor-label"] {
display: flex;
justify-content: space-between;
align-items: baseline;
}
`}toFileSize(){return this.fileSize?rs(this.fileSize):""}updated(e){if(e.has("altTextDialogOpen")){let r=this.shadowRoot?.querySelector("dialog");if(r)try{this.altTextDialogOpen?r.showModal():r.close()}catch{}}return e.has("altText")&&(this.altText.length>=this.altTextMinLength&&this.altText.length<=this.altTextMaxLength?this.deleteCustomState("invalid-alt-text"):this.addCustomState("invalid-alt-text")),super.updated(e)}render(){return T`
<button
class="delete-button"
part="button delete-button"
@pointerdown=${e=>{e.preventDefault(),this.removeFigure()}}
type="button"
>
${this.closeIcon()}
</button>
${Zr(this.altTextEditor,()=>T`
${this.renderAltTextButton()} ${this.renderAltTextDialog()}
`,()=>T``)}
<span
part="file-metadata"
class="file-metadata"
?hidden=${!this.showMetadata||!(this.fileName||this.toFileSize())}
>
<span class="file-name" part="file-name">${this.fileName}</span>
<br />
<span class="file-size" part="file-size">${this.toFileSize()}</span>
</span>
<div class="file-progress-container" part="file-progress-container">
<progress
id="file-progress"
class="file-progress"
part="file-progress"
value=${this.progress||0}
min="0"
max="100"
></progress>
<label
for="file-progress"
class="file-progress-error"
part="file-progress-error"
>
${this.loadingState==="error"?this.fileUploadErrorMessage:null}
</label>
</div>
`}renderAltTextButton(){return T`
<button
part="button alt-text-button"
type="button"
@pointerdown=${e=>{e.preventDefault(),this.setNodeAttributes({altTextDialogOpen:this.altTextDialogOpen}),this.altTextDialogOpen=!0,this.waitForDialogOpen=!0,setTimeout(()=>{this.waitForDialogOpen=!1},200)}}
>
${this.altText?T``:this.warningIcon()}
<span part="alt-text-button-label">Alt</span>
</button>
`}renderAltTextDialog(){return T`
<dialog
part="dialog"
@close=${e=>{e.target,e.currentTarget}}
>
<div part="dialog-heading-wrapper">
<h2 part="dialog-heading">Add alt text</h2>
<button
part="button dialog-close-button"
@mousedown=${e=>e.preventDefault()}
@click=${e=>{e.preventDefault(),this.altTextDialogOpen=!1,this.setNodeAttributes({altTextDialogOpen:this.altTextDialogOpen})}}
>
${this.closeIcon()}
</button>
</div>
<img
part="alt-text-image"
src="${this.imgSrc}"
@load=${()=>{this.deleteCustomState("image-error")}}
@error=${()=>{this.addCustomState("image-error")}}
/>
<label part="alt-text-editor-label" for="alt-text-editor">
<span part="alt-text-editor-label-text"> Descriptive alt text </span>
<span part="alt-text-editor-label-counter"
>${this.editorValue?.length||0} / ${this.altTextMaxLength}</span
>
</label>
<textarea
part="alt-text-editor"
id="alt-text-editor"
.value=${this.altText}
@input=${e=>this.editorValue=e.currentTarget.value}
maxlength="${this.altTextMaxLength}"
minlength="${this.altTextMinLength}"
></textarea>
<button
part="button alt-text-save-button"
type="button"
@pointerdown=${e=>{e.currentTarget.ariaDisabled!=="true"&&e.preventDefault()}}
@click=${e=>{if(e.currentTarget.ariaDisabled==="true")return;e.preventDefault();let r=this.shadowRoot?.querySelector("textarea")?.value||"";this.altText=r,this.altTextDialogOpen=!1,this.setNodeAttributes({alt:this.altText,altTextDialogOpen:this.altTextDialogOpen})}}
aria-disabled="${(this.editorValue?.length||0)>this.altTextMaxLength||(this.editorValue?.length||0)<this.altTextMinLength}}"
>
Save
</button>
</dialog>
`}};to.baseName="rhino-attachment-editor";function as({fileName:n,fileSize:t}){return!n||!t?"":`${n} \xB7 ${rs(Number(t))}`}var Np={exports:{}};(function(n,t){(function(e){n.exports=e()})(function(e){var r=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function o(b,k){var m=b[0],g=b[1],v=b[2],S=b[3];m+=(g&v|~g&S)+k[0]-680876936|0,m=(m<<7|m>>>25)+g|0,S+=(m&g|~m&v)+k[1]-389564586|0,S=(S<<12|S>>>20)+m|0,v+=(S&m|~S&g)+k[2]+606105819|0,v=(v<<17|v>>>15)+S|0,g+=(v&S|~v&m)+k[3]-1044525330|0,g=(g<<22|g>>>10)+v|0,m+=(g&v|~g&S)+k[4]-176418897|0,m=(m<<7|m>>>25)+g|0,S+=(m&g|~m&v)+k[5]+1200080426|0,S=(S<<12|S>>>20)+m|0,v+=(S&m|~S&g)+k[6]-1473231341|0,v=(v<<17|v>>>15)+S|0,g+=(v&S|~v&m)+k[7]-45705983|0,g=(g<<22|g>>>10)+v|0,m+=(g&v|~g&S)+k[8]+1770035416|0,m=(m<<7|m>>>25)+g|0,S+=(m&g|~m&v)+k[9]-1958414417|0,S=(S<<12|S>>>20)+m|0,v+=(S&m|~S&g)+k[10]-42063|0,v=(v<<17|v>>>15)+S|0,g+=(v&S|~v&m)+k[11]-1990404162|0,g=(g<<22|g>>>10)+v|0,m+=(g&v|~g&S)+k[12]+1804603682|0,m=(m<<7|m>>>25)+g|0,S+=(m&g|~m&v)+k[13]-40341101|0,S=(S<<12|S>>>20)+m|0,v+=(S&m|~S&g)+k[14]-1502002290|0,v=(v<<17|v>>>15)+S|0,g+=(v&S|~v&m)+k[15]+1236535329|0,g=(g<<22|g>>>10)+v|0,m+=(g&S|v&~S)+k[1]-165796510|0,m=(m<<5|m>>>27)+g|0,S+=(m&v|g&~v)+k[6]-1069501632|0,S=(S<<9|S>>>23)+m|0,v+=(S&g|m&~g)+k[11]+643717713|0,v=(v<<14|v>>>18)+S|0,g+=(v&m|S&~m)+k[0]-373897302|0,g=(g<<20|g>>>12)+v|0,m+=(g&S|v&~S)+k[5]-701558691|0,m=(m<<5|m>>>27)+g|0,S+=(m&v|g&~v)+k[10]+38016083|0,S=(S<<9|S>>>23)+m|0,v+=(S&g|m&~g)+k[15]-660478335|0,v=(v<<14|v>>>18)+S|0,g+=(v&m|S&~m)+k[4]-405537848|0,g=(g<<20|g>>>12)+v|0,m+=(g&S|v&~S)+k[9]+568446438|0,m=(m<<5|m>>>27)+g|0,S+=(m&v|g&~v)+k[14]-1019803690|0,S=(S<<9|S>>>23)+m|0,v+=(S&g|m&~g)+k[3]-187363961|0,v=(v<<14|v>>>18)+S|0,g+=(v&m|S&~m)+k[8]+1163531501|0,g=(g<<20|g>>>12)+v|0,m+=(g&S|v&~S)+k[13]-1444681467|0,m=(m<<5|m>>>27)+g|0,S+=(m&v|g&~v)+k[2]-51403784|0,S=(S<<9|S>>>23)+m|0,v+=(S&g|m&~g)+k[7]+1735328473|0,v=(v<<14|v>>>18)+S|0,g+=(v&m|S&~m)+k[12]-1926607734|0,g=(g<<20|g>>>12)+v|0,m+=(g^v^S)+k[5]-378558|0,m=(m<<4|m>>>28)+g|0,S+=(m^g^v)+k[8]-2022574463|0,S=(S<<11|S>>>21)+m|0,v+=(S^m^g)+k[11]+1839030562|0,v=(v<<16|v>>>16)+S|0,g+=(v^S^m)+k[14]-35309556|0,g=(g<<23|g>>>9)+v|0,m+=(g^v^S)+k[1]-1530992060|0,m=(m<<4|m>>>28)+g|0,S+=(m^g^v)+k[4]+1272893353|0,S=(S<<11|S>>>21)+m|0,v+=(S^m^g)+k[7]-155497632|0,v=(v<<16|v>>>16)+S|0,g+=(v^S^m)+k[10]-1094730640|0,g=(g<<23|g>>>9)+v|0,m+=(g^v^S)+k[13]+681279174|0,m=(m<<4|m>>>28)+g|0,S+=(m^g^v)+k[0]-358537222|0,S=(S<<11|S>>>21)+m|0,v+=(S^m^g)+k[3]-722521979|0,v=(v<<16|v>>>16)+S|0,g+=(v^S^m)+k[6]+76029189|0,g=(g<<23|g>>>9)+v|0,m+=(g^v^S)+k[9]-640364487|0,m=(m<<4|m>>>28)+g|0,S+=(m^g^v)+k[12]-421815835|0,S=(S<<11|S>>>21)+m|0,v+=(S^m^g)+k[15]+530742520|0,v=(v<<16|v>>>16)+S|0,g+=(v^S^m)+k[2]-995338651|0,g=(g<<23|g>>>9)+v|0,m+=(v^(g|~S))+k[0]-198630844|0,m=(m<<6|m>>>26)+g|0,S+=(g^(m|~v))+k[7]+1126891415|0,S=(S<<10|S>>>22)+m|0,v+=(m^(S|~g))+k[14]-1416354905|0,v=(v<<15|v>>>17)+S|0,g+=(S^(v|~m))+k[5]-57434055|0,g=(g<<21|g>>>11)+v|0,m+=(v^(g|~S))+k[12]+1700485571|0,m=(m<<6|m>>>26)+g|0,S+=(g^(m|~v))+k[3]-1894986606|0,S=(S<<10|S>>>22)+m|0,v+=(m^(S|~g))+k[10]-1051523|0,v=(v<<15|v>>>17)+S|0,g+=(S^(v|~m))+k[1]-2054922799|0,g=(g<<21|g>>>11)+v|0,m+=(v^(g|~S))+k[8]+1873313359|0,m=(m<<6|m>>>26)+g|0,S+=(g^(m|~v))+k[15]-30611744|0,S=(S<<10|S>>>22)+m|0,v+=(m^(S|~g))+k[6]-1560198380|0,v=(v<<15|v>>>17)+S|0,g+=(S^(v|~m))+k[13]+1309151649|0,g=(g<<21|g>>>11)+v|0,m+=(v^(g|~S))+k[4]-145523070|0,m=(m<<6|m>>>26)+g|0,S+=(g^(m|~v))+k[11]-1120210379|0,S=(S<<10|S>>>22)+m|0,v+=(m^(S|~g))+k[2]+718787259|0,v=(v<<15|v>>>17)+S|0,g+=(S^(v|~m))+k[9]-343485551|0,g=(g<<21|g>>>11)+v|0,b[0]=m+b[0]|0,b[1]=g+b[1]|0,b[2]=v+b[2]|0,b[3]=S+b[3]|0}function i(b){var k=[],m;for(m=0;m<64;m+=4)k[m>>2]=b.charCodeAt(m)+(b.charCodeAt(m+1)<<8)+(b.charCodeAt(m+2)<<16)+(b.charCodeAt(m+3)<<24);return k}function s(b){var k=[],m;for(m=0;m<64;m+=4)k[m>>2]=b[m]+(b[m+1]<<8)+(b[m+2]<<16)+(b[m+3]<<24);return k}function a(b){var k=b.length,m=[1732584193,-271733879,-1732584194,271733878],g,v,S,C,M,B;for(g=64;g<=k;g+=64)o(m,i(b.substring(g-64,g)));for(b=b.substring(g-64),v=b.length,S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],g=0;g<v;g+=1)S[g>>2]|=b.charCodeAt(g)<<(g%4<<3);if(S[g>>2]|=128<<(g%4<<3),g>55)for(o(m,S),g=0;g<16;g+=1)S[g]=0;return C=k*8,C=C.toString(16).match(/(.*?)(.{0,8})$/),M=parseInt(C[2],16),B=parseInt(C[1],16)||0,S[14]=M,S[15]=B,o(m,S),m}function l(b){var k=b.length,m=[1732584193,-271733879,-1732584194,271733878],g,v,S,C,M,B;for(g=64;g<=k;g+=64)o(m,s(b.subarray(g-64,g)));for(b=g-64<k?b.subarray(g-64):new Uint8Array(0),v=b.length,S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],g=0;g<v;g+=1)S[g>>2]|=b[g]<<(g%4<<3);if(S[g>>2]|=128<<(g%4<<3),g>55)for(o(m,S),g=0;g<16;g+=1)S[g]=0;return C=k*8,C=C.toString(16).match(/(.*?)(.{0,8})$/),M=parseInt(C[2],16),B=parseInt(C[1],16)||0,S[14]=M,S[15]=B,o(m,S),m}function c(b){var k="",m;for(m=0;m<4;m+=1)k+=r[b>>m*8+4&15]+r[b>>m*8&15];return k}function d(b){var k;for(k=0;k<b.length;k+=1)b[k]=c(b[k]);return b.join("")}d(a("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&function(){function b(k,m){return k=k|0||0,k<0?Math.max(k+m,0):Math.min(k,m)}ArrayBuffer.prototype.slice=function(k,m){var g=this.byteLength,v=b(k,g),S=g,C,M,B,V;return m!==e&&(S=b(m,g)),v>S?new ArrayBuffer(0):(C=S-v,M=new ArrayBuffer(C),B=new Uint8Array(M),V=new Uint8Array(this,v,C),B.set(V),M)}}();function u(b){return/[\u0080-\uFFFF]/.test(b)&&(b=unescape(encodeURIComponent(b))),b}function h(b,k){var m=b.length,g=new ArrayBuffer(m),v=new Uint8Array(g),S;for(S=0;S<m;S+=1)v[S]=b.charCodeAt(S);return k?v:g}function f(b){return String.fromCharCode.apply(null,new Uint8Array(b))}function p(b,k,m){var g=new Uint8Array(b.byteLength+k.byteLength);return g.set(new Uint8Array(b)),g.set(new Uint8Array(k),b.byteLength),m?g:g.buffer}function y(b){var k=[],m=b.length,g;for(g=0;g<m-1;g+=2)k.push(parseInt(b.substr(g,2),16));return String.fromCharCode.apply(String,k)}function x(){this.reset()}return x.prototype.append=function(b){return this.appendBinary(u(b)),this},x.prototype.appendBinary=function(b){this._buff+=b,this._length+=b.length;var k=this._buff.length,m;for(m=64;m<=k;m+=64)o(this._hash,i(this._buff.substring(m-64,m)));return this._buff=this._buff.substring(m-64),this},x.prototype.end=function(b){var k=this._buff,m=k.length,g,v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],S;for(g=0;g<m;g+=1)v[g>>2]|=k.charCodeAt(g)<<(g%4<<3);return this._finish(v,m),S=d(this._hash),b&&(S=y(S)),this.reset(),S},x.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},x.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},x.prototype.setState=function(b){return this._buff=b.buff,this._length=b.length,this._hash=b.hash,this},x.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},x.prototype._finish=function(b,k){var m=k,g,v,S;if(b[m>>2]|=128<<(m%4<<3),m>55)for(o(this._hash,b),m=0;m<16;m+=1)b[m]=0;g=this._length*8,g=g.toString(16).match(/(.*?)(.{0,8})$/),v=parseInt(g[2],16),S=parseInt(g[1],16)||0,b[14]=v,b[15]=S,o(this._hash,b)},x.hash=function(b,k){return x.hashBinary(u(b),k)},x.hashBinary=function(b,k){var m=a(b),g=d(m);return k?y(g):g},x.ArrayBuffer=function(){this.reset()},x.ArrayBuffer.prototype.append=function(b){var k=p(this._buff.buffer,b,!0),m=k.length,g;for(this._length+=b.byteLength,g=64;g<=m;g+=64)o(this._hash,s(k.subarray(g-64,g)));return this._buff=g-64<m?new Uint8Array(k.buffer.slice(g-64)):new Uint8Array(0),this},x.ArrayBuffer.prototype.end=function(b){var k=this._buff,m=k.length,g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],v,S;for(v=0;v<m;v+=1)g[v>>2]|=k[v]<<(v%4<<3);return this._finish(g,m),S=d(this._hash),b&&(S=y(S)),this.reset(),S},x.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},x.ArrayBuffer.prototype.getState=function(){var b=x.prototype.getState.call(this);return b.buff=f(b.buff),b},x.ArrayBuffer.prototype.setState=function(b){return b.buff=h(b.buff,!0),x.prototype.setState.call(this,b)},x.ArrayBuffer.prototype.destroy=x.prototype.destroy,x.ArrayBuffer.prototype._finish=x.prototype._finish,x.ArrayBuffer.hash=function(b,k){var m=l(new Uint8Array(b)),g=d(m);return k?y(g):g},x})})(Np);var zv=Np.exports,Hv=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,Nc=class n{static create(t,e){new n(t).create(e)}constructor(t){this.file=t,this.chunkSize=2097152,this.chunkCount=Math.ceil(this.file.size/this.chunkSize),this.chunkIndex=0}create(t){this.callback=t,this.md5Buffer=new zv.ArrayBuffer,this.fileReader=new FileReader,this.fileReader.addEventListener("load",e=>this.fileReaderDidLoad(e)),this.fileReader.addEventListener("error",e=>this.fileReaderDidError(e)),this.readNextChunk()}fileReaderDidLoad(t){if(this.md5Buffer.append(t.target.result),!this.readNextChunk()){let e=this.md5Buffer.end(!0),r=btoa(e);this.callback(null,r)}}fileReaderDidError(t){this.callback(`Error reading ${this.file.name}`)}readNextChunk(){if(this.chunkIndex<this.chunkCount||this.chunkIndex==0&&this.chunkCount==0){let t=this.chunkIndex*this.chunkSize,e=Math.min(t+this.chunkSize,this.file.size),r=Hv.call(this.file,t,e);return this.fileReader.readAsArrayBuffer(r),this.chunkIndex++,!0}else return!1}};function Fv(n){let t=Pp(document.head,`meta[name="${n}"]`);if(t)return t.getAttribute("content")}function Vv(n,t){typeof n=="string"&&(t=n,n=document);let e=n.querySelectorAll(t);return Dp(e)}function Pp(n,t){return typeof n=="string"&&(t=n,n=document),n.querySelector(t)}function Rp(n,t,e={}){let{disabled:r}=n,{bubbles:o,cancelable:i,detail:s}=e,a=document.createEvent("Event");a.initEvent(t,o||!0,i||!0),a.detail=s||{};try{n.disabled=!1,n.dispatchEvent(a)}finally{n.disabled=r}return a}function Dp(n){return Array.isArray(n)?n:Array.from?Array.from(n):[].slice.call(n)}var Pc=class{constructor(t,e,r,o={}){this.file=t,this.attributes={filename:t.name,content_type:t.type||"application/octet-stream",byte_size:t.size,checksum:e},this.xhr=new XMLHttpRequest,this.xhr.open("POST",r,!0),this.xhr.responseType="json",this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.setRequestHeader("Accept","application/json"),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(o).forEach(s=>{this.xhr.setRequestHeader(s,o[s])});let i=Fv("csrf-token");i!=null&&this.xhr.setRequestHeader("X-CSRF-Token",i),this.xhr.addEventListener("load",s=>this.requestDidLoad(s)),this.xhr.addEventListener("error",s=>this.requestDidError(s))}get status(){return this.xhr.status}get response(){let{responseType:t,response:e}=this.xhr;return t=="json"?e:JSON.parse(e)}create(t){this.callback=t,this.xhr.send(JSON.stringify({blob:this.attributes}))}requestDidLoad(t){if(this.status>=200&&this.status<300){let{response:e}=this,{direct_upload:r}=e;delete e.direct_upload,this.attributes=e,this.directUploadData=r,this.callback(null,this.toJSON())}else this.requestDidError(t)}requestDidError(t){this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.status}`)}toJSON(){let t={};for(let e in this.attributes)t[e]=this.attributes[e];return t}},Rc=class{constructor(t){this.blob=t,this.file=t.file;let{url:e,headers:r}=t.directUploadData;this.xhr=new XMLHttpRequest,this.xhr.open("PUT",e,!0),this.xhr.responseType="text";for(let o in r)this.xhr.setRequestHeader(o,r[o]);this.xhr.addEventListener("load",o=>this.requestDidLoad(o)),this.xhr.addEventListener("error",o=>this.requestDidError(o))}create(t){this.callback=t,this.xhr.send(this.file.slice())}requestDidLoad(t){let{status:e,response:r}=this.xhr;e>=200&&e<300?this.callback(null,r):this.requestDidError(t)}requestDidError(t){this.callback(`Error storing "${this.file.name}". Status: ${this.xhr.status}`)}},Uv=0,eo=class{constructor(t,e,r,o={}){this.id=++Uv,this.file=t,this.url=e,this.delegate=r,this.customHeaders=o}create(t){Nc.create(this.file,(e,r)=>{if(e){t(e);return}let o=new Pc(this.file,r,this.url,this.customHeaders);Cp(this.delegate,"directUploadWillCreateBlobWithXHR",o.xhr),o.create(i=>{if(i)t(i);else{let s=new Rc(o);Cp(this.delegate,"directUploadWillStoreFileWithXHR",s.xhr),s.create(a=>{a?t(a):t(null,o.toJSON())})}})})}};function Cp(n,t,...e){if(n&&typeof n[t]=="function")return n[t](...e)}var Dc=class{constructor(t,e){this.input=t,this.file=e,this.directUpload=new eo(this.file,this.url,this),this.dispatch("initialize")}start(t){let e=document.createElement("input");e.type="hidden",e.name=this.input.name,this.input.insertAdjacentElement("beforebegin",e),this.dispatch("start"),this.directUpload.create((r,o)=>{r?(e.parentNode.removeChild(e),this.dispatchError(r)):e.value=o.signed_id,this.dispatch("end"),t(r)})}uploadRequestDidProgress(t){let e=t.loaded/t.total*100;e&&this.dispatch("progress",{progress:e})}get url(){return this.input.getAttribute("data-direct-upload-url")}dispatch(t,e={}){return e.file=this.file,e.id=this.directUpload.id,Rp(this.input,`direct-upload:${t}`,{detail:e})}dispatchError(t){this.dispatch("error",{error:t}).defaultPrevented||alert(t)}directUploadWillCreateBlobWithXHR(t){this.dispatch("before-blob-request",{xhr:t})}directUploadWillStoreFileWithXHR(t){this.dispatch("before-storage-request",{xhr:t}),t.upload.addEventListener("progress",e=>this.uploadRequestDidProgress(e))}},Kv="input[type=file][data-direct-upload-url]:not([disabled])",$c=class{constructor(t){this.form=t,this.inputs=Vv(t,Kv).filter(e=>e.files.length)}start(t){let e=this.createDirectUploadControllers(),r=()=>{let o=e.shift();o?o.start(i=>{i?(t(i),this.dispatch("end")):r()}):(t(),this.dispatch("end"))};this.dispatch("start"),r()}createDirectUploadControllers(){let t=[];return this.inputs.forEach(e=>{Dp(e.files).forEach(r=>{let o=new Dc(e,r);t.push(o)})}),t}dispatch(t,e={}){return Rp(this.form,`direct-uploads:${t}`,{detail:e})}},Oc="data-direct-uploads-processing",Ic=new WeakMap,Op=!1;function jv(){Op||(Op=!0,document.addEventListener("click",Wv,!0),document.addEventListener("submit",qv,!0),document.addEventListener("ajax:before",Jv))}function Wv(n){let t=n.target.closest("button, input");t&&t.type==="submit"&&t.form&&Ic.set(t.form,t)}function qv(n){$p(n)}function Jv(n){n.target.tagName=="FORM"&&$p(n)}function $p(n){let t=n.target;if(t.hasAttribute(Oc)){n.preventDefault();return}let e=new $c(t),{inputs:r}=e;r.length&&(n.preventDefault(),t.setAttribute(Oc,""),r.forEach(Xv),e.start(o=>{t.removeAttribute(Oc),o?r.forEach(Yv):Gv(t)}))}function Gv(n){let t=Ic.get(n)||Pp(n,"input[type=submit], button[type=submit]");if(t){let{disabled:e}=t;t.disabled=!1,t.focus(),t.click(),t.disabled=e}else t=document.createElement("input"),t.type="submit",t.style.display="none",n.appendChild(t),t.click(),n.removeChild(t);Ic.delete(n)}function Xv(n){n.disabled=!0}function Yv(n){n.disabled=!1}function Qv(){window.ActiveStorage&&jv()}setTimeout(Qv,1);var U=class extends Event{constructor(t,e){e==null&&(e={}),e.bubbles==null&&(e.bubbles=!0),e.composed==null&&(e.composed=!0),e.cancelable==null&&(e.cancelable=!0),super(t,e)}};var ds=class ds extends U{constructor(e,r){super(ds.eventName,r);this.attachmentUpload=e;this.attachmentUpload=e}};ds.eventName="rhino-direct-upload:start";var no=ds,us=class us extends U{constructor(e,r){super(us.eventName,r);this.attachmentUpload=e;this.attachmentUpload=e}};us.eventName="rhino-direct-upload:progress";var Lc=us,hs=class hs extends U{constructor(e,r){super(hs.eventName,r);this.attachmentUpload=e;this.attachmentUpload=e}};hs.eventName="rhino-direct-upload:error";var Bc=hs,fs=class fs extends U{constructor(e,r){super(fs.eventName,r);this.attachmentUpload=e;this.attachmentUpload=e}};fs.eventName="rhino-direct-upload:succeed";var ls=fs,ps=class ps extends U{constructor(e,r){super(ps.eventName,r);this.attachmentUpload=e;this.attachmentUpload=e}};ps.eventName="rhino-direct-upload:complete";var Sn=ps,cs=class{constructor(t,e){this.progress=0;if(this.attachment=t,this.element=e,this.attachment.file==null)throw"No file found for direct upload";this.directUpload=new eo(this.attachment.file,this.directUploadUrl,this)}start(){this.directUpload.create(this.directUploadDidComplete.bind(this)),this.element.dispatchEvent(new no(this))}directUploadWillStoreFileWithXHR(t){t.upload.addEventListener("progress",r=>{let o=Math.min(r.loaded/r.total*100,90);this.progress=o,this.setUploadProgress(),this.element.dispatchEvent(new Lc(this))})}handleError(t){if(this.progress=0,this.attachment.content==null&&this.attachment.setNodeMarkup({progress:0,loadingState:Xt.error}),this.element.dispatchEvent(new Bc(this)),this.element.dispatchEvent(new Sn(this)),t)throw Error(`Direct upload failed: ${t}`)}directUploadDidComplete(t,e){if(t){this.handleError(t);return}if(e&&e.attachable_sgid){let r=this.createBlobUrl(e.signed_id,e.filename);this.attachment.directUpload=this,this.attachment.setAttributes({sgid:e.attachable_sgid,url:r})}}setUploadProgress(){if(this.progress>=100){this.progress=100,this.attachment.setUploadProgress(100);return}this.attachment.setUploadProgress(this.progress)}createBlobUrl(t,e){return this.blobUrlTemplate==null?"":this.blobUrlTemplate.replace(":signed_id",t).replace(":filename",encodeURIComponent(e))}get directUploadUrl(){if(this.element.dataset.directUploadUrl==null)throw Error(`No "data-direct-upload-url" attribute is set on ${this.element}`);return this.element.dataset.directUploadUrl}get blobUrlTemplate(){return this.element.dataset.blobUrlTemplate}};var qe=class n{static get previewableRegex(){return/^image(\/(gif|png|jpe?g)|$)/}static isPreviewable(t){return(this||n).previewableRegex.test(t)}constructor(t,e){this.editorView=e,this.attributes={attachmentId:Tc(),content:null,imageId:Tc(),sgid:null,url:null,...t},this.attributes.previewable=this.isPreviewable}setUploadProgress(t){this.content==null&&this.setNodeMarkup({progress:t,loadingState:t>=100?Xt.success:Xt.loading})}setAttributes(t){if(this.attributes=Object.assign(this.attributes,t),t.content){this.setNodeMarkup({sgid:this.attributes.sgid,content:this.attributes.content,previewable:this.isPreviewable}),this.handleSuccess();return}if(t.url){if(this.isPreviewable){let e=new Image;e.setAttribute("src",t.url),e.onload=()=>{this.attributes.width=e.naturalWidth,this.attributes.height=e.naturalHeight,this.setNodeMarkup({sgid:this.attributes.sgid,url:this.attributes.url,src:this.attributes.url,href:this.attributes.url+"?content-disposition=attachment",width:this.attributes.width,height:this.attributes.height,contentType:this.contentType,previewable:this.isPreviewable}),e.remove(),this.handleSuccess()};return}this.setNodeMarkup({sgid:this.attributes.sgid,url:this.attributes.url,contentType:this.contentType,previewable:this.isPreviewable}),this.handleSuccess()}}handleSuccess(){this.setUploadProgress(100);let t=this.directUpload;t&&(t.element.dispatchEvent(new ls(t)),t.element.dispatchEvent(new Sn(t)))}setNodeMarkup(t){let e=this.editorView;e?.state.doc.descendants((r,o)=>{r.attrs.attachmentId===this.attachmentId&&e.dispatch(e.state.tr.setNodeMarkup(o,void 0,{...r.attrs,...t}))})}get attachmentId(){return this.attributes.attachmentId}get imageId(){return this.attributes.imageId}get src(){return this.attributes.src}set src(t){this.attributes.src=t}get sgid(){return this.attributes.sgid}get file(){return this.attributes.file}get contentType(){return this.attributes.contentType||this.file?.type}get fileName(){return this.attributes.fileName||this.file?.name}get fileSize(){return this.attributes.fileSize||this.file?.size}get content(){return this.attributes.content}set content(t){this.attributes.content=t}get height(){return this.attributes.height}get width(){return this.attributes.width}get isPreviewable(){let t=this.constructor.isPreviewable,e=this.contentType;return t(e||"")}get caption(){let t=as({fileName:this.attributes.fileName,fileSize:this.attributes.fileSize});return this.isPreviewable?t:this.attributes.caption||t||""}};function Ip(n,t,e){let r=n.steps.length-1;if(r<t)return;let o=n.steps[r];if(!(o instanceof at||o instanceof J))return;let i=n.mapping.maps[r],s=0;i.forEach((a,l,c,d)=>{s===0&&(s=d)}),n.setSelection(R.near(n.doc.resolve(s),e))}function lt(n,t){let e=n.closest("action-text-attachment")?.getAttribute(t);if(e)return e;let r=n.closest("[data-trix-attachment]")?.getAttribute("data-trix-attachment");return r?JSON.parse(r)[t]:null}var Zv=(n,t)=>Array.isArray(n)&&n.indexOf(t.type)>-1||t.type===n;var tx=(n,t)=>{for(let e=n.depth;e>0;e--){let r=n.node(e);if(t(r))return{pos:e>0?n.before(e):0,start:n.start(e),depth:e,node:r}}};var tr=(n,t)=>tx(n,e=>Zv(t,e));var ex=(n,t=!0)=>{if(!n)throw new Error('Invalid "node" parameter');let e=[];return n.descendants((r,o)=>{if(e.push({node:r,pos:o}),!t)return!1}),e},nx=(n,t,e=!0)=>{if(n){if(!t)throw new Error('Invalid "predicate" parameter')}else throw new Error('Invalid "node" parameter');return ex(n,e).filter(r=>t(r.node))};var zc=(n,t,e=!0)=>nx(n,r=>r.type===t,e);var ms=class ms extends U{constructor(e,r={}){super(ms.eventName,r);this.attachment=e;this.attachment=e}};ms.eventName="rhino-attachment-remove";var er=ms;var ro=class extends De{constructor(t){if(super(t),this.it=K,t.type!==Nn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===K||t==null)return this._t=void 0,this.it=t;if(t===qt)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};ro.directiveName="unsafeHTML",ro.resultType=1;var Lp=tn(ro);var nr=n=>n??K;var oo=["previewable-attachment-figure","attachment-figure"];function Fp(n){return lt(n,"content-type")||JSON.parse(n.getAttribute("data-trix-attachment")||"{}").contentType||"application/octet-stream"}var Hc=(n,t)=>{if(n instanceof HTMLElement){if(Fp(n)==="application/octet-stream")return!1;let r=n.closest("action-text-attachment");if(r){let i=r.getAttribute("previewable")==="true";return r.getAttribute("sgid")?i===t:!1}if(rr(lt(n,"previewable"),lt(n,"contentType"))===t)return!0}return!1};function rx(n,t,e,r){let o=!1;if(oo.includes(n.type.name)===!1)return o;let i=document.createElement("div");i.appendChild(At.fromSchema(e.schema).serializeNode(n));let s=i.querySelector("figcaption");if(s==null)return o;let a=s.innerHTML;return n.attrs.caption!==a&&(t.setNodeMarkup(r,void 0,{...n.attrs,caption:a}),o=!0),o}function rr(n,t){return!!(n||qe.isPreviewable(t||""))}function Bp(n){return n?"attachment--"+n.match(/\.(\w+)$/)?.[1].toLowerCase():""}function zp(n,t){return t?"attachment--preview":n?"attachment--content":"attachment--file"}var gs=F.create({name:"attachment-figure",group:"block attachmentFigure",content:"inline*",selectable:!0,draggable:!0,isolating:!0,defining:!0,addProseMirrorPlugins(){return[new O({key:new D("rhino-attachment-fixer"),appendTransaction(n,t,e){let r=e.tr,o=!1;if(e.doc.descendants((i,s,a)=>{[rx(i,r,e,s)].some(d=>d===!0)&&(o=!0)}),o)return r}}),new O({key:new D("rhino-prevent-unintended-figcaption-behavior"),props:{handlePaste:(n,t)=>{let e=n.state.selection.$anchor.parent.type.name,{clipboardData:r}=t;if(!r)return!1;if(oo.includes(e)){t.preventDefault();let o=n.state.tr,i=r.getData("text/plain");return o.insertText(i),n.dispatch(o),!0}return!1},handleKeyDown:(n,t)=>{if(["Backspace","Enter"].includes(t.key)){let e=n.state.selection.$head.parent.type.name,r=n.state.selection.$head.parent.textContent;if(n.state.selection.to!==n.state.selection.from)return!1;if(oo.includes(e)&&r==="")return t.preventDefault(),!0}return!1}}}),new O({key:new D("rhino-attachment-remove-event"),view(){let n=new Map;return{update(t,e){[t.state.schema.nodes["previewable-attachment-figure"],t.state.schema.nodes["attachment-figure"]].forEach(o=>{let i=zc(e.doc,o);zc(t.state.doc,o).forEach(s=>{let a=s.node.attrs,l=a.sgid,c=a.attachmentId;l&&n.set(l,s),c&&n.set(c,s)}),i.forEach(s=>{let a=s.node.attrs,{sgid:l,attachmentId:c}=a;if(l&&n.has(l)||c&&n.has(c))return;let d=new qe(a,t);t.dom.dispatchEvent(new er(d))}),n.clear()})}}}})]},addOptions(){return{HTMLAttributes:{class:"attachment"},fileUploadErrorMessage:Qr,captionPlaceholder:Cc,previewable:!1,altTextEditor:!1,shouldStopEvent:n=>!!n.composedPath().find(r=>r?.tagName?.toLowerCase()==="rhino-attachment-editor")}},parseHTML(){return[{tag:"figure[data-trix-attachment]",getAttrs:n=>Hc(n,this.options.previewable)?null:!1},{tag:"action-text-attachment:not([content]) > figure.attachment",contentElement:"figcaption",getAttrs:n=>Hc(n,this.options.previewable)?null:!1},{tag:"action-text-attachment[content]",getAttrs:n=>Hc(n,this.options.previewable)?null:!1}]},renderHTML({node:n}){let{content:t,contentType:e,sgid:r,fileName:o,fileSize:i,caption:s,url:a,previewable:l,src:c,width:d,height:u,alt:h}=n.attrs,f={caption:s,contentType:e,content:t,filename:o,filesize:i,height:u,width:d,sgid:r,url:a,src:c,alt:h},p=["figure",$(this.options.HTMLAttributes,{class:this.options.HTMLAttributes.class+" "+zp(t,rr(l,e))+" "+Bp(o),"data-trix-content-type":e,"data-trix-attachment":JSON.stringify(f),"data-trix-attributes":JSON.stringify({caption:s,...rr(l,e)?{presentation:"gallery"}:{}})})],y=["figcaption",$({},{class:"attachment__caption attachment__caption--edited"}),0],x=["img",$({},{src:a||c,contenteditable:!1,width:d,height:u,alt:h})];return!t&&rr(l,e)?[...p,x,y]:[...p,y]},addAttributes(){return{attachmentId:{default:null},altTextDialogOpen:{default:!1},caption:{default:null,parseHTML:n=>n.querySelector("figcaption")?.innerHTML||lt(n,"caption")},progress:{default:0,parseHTML:n=>lt(n,"sgid")||lt(n,"content")||n.closest("action-text-attachment")?.innerHTML?100:0},loadingState:{default:Xt.notStarted,parseHTML:n=>lt(n,"sgid")?Xt.success:Xt.notStarted},alt:{default:"",parseHTML:n=>lt(n,"alt")||n.querySelector("img")?.getAttribute("alt")||""},sgid:{default:null,parseHTML:n=>lt(n,"sgid")},src:{default:null,parseHTML:n=>lt(n,"src")},height:{default:null,parseHTML:n=>lt(n,"height")},width:{default:null,parseHTML:n=>lt(n,"width")},contentType:{default:null,parseHTML:n=>Fp(n)},fileName:{default:null,parseHTML:n=>lt(n,"filename")},fileSize:{default:null,parseHTML:n=>lt(n,"filesize")},content:{default:null,parseHTML:n=>{let t=n.closest("action-text-attachment"),e="";if(t){let i=new DOMParser().parseFromString(t.innerHTML,"text/html").body.firstElementChild;i&&(i.tagName.toLowerCase()!=="figure"||!i.classList.contains("attachment"))&&(e=t.innerHTML)}return e||lt(n,"content")}},url:{default:null,parseHTML:n=>lt(n,"url")},previewable:{default:!1,parseHTML:n=>{let{previewable:t}=JSON.parse(n.getAttribute("data-trix-attachment")||"{}");return t==null&&(t=lt(n,"previewable")),t}}}},addNodeView(){return({node:n,getPos:t,editor:e})=>{let{content:r,contentType:o,sgid:i,fileName:s,progress:a,fileSize:l,url:c,src:d,width:u,height:h,caption:f,previewable:p,loadingState:y,alt:x,altTextDialogOpen:b}=n.attrs,k=JSON.stringify({contentType:o,content:r,filename:s,filesize:l,alt:x,height:h,width:u,sgid:i,url:c,caption:f}),m=rr(p,o),g=JSON.stringify({...m?{presentation:"gallery"}:{},caption:f}),v=`
${this.options.HTMLAttributes.class}
${zp(r,rr(p,o))}
${Bp(s)}
`;function S(ht){let It=ht.currentTarget,Lt=It.querySelector("figcaption"),be=It.querySelector("rhino-attachment-editor"),td=ht.composedPath();if(!(Lt&&td.includes(Lt))&&!(be&&td.includes(be))&&typeof t=="function"){let{view:mo}=e,{tr:ed}=mo.state,Ys=t();if(Ys==null)return;let nd=mo.state.doc.nodeAt(Ys+1);nd?.nodeSize,ed.setSelection(_.create(mo.state.doc,Ys+1+(nd?.nodeSize||0))),mo.dispatch(ed)}}let C;m&&(c||d)&&(C=c||d);let M=!1,B=null,V=ht=>{B=setTimeout(()=>{M=!0},20)},gt=ht=>{M=!1,B&&clearTimeout(B)},ot=ht=>{if(M&&typeof t=="function"){let It=t();if(It==null)return;let{view:Lt}=e;Lt.dispatch(Lt.state.tr.setSelection(N.create(Lt.state.doc,It)))}};function bt(ht){if(typeof t=="function"){let{view:It}=e,{tr:Lt}=It.state,be=t();if(be==null)return;Lt.setNodeMarkup(be,null,{...n.attrs,...ht}),It.dispatch(Lt)}}function X(){if(typeof t=="function"){let{view:It}=e,{tr:Lt}=It.state,be=t();if(be==null)return;Lt.delete(be,be+1),It.dispatch(Lt)}let ht=this.closest(".attachment");ht&&ht.remove()}let Et=T`
<figure
class=${v}
attachment-type=${this.name}
sgid=${nr(i||void 0)}
data-trix-content-type=${o}
data-trix-attachment=${k}
data-trix-attributes=${g}
@click=${S}
@mousedown=${V}
@mouseup=${gt}
@mousemove=${ot}
>
<rhino-attachment-editor
file-name=${s||""}
file-size=${String(l||0)}
loading-state=${y||Xt.notStarted}
img-src=${nr(C)}
progress=${String(a||(i||r||!l?100:a))}
contenteditable="false"
?previewable=${m}
?show-metadata=${m}
.fileUploadErrorMessage=${this.options.fileUploadErrorMessage}
.removeFigure=${X}
.setNodeAttributes=${bt}
.altTextDialogOpen=${b}
.altTextEditor=${!!this.options.altTextEditor}
alt-text=${x}
>
</rhino-attachment-editor>
${Zr(r,()=>T`${Lp(r)}`,()=>T``)}
${Zr(m&&!r,()=>T` <img
class=${y===Xt.error?"rhino-upload-error":""}
width=${String(u)}
height=${String(h)}
src=${nr(C)}
alt=${x}
contenteditable="false"
/>`,()=>T``)}
<figcaption
style="${r?"display: none;":""}"
class=${`attachment__caption ${f?"attachment__caption--edited":"is-empty"}`}
data-placeholder=${this.options.captionPlaceholder}
data-default-caption=${as({fileName:s,fileSize:l})}
></figcaption>
</figure>
`,rt=document.createElement("div");So(Et,rt);let Z=rt.firstElementChild,Pt=Z?.querySelector("figcaption"),Wt=!1,Xs=this.options.shouldStopEvent;return{dom:Z,contentDOM:Pt,stopEvent(ht){return Xs(ht)},update(ht){if(ht.type.name!=="attachment")return!1;if(!Wt&&ht.attrs.url){Wt=!0;try{URL.revokeObjectURL(ht.attrs.src)}catch{}}return!1}}}},addCommands(){return{setAttachmentAtCoords:(n,t)=>({view:e,state:r,tr:o,dispatch:i})=>{let s=e.posAtCoords(t),a=r.doc.resolve(s?.pos||0);return Hp(n,a,{state:r,tr:o,dispatch:i})},setAttachment:n=>({state:t,tr:e,dispatch:r})=>{let o=t.doc.resolve(t.selection.anchor);return Hp(n,o,{state:t,tr:e,dispatch:r})}}}}),Vp=gs.extend({name:"previewable-attachment-figure",group:"block previewableAttachmentFigure",addOptions(){return{...gs.options,previewable:!0}},addProseMirrorPlugins(){return[]}});function Hp(n,t,{state:e,tr:r,dispatch:o}){let{schema:i}=e,s=0,a=r.doc.content.size;function l(g,v=s,S=a){return g<v?v:g>S?S:g}let c=i.nodes["attachment-gallery"]==null,d=e.doc.resolve(t.pos),u=tr(d,i.nodes.paragraph),h=tr(e.doc.resolve(t.pos),i.nodes["attachment-gallery"]),f=null;if(u){let g=t.parent.textContent==="",v=e.doc.resolve(l(u.pos-1));g&&v.parent.type.name==="attachment-gallery"&&(f=l(u.pos-1))}let p=h||f,y=Array.isArray(n)?n:[].concat(n),x=!0,b=[],k=[];y.forEach(g=>{let v=g.isPreviewable?"previewable-attachment-figure":"attachment-figure",S=i.nodes[v].create(g,g.caption?[i.text(g.caption)]:[]);if(c){b.push(S);return}if(!g.isPreviewable){x=!1,k.length>=1&&(b=b.concat(i.nodes["attachment-gallery"].create({},k)),k=[]),b.push(S);return}k.push(S)});let m=0;if(h?m=h.start+h.node.nodeSize-2:f!=null&&(m=f),m=l(m),c)return b=b.flatMap(g=>[g]),r.insert(m,b.concat([i.nodes.paragraph.create()])),o&&o(r),!0;if(p)x?r.insert(m,k):(!c&&k.length>=1&&(b=b.concat(i.nodes["attachment-gallery"].create({},k))),r.insert(m+1,b));else{let g=e.selection;!c&&k.length>=1&&(b=b.concat(i.nodes["attachment-gallery"].create({},k)));let v=g.from,S=e.doc.resolve(v-1),C=S.parent;if(C&&C.type.name==="doc")v-=1;else{let M=tr(S,i.nodes.paragraph);M&&M.node.textContent===""&&(v-=1)}r.replaceWith(v,g.to,[...b,i.nodes.paragraph.create()]),Ip(r,r.steps.length-1,-1)}return o&&o(r),!0}function ox(n,t,e,r){let o=!1;return n.type.name!="attachment-gallery"||n.nodeSize===2&&(t.replaceWith(r,r+n.nodeSize,e.schema.node("paragraph",null,[])),o=!0),o}var Up=F.create({name:"attachment-gallery",group:"block",draggable:!1,selectable:!1,content:"(paragraph | previewableAttachmentFigure)*",parseHTML(){return[{tag:"div.attachment-gallery"}]},renderHTML(){return["div",$({},{class:"attachment-gallery"}),0]},addProseMirrorPlugins(){return[new O({props:{handleDOMEvents:{keydown:(n,t)=>{if(t.key==="Enter"){let e=n.state.selection.$head.parent.type.name;if(e==="attachment-gallery")return t.preventDefault(),Gn(Jn)(n.state,n.dispatch),!0;if(oo.includes(e)){t.preventDefault(),Gn(Jn)(n.state,n.dispatch);let r=tr(n.state.selection.$anchor,n.state.schema.nodes["attachment-gallery"]);if(r){let o=n.state.tr;o.insert(r.pos+r.node.nodeSize,n.state.schema.nodes.paragraph.create()),Ll(o,o.steps.length-1,-1),n.dispatch(o)}return!0}}return!1}}},appendTransaction:(n,t,e)=>{let r=e.tr,o=!1;if(e.doc.descendants((i,s,a)=>{[ox(i,r,e,s)].some(d=>d===!0)&&(o=!0)}),o)return r}})]}});var Kp=hp.extend({name:"rhino-strike",renderHTML({HTMLAttributes:n}){return["del",$(this.options.HTMLAttributes,n),0]}});var jp=Ac;var Wp=Mc;var ys=class ys extends U{constructor(e,r,o){super(ys.eventName,o);this.clipboardData=e;this.originalPasteEvent=r;this.clipboardData=e,this.originalPasteEvent=r}};ys.eventName="rhino-paste";var bs=ys;function qp(){let n=new WeakMap;return new O({key:new D("rhino-paste-event"),props:{handlePaste(t,e){let{clipboardData:r}=e;if(n.has(e)||(n.set(e,null),e.defaultPrevented))return!1;let o=new bs(r,e);return t.dom.dispatchEvent(o),!1}}})}function Vc({view:n,from:t,editor:e}){let r=n.nodeDOM(t);(e.isActive("attachment-figure")||e.isActive("previewable-attachment-figure"))&&(r=r.querySelector("figcaption")||r);let o=r.dataset.nodeViewWrapper?r:r.querySelector("[data-node-view-wrapper]");return o&&(r=o.firstChild),r}var Fc=class{constructor({editor:t,element:e,view:r,updateDelay:o=250,shouldShow:i,determineNodeViewAnchor:s}){this.preventHide=!1;this.shouldShow=({view:t,state:e,from:r,to:o})=>{let{doc:i,selection:s}=e,{empty:a}=s,l=!i.textBetween(r,o).length&&fi(e.selection),c=this.element.matches(":focus-within");return!(!(t.hasFocus()||c)||a||l||!this.editor.isEditable)};this.determineNodeViewAnchor=({view:t,from:e})=>Vc({view:t,from:e,editor:this.editor});this.dragstartHandler=()=>{};this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))};this.blurHandler=()=>{setTimeout(()=>{!this.element.matches(":focus-within")&&!this.view.dom.matches(":focus-within")&&this.hide()})};this.handleDebouncedUpdate=(t,e)=>{let r=!e?.selection.eq(t.state.selection),o=!e?.doc.eq(t.state.doc);!r&&!o||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(t,r,o,e)},this.updateDelay))};this.updateHandler=(t,e,r,o)=>{let{state:i,composing:s}=t,{selection:a}=i;if(s||!e&&!r)return;let{ranges:c}=a,d=Math.min(...c.map(p=>p.$from.pos)),u=Math.max(...c.map(p=>p.$to.pos));if(!this.shouldShow?.({editor:this.editor,view:t,state:i,oldState:o,from:d,to:u})){this.hide();return}let f=null;if(Ue(i.selection)){let p=this.determineNodeViewAnchor?.({editor:this.editor,view:t,state:i,oldState:o,from:d,to:u})||t.nodeDOM(d);p&&(f=()=>p.getBoundingClientRect())}else f=()=>{let p=pi(t,d,u);return p.x=p.x-p.width/2,p};f&&this.show(f)};this.editor=t,this.element=e,this.view=r,this.updateDelay=o,i&&(this.shouldShow=i),s&&(this.determineNodeViewAnchor=s),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.element.addEventListener("focusout",this.blurHandler)}destroy(){this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.element.removeEventListener("focusout",this.blurHandler)}update(t,e){let{state:r}=t,o=r.selection.from!==r.selection.to;if(this.updateDelay>0&&o){this.handleDebouncedUpdate(t,e);return}let i=!e?.selection.eq(t.state.selection),s=!e?.doc.eq(t.state.doc);this.updateHandler(t,i,s,e)}show(t){let e=new Event("rhino-bubble-menu-show",{bubbles:!0,composed:!0,cancelable:!0});e.clientRect=t,this.element.dispatchEvent(e)}hide(){let t=new Event("rhino-bubble-menu-hide",{bubbles:!0,composed:!0});this.element.dispatchEvent(t)}},ix=n=>new O({key:typeof n.pluginKey=="string"?new D(n.pluginKey):n.pluginKey,view:t=>new Fc({view:t,...n})}),Jp=L.create({name:"rhino-bubble-menu",addOptions(){return{element:null,pluginKey:"rhino-bubble-menu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[ix({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow,determineNodeViewAnchor:this.options.determineNodeViewAnchor})]:[]}});var sx="codemark",io=100,Gp=new D(sx);function he(n,t){var e,r;return"schema"in n?(e=t?.markType)!==null&&e!==void 0?e:n.schema.marks.code:(r=t?.markType)!==null&&r!==void 0?r:n.state.schema.marks.code}function Ne(n,t){return n.resolve(Math.min(Math.max(1,t),n.nodeSize-2))}function Qp(n,t,e,r){var o;let i=n.isInSet((o=t.state.storedMarks)!==null&&o!==void 0?o:t.state.doc.resolve(e).marks()),s=t.state.doc.rangeHasMark(e,r,n);return!!(i||s)}var Xp={match:/`((?:[^`\w]|[\w])+)`$/,handler:(n,t,e,r,o,i,s)=>{if(Qp(n,t,o,i))return!1;let a=r[1],l=n.create(),c=o+a.length,d=t.state.tr.delete(o,i).insertText(a).addMark(o,c,l),u=d.setSelection(_.create(d.doc,c)).removeStoredMark(n),h=u.setMeta(s.input,{transform:u,from:o,to:i,text:`\`${a}${e}`});return t.dispatch(h),!0}},Yp={match:/^`((?:[^`\w]|[\w])+)`/,handler:(n,t,e,r,o,i,s)=>{if(Qp(n,t,o,i))return!1;let a=n.create(),l=r[1],c=o,d=t.state.tr.delete(o,i).insertText(l).addMark(o,o+l.length,a),u=d.setSelection(_.create(d.doc,c)).addStoredMark(n.create()),h=u.setMeta(s.input,{transform:u,from:o,to:i,text:`\`${l}${e}`});return t.dispatch(h),!0}};function ax(n,t,e,r,o,i){if(t.composing)return!1;let{state:s}=t,a=s.doc.resolve(e);if(a.parent.type.spec.code)return!1;let l="\uFFFC",c=a.parent.textBetween(Math.max(0,a.parentOffset-io),a.parentOffset,void 0,l)+o,d=o+a.parent.textBetween(a.parentOffset,Math.min(a.parent.nodeSize-2,a.parentOffset+io),void 0,l),u=Xp.match.exec(c),h=Yp.match.exec(d);if(u){let f=Xp.handler(n,t,o,u,e-u[0].length+o.length,r,i);if(f)return f}return h?Yp.handler(n,t,o,h,e,r+h[0].length-o.length,i):!1}function Zp(n,t){let e=new O({isInputRules:!0,state:{init:()=>null,apply(r,o){let i=r.getMeta(e);return i||(r.selectionSet||r.docChanged?null:o)}},props:{handleTextInput(r,o,i,s){let a=he(r,t);return ax(a,r,o,i,s,{input:e,cursor:n})}}});return e}function fe(n,t,e="next"){let r={action:e};return n.dispatch(n.state.tr.setMeta(t,r)),!1}function tm(n,t,e,r){if(n.state.selection.empty||e.metaKey||e.shiftKey||e.altKey||e.ctrlKey)return!1;let{from:o,to:i}=n.state.selection;if(i-o>=io||n.state.doc.rangeHasMark(o,i,r))return!1;let s=n.state.tr.addMark(o,i,r.create()),a=s.setSelection(_.create(s.doc,i)).removeStoredMark(r);return n.dispatch(a),!0}function lx(n,t,e,r){var o;if(e.metaKey)return fe(n,t);if(e.shiftKey||e.altKey||e.ctrlKey)return!1;let{selection:i,doc:s}=n.state;if(!i.empty)return!1;let a=t.getState(n.state),l=i.$from,c=!!r.isInSet(l.marks()),d=!!r.isInSet((o=l.marksAcross(Ne(s,i.from+1)))!==null&&o!==void 0?o:[]);return l.pos===n.state.doc.nodeSize-3&&l.parentOffset===l.parent.nodeSize-2&&a?.active?(n.dispatch(n.state.tr.removeStoredMark(r)),!0):c===d&&l.parentOffset!==0?!1:c&&(!a?.active||a.side===-1)&&l.parentOffset!==0?(n.dispatch(n.state.tr.removeStoredMark(r)),!0):d&&a?.side===-1?(n.dispatch(n.state.tr.addStoredMark(r.create())),!0):!1}function em(n,t,e,r){if(lx(n,t,e,r))return!0;let{selection:i}=n.state,s=i.$from;return i.empty&&s.parentOffset===s.parent.nodeSize-2?fe(n,t):!1}function cx(n,t,e,r){var o;if(e.metaKey)return fe(n,t);if(e.shiftKey||e.altKey||e.ctrlKey)return!1;let{selection:i,doc:s}=n.state,a=t.getState(n.state),l=!!r.isInSet(i.$from.marks()),c=!!r.isInSet((o=Ne(s,i.empty?i.from-1:i.from+1).marks())!==null&&o!==void 0?o:[]);if(l&&a?.side===-1&&i.$from.parentOffset===0)return!1;if(a?.side===0&&i.$from.parentOffset===0)return n.dispatch(n.state.tr.removeStoredMark(r)),!0;if(l&&c&&a?.side===0)return n.dispatch(n.state.tr.addStoredMark(r.create())),!0;if(l&&!c&&a?.active&&i.$from.parentOffset===0||!l&&a?.active&&a?.side===0)return n.dispatch(n.state.tr.removeStoredMark(r)),!0;if(l===c)return!1;if(c||!i.empty&&l){let d=i.empty?i.from-1:i.from,u=n.state.tr.setSelection(_.create(s,d));return!i.empty&&c?n.dispatch(u.addStoredMark(r.create())):n.dispatch(u.removeStoredMark(r)),!0}if((c||!i.empty&&l)&&!a?.active){let d=i.empty?i.from-1:i.from;return n.dispatch(n.state.tr.setSelection(_.create(s,d)).removeStoredMark(r)),!0}if(l&&!a?.active&&i.$from.parentOffset>0)return n.dispatch(n.state.tr.setSelection(_.create(s,i.from-1)).addStoredMark(r.create())),!0;if(l&&!c&&a?.active&&a.side!==-1)return n.dispatch(n.state.tr.addStoredMark(r.create())),!0;if(l&&!c&&a?.active){let d=i.from-1;return n.dispatch(n.state.tr.setSelection(_.create(s,d)).addStoredMark(r.create())),!0}return!1}function nm(n,t,e,r){if(cx(n,t,e,r))return!0;let{selection:i}=n.state,s=i.$from,a=t.getState(n.state);return s.pos===1&&s.parentOffset===0&&a?.side===-1?!0:i.empty&&s.parentOffset===0?fe(n,t):!1}function rm(n,t,e,r){if(e.metaKey||e.shiftKey||e.altKey||e.ctrlKey)return!1;let{selection:o,doc:i}=n.state,s=Ne(i,o.from-1),a=!!r.isInSet(s.marks()),l=s.parentOffset===0,c=!!r.isInSet(Ne(i,o.to+1).marks());if((!a||l)&&!c)return fe(n,t);let d=t.getState(n.state);if(o.empty&&d?.side===-1){let u=n.state.tr.delete(o.from-1,o.from);return n.dispatch(u),!0}return!1}function om(n,t,e,r){if(e.metaKey||e.shiftKey||e.altKey||e.ctrlKey)return!1;let{selection:o,doc:i}=n.state,s=!!r.isInSet(o.$from.marks()),a=o.$from.parentOffset===0,l=!!r.isInSet(Ne(i,o.to+2).marks());return(!s||a)&&!l?fe(n,t):!1}function im(n,t){var e,r;if(!n)return null;let{selection:o,doc:i}=n;if(!o.empty)return null;let s=!!t.isInSet((e=n.storedMarks)!==null&&e!==void 0?e:[]),a=!!t.isInSet(o.$from.marks()),l=!!t.isInSet((r=Ne(i,o.from+1).marks())!==null&&r!==void 0?r:[]),c=o.$from.parentOffset===0;return a!==l||!a&&s!==a||a&&c?n.tr.removeStoredMark(t):null}function dx(){let n=document.createElement("span");return n.classList.add("fake-cursor"),n}function ux(n){let t=new O({key:Gp,appendTransaction:(e,r,o)=>{var i;let s=t.getState(r),a=(i=e[0])===null||i===void 0?void 0:i.getMeta(t);return s?.next||a?.action==="click"?im(o,he(o,n)):null},state:{init:()=>null,apply(e,r,o,i){var s;let a=e.getMeta(t);if(a?.action==="next")return{next:!0};let l=he(i,n),c=l.isInSet((s=i.storedMarks)!==null&&s!==void 0?s:i.doc.resolve(e.selection.from).marks()),d=l.isInSet(i.doc.resolve(e.selection.from).marks()),u=l.isInSet(Ne(i.doc,e.selection.from+1).marks()),h=e.selection.$from.parentOffset===0;return e.selection.empty?!c&&u&&(!d||h)?{active:!0,side:-1}:c&&(!d||h)?{active:!0,side:0}:!c&&d&&!u?{active:!0,side:0}:c&&d&&!u?{active:!0,side:-1}:null:null}},props:{attributes:e=>{var r;let{active:o=!1}=(r=t.getState(e))!==null&&r!==void 0?r:{};return Object.assign({},o?{class:"no-cursor"}:{})},decorations:e=>{var r;let{active:o,side:i}=(r=t.getState(e))!==null&&r!==void 0?r:{};if(!o)return W.empty;let s=et.widget(e.selection.from,dx,{side:i});return W.create(e.doc,[s])},handleKeyDown(e,r){switch(r.key){case"`":return tm(e,t,r,he(e,n));case"ArrowRight":return em(e,t,r,he(e,n));case"ArrowLeft":return nm(e,t,r,he(e,n));case"Backspace":return rm(e,t,r,he(e,n));case"Delete":return om(e,t,r,he(e,n));case"ArrowUp":case"ArrowDown":case"Home":case"End":return fe(e,t);case"e":case"a":return r.ctrlKey?fe(e,t):!1;default:return!1}},handleClick(e){return fe(e,t,"click")}}});return t}function sm(n){let t=ux(n),e=Zp(t,n);return[t,e]}var am=sm;var lm=L.create({name:"rhino-codemark-plugin",addProseMirrorPlugins(){return am({markType:this.editor.schema.marks.code})}});var hx=n=>{let t=new O({key:new D("rhino-selection"),state:{init(){return W.empty},apply(e,r){if(!e.getMeta(t))return r;r=r.map(e.mapping,e.doc);let o=r.find(void 0,void 0,l=>l.rhinoSelection===!0);o?.length>=1&&(r=r.remove(o));let{doc:i,selection:s}=e,a=null;return s.to!==s.from&&(a=et.inline(s.from,s.to,n.HTMLAttributes||{},{rhinoSelection:!0})),a&&(r=r.add(i,[a])),r}},props:{handleDOMEvents:{blur:e=>{let{tr:r}=e.state,o=r.setMeta(t,{from:r.selection.from,to:r.selection.to});e.dispatch(o)},focus:e=>{let{tr:r}=e.state,o=r.setMeta(t,{from:r.selection.from,to:r.selection.to});e.dispatch(o)}},decorations(e){return this.getState(e)}}});return t},cm=L.create({name:"rhino-selection",addOptions(){return{HTMLAttributes:{class:"rhino-selection",readonly:""}}},addProseMirrorPlugins(){return[hx(this.options)]}});var dm=L.create({name:"rhino-starter-kit",addProseMirrorPlugins(){let n=[];return[["rhinoPasteEvent",qp]].forEach(([e,r])=>{let o=this.options[e];o!==!1&&n.push(r(o))}),n},addExtensions(){let n=[];return[["rhinoGallery",Up],["rhinoAttachment",gs],["rhinoStrike",Kp],["rhinoLink",ep],["rhinoFocus",Wp],["rhinoPlaceholder",jp],["rhinoBubbleMenu",Jp],["rhinoCodemarkPlugin",lm],["rhinoSelection",cm]].forEach(([e,r])=>{let o=this.options[e];o!==!1&&(n.push(r.configure(o)),e==="rhinoAttachment"&&n.push(Vp.configure(o)))}),n}});var vs=class vs extends U{constructor(e,r={}){super(vs.eventName,r);this.attachment=e;this.attachment=e}};vs.eventName="rhino-attachment-add";var so=vs;var ks=class ks extends U{constructor(e,r){super(ks.eventName,r);this.file=e;this.file=e}};ks.eventName="rhino-file-accept";var xs=ks;var ws=class ws extends U{constructor(t){super(ws.eventName,t)}};ws.eventName="rhino-before-initialize";var Ss=ws;var Ms=class Ms extends U{constructor(t){super(Ms.eventName,t)}};Ms.eventName="rhino-initialize";var Es=Ms;var Ts=class Ts extends U{constructor(t){super(Ts.eventName,t)}};Ts.eventName="rhino-focus";var As=Ts;var Cs=class Cs extends U{constructor(t){super(Cs.eventName,t)}};Cs.eventName="rhino-blur";var _s=Cs;var Ns=class Ns extends U{constructor(t){super(Ns.eventName,t)}};Ns.eventName="rhino-change";var Os=Ns;var Rs=class Rs extends U{constructor({transaction:t},e){super(Rs.eventName,e),this.transaction=t}};Rs.eventName="rhino-selection-change";var Ps=Rs;var ao="\xA0",wn=class extends en{constructor(){super();this.readonly=!1;this.hasInitialized=!1;this.pendingAttachments=[];this.serializer="html";this.accept="*";this.starterKitOptions={strike:!1,link:!1,rhinoLink:{openOnClick:!1}};this.extensions=[];this.deferInitialize=!1;this.__initialAttributes={};this.__hasRendered=!1;this.__initializationPromise__=null;this.__initializationResolver__=null;this.handleAttachment=e=>{setTimeout(()=>{if(e.defaultPrevented)return;let{attachment:r,target:o}=e;o instanceof HTMLElement&&r.file&&new cs(r,o).start()})};this.handleFileAccept=e=>{};this.handleDropFile=(e,r,o,i)=>!(r instanceof DragEvent)||i?!1:this.handleNativeDrop(r);this.handlePaste=async e=>{if(this.editor==null||e==null)return;let{clipboardData:r}=e;if(r==null)return;let o=!1,i=r.files?.length>0,s=[];if(i)s=await this.handleFiles(r.files);else{let a="text/plain";r.types.includes("text/html")&&(a="text/html"),o=r.getData(a)}setTimeout(async()=>{if(!(e.defaultPrevented||e.originalPasteEvent.defaultPrevented)){if(o!==!1){this.editor?.chain().focus().insertContent(o).run();return}if(s.length>0){this.editor?.chain().focus().setAttachment(s).run();return}}})};this.__handleCreate=()=>{this.requestUpdate()};this.__handleUpdate=()=>{this.requestUpdate(),this.hasInitialized&&(this.updateInputElementValue(),this.dispatchEvent(new Os))};this.__handleFocus=()=>{this.dispatchEvent(new As),this.requestUpdate()};this.__handleBlur=()=>{this.updateInputElementValue(),this.requestUpdate(),this.dispatchEvent(new _s)};this.__handleSelectionUpdate=({transaction:e})=>{this.requestUpdate(),this.dispatchEvent(new Ps({transaction:e}))};this.__handleTransaction=()=>{this.requestUpdate()};this.__addPendingAttachment=this.__addPendingAttachment.bind(this),this.__removePendingAttachment=this.__removePendingAttachment.bind(this),this.registerDependencies(),this.addEventListener(so.eventName,this.handleAttachment),this.addEventListener(no.eventName,this.__addPendingAttachment),this.addEventListener(Sn.eventName,this.__removePendingAttachment),this.addEventListener(er.eventName,this.__removePendingAttachment),this.addEventListener("drop",this.handleNativeDrop),this.addEventListener("rhino-paste",this.handlePaste),this.addEventListener("rhino-file-accept",this.handleFileAccept)}static get styles(){return[is,Of,Ad]}static get properties(){return{readonly:{type:Boolean,reflect:!0},input:{reflect:!0},class:{reflect:!0},accept:{reflect:!0},serializer:{reflect:!0},deferInitialize:{type:Boolean,attribute:"defer-initialize",reflect:!0},editor:{state:!0},editorElement:{state:!0},starterKitOptions:{state:!0},extensions:{state:!0}}}__getInitialAttributes(){if(this.__hasRendered)return;let e=this.slottedEditor;e&&(this.__initialAttributes={},[...e.attributes].forEach(r=>{let{nodeName:o,nodeValue:i}=r;o&&i!=null&&(this.__initialAttributes[o]=i)})),this.__hasRendered=!0}rebuildEditor(){if(!this.hasInitialized)return;let e=this.querySelectorAll("[slot='editor']");this.__getInitialAttributes(),this.editor&&this.editor.destroy(),e.forEach(r=>{r.editor?.destroy(),r.remove()}),this.editor=this.__setupEditor(this),this.__bindEditorListeners(),this.editorElement=this.querySelector(".ProseMirror"),Object.entries(this.__initialAttributes)?.forEach(([r,o])=>{if(r==="class"){this.editorElement?.classList.add(...o.split(" "));return}this.editorElement?.setAttribute(r,o)}),this.editorElement?.setAttribute("slot","editor"),this.editorElement?.classList.add("trix-content"),this.editorElement?.setAttribute("tabindex","0"),this.editorElement?.setAttribute("role","textbox"),this.requestUpdate()}getHTMLContentFromRange(e,r){let o=this.editor;if(!o)return"";let i;if(!e&&!r){let d=o.state.selection;e=d.from,r=d.to}if(i||e==null||r==null)return"";let s=document.createElement("div"),l=o.view.state.doc.slice(e,r).content,c=At.fromSchema(o.schema).serializeFragment(l);return s.append(c),s.querySelectorAll(":scope > p").forEach(d=>{um(d)}),s.innerHTML}getTextContentFromRange(e,r){let o=this.editor;if(!o)return"";let i;if(!e&&!r){let s=o.state.selection;e=s.from,r=s.to,i=s.empty}return i||e==null||r==null?"":o.state.doc.textBetween(e,r," ")}willUpdate(e){e.has("deferInitialize")&&!this.deferInitialize&&this.startEditor(),e.has("class")&&this.classList.add("rhino-editor"),super.willUpdate(e)}updated(e){if(!this.hasInitialized)return super.updated(e);e.has("readonly")&&this.editor?.setEditable(!this.readonly),(e.has("extensions")||e.has("serializer")||e.has("starterKitOptions")||e.has("translations"))&&this.rebuildEditor(),e.has("serializer")&&this.updateInputElementValue(),super.updated(e),this.dispatchEvent(new Event("rhino-update",{bubbles:!0,composed:!0,cancelable:!1}))}registerDependencies(){[to].forEach(e=>e.define())}get slottedEditor(){return this.querySelector("[slot='editor']")}__addPendingAttachment(e){this.pendingAttachments.push(e.attachmentUpload)}__removePendingAttachment(e){let r=this.pendingAttachments.findIndex(o=>"attachmentUpload"in e?o===e.attachmentUpload:"attachment"in e?o.attachment.attachmentId===e.attachment.attachmentId:!1);r>-1&&this.pendingAttachments.splice(r,1)}async connectedCallback(){super.connectedCallback(),this.__setupInitialization__(),this.editor&&this.__unBindEditorListeners(),this.classList.add("rhino-editor"),this.deferInitialize||this.startEditor()}async startEditor(){await this.updateComplete,setTimeout(()=>{this.dispatchEvent(new Ss),setTimeout(async()=>{await this.updateComplete,this.hasInitialized=!0,this.rebuildEditor(),this.dispatchEvent(new Es),this.__initializationResolver__?.(),await this.__initializationPromise__,this.updateInputElementValue()})})}disconnectedCallback(){super.disconnectedCallback(),this.editor?.destroy(),this.hasInitialized=!1,this.__initializationPromise__=null,this.__initializationResolver__=null}__setupInitialization__(){this.__initializationPromise__||(this.__initializationPromise__=new Promise(e=>{this.__initializationResolver__=e}))}get initializationComplete(){return this.__setupInitialization__(),this.__initializationPromise__}addExtensions(...e){let r=[];e.forEach(i=>{if(Array.isArray(i)){r=r.concat(i.flat(1));return}r.push(i)});let o=this.extensions.map(i=>i.name);r=r.filter(i=>!o.includes(i.name)),this.extensions=this.extensions.concat(r)}disableStarterKitOptions(...e){let r={};e.forEach(o=>{if(Array.isArray(o)){o.flat(1).forEach(i=>r[i]=!1);return}r[o]=!1}),this.starterKitOptions={...this.starterKitOptions,...r}}editorOptions(e){return{}}updateInputElementValue(){this.inputElement!=null&&this.editor!=null&&!this.readonly&&(this.inputElement.value=this.serialize())}serialize(){let e=this.editor;return e==null?"":this.serializer?.toLowerCase()==="json"?JSON.stringify(e.getJSON()):this.getHTMLAndPreserveSignificantWhiteSpace()}getHTML(){return this.editor?this.getHTMLAndPreserveSignificantWhiteSpace():""}get inputElement(){return this.input?(this.getRootNode()||document).querySelector(`#${this.input}`):void 0}async handleFiles(e){return this.editor==null?[]:e==null?[]:new Promise((r,o)=>{let i=[...e].map(l=>{let c=new xs(l);return this.dispatchEvent(c),c}),s=[];for(let l=0;l<i.length;l++){let c=i[l];c.defaultPrevented||s.push(c.file)}let a=this.transformFilesToAttachments(s);a==null||a.length<=0||(a.forEach(l=>{this.dispatchEvent(new so(l))}),r(a))})}handleNativeDrop(e){if(this.editor==null||e==null)return!1;let{dataTransfer:r}=e;return r==null||r.files.length<=0||e.defaultPrevented?!1:(e.preventDefault(),this.handleFiles(r.files).then(o=>{this.editor?.chain().focus().setAttachmentAtCoords(o,{top:e.clientY,left:e.clientX}).run()}),!0)}transformFilesToAttachments(e){if(this.editor==null||e==null||e.length===0)return;let r=[];for(let o=0;o<e.length;o++){let i=e[o];if(i==null)return;let s=URL.createObjectURL(i),a=new qe({src:s,file:i},this.editor.view);r.push(a)}return r}renderToolbar(){return T``}renderDialog(){return T``}render(){return T`
${this.renderToolbar()}
<div class="editor-wrapper" part="editor-wrapper">
${this.renderDialog()}
<div class="editor" part="editor">
<slot name="editor">
<div class="trix-content"></div>
</slot>
</div>
</div>
`}allOptions(e){return{...this.__defaultOptions(e),...this.editorOptions(e)}}normalizeDOM(e,r=new DOMParser){if(e==null||e.value==null)return;let o=r.parseFromString(e.value,"text/html"),s=[...o.querySelectorAll("figure[data-trix-attachment]")].filter(l=>l.querySelector("figcaption")==null);o.querySelectorAll("div > figure:first-child").forEach(l=>{l.parentElement?.classList.add("attachment-gallery")}),s.forEach(l=>{let c=l.getAttribute("data-trix-attributes");if(!c)return;let{caption:d}=JSON.parse(c);if(d){l.insertAdjacentHTML("beforeend",`<figcaption class="attachment__caption">${d}</figcaption>`);return}}),o.querySelectorAll("figure :not(.attachment__caption--edited) .attachment__name").forEach(l=>{l.textContent?.includes(" \xB7 ")!==!1&&l.insertAdjacentText("beforeend"," \xB7 ")}),o.querySelectorAll(":scope > p > br:not(.ProseMirror-trailingBreak)").forEach(l=>l.remove());let a=o.querySelector("body");a&&(e.value=a.innerHTML)}get __starterKitExtensions__(){return[Ap.configure(this.starterKitOptions),dm.configure(this.starterKitOptions)]}__defaultOptions(e){let r=this.inputElement?.value||"";if(r)try{r=JSON.parse(r)}catch{}return{injectCSS:!1,extensions:this.__starterKitExtensions__.concat(this.extensions),autofocus:!1,element:e,content:r,editable:!this.readonly,editorProps:{handleDrop:this.handleDropFile}}}__bindEditorListeners(){this.editor!=null&&(this.editor.on("focus",this.__handleFocus),this.editor.on("create",this.__handleCreate),this.editor.on("update",this.__handleUpdate),this.editor.on("selectionUpdate",this.__handleSelectionUpdate),this.editor.on("transaction",this.__handleTransaction),this.editor.on("blur",this.__handleBlur))}__unBindEditorListeners(){this.editor!=null&&(this.editor.off("focus",this.__handleFocus),this.editor.off("create",this.__handleCreate),this.editor.off("update",this.__handleUpdate),this.editor.off("selectionUpdate",this.__handleSelectionUpdate),this.editor.off("transaction",this.__handleTransaction),this.editor.off("blur",this.__handleBlur))}__setupEditor(e=this){return(!this.serializer||this.serializer==="html")&&this.normalizeDOM(this.inputElement),new Af(this.allOptions(e))}getHTMLAndPreserveSignificantWhiteSpace(){let e=this.editor;if(!e)return"";let r=document.createElement("div"),o=e.view.state.doc,i=e.schema,s=At.fromSchema(i).serializeFragment(o.content);return r.append(s),r.querySelectorAll(":scope > p").forEach(a=>{um(a)}),r.innerHTML}};wn.baseName="rhino-editor";function fx(n,t,e){return e&&(n=n.replace(/\ $/,ao)),n=n.replace(/(\S)\ {3}(\S)/g,"$1 "+ao+" $2").replace(/\ {2}/g,ao+" ").replace(/\ {2}/g," "+ao),t&&(n=n.replace(/^\ /,ao)),n}function um(n){if(n.textContent?.trim()===""&&!n.querySelector("br")){n.innerHTML="<br>"+n.innerHTML;return}let t=px(n);t.forEach((e,r)=>{let o=r===0,i=r===t.length-1;if(e.textContent){let s=fx(e.textContent,o,i);e.textContent=s}})}function px(n){let t=[],e=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null),r;for(;r=e.nextNode();)t.push(r);return t}function Ds(n){var t;return t=class extends n{static define(r,o,i){r||(r=this.baseName),o||(o=this);let s=window.customElements;this.__registry instanceof CustomElementRegistry&&(s=this.__registry);let a=!!s.get(r);a&&this.warnOnExistingElement&&console.warn(`${r} has already been registered.`),!a&&o&&s.define(r,class extends o{},i)}},tt(t,"baseName",""),tt(t,"warnOnExistingElement",!1),t}var Uc=class extends Ds(HTMLElement){};var hm=new WeakMap;function mx(n,t){let e=t;for(;e;){if(hm.get(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}function lo(n){return t=>{if(mx(n,t))return t;let e=n(t);return hm.set(e,n),e}}var $s=!!ShadowRoot.prototype.createElement,gx=n=>{var t;return t=class extends n{static get scopedElements(){return{}}static get shadowRootOptions(){return this.__shadowRootOptions||{mode:"open"}}static set shadowRootOptions(r){this.__shadowRootOptions=r}constructor(...r){super(...r),this.renderOptions=this.renderOptions||void 0}get registry(){return this.constructor.__registry}set registry(r){let o=this.constructor;o.__registry=r}createRenderRoot(){let r=this.constructor,{scopedElements:o,shadowRootOptions:i}=r;if(!this.registry||this.registry===r.__registry&&!Object.prototype.hasOwnProperty.call(this.constructor,"__registry")){this.registry=$s?new CustomElementRegistry:customElements;for(let[c,d]of Object.entries(o))this.defineScopedElement(c,d)}let a={mode:"open",...i,customElements:this.registry},l=this.attachShadow(a);return $s&&(this.renderOptions.creationScope=l),l instanceof ShadowRoot&&this.adoptStyles(l),l}createScopedElement(r){return($s?this.shadowRoot:document).createElement(r)}adoptStyles(r){}defineScopedElement(r,o){let i=this.registry.get(r);return i&&$s===!1&&i!==o&&console.error([`You are trying to re-register the "${r}" custom element with a different class via ScopedElementsMixin.`,"This is only possible with a CustomElementRegistry.","Your browser does not support this feature so you will need to load a polyfill for it.",'Load "@webcomponents/scoped-custom-element-registry" before you register ANY web component to the global customElements registry.','e.g. add "<script src="/node_modules/@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js"><\/script>" as your first script tag.',"For more details you can visit https://open-wc.org/docs/development/scoped-elements/"].join(`
`)),i?this.registry.get(r):this.registry.define(r,o)}},tt(t,"__registry",window.customElements),t},bx=lo(gx);var yx=n=>class extends n{static get shadowRootOptions(){return this.__shadowRootOptions||{mode:"open"}}static set shadowRootOptions(e){this.__shadowRootOptions=e}get shadowRootOptions(){return this.constructor.shadowRootOptions}createRenderRoot(){return this.shadowRoot??this.attachShadow(this.shadowRootOptions||{mode:"open"})}connectedCallback(){typeof super.connectedCallback=="function"&&super.connectedCallback(),this.renderRoot==null&&(this.renderRoot=this.createRenderRoot())}},vx=lo(yx);function fm(){let n=window.crypto||window.msCrypto;return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(t^n.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}var St=class St{constructor(t){this.element=t,this.handleLangChange=()=>{},this.handleDirChange=()=>{},this.__handleLangChange=()=>this.handleLangChange(),this.__handleDirChange=()=>this.handleDirChange(),this.constructor.eventTarget.addEventListener("lang-change",this.__handleLangChange),this.constructor.eventTarget.addEventListener("dir-change",this.__handleDirChange)}start(){let t=this.constructor;t.observer.observe(document.documentElement,t.options);let e=this.element.getRootNode().host;return e&&t.observer.observe(e,t.options),this}stop(){return this.constructor.observer.disconnect(),this}};tt(St,"options",{subtree:!0,attributes:!0,childList:!0,attributeFilter:["lang","dir"],attributeOldValue:!0}),tt(St,"langTimeout",null),tt(St,"dirTimeout",null),tt(St,"eventTarget",new EventTarget),tt(St,"observer",new MutationObserver(t=>{for(let e of t)e.type==="attributes"&&(e.attributeName==="lang"&&(St.langTimeout&&clearTimeout(St.langTimeout),St.langTimeout=setTimeout(()=>{St.eventTarget.dispatchEvent(new Event("lang-change"))},20)),e.attributeName==="dir"&&(St.dirTimeout&&clearTimeout(St.dirTimeout),St.dirTimeout=setTimeout(()=>{St.eventTarget.dispatchEvent(new Event("dir-change"))},20)))}));var Is=St;var Kc=class{constructor(t){this.element=t,this.events=new WeakMap}get(t){let e=this.events.get(t);return e||(e=(...r)=>t.apply(this.element,r),this.events.set(t,e)),e}},Je=class extends Ds(te){static get dependencies(){return{}}constructor(...t){super(...t),Object.entries(this.constructor.dependencies).forEach(([e,r])=>{customElements.get(e)||customElements.define(e,r)}),this.textDirection="ltr",this.eventHandler=new Kc(this),this.languageObserver=new Is(this).start(),this.languageObserver.handleLangChange=()=>{let e=this.textDirection;this.textDirection=this.getTextDirection(),this.requestUpdate("textDirection",e)},this.languageObserver.handleDirChange=()=>{let e=this.textDirection;this.textDirection=this.getTextDirection(),this.requestUpdate("textDirection",e)},this.__debounceMap__=null,this.internals||(this.internals=this.attachInternals())}getOrAssignId(t="",e=!1){let r=this.id;return(!r||e)&&(r=t+"-"+fm(),this.id=r),r}getTextDirection(){return this.matches(":dir(rtl)")?"rtl":"ltr"}disconnectedCallback(){super.disconnectedCallback(),this.__debounceMap__=null}debounce(t,e){this.__debounceMap__==null&&(this.__debounceMap__=new Map);let r=this.__debounceMap__.get(e.key);return r&&clearTimeout(r),r=setTimeout(()=>{t()},e.wait),this.__debounceMap__.set(e.key,r),r}setAria(t,e){this.internals[t]=e,this[t]=e}};var pm=Y`
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
`,or=Y`
:host {
--role-background-hover-color: #005a9c;
--role-border-focus-color: #005a9c;
display: block;
box-sizing: border-box;
}
*,
*:after,
*:before {
box-sizing: border-box;
}
[hidden] {
display: none !important;
}
[invisible] {
visibility: hidden !important;
}
[popover]:not(:popover-open):not(dialog[open]) {
display: none;
}
.visually-hidden:not(:focus-within):not(:active) {
${pm}
}
.always-visually-hidden {
${pm}
}
`;var ir=class extends Je{constructor(){super(),this._currentFocusIndex=0,this.orientation="horizontal",this._toolbarItems=[],this.orientation="horizontal",this.ignoreQuery="textarea, select, input, [contenteditable='true'], [data-toolbar-ignore]",this.addEventListener("click",this.eventHandler.get(this.handleClick)),this.addEventListener("keydown",this.eventHandler.get(this.handleKeyDown)),this.addEventListener("focus",this.eventHandler.get(this.handleClick))}willUpdate(t){t.has("_toolbarItems")&&this.updateToolbarItems(),t.has("orientation")&&(this.ariaOrientation=this.orientation),super.willUpdate(t)}static get baseName(){return"role-toolbar"}static get styles(){return[or,Y`
.base {
display: flex;
max-width: 100%;
padding: 0.4rem 0.6rem;
border-radius: 4px;
border: 2px solid transparent;
gap: 4px;
overflow: auto;
}
:host([orientation="vertical"]) .base {
flex-direction: column;
}
:host(:focus-within) .base {
border-color: var(--role-border-focus-color);
}
`]}get keydownHandlers(){return this._keydownHandlers?this._keydownHandlers:(this._keydownHandlers={arrowleft:this.focusPrevious,arrowup:this.focusPrevious,arrowright:this.focusNext,arrowdown:this.focusNext,home:this.focusFirst,end:this.focusLast},this._keydownHandlers)}render(){return T`
<div role="toolbar" class="base" part="base">
<slot @slotchange=${this.updateToolbarItems}></slot>
</div>
`}handleClick(t){let e=!1,r=t.composedPath().find(o=>{if(o?.matches?.(this.ignoreQuery)){e=!0;return}return(o?.getAttribute?.("data-role")||"").includes("toolbar-item")});e||(r?(this._toolbarItems.forEach((o,i)=>{if(o===r){this._currentFocusIndex=i;return}o.setAttribute("tabindex","-1")}),this.setTabIndex({focus:!1})):this.setTabIndex({focus:!0}))}handleKeyDown(t){let e=t.key?.toLowerCase();this.orientation==="vertical"&&(e==="arrowleft"||e==="arrowright")||this.orientation==="horizontal"&&(e==="arrowdown"||e==="arrowup")||t.composedPath().find(r=>r.matches?.(this.ignoreQuery))||Object.keys(this.keydownHandlers).includes(e)&&(t.preventDefault(),this.keydownHandlers[e].call(this,t))}focusNext(t){if(this.currentFocusElement?.setAttribute("tabindex","-1"),this._currentFocusIndex+=1,this._currentFocusIndex>=this._toolbarItems.length){this.focusFirst();return}this.setTabIndex()}focusPrevious(t){if(this.currentFocusElement?.setAttribute("tabindex","-1"),this._currentFocusIndex-=1,this._currentFocusIndex<0){this.focusLast();return}this.setTabIndex()}focusFirst(){this._currentFocusIndex=0,this.setTabIndex()}focusLast(){this._toolbarItems!=null&&(this._currentFocusIndex=this._toolbarItems.length-1,this.setTabIndex())}setTabIndex({focus:t=!0}={}){this.currentFocusElement?.setAttribute("tabindex","0"),t&&this.currentFocusElement?.focus?.()}get currentFocusElement(){if(this._toolbarItems!=null)return this._toolbarItems[this._currentFocusIndex]}updateToolbarItems(t){let e=t?.target||this.shadowRoot.querySelector("slot");if(e==null)return;let r=e.assignedElements({flatten:!0}).filter(o=>o instanceof HTMLElement&&o.dataset.role?.match(/toolbar-item/));this._toolbarItems=r,this._currentFocusIndex=this._toolbarItems.findIndex(o=>o.getAttribute("tabindex")==="0"),this._toolbarItems.forEach(o=>{this._toolbarItems[this._currentFocusIndex]!==o&&o.setAttribute("tabindex","-1")}),this._currentFocusIndex===-1&&(this._currentFocusIndex=0,this.currentFocusElement?.setAttribute("tabindex","0"))}};tt(ir,"properties",{orientation:{reflect:!0},ariaOrientation:{reflect:!0},_currentFocusIndex:{state:!0},_toolbarItems:{state:!0}});var pe=Math.min,wt=Math.max,uo=Math.round,ho=Math.floor,Yt=n=>({x:n,y:n}),xx={left:"right",right:"left",bottom:"top",top:"bottom"},kx={start:"end",end:"start"};function Bs(n,t,e){return wt(n,pe(t,e))}function En(n,t){return typeof n=="function"?n(t):n}function Pe(n){return n.split("-")[0]}function Mn(n){return n.split("-")[1]}function jc(n){return n==="x"?"y":"x"}function zs(n){return n==="y"?"height":"width"}var Sx=new Set(["top","bottom"]);function me(n){return Sx.has(Pe(n))?"y":"x"}function Hs(n){return jc(me(n))}function bm(n,t,e){e===void 0&&(e=!1);let r=Mn(n),o=Hs(n),i=zs(o),s=o==="x"?r===(e?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=co(s)),[s,co(s)]}function ym(n){let t=co(n);return[Ls(n),t,Ls(t)]}function Ls(n){return n.replace(/start|end/g,t=>kx[t])}var mm=["left","right"],gm=["right","left"],wx=["top","bottom"],Ex=["bottom","top"];function Mx(n,t,e){switch(n){case"top":case"bottom":return e?t?gm:mm:t?mm:gm;case"left":case"right":return t?wx:Ex;default:return[]}}function vm(n,t,e,r){let o=Mn(n),i=Mx(Pe(n),e==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(Ls)))),i}function co(n){return n.replace(/left|right|bottom|top/g,t=>xx[t])}function Ax(n){return{top:0,right:0,bottom:0,left:0,...n}}function Wc(n){return typeof n!="number"?Ax(n):{top:n,right:n,bottom:n,left:n}}function An(n){let{x:t,y:e,width:r,height:o}=n;return{width:r,height:o,top:e,left:t,right:t+r,bottom:e+o,x:t,y:e}}function xm(n,t,e){let{reference:r,floating:o}=n,i=me(t),s=Hs(t),a=zs(s),l=Pe(t),c=i==="y",d=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2,f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-o.width,y:u};break;default:f={x:r.x,y:r.y}}switch(Mn(t)){case"start":f[s]-=h*(e&&c?-1:1);break;case"end":f[s]+=h*(e&&c?-1:1);break}return f}var km=async(n,t,e)=>{let{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=e,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t)),c=await s.getElementRects({reference:n,floating:t,strategy:o}),{x:d,y:u}=xm(c,r,l),h=r,f={},p=0;for(let y=0;y<a.length;y++){let{name:x,fn:b}=a[y],{x:k,y:m,data:g,reset:v}=await b({x:d,y:u,initialPlacement:r,placement:h,strategy:o,middlewareData:f,rects:c,platform:s,elements:{reference:n,floating:t}});d=k??d,u=m??u,f={...f,[x]:{...f[x],...g}},v&&p<=50&&(p++,typeof v=="object"&&(v.placement&&(h=v.placement),v.rects&&(c=v.rects===!0?await s.getElementRects({reference:n,floating:t,strategy:o}):v.rects),{x:d,y:u}=xm(c,h,l)),y=-1)}return{x:d,y:u,placement:h,strategy:o,middlewareData:f}};async function Fs(n,t){var e;t===void 0&&(t={});let{x:r,y:o,platform:i,rects:s,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=!1,padding:f=0}=En(t,n),p=Wc(f),x=a[h?u==="floating"?"reference":"floating":u],b=An(await i.getClippingRect({element:(e=await(i.isElement==null?void 0:i.isElement(x)))==null||e?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),k=u==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,m=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),g=await(i.isElement==null?void 0:i.isElement(m))?await(i.getScale==null?void 0:i.getScale(m))||{x:1,y:1}:{x:1,y:1},v=An(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:k,offsetParent:m,strategy:l}):k);return{top:(b.top-v.top+p.top)/g.y,bottom:(v.bottom-b.bottom+p.bottom)/g.y,left:(b.left-v.left+p.left)/g.x,right:(v.right-b.right+p.right)/g.x}}var Sm=n=>({name:"arrow",options:n,async fn(t){let{x:e,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=En(n,t)||{};if(c==null)return{};let u=Wc(d),h={x:e,y:r},f=Hs(o),p=zs(f),y=await s.getDimensions(c),x=f==="y",b=x?"top":"left",k=x?"bottom":"right",m=x?"clientHeight":"clientWidth",g=i.reference[p]+i.reference[f]-h[f]-i.floating[p],v=h[f]-i.reference[f],S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),C=S?S[m]:0;(!C||!await(s.isElement==null?void 0:s.isElement(S)))&&(C=a.floating[m]||i.floating[p]);let M=g/2-v/2,B=C/2-y[p]/2-1,V=pe(u[b],B),gt=pe(u[k],B),ot=V,bt=C-y[p]-gt,X=C/2-y[p]/2+M,Et=Bs(ot,X,bt),rt=!l.arrow&&Mn(o)!=null&&X!==Et&&i.reference[p]/2-(X<ot?V:gt)-y[p]/2<0,Z=rt?X<ot?X-ot:X-bt:0;return{[f]:h[f]+Z,data:{[f]:Et,centerOffset:X-Et-Z,...rt&&{alignmentOffset:Z}},reset:rt}}});var wm=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(t){var e,r;let{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:y=!0,...x}=En(n,t);if((e=i.arrow)!=null&&e.alignmentOffset)return{};let b=Pe(o),k=me(a),m=Pe(a)===a,g=await(l.isRTL==null?void 0:l.isRTL(c.floating)),v=h||(m||!y?[co(a)]:ym(a)),S=p!=="none";!h&&S&&v.push(...vm(a,y,p,g));let C=[a,...v],M=await Fs(t,x),B=[],V=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&B.push(M[b]),u){let X=bm(o,s,g);B.push(M[X[0]],M[X[1]])}if(V=[...V,{placement:o,overflows:B}],!B.every(X=>X<=0)){var gt,ot;let X=(((gt=i.flip)==null?void 0:gt.index)||0)+1,Et=C[X];if(Et&&(!(u==="alignment"?k!==me(Et):!1)||V.every(Pt=>me(Pt.placement)===k?Pt.overflows[0]>0:!0)))return{data:{index:X,overflows:V},reset:{placement:Et}};let rt=(ot=V.filter(Z=>Z.overflows[0]<=0).sort((Z,Pt)=>Z.overflows[1]-Pt.overflows[1])[0])==null?void 0:ot.placement;if(!rt)switch(f){case"bestFit":{var bt;let Z=(bt=V.filter(Pt=>{if(S){let Wt=me(Pt.placement);return Wt===k||Wt==="y"}return!0}).map(Pt=>[Pt.placement,Pt.overflows.filter(Wt=>Wt>0).reduce((Wt,Xs)=>Wt+Xs,0)]).sort((Pt,Wt)=>Pt[1]-Wt[1])[0])==null?void 0:bt[0];Z&&(rt=Z);break}case"initialPlacement":rt=a;break}if(o!==rt)return{reset:{placement:rt}}}return{}}}};var Tx=new Set(["left","top"]);async function _x(n,t){let{placement:e,platform:r,elements:o}=n,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Pe(e),a=Mn(e),l=me(e)==="y",c=Tx.has(s)?-1:1,d=i&&l?-1:1,u=En(t,n),{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof p=="number"&&(f=a==="end"?p*-1:p),l?{x:f*d,y:h*c}:{x:h*c,y:f*d}}var Em=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(t){var e,r;let{x:o,y:i,placement:s,middlewareData:a}=t,l=await _x(t,n);return s===((e=a.offset)==null?void 0:e.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},Mm=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(t){let{x:e,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:x=>{let{x:b,y:k}=x;return{x:b,y:k}}},...l}=En(n,t),c={x:e,y:r},d=await Fs(t,l),u=me(Pe(o)),h=jc(u),f=c[h],p=c[u];if(i){let x=h==="y"?"top":"left",b=h==="y"?"bottom":"right",k=f+d[x],m=f-d[b];f=Bs(k,f,m)}if(s){let x=u==="y"?"top":"left",b=u==="y"?"bottom":"right",k=p+d[x],m=p-d[b];p=Bs(k,p,m)}let y=a.fn({...t,[h]:f,[u]:p});return{...y,data:{x:y.x-e,y:y.y-r,enabled:{[h]:i,[u]:s}}}}}};var Am=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(t){var e,r;let{placement:o,rects:i,platform:s,elements:a}=t,{apply:l=()=>{},...c}=En(n,t),d=await Fs(t,c),u=Pe(o),h=Mn(o),f=me(o)==="y",{width:p,height:y}=i.floating,x,b;u==="top"||u==="bottom"?(x=u,b=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(b=u,x=h==="end"?"top":"bottom");let k=y-d.top-d.bottom,m=p-d.left-d.right,g=pe(y-d[x],k),v=pe(p-d[b],m),S=!t.middlewareData.shift,C=g,M=v;if((e=t.middlewareData.shift)!=null&&e.enabled.x&&(M=m),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=k),S&&!h){let V=wt(d.left,0),gt=wt(d.right,0),ot=wt(d.top,0),bt=wt(d.bottom,0);f?M=p-2*(V!==0||gt!==0?V+gt:wt(d.left,d.right)):C=y-2*(ot!==0||bt!==0?ot+bt:wt(d.top,d.bottom))}await l({...t,availableWidth:M,availableHeight:C});let B=await s.getDimensions(a.floating);return p!==B.width||y!==B.height?{reset:{rects:!0}}:{}}}};function Vs(){return typeof window<"u"}function Tn(n){return _m(n)?(n.nodeName||"").toLowerCase():"#document"}function Ot(n){var t;return(n==null||(t=n.ownerDocument)==null?void 0:t.defaultView)||window}function Qt(n){var t;return(t=(_m(n)?n.ownerDocument:n.document)||window.document)==null?void 0:t.documentElement}function _m(n){return Vs()?n instanceof Node||n instanceof Ot(n).Node:!1}function Kt(n){return Vs()?n instanceof Element||n instanceof Ot(n).Element:!1}function Zt(n){return Vs()?n instanceof HTMLElement||n instanceof Ot(n).HTMLElement:!1}function Tm(n){return!Vs()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Ot(n).ShadowRoot}var Cx=new Set(["inline","contents"]);function ar(n){let{overflow:t,overflowX:e,overflowY:r,display:o}=jt(n);return/auto|scroll|overlay|hidden|clip/.test(t+r+e)&&!Cx.has(o)}var Ox=new Set(["table","td","th"]);function Cm(n){return Ox.has(Tn(n))}var Nx=[":popover-open",":modal"];function fo(n){return Nx.some(t=>{try{return n.matches(t)}catch{return!1}})}var Px=["transform","translate","scale","rotate","perspective"],Rx=["transform","translate","scale","rotate","perspective","filter"],Dx=["paint","layout","strict","content"];function Us(n){let t=Ks(),e=Kt(n)?jt(n):n;return Px.some(r=>e[r]?e[r]!=="none":!1)||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||Rx.some(r=>(e.willChange||"").includes(r))||Dx.some(r=>(e.contain||"").includes(r))}function Om(n){let t=Re(n);for(;Zt(t)&&!_n(t);){if(Us(t))return t;if(fo(t))return null;t=Re(t)}return null}function Ks(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var $x=new Set(["html","body","#document"]);function _n(n){return $x.has(Tn(n))}function jt(n){return Ot(n).getComputedStyle(n)}function po(n){return Kt(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Re(n){if(Tn(n)==="html")return n;let t=n.assignedSlot||n.parentNode||Tm(n)&&n.host||Qt(n);return Tm(t)?t.host:t}function Nm(n){let t=Re(n);return _n(t)?n.ownerDocument?n.ownerDocument.body:n.body:Zt(t)&&ar(t)?t:Nm(t)}function sr(n,t,e){var r;t===void 0&&(t=[]),e===void 0&&(e=!0);let o=Nm(n),i=o===((r=n.ownerDocument)==null?void 0:r.body),s=Ot(o);if(i){let a=js(s);return t.concat(s,s.visualViewport||[],ar(o)?o:[],a&&e?sr(a):[])}return t.concat(o,sr(o,[],e))}function js(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function $m(n){let t=jt(n),e=parseFloat(t.width)||0,r=parseFloat(t.height)||0,o=Zt(n),i=o?n.offsetWidth:e,s=o?n.offsetHeight:r,a=uo(e)!==i||uo(r)!==s;return a&&(e=i,r=s),{width:e,height:r,$:a}}function Jc(n){return Kt(n)?n:n.contextElement}function lr(n){let t=Jc(n);if(!Zt(t))return Yt(1);let e=t.getBoundingClientRect(),{width:r,height:o,$:i}=$m(t),s=(i?uo(e.width):e.width)/r,a=(i?uo(e.height):e.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var Ix=Yt(0);function Im(n){let t=Ot(n);return!Ks()||!t.visualViewport?Ix:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Lx(n,t,e){return t===void 0&&(t=!1),!e||t&&e!==Ot(n)?!1:t}function Cn(n,t,e,r){t===void 0&&(t=!1),e===void 0&&(e=!1);let o=n.getBoundingClientRect(),i=Jc(n),s=Yt(1);t&&(r?Kt(r)&&(s=lr(r)):s=lr(n));let a=Lx(i,e,r)?Im(i):Yt(0),l=(o.left+a.x)/s.x,c=(o.top+a.y)/s.y,d=o.width/s.x,u=o.height/s.y;if(i){let h=Ot(i),f=r&&Kt(r)?Ot(r):r,p=h,y=js(p);for(;y&&r&&f!==p;){let x=lr(y),b=y.getBoundingClientRect(),k=jt(y),m=b.left+(y.clientLeft+parseFloat(k.paddingLeft))*x.x,g=b.top+(y.clientTop+parseFloat(k.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,u*=x.y,l+=m,c+=g,p=Ot(y),y=js(p)}}return An({width:d,height:u,x:l,y:c})}function Ws(n,t){let e=po(n).scrollLeft;return t?t.left+e:Cn(Qt(n)).left+e}function Lm(n,t){let e=n.getBoundingClientRect(),r=e.left+t.scrollLeft-Ws(n,e),o=e.top+t.scrollTop;return{x:r,y:o}}function Bx(n){let{elements:t,rect:e,offsetParent:r,strategy:o}=n,i=o==="fixed",s=Qt(r),a=t?fo(t.floating):!1;if(r===s||a&&i)return e;let l={scrollLeft:0,scrollTop:0},c=Yt(1),d=Yt(0),u=Zt(r);if((u||!u&&!i)&&((Tn(r)!=="body"||ar(s))&&(l=po(r)),Zt(r))){let f=Cn(r);c=lr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}let h=s&&!u&&!i?Lm(s,l):Yt(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:e.y*c.y-l.scrollTop*c.y+d.y+h.y}}function zx(n){return Array.from(n.getClientRects())}function Hx(n){let t=Qt(n),e=po(n),r=n.ownerDocument.body,o=wt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=wt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),s=-e.scrollLeft+Ws(n),a=-e.scrollTop;return jt(r).direction==="rtl"&&(s+=wt(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}var Pm=25;function Fx(n,t){let e=Ot(n),r=Qt(n),o=e.visualViewport,i=r.clientWidth,s=r.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;let d=Ks();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}let c=Ws(r);if(c<=0){let d=r.ownerDocument,u=d.body,h=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-u.clientWidth-f);p<=Pm&&(i-=p)}else c<=Pm&&(i+=c);return{width:i,height:s,x:a,y:l}}var Vx=new Set(["absolute","fixed"]);function Ux(n,t){let e=Cn(n,!0,t==="fixed"),r=e.top+n.clientTop,o=e.left+n.clientLeft,i=Zt(n)?lr(n):Yt(1),s=n.clientWidth*i.x,a=n.clientHeight*i.y,l=o*i.x,c=r*i.y;return{width:s,height:a,x:l,y:c}}function Rm(n,t,e){let r;if(t==="viewport")r=Fx(n,e);else if(t==="document")r=Hx(Qt(n));else if(Kt(t))r=Ux(t,e);else{let o=Im(n);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return An(r)}function Bm(n,t){let e=Re(n);return e===t||!Kt(e)||_n(e)?!1:jt(e).position==="fixed"||Bm(e,t)}function Kx(n,t){let e=t.get(n);if(e)return e;let r=sr(n,[],!1).filter(a=>Kt(a)&&Tn(a)!=="body"),o=null,i=jt(n).position==="fixed",s=i?Re(n):n;for(;Kt(s)&&!_n(s);){let a=jt(s),l=Us(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&Vx.has(o.position)||ar(s)&&!l&&Bm(n,s))?r=r.filter(d=>d!==s):o=a,s=Re(s)}return t.set(n,r),r}function jx(n){let{element:t,boundary:e,rootBoundary:r,strategy:o}=n,s=[...e==="clippingAncestors"?fo(t)?[]:Kx(t,this._c):[].concat(e),r],a=s[0],l=s.reduce((c,d)=>{let u=Rm(t,d,o);return c.top=wt(u.top,c.top),c.right=pe(u.right,c.right),c.bottom=pe(u.bottom,c.bottom),c.left=wt(u.left,c.left),c},Rm(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Wx(n){let{width:t,height:e}=$m(n);return{width:t,height:e}}function qx(n,t,e){let r=Zt(t),o=Qt(t),i=e==="fixed",s=Cn(n,!0,i,t),a={scrollLeft:0,scrollTop:0},l=Yt(0);function c(){l.x=Ws(o)}if(r||!r&&!i)if((Tn(t)!=="body"||ar(o))&&(a=po(t)),r){let f=Cn(t,!0,i,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();i&&!r&&o&&c();let d=o&&!r&&!i?Lm(o,a):Yt(0),u=s.left+a.scrollLeft-l.x-d.x,h=s.top+a.scrollTop-l.y-d.y;return{x:u,y:h,width:s.width,height:s.height}}function qc(n){return jt(n).position==="static"}function Dm(n,t){if(!Zt(n)||jt(n).position==="fixed")return null;if(t)return t(n);let e=n.offsetParent;return Qt(n)===e&&(e=e.ownerDocument.body),e}function zm(n,t){let e=Ot(n);if(fo(n))return e;if(!Zt(n)){let o=Re(n);for(;o&&!_n(o);){if(Kt(o)&&!qc(o))return o;o=Re(o)}return e}let r=Dm(n,t);for(;r&&Cm(r)&&qc(r);)r=Dm(r,t);return r&&_n(r)&&qc(r)&&!Us(r)?e:r||Om(n)||e}var Jx=async function(n){let t=this.getOffsetParent||zm,e=this.getDimensions,r=await e(n.floating);return{reference:qx(n.reference,await t(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Gx(n){return jt(n).direction==="rtl"}var Xx={convertOffsetParentRelativeRectToViewportRelativeRect:Bx,getDocumentElement:Qt,getClippingRect:jx,getOffsetParent:zm,getElementRects:Jx,getClientRects:zx,getDimensions:Wx,getScale:lr,isElement:Kt,isRTL:Gx};function Hm(n,t){return n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height}function Yx(n,t){let e=null,r,o=Qt(n);function i(){var a;clearTimeout(r),(a=e)==null||a.disconnect(),e=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();let c=n.getBoundingClientRect(),{left:d,top:u,width:h,height:f}=c;if(a||t(),!h||!f)return;let p=ho(u),y=ho(o.clientWidth-(d+h)),x=ho(o.clientHeight-(u+f)),b=ho(d),m={rootMargin:-p+"px "+-y+"px "+-x+"px "+-b+"px",threshold:wt(0,pe(1,l))||1},g=!0;function v(S){let C=S[0].intersectionRatio;if(C!==l){if(!g)return s();C?s(!1,C):r=setTimeout(()=>{s(!1,1e-7)},1e3)}C===1&&!Hm(c,n.getBoundingClientRect())&&s(),g=!1}try{e=new IntersectionObserver(v,{...m,root:o.ownerDocument})}catch{e=new IntersectionObserver(v,m)}e.observe(n)}return s(!0),i}function Fm(n,t,e,r){r===void 0&&(r={});let{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Jc(n),d=o||i?[...c?sr(c):[],...sr(t)]:[];d.forEach(b=>{o&&b.addEventListener("scroll",e,{passive:!0}),i&&b.addEventListener("resize",e)});let u=c&&a?Yx(c,e):null,h=-1,f=null;s&&(f=new ResizeObserver(b=>{let[k]=b;k&&k.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var m;(m=f)==null||m.observe(t)})),e()}),c&&!l&&f.observe(c),f.observe(t));let p,y=l?Cn(n):null;l&&x();function x(){let b=Cn(n);y&&!Hm(y,b)&&e(),y=b,p=requestAnimationFrame(x)}return e(),()=>{var b;d.forEach(k=>{o&&k.removeEventListener("scroll",e),i&&k.removeEventListener("resize",e)}),u?.(),(b=f)==null||b.disconnect(),f=null,l&&cancelAnimationFrame(p)}}var Vm=Em;var Um=Mm,Km=wm,Gc=Am;var jm=Sm;var Wm=(n,t,e)=>{let r=new Map,o={platform:Xx,...e},i={...o.platform,_c:r};return km(n,t,{...o,platform:i})};var qm=tn(class extends De{constructor(n){if(super(n),n.type!==Nn.ATTRIBUTE||n.name!=="class"||n.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(n){return" "+Object.keys(n).filter(t=>n[t]).join(" ")+" "}update(n,[t]){if(this.st===void 0){this.st=new Set,n.strings!==void 0&&(this.nt=new Set(n.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(let r in t)t[r]&&!this.nt?.has(r)&&this.st.add(r);return this.render(t)}let e=n.element.classList;for(let r of this.st)r in t||(e.remove(r),this.st.delete(r));for(let r in t){let o=!!t[r];o===this.st.has(r)||this.nt?.has(r)||(o?(e.add(r),this.st.add(r)):(e.remove(r),this.st.delete(r)))}return qt}});function Xc(n){let t="";for(let[e,r]of Object.entries(n))r&&(t+=`${e} `);return t}var cr=class extends Event{constructor(t,e){e==null&&(e={}),e.bubbles==null&&(e.bubbles=!0),e.composed==null&&(e.composed=!0),e.cancelable==null&&(e.cancelable=!1),super(t,e)}};var qs=class extends cr{constructor(t={}){super("role-reposition",t)}};function Qx(n){return n!==null&&typeof n=="object"&&"getBoundingClientRect"in n&&("contextElement"in n?n instanceof Element:!0)}function Yc(n){return class extends n{constructor(...e){super(...e),this.anchor=this.anchor??null,this.placement=this.placement??"top",this.currentPlacement=this.placement??null,this.strategy=this.strategy??"fixed",this.distance=this.distance??0,this.skidding=this.skidding??0,this.arrow=this.arrow??!1,this.arrowPlacement=this.arrowPlacement??"anchor",this.arrowPadding=this.arrowPadding??10,this.flip=this.flip??!0,this.flipFallbackPlacements=this.flipFallbackPlacements??"",this.flipFallbackStrategy=this.flipFallbackStrategy??"best-fit",this.flipBoundary=this.flipBoundary??void 0,this.flipPadding=this.flipPadding??0,this.shift=this.shift??!0,this.shiftBoundary=this.shiftBoundary??void 0,this.shiftPadding=this.shiftPadding??0,this.autoSize=this.autoSize??null,this.sync=this.sync??null,this.autoSizeBoundary=this.autoSizeBoundary??void 0,this.autoSizePadding=this.autoSizePadding??0,this.hoverBridge=this.hoverBridge??!0,this.active=this.active??!1,this.anchoredPopoverType=this.anchoredPopoverType??"auto"}}}var Qc=()=>({active:{type:Boolean,reflect:!0},anchor:{attribute:!1,state:!0},placement:{reflect:!0},currentPlacement:{attribute:"current-placement",reflect:!0},strategy:{reflect:!0},distance:{type:Number},skidding:{type:Number},arrow:{type:Boolean},arrowPlacement:{attribute:"arrow-placement"},arrowPadding:{attribute:"arrow-padding",type:Number},flip:{type:Boolean},flipFallbackPlacements:{attribute:"flip-fallback-placements",converter:{fromAttribute:n=>n.split(" ").map(t=>t.trim()).filter(t=>t!==""),toAttribute:n=>n.join(" ")}},flipFallbackStrategy:{attribute:"flip-fallback-strategy"},flipBoundary:{attribute:!1,type:Object},flipPadding:{attribute:"flip-padding",type:Number},shift:{type:Boolean},shiftBoundary:{attribute:!1,type:Object},shiftPadding:{attribute:"shift-padding",type:Number},autoSize:{attribute:"auto-size"},sync:{},autoSizeBoundary:{type:Object},autoSizePadding:{attribute:"auto-size-padding",type:Number},hoverBridge:{attribute:"hover-bridge",type:Boolean},anchoredPopoverType:{attribute:"anchored-popover-type",reflect:!0}}),ge=class extends Yc(Je){constructor(){super();tt(this,"updateHoverBridge",()=>{if(this.hoverBridge&&this.__anchorEl&&this.popoverElement){let e=this.__anchorEl.getBoundingClientRect(),r=this.popoverElement.getBoundingClientRect(),o=(this.currentPlacement?.includes("top")||this.currentPlacement?.includes("bottom"))??!0,i=0,s=0,a=0,l=0,c=0,d=0,u=0,h=0;o?e.top<r.top?(i=e.left,s=e.bottom,a=e.right,l=e.bottom,c=r.left,d=r.top,u=r.right,h=r.top):(i=r.left,s=r.bottom,a=r.right,l=r.bottom,c=e.left,d=e.top,u=e.right,h=e.top):this.currentPlacement?.includes("left")?(i=r.right,s=r.top,a=e.right,l=e.top,c=r.right,d=r.bottom,u=e.right,h=e.bottom):(i=e.left,s=e.top,a=r.left,l=r.top,c=e.left,d=e.bottom,u=r.left,h=r.bottom),this.style.setProperty("--hover-bridge-top-left-x",`${i}px`),this.style.setProperty("--hover-bridge-top-left-y",`${s}px`),this.style.setProperty("--hover-bridge-top-right-x",`${a}px`),this.style.setProperty("--hover-bridge-top-right-y",`${l}px`),this.style.setProperty("--hover-bridge-bottom-left-x",`${c}px`),this.style.setProperty("--hover-bridge-bottom-left-y",`${d}px`),this.style.setProperty("--hover-bridge-bottom-right-x",`${u}px`),this.style.setProperty("--hover-bridge-bottom-right-y",`${h}px`)}});window.process==null&&(window.process={}),window.process.env==null&&(window.process.env="development"),this.anchor=null,this.active=!1,this.__anchorEl=null,this.__cleanup}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.__start()}disconnectedCallback(){super.disconnectedCallback(),this.__stop()}willUpdate(e){super.willUpdate(e),e.has("active")&&(this.active?this.__start():this.__stop()),e.has("anchor")&&this.__handleAnchorChange()}async updated(e){super.updated(e),this.active&&(await this.updateComplete,this.reposition())}get popoverElement(){return this.shadowRoot?.querySelector('[part~="popover"]')||null}get arrowElement(){return this.shadowRoot?.querySelector('[part~="arrow"]')||null}async __handleAnchorChange(){if(await this.__stop(),this.anchor&&typeof this.anchor=="string"){let e=this.getRootNode();this.__anchorEl=e.getElementById(this.anchor)}else this.anchor instanceof Element||Qx(this.anchor)?this.__anchorEl=this.anchor:this.__anchorEl=this.querySelector('[slot="anchor"]');this.__anchorEl instanceof HTMLSlotElement&&(this.__anchorEl=this.__anchorEl.assignedElements({flatten:!0})[0]),this.__anchorEl&&this.__start()}__start(){this.__anchorEl&&this.popoverElement&&(this.__togglePopover__(),this.cleanup=Fm(this.__anchorEl,this.popoverElement,()=>{this.reposition()}))}async __stop(){return new Promise(e=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,this.currentPlacement=null,this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height"),requestAnimationFrame(()=>{e(),this.__togglePopover__()})):(this.__togglePopover__(),e())})}__togglePopover__(){let e=this.shadowRoot?.querySelector("[popover]")||null;if(e)if(this.active)try{e.showPopover()}catch{}else try{e.hidePopover()}catch{}}reposition(){let e=this.popoverElement;if(!this.active||!this.__anchorEl||!e)return;let r=[Vm({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?r.push(Gc({apply:({rects:o})=>{let i=this.sync==="width"||this.sync==="both",s=this.sync==="height"||this.sync==="both";e.style.width=i?`${o.reference.width}px`:"",e.style.height=s?`${o.reference.height}px`:""}})):(e.style.width="",e.style.height=""),this.flip&&r.push(Km({boundary:this.flipBoundary,fallbackPlacements:this.flipFallbackPlacements,fallbackStrategy:this.flipFallbackStrategy==="best-fit"?"bestFit":"initialPlacement",padding:this.flipPadding})),this.shift&&r.push(Um({boundary:this.shiftBoundary,padding:this.shiftPadding})),this.autoSize?r.push(Gc({boundary:this.autoSizeBoundary,padding:this.autoSizePadding,apply:({availableWidth:o,availableHeight:i})=>{this.autoSize==="vertical"||this.autoSize==="both"?this.style.setProperty("--auto-size-available-height",`${i}px`):this.style.removeProperty("--auto-size-available-height"),this.autoSize==="horizontal"||this.autoSize==="both"?this.style.setProperty("--auto-size-available-width",`${o}px`):this.style.removeProperty("--auto-size-available-width")}})):(this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height")),this.arrow&&this.arrowElement&&r.push(jm({element:this.arrowElement,padding:this.arrowPadding})),Wm(this.__anchorEl,e,{placement:this.placement,middleware:r,strategy:this.strategy}).then(({x:o,y:i,middlewareData:s,placement:a})=>{let l=getComputedStyle(this).direction==="rtl";this.currentPlacement=a;let c={top:"bottom",right:"left",bottom:"top",left:"right"}[a.split("-")[0]]||this.placement;if(Object.assign(e.style,{left:`${o}px`,top:`${i}px`}),this.arrow&&s.arrow){let d=s.arrow.x,u=s.arrow.y,h="",f="",p="",y="";if(this.arrowPlacement==="start"){let x=typeof d=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";h=typeof u=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"",f=l?x:"",y=l?"":x}else if(this.arrowPlacement==="end"){let x=typeof d=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";f=l?"":x,y=l?x:"",p=typeof u=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:""}else this.arrowPlacement==="center"?(y=typeof d=="number"?"calc(50% - var(--arrow-size-diagonal))":"",h=typeof u=="number"?"calc(50% - var(--arrow-size-diagonal))":""):(y=typeof d=="number"?`${d}px`:"",h=typeof u=="number"?`${u}px`:"");this.arrowElement&&Object.assign(this.arrowElement.style,{top:h,right:f,bottom:p,left:y,[c]:"calc(var(--arrow-size-diagonal) * -1)"})}}),requestAnimationFrame(()=>this.updateHoverBridge()),this.dispatchEvent(new qs)}render(){return T`
<slot name="anchor" @slotchange=${this.__handleAnchorChange}></slot>
<div
part="popover-base"
popover=${nr(this.anchoredPopoverType==="none"?null:this.anchoredPopoverType)}
>
<span
part=${Xc({"hover-bridge":!0,"hover-bridge--visible":this.hoverBridge&&this.active})}
></span>
<div
part=${Xc({popover:!0,"popover--active":this.active,"popover--fixed":this.strategy==="fixed","popover--has-arrow":this.arrow})}
class=${qm({"visually-hidden":!this.active})}
>
<slot></slot>
${this.arrow?T`<div part="arrow" role="presentation"></div>`:""}
</div>
</div>
`}};tt(ge,"baseName","role-anchored-region"),tt(ge,"styles",[or,Y`
:host {
--__background: var(--background, #222);
--__border-color: var(--border-color, #222);
--__border-width: var(--border-width, 1px);
--__arrow-size: var(--arrow-size, 8px);
/*
* These properties are computed to account for the arrow's dimensions after being rotated 45º. The constant
* 0.7071 is derived from sin(45), which is the diagonal size of the arrow's container after rotating.
*/
--arrow-size-diagonal: calc(var(--__arrow-size) * 0.7071);
--arrow-padding-offset: calc(var(--arrow-size-diagonal) - var(--__arrow-size));
display: contents;
}
[part~="popover"] {
position: absolute;
isolation: isolate;
max-width: var(--auto-size-available-width, none);
max-height: var(--auto-size-available-height, none);
border: var(--__border-width) solid var(--__border-color);
background: var(--__background);
}
[popover] {
position: fixed;
border: none;
background: none;
inset: unset;
color: inherit;
margin: 0;
padding: 0;
}
[part~="popover--fixed"] {
position: fixed;
}
[part~="arrow"] {
position: absolute;
width: calc(var(--arrow-size-diagonal) * 2);
height: calc(var(--arrow-size-diagonal) * 2);
background: var(--__background);
/* background: tomato; */
z-index: -1;
margin: 0;
transform-style: preserve-3d;
border: var(--__border-width) solid var(--__border-color);
border-top-color: transparent;
border-right-color: transparent;
}
/* Hover bridge */
[part~="hover-bridge"]:not([part~="hover-bridge--visible"]) {
display: none;
}
[part~="hover-bridge"] {
/* background: tomato; */
position: fixed;
z-index: calc(var(--z-index-dropdown, 900) - 1);
top: 0;
right: 0;
bottom: 0;
left: 0;
clip-path: polygon(
var(--hover-bridge-top-left-x, 0) var(--hover-bridge-top-left-y, 0),
var(--hover-bridge-top-right-x, 0) var(--hover-bridge-top-right-y, 0),
var(--hover-bridge-bottom-right-x, 0) var(--hover-bridge-bottom-right-y, 0),
var(--hover-bridge-bottom-left-x, 0) var(--hover-bridge-bottom-left-y, 0)
);
}
:host([current-placement="top"]) [part~="arrow"] {
transform: rotate(315deg);
}
:host([current-placement="bottom"]) [part~="arrow"] {
transform: rotate(135deg);
}
:host([current-placement="left"]) [part~="arrow"] {
transform: rotate(225deg);
}
:host([current-placement="right"]) [part~="arrow"] {
transform: rotate(45deg);
}
`]),tt(ge,"properties",{...Qc()});var Js=class extends cr{constructor(t){super("role-tooltip-toggle",t),this.triggerElement=t.triggerElement,this.triggerEvent=t.triggerEvent}};function Zx(n){let t=n.composedPath().find(e=>e.getAttribute?.("data-role-tooltip"));return t||null}function tk(n){let t=n.getRootNode(),e=n.getAttribute("data-role-tooltip");if(!e)return null;let r=t.querySelector(`#${e}`);return r||null}function ek(n){let t=Zx(n);if(!t)return;let e=tk(t);if(!e)return;let r=new Js({triggerElement:t,triggerEvent:n});e.dispatchEvent(r)}var dr=class extends Yc(Je){static get properties(){return{...Qc(),role:{reflect:!0},__triggerSource:{attribute:!1,state:!0}}}static get baseName(){return"role-tooltip"}static get styles(){return[or,Y`
@media screen and (prefers-color-scheme: dark) {
:host {
--border-color: CanvasText;
}
}
@media screen and not (prefers-color-scheme: dark) {
:host {
--border-color: transparent;
}
}
:host {
--background: #222;
--border-color: #222;
--border-width: 2px;
--arrow-size: 8px;
color: white;
margin: 0;
border: none;
background: transparent;
display: inline-block;
}
:host([active]) [part~="anchored-region"]::part(popover) {
opacity: 1;
transform: scale(1.0);
}
:host([active][trigger-source="hover"]) [part~="anchored-region"]::part(popover) {
transition:
opacity var(--transition-speed, 200ms) var(--transition-timing, ease-in-out) var(--transition-delay, 100ms),
transform var(--transition-speed, 200ms) var(--transition-timing, ease-in-out) var(--transition-delay, 100ms);
}
[part~="anchored-region"]::part(popover) {
opacity: 0;
transform: scale(0.8);
padding: 0.2em 0.4em;
border-radius: 4px;
}
`]}constructor(){super(),this.role="tooltip",this.active=!1,this.anchor=null,this.arrow=!0,this.distance=10,this.__triggerSource=null,this.__eventAbortController=new AbortController,this.addEventListener("role-tooltip-toggle",this.eventHandler.get(this.handlePopoverTriggerEvent)),this.addEventListener("role-reposition",this.eventHandler.get(this.handleReposition)),document.addEventListener("click",ek),this.__activeElements=[]}handlePopoverTriggerEvent(t){this.active?this.hide("click"):this.show(t.triggerElement,"click")}handleReposition(){let t=this.anchoredRegion;!t||!t.popoverElement||(this.currentPlacement=this.anchoredRegion.currentPlacement)}get anchoredRegion(){return this.shadowRoot?.querySelector("[part~='anchored-region']")||null}connectedCallback(){super.connectedCallback();let{signal:t}=this.__eventAbortController,e=this.getRootNode();document.addEventListener("focusout",this.eventHandler.get(this.handleHide),{signal:t}),e.addEventListener("pointerover",this.eventHandler.get(this.handleShow),{passive:!0,signal:t}),e.addEventListener("focusin",this.eventHandler.get(this.handleFocusChange),{passive:!0,signal:t}),e.addEventListener("focusout",this.eventHandler.get(this.handleFocusChange),{passive:!0,signal:t}),document.addEventListener("focusin",this.eventHandler.get(this.handleFocusChange),{passive:!0,signal:t}),document.addEventListener("focusout",this.eventHandler.get(this.handleFocusChange),{passive:!0,signal:t}),document.addEventListener("keydown",this.eventHandler.get(this.handleKeyDown),{passive:!0,signal:t})}disconnectedCallback(){super.disconnectedCallback(),this.__eventAbortController?.abort()}handleKeyDown(t){if(t.key==="Escape"){this.hide("focus");return}t.key==="Tab"&&this.handleFocusChange()}handleFocusChange(){this.__activeElements=[];let t=o=>{this.__activeElements.push(o);let i=o?.shadowRoot?.activeElement;i&&t(i)},e=document.activeElement;if(!e){this.hide("focus");return}t(e);let r=this.__activeElements.find(o=>o.getAttribute?.("data-role-tooltip")===this.id);if(r){this.anchor=r,this.active=!0,this.__triggerSource="focus";return}this.hide("focus")}render(){return T`
<role-anchored-region
part="anchored-region"
exportparts="
popover,
popover--active,
popover--fixed,
popover--has-arrow,
arrow,
hover-bridge,
hover-bridge--visible
"
.anchor=${this.anchor}
?active=${this.active}
.anchoredPopoverType=${this.anchoredPopoverType}
.placement=${this.placement}
.strategy=${this.strategy}
.distance=${this.distance}
.skidding=${this.skidding}
.arrow=${this.arrow}
.arrowPlacement=${this.arrowPlacement}
.arrowPadding=${this.arrowPadding}
.flip=${this.flip}
.flipFallbackPlacements=${this.flipFallbackPlacements}
.flipFallbackStrategy=${this.flipFallbackStrategy}
.flipBoundary=${this.flipBoundary}
.flipPadding=${this.flipPadding}
.shift=${this.shift}
.shiftBoundary=${this.shiftBoundary}
.shiftPadding=${this.shiftPadding}
.autoSize=${this.autoSize}
.sync=${this.sync}
.autoSizeBoundary=${this.autoSizeBoundary}
.autoSizePadding=${this.autoSizePadding}
.hoverBridge=${this.hoverBridge}
class="${this.active?"":"visually-hidden"}"
>
<slot></slot>
</role-anchored-region>
`}handleShow(t){let e=t.type.startsWith("pointer")?"hover":"focus",r=this.findTriggerForTooltip(t);r&&this.show(r,e)}show(t,e=null){e||(e=null),this.__triggerSource!=="focus"&&(this.__triggerSource=e),this.anchor=t,this.active=!0}findTriggerForTooltip(t){let e=t.target;if(!e)return null;let r=e.closest("[data-role-tooltip]");if(!r)return null;let o=r.getAttribute?.("data-role-tooltip");return!o||o!==this.id?null:r}willUpdate(t){if(t.has("active")){let e=this.getRootNode(),{signal:r}=this.__eventAbortController;if(this.active){if(e.addEventListener("pointermove",this.eventHandler.get(this.handleHide),{signal:r}),document.addEventListener("pointermove",this.eventHandler.get(this.handleHide),{signal:r}),this.anchor instanceof Element){let o=this.anchor?.getAttribute("aria-describedby")||"";o||this.anchor?.setAttribute("aria-describedby",this.id),o.split(/\s+/).includes(this.id)||this.anchor?.setAttribute("aria-describedby",o+" "+this.id)}}else e.removeEventListener("pointermove",this.eventHandler.get(this.handleHide)),document.removeEventListener("pointermove",this.eventHandler.get(this.handleHide))}super.willUpdate(t)}handleHide(t){let e=t.composedPath();if(e.includes(this)||this.anchor instanceof HTMLElement&&e.includes(this.anchor))return;let r=t.type.startsWith("pointer")?"hover":"focus";this.hide(r)}hide(t){t||(t=null),!(this.active&&this.__triggerSource==="focus"&&t==="hover")&&(this.__triggerSource=null,this.active=!1)}};tt(dr,"dependencies",{"role-anchored-region":ge});function ut(n){let t="";for(let[e,r]of Object.entries(n))r&&(t+=`${e} `);return t}function Zc(n,t,e={}){let{from:r,to:o,empty:i}=n.selection,s=t?q(t,n.schema):null,a=[];n.doc.nodesBetween(r,o,(u,h)=>{if(u.isText)return;let f=Math.max(r,h),p=Math.min(o,h+u.nodeSize);a.push({node:u,from:f,to:p})});let l=o-r,c=a.slice(-3).filter(u=>s?s.name===u.node.type.name:!0).filter(u=>Yn(u.node.attrs,e,{strict:!1}));return i?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=l}function nk(n){if(!n)return null;let t=n.state,{selection:e}=t,r=n.view;if(r.composing)return null;let{ranges:o}=e,i=Math.min(...o.map(l=>l.$from.pos)),s=Math.max(...o.map(l=>l.$to.pos)),a=null;if(Ue(t.selection)){let l=Vc?.({editor:n,view:r,from:i})||r.nodeDOM(i);l&&(l.scrollIntoView({block:"nearest"}),a=()=>l.getBoundingClientRect())}else{let l=r.domAtPos(s).node;l instanceof HTMLElement&&l.scrollIntoView({block:"nearest"}),a=()=>{let c=pi(r,i,s);return c.x=c.x-c.width/2,c}}return a}var Gs=class extends wn{constructor(){super();this.altTextEditor=!1;this.defaultHeadingLevel=1;this.translations=_p;this.linkInputRef=bd();this.linkDialogExpanded=!1;this.__invalidLink__=!1;this.handleKeyboardDialogToggle=e=>{let{key:r,metaKey:o,ctrlKey:i}=e;if(r==null)return;if(r=r.toLowerCase(),r==="escape"&&this.linkDialogExpanded){this.closeLinkDialog();return}r==="k"&&(ss?o:i)&&this.showLinkDialog()};this.__handleLinkDialogClick=e=>{if(e.defaultPrevented)return;let r=this.shadowRoot?.querySelector(".link-dialog__container");if(!r){this.linkDialogExpanded=!1;return}let o=e.composedPath(),i=this.shadowRoot?.querySelector("[name='link-button']");o.includes(r)||i&&o.includes(i)||(this.linkDialogExpanded=!1)};this.starterKitOptions=Object.assign(this.starterKitOptions,{rhinoPlaceholder:{placeholder:this.translations.placeholder},rhinoAttachment:{fileUploadErrorMessage:this.translations.fileUploadErrorMessage,captionPlaceholder:this.translations.captionPlaceholder}}),this.addEventListener("keydown",this.handleKeyboardDialogToggle)}static get styles(){return wn.styles.concat([Md])}static get properties(){return Object.assign(wn.properties,{linkDialogExpanded:{type:Boolean,reflect:!0,attribute:"link-dialog-expanded"},altTextEditor:{type:Boolean,reflect:!0,attribute:"alt-text-editor"},defaultHeadingLevel:{attribute:"default-heading-level",type:Number},linkInputRef:{state:!0},translations:{state:!0},__invalidLink__:{state:!0,type:Boolean}})}registerDependencies(){super.registerDependencies(),[ir,dr,ge].forEach(e=>e.define())}updated(e){if(e.has("altTextEditor")&&this.starterKitOptions.rhinoAttachment!==!1&&(this.starterKitOptions={...this.starterKitOptions,rhinoAttachment:{...this.starterKitOptions.rhinoAttachment,altTextEditor:this.altTextEditor}}),!this.hasInitialized)return super.updated(e);if(e.has("translations")){let{rhinoAttachment:r,rhinoPlaceholder:o}=this.starterKitOptions;o&&(o.placeholder=this.translations.placeholder),r&&(r.captionPlaceholder=this.translations.captionPlaceholder,r.fileUploadErrorMessage=this.translations.fileUploadErrorMessage)}return super.updated(e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.starterKitOptions=Object.assign(this.starterKitOptions,{rhinoBubbleMenu:{...this.starterKitOptions.rhinoBubbleMenu,element:this.shadowRoot?.querySelector("role-anchored-region")}}),document.addEventListener("click",this.__handleLinkDialogClick)}async startEditor(){await super.startEditor(),this.editor&&this.editor.on("focus",this.closeLinkDialog)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.__handleLinkDialogClick)}get icons(){return _c}toggleLinkDialog(){if(this.linkDialogExpanded){this.closeLinkDialog();return}this.showLinkDialog()}closeLinkDialog(){this.linkDialogExpanded=!1,this.editor?.commands.focus()}showLinkDialog(){let e=this.linkInputRef.value;e!=null&&(e.value=this.editor?.getAttributes("link").href||"",e.setSelectionRange(0,e.value.length)),this.__invalidLink__=!1,this.linkDialogExpanded=!0,setTimeout(()=>{requestAnimationFrame(()=>{e?.focus()})})}get linkDialog(){return this.shadowRoot?.querySelector("#link-dialog")}attachFiles(){let e=this.fileInputEl;e?.click()}addLink(){let e=this.linkInputRef.value;if(e==null)return;let r=e.value;try{new URL(r),e.setCustomValidity(""),this.__invalidLink__=!1}catch{e.setCustomValidity("Not a valid URL"),this.__invalidLink__=!0,e.reportValidity();return}if(this.editor&&r){if(this.closeLinkDialog(),e.value="",this.editor.state.selection.empty&&!this.editor.getAttributes("link").href){let o=this.editor.state.selection.anchor;this.editor.commands.insertContent(r);let i=this.editor.state.selection.anchor;this.editor.commands.setTextSelection({from:o,to:i})}this.editor?.chain().extendMarkRange("link").setLink({href:r}).run()}}get fileInputEl(){return this.shadowRoot?.getElementById("file-input")}async handleFileUpload(){let e=this.fileInputEl;if(e==null||e.files==null)return;let r=await this.handleFiles(e.files);r.length>0&&this.editor?.chain().focus().setAttachment(r).run(),e.value=""}get __tooltipExportParts(){return"base:toolbar__tooltip__base, arrow:toolbar__tooltip__arrow"}renderBoldButton(e=""){if(!(this.starterKitOptions.bold!==!1||!!this.editor?.commands.toggleBold))return T``;let o=this.editor==null||!this.editor.can().toggleBold(),i=!!this.editor?.isActive("bold"),s="bold-tooltip",a="bold",l="toolbar__tooltip toolbar__tooltip--bold",c="bold-icon";return e&&(s=e+"__"+s,c=e+"__"+c,a=e+"__"+a),T`
<slot name=${s}>
<role-tooltip
id=${a}
part=${l}
exportparts=${this.__tooltipExportParts}
>
${this.translations.bold}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
part=${ut({toolbar__button:!0,"toolbar__button--bold":!0,"toolbar__button--active":i,"toolbar__button--disabled":o})}
aria-disabled=${o}
aria-pressed=${i}
data-role="toolbar-item"
data-role-tooltip=${a}
@click=${async d=>{Nt(d.currentTarget)||this.editor?.chain().focus().toggleBold().run()}}
>
<slot name=${c}>${this.icons.bold}</slot>
</button>
`}renderItalicButton(e=""){if(!(this.starterKitOptions.italic!==!1||!!this.editor?.commands.toggleItalic))return T``;let o=!!this.editor?.isActive("italic"),i=this.editor==null||!this.editor.can().toggleItalic(),s="italics-tooltip",a="italics",l="toolbar__tooltip toolbar__tooltip--italics",c="italics-icon";return e&&(s=e+"__"+s,c=e+"__"+c,a=e+"__"+a),T`
<slot name=${s}>
<role-tooltip
id=${a}
part=${l}
exportparts=${this.__tooltipExportParts}
>
${this.translations.italics}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
tabindex="-1"
type="button"
part=${ut({toolbar__button:!0,"toolbar__button--italic":!0,"toolbar__button--active":o,"toolbar__button--disabled":i})}
aria-disabled=${i}
aria-pressed=${o}
data-role="toolbar-item"
data-role-tooltip=${a}
@click=${d=>{Nt(d.currentTarget)||this.editor?.chain().focus().toggleItalic().run()}}
>
<slot name=${c}> ${this.icons.italics} </slot>
</button>
`}renderStrikeButton(e=""){if(!(this.starterKitOptions.rhinoStrike!==!1||!!this.editor?.commands.toggleStrike))return T``;let o=!!this.editor?.isActive("rhino-strike"),i=this.editor==null||!this.editor.can().toggleStrike(),s="strike-tooltip",a="strike",l="toolbar__tooltip toolbar__tooltip--strike",c="strike-icon";return e&&(s=e+"__"+s,c=e+"__"+c,a=e+"__"+a),T`
<slot name=${s}>
<role-tooltip
id=${a}
part=${l}
exportparts=${this.__tooltipExportParts}
>
${this.translations.strike}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--strike":!0,"toolbar__button--active":o,"toolbar__button--disabled":i})}
aria-disabled=${i}
aria-pressed=${o}
data-role-tooltip=${a}
data-role="toolbar-item"
@click=${d=>{Nt(d.currentTarget)||this.editor?.chain().focus().toggleStrike().run()}}
>
<slot name=${c}>${this.icons.strike}</slot>
</button>
`}renderLinkButton(e=""){if(!(this.starterKitOptions.rhinoLink!==!1||!!this.editor?.commands.setLink))return T``;let o=!!(this.editor?.isActive("link")||this.linkDialogExpanded),i=this.editor==null||!this.editor.can().setLink({href:""}),s="link-tooltip",a="link",l="toolbar__tooltip toolbar__tooltip--link",c="link-icon";return e&&(s=e+"__"+s,c=e+"__"+c,a=e+"__"+a),T`
<slot name=${s}>
<role-tooltip
id=${a}
part=${l}
exportparts=${this.__tooltipExportParts}
>
${this.translations.link}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--link":!0,"toolbar__button--active":o,"toolbar__button--disabled":i})}
aria-disabled=${i}
aria-pressed=${o}
aria-controls="link-dialog"
data-role="toolbar-item"
data-role-tooltip=${a}
@click=${d=>{this.editor!=null&&(Nt(d.currentTarget)||(d.preventDefault(),this.toggleLinkDialog()))}}
>
<slot name=${c}>${this.icons.link}</slot>
</button>
`}renderHeadingButton(e=""){if(!(this.starterKitOptions.heading!==!1||!!this.editor?.commands.toggleHeading))return T``;let o=this.defaultHeadingLevel||1,i=!!this.editor?.isActive("heading"),s=this.editor==null||!this.editor.can().toggleHeading({level:o}),a="heading-tooltip",l="heading",c="toolbar__tooltip toolbar__tooltip--heading",d="heading-icon";return e&&(d=e+"__"+d,a=e+"__"+a,l=e+"__"+l),T`
<slot name=${a}>
<role-tooltip
id=${l}
part=${c}
exportparts=${this.__tooltipExportParts}
>
${this.translations.heading}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--heading":!0,"toolbar__button--active":i,"toolbar__button--disabled":s})}
aria-disabled=${s}
aria-pressed=${i}
data-role="toolbar-item"
data-role-tooltip=${l}
@click=${u=>{Nt(u.currentTarget)||this.editor?.chain().focus().toggleHeading({level:o}).run()}}
>
<slot name=${d}>${this.icons.heading}</slot>
</button>
`}renderBlockquoteButton(e=""){if(!(this.starterKitOptions.blockquote!==!1||!!this.editor?.commands.toggleBlockquote))return T``;let o=!!this.editor?.isActive("blockquote"),i=this.editor==null||!this.editor.can().toggleBlockquote(),s="blockquote-tooltip",a="blockquote",l="toolbar__tooltip toolbar__tooltip--blockquote",c="blockquote-icon";return e&&(c=e+"__"+c,s=e+"__"+s,a=e+"__"+a),T`
<slot name=${s}>
<role-tooltip
id=${a}
part=${l}
exportparts=${this.__tooltipExportParts}
>
${this.translations.blockQuote}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--blockquote":!0,"toolbar__button--active":o,"toolbar__button--disabled":i})}
aria-disabled=${i}
aria-pressed=${o}
data-role-tooltip=${a}
data-role="toolbar-item"
@click=${d=>{Nt(d.currentTarget)||this.editor?.chain().focus().toggleBlockquote().run()}}
>
<slot name=${c}>${this.icons.blockQuote}</slot>
</button>
`}renderCodeButton(e=""){if(!(this.starterKitOptions.code!==!1||!!this.editor?.commands.toggleCode))return T``;let o=!!this.editor?.isActive("code"),i=this.editor==null||!this.editor.can().toggleCode(),s="code-tooltip",a="code",l="toolbar__tooltip toolbar__tooltip--code",c="code-icon";return e&&(c=e+"__"+c,s=e+"__"+s,a=e+"__"+a),T`
<slot name=${s}>
<role-tooltip
id=${a}
part=${l}
exportparts=${this.__tooltipExportParts}
>
${this.translations.code}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--code":!0,"toolbar__button--active":o,"toolbar__button--disabled":i})}
aria-disabled=${i}
aria-pressed=${o}
data-role-tooltip=${a}
data-role="toolbar-item"
@click=${d=>{Nt(d.currentTarget)||this.editor?.chain().focus().toggleCode().run()}}
>
<slot name=${c}>${this.icons.code}</slot>
</button>
`}renderCodeBlockButton(e=""){if(!(this.starterKitOptions.codeBlock!==!1||!!this.editor?.commands.toggleCodeBlock))return T``;let o=!!this.editor?.isActive("codeBlock"),i=this.editor==null||!this.editor.can().toggleCodeBlock(),s="code-block-tooltip",a="code-block",l="toolbar__tooltip toolbar__tooltip--code-block",c="code-block-icon";return e&&(c=e+"__"+c,s=e+"__"+s,a=e+"__"+a),T`
<slot name=${s}>
<role-tooltip
id=${a}
part=${l}
exportparts=${this.__tooltipExportParts}
>
${this.translations.codeBlock}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--code-block":!0,"toolbar__button--active":o,"toolbar__button--disabled":i})}
aria-disabled=${i}
aria-pressed=${o}
data-role-tooltip=${a}
data-role="toolbar-item"
@click=${d=>{Nt(d.currentTarget)||this.editor?.chain().focus().toggleCodeBlock().run()}}
>
<slot name=${c}>${this.icons.codeBlock}</slot>
</button>
`}renderBulletListButton(e=""){if(!(this.starterKitOptions.bulletList!==!1||!!this.editor?.commands.toggleBulletList))return T``;let o=this.editor==null||!(this.editor.can().toggleOrderedList?.()||this.editor.can().toggleBulletList()),i=!!(this.editor!=null&&Zc(this.editor.state,"bulletList")),s="bullet-list-tooltip",a="bullet-list",l="toolbar__tooltip toolbar__tooltip--bullet-list",c="bullet-list-icon";return e&&(c=e+"__"+c,s=e+"__"+s,a=e+"__"+a),T`
<slot name=${s}>
<role-tooltip
id=${a}
part=${l}
exportparts=${this.__tooltipExportParts}
>
${this.translations.bulletList}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--bullet-list":!0,"toolbar__button--active":i,"toolbar__button--disabled":o})}
aria-disabled=${o}
aria-pressed=${i}
data-role-tooltip=${a}
data-role="toolbar-item"
@click=${d=>{Nt(d.currentTarget)||this.editor?.chain().focus().toggleBulletList().run()}}
>
<slot name=${c}>${this.icons.bulletList}</slot>
</button>
`}renderOrderedListButton(e=""){if(!(this.starterKitOptions.orderedList!==!1||!!this.editor?.commands.toggleOrderedList))return T``;let o=this.editor==null||!(this.editor.can().toggleOrderedList()||this.editor.can().toggleBulletList?.()),i=!!(this.editor!=null&&Zc(this.editor.state,"orderedList")),s="ordered-list-tooltip",a="ordered-list",l="toolbar__tooltip toolbar__tooltip--ordered-list",c="ordered-list-icon";return e&&(c=e+"__"+c,s=e+"__"+s,a=e+"__"+a),T`
<slot name=${s}>
<role-tooltip
id=${a}
part=${l}
exportparts=${this.__tooltipExportParts}
>
${this.translations.orderedList}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--ordered-list":!0,"toolbar__button--active":i,"toolbar__button--disabled":o})}
aria-disabled=${o}
aria-pressed=${i}
data-role-tooltip=${a}
data-role="toolbar-item"
@click=${d=>{Nt(d.currentTarget)||this.editor?.chain().focus().toggleOrderedList().run()}}
>
<slot name=${c}>${this.icons.orderedList}</slot>
</button>
`}renderAttachmentButton(e=""){if(!(this.starterKitOptions.rhinoAttachment!==!1||!!this.editor?.commands.setAttachment))return T``;let o=this.editor==null,i="attach-files-tooltip",s="attach-files",a="toolbar__tooltip toolbar__tooltip--attach-files",l="attach-files-icon",c="file-input";return e&&(l=e+"__"+l,i=e+"__"+i,s=e+"__"+s,c=e+"__"+c),T`
<slot name=${i}>
<role-tooltip
id=${s}
part=${a}
exportparts=${this.__tooltipExportParts}
>
${this.translations.attachFiles}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
tabindex="-1"
type="button"
part=${ut({toolbar__button:!0,"toolbar__button--attach-files":!0,"toolbar__button--disabled":o})}
aria-disabled=${o}
data-role-tooltip=${s}
data-role="toolbar-item"
@click=${this.attachFiles}
>
<slot name=${l}>${this.icons.attachFiles}</slot>
<!-- @TODO: Write documentation. Hookup onchange to the slotted elements? -->
<slot name="attach-files-input">
<input
id=${c}
type="file"
hidden
multiple
accept=${this.accept||"*"}
@change=${this.handleFileUpload}
/>
</slot>
</button>
`}renderUndoButton(e=""){if(!(this.starterKitOptions.undoRedo!==!1||!!this.editor?.commands.undo))return T``;let o=this.editor==null||!this.editor.can().undo(),i="undo-tooltip",s="undo",a="toolbar__tooltip toolbar__tooltip--undo",l="undo-icon";return e&&(l=e+"__"+l,i=e+"__"+i,s=e+"__"+s),T`
<slot name=${i}>
<role-tooltip
id=${s}
part=${a}
exportparts=${this.__tooltipExportParts}
>
${this.translations.undo}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--undo":!0,"toolbar__button--disabled":o})}
aria-disabled=${o}
data-role-tooltip=${s}
data-role="toolbar-item"
@click=${c=>{Nt(c.currentTarget)||this.editor?.chain().focus().undo().run()}}
>
<slot name=${l}>${this.icons.undo}</slot>
</button>
`}renderDecreaseIndentation(e=""){if(!(this.starterKitOptions.decreaseIndentation!==!1))return T``;let o=this.editor==null||!this.editor.can().liftListItem("listItem"),i="decrease-indentation-tooltip",s="decrease-indentation",a="toolbar__tooltip toolbar__tooltip--decrease-indentation",l="decrease-indentation-icon";return e&&(l=e+"__"+l,i=e+"__"+i,s=e+"__"+s),T`
<slot name=${i}>
<role-tooltip
id=${s}
part=${a}
exportparts=${this.__tooltipExportParts}
>
${this.translations.decreaseIndentation}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--decrease-indentation":!0,"toolbar__button--disabled":o})}
aria-disabled=${o}
data-role-tooltip=${s}
data-role="toolbar-item"
@click=${c=>{Nt(c.currentTarget)||this.editor?.chain().focus().liftListItem("listItem").run()}}
>
<slot name=${l}> ${this.icons.decreaseIndentation} </slot>
</button>
`}renderIncreaseIndentation(e=""){if(!(this.starterKitOptions.increaseIndentation!==!1))return T``;let o=this.editor==null||!this.editor.can().sinkListItem("listItem"),i="increase-indentation-tooltip",s="increase-indentation",a="toolbar__tooltip toolbar__tooltip--increase-indentation",l="increase-indentation-icon";return e&&(l=e+"__"+l,i=e+"__"+i,s=e+"__"+s),T`
<slot name=${i}>
<role-tooltip
id=${s}
part=${a}
exportparts=${this.__tooltipExportParts}
>
${this.translations.increaseIndentation}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
type="button"
tabindex="-1"
part=${ut({toolbar__button:!0,"toolbar__button--increase-indentation":!0,"toolbar__button--disabled":o})}
aria-disabled=${o}
data-role-tooltip=${s}
data-role="toolbar-item"
@click=${c=>{Nt(c.currentTarget)||this.editor?.chain().focus().sinkListItem("listItem").run()}}
>
<slot name=${l}> ${this.icons.increaseIndentation} </slot>
</button>
`}renderRedoButton(e=""){if(!(this.starterKitOptions.undoRedo!==!1||!!this.editor?.commands.redo))return T``;let o=this.editor==null||!this.editor.can().redo?.(),i="redo-indentation-tooltip",s="redo-indentation",a="toolbar__tooltip toolbar__tooltip--redo-indentation",l="redo-indentation-icon";return e&&(l=e+"__"+l,i=e+"__"+i,s=e+"__"+s),T`
<slot name=${i}>
<role-tooltip
id=${s}
part=${a}
exportparts=${this.__tooltipExportParts}
>
${this.translations.redo}
</role-tooltip>
</slot>
<button
class="toolbar__button rhino-toolbar-button"
tabindex="-1"
type="button"
part=${ut({toolbar__button:!0,"toolbar__button--redo":!0,"toolbar__button--disabled":o})}
aria-disabled=${o}
data-role-tooltip=${s}
data-role="toolbar-item"
@click=${c=>{Nt(c.currentTarget)||this.editor?.chain().focus().redo().run()}}
>
<slot name=${l}>${this.icons.redo}</slot>
</button>
`}renderToolbarStart(){return T``}renderToolbarEnd(){return T``}renderToolbar(){return this.readonly?T``:T`
<slot name="toolbar">
<role-toolbar
part="toolbar main__toolbar"
role="toolbar"
exportparts="
base:toolbar__base,
base:main__toolbar__base
"
>
<slot name="toolbar-start">${this.renderToolbarStart()}</slot>
<!-- Bold -->
<slot name="before-bold-button"></slot>
<slot name="bold-button">${this.renderBoldButton()}</slot>
<slot name="after-bold-button"></slot>
<!-- Italic -->
<slot name="before-italic-button"></slot>
<slot name="italic-button">${this.renderItalicButton()}</slot>
<slot name="after-italic-button"></slot>
<!-- Strike -->
<slot name="before-strike-button"></slot>
<slot name="strike-button">${this.renderStrikeButton()}</slot>
<slot name="after-strike-button"></slot>
<!-- Code -->
<slot name="before-code-button"></slot>
<slot name="code-button">${this.renderCodeButton()}</slot>
<slot name="after-code-button"></slot>
<!-- Link -->
<slot name="before-link-button"></slot>
<slot name="link-button">${this.renderLinkButton()}</slot>
<slot name="after-link-button"></slot>
<!-- Heading -->
<slot name="before-heading-button"></slot>
<slot name="heading-button">${this.renderHeadingButton()}</slot>
<slot name="after-heading-button"></slot>
<!-- Blockquote -->
<slot name="before-blockquote-button"></slot>
<slot name="blockquote-button">${this.renderBlockquoteButton()}</slot>
<slot name="after-blockquote-button"></slot>
<!-- Code block -->
<slot name="before-code-block-button"></slot>
<slot name="code-block-button">${this.renderCodeBlockButton()}</slot>
<slot name="after-code-block-button"></slot>
<!-- Bullet List -->
<slot name="before-bullet-list-button"></slot>
<slot name="bullet-list-button"
>${this.renderBulletListButton()}</slot
>
<slot name="after-bullet-list-button"></slot>
<!-- Ordered list -->
<slot name="before-ordered-list-button"></slot>
<slot name="ordered-list-button">
${this.renderOrderedListButton()}
</slot>
<slot name="after-ordered-list-button"></slot>
<slot name="before-decrease-indentation-button"></slot>
<slot name="decrease-indentation-button"
>${this.renderDecreaseIndentation()}</slot
>
<slot name="after-decrease-indentation-button"></slot>
<slot name="before-increase-indentation-button"></slot>
<slot name="increase-indentation-button"
>${this.renderIncreaseIndentation()}</slot
>
<slot name="after-increase-indentation-button"></slot>
<!-- Attachments -->
<slot name="before-attach-files-button"></slot>
<slot name="attach-files-button"
>${this.renderAttachmentButton()}</slot
>
<slot name="after-attach-files-button"></slot>
<!-- Undo -->
<slot name="before-undo-button"></slot>
<!-- @ts-expect-error -->
<slot name="undo-button"> ${this.renderUndoButton()} </slot>
<slot name="after-undo-button"></slot>
<!-- Redo -->
<slot name="before-redo-button"></slot>
<slot name="redo-button"> ${this.renderRedoButton()} </slot>
<slot name="after-redo-button"></slot>
<slot name="toolbar-end">${this.renderToolbarEnd()}</slot>
</role-toolbar>
</slot>
${this.renderBubbleMenuToolbar()} ${this.renderLinkDialogAnchoredRegion()}
`}renderLinkDialogAnchoredRegion(){let e=this.linkDialogExpanded?nk(this.editor):null;return T`
<role-anchored-region
part="link-bubble-menu__anchored-region"
exportparts="
popover-base:link-bubble-menu__popover-base,
hover-bridge:link-bubble-menu__hover-bridge,
hover-bridge--visible:link-bubble-menu__hover-bridge--visible,
popover:link-bubble-menu__popover,
popover--active:link-bubble-menu__popover--active,
popover--fixed:link-bubble-menu__popover--fixed,
popover--has-arrow:link-bubble-menu__popover--has-arrow,
arrow:link-bubble-menu__arrow
"
anchored-popover-type="manual"
distance="4"
.active=${this.linkDialogExpanded}
.shiftBoundary=${this.querySelector(".ProseMirror")||this}
.flipBoundary=${this.querySelector(".ProseMirror")||this}
.anchor=${typeof e=="function"?{getBoundingClientRect:e}:null}
>
<slot name="link-bubble-menu-dialog"> ${this.renderLinkDialog()} </slot>
</role-anchored-region>
`}renderLinkDialog(){return this.readonly?T``:T` <div
id="link-dialog"
part=${ut({"link-dialog":!0,"link-dialog--expanded":this.linkDialogExpanded})}
>
<div class="link-dialog__container" part="link-dialog__container">
<input
id="link-dialog__input"
class=${`link-dialog__input ${this.__invalidLink__?"link-validate":""}`}
part=${`link-dialog__input ${this.__invalidLink__?"link-dialog__input--invalid":""}`}
type="text"
placeholder="Enter a URL..."
aria-label="Enter a URL"
required
type="url"
${yd(this.linkInputRef)}
@input=${()=>{let e=this.linkInputRef.value;e!=null&&(e.setCustomValidity(""),this.__invalidLink__=!1)}}
@blur=${()=>{this.linkInputRef.value!=null&&(this.__invalidLink__=!1)}}
@keydown=${e=>{e.key?.toLowerCase()==="enter"&&(e.preventDefault(),this.addLink())}}
/>
<div class="link-dialog__buttons" part="link-dialog__buttons">
<button
class="rhino-toolbar-button link-dialog__button"
part="link-dialog__button link-dialog__button--link"
@click=${this.addLink}
>
${this.translations.linkDialogLink}
</button>
<button
class="rhino-toolbar-button link-dialog__button"
part="link-dialog__button link-dialog__button--unlink"
@click=${()=>{this.linkDialogExpanded=!1,this.editor?.chain().focus().extendMarkRange("link").unsetLink().run()}}
>
${this.translations.linkDialogUnlink}
</button>
</div>
</div>
</div>`}get defaultBubbleMenuToolbar(){return this.shadowRoot?.querySelector("[part~='bubble-menu__toolbar']")}renderBubbleMenuToolbar(){return T`
<role-anchored-region
part="bubble-menu__anchored-region"
exportparts="
popover-base:bubble-menu__popover-base,
hover-bridge:bubble-menu__hover-bridge,
hover-bridge--visible:bubble-menu__hover-bridge--visible,
popover:bubble-menu__popover,
popover--active:bubble-menu__popover--active,
popover--fixed:bubble-menu__popover--fixed,
popover--has-arrow:bubble-menu__popover--has-arrow,
arrow:bubble-menu__arrow
"
@rhino-bubble-menu-show=${e=>{if(e.defaultPrevented)return;let r=e.currentTarget;r.anchor={getBoundingClientRect:e.clientRect},r.shiftBoundary=this.querySelector(".ProseMirror")||this,r.flipBoundary=this.querySelector(".ProseMirror")||this,r.active=!0}}
@rhino-bubble-menu-hide=${e=>{if(e.defaultPrevented)return;let r=e.currentTarget;r.anchor=null,r.active=!1}}
anchored-popover-type="manual"
distance="4"
>
<slot name="bubble-menu-toolbar">
<role-toolbar
part="toolbar bubble-menu__toolbar"
role="toolbar"
exportparts="
base:toolbar__base,
base:bubble-menu__toolbar__base
"
>
<slot name="before-bubble-menu-toolbar-items"></slot>
<slot name="bubble-menu-toolbar-items">
${this.renderBoldButton("bubble-menu")}
${this.renderItalicButton("bubble-menu")}
${this.renderStrikeButton("bubble-menu")}
${this.renderCodeButton("bubble-menu")}
${this.renderLinkButton("bubble-menu")}
</slot>
<slot name="after-bubble-menu-toolbar-items"></slot>
</role-toolbar>
</slot>
<slot name="additional-bubble-menu-toolbar"></slot>
</role-anchored-region>
`}};function Nt(n){return n==null||!("getAttribute"in n)?!0:n.getAttribute("aria-disabled")==="true"||n.hasAttribute("disabled")}Gs.define();export{qe as AttachmentManager,Gs as TipTapEditor};
/*! Bundled license information:
lit-html/lit-html.js:
(**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/directive-helpers.js:
(**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/directive.js:
(**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/async-directive.js:
(**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/directives/ref.js:
(**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
@lit/reactive-element/css-tag.js:
(**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
@lit/reactive-element/reactive-element.js:
(**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-element/lit-element.js:
(**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/is-server.js:
(**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/directives/when.js:
(**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/directives/unsafe-html.js:
(**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/directives/if-defined.js:
(**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/directives/class-map.js:
(**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
*/
//# sourceMappingURL=index.module.js.map