@panphora/clayjs 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  /* richclay self-contained vendor build (bundles Squire + DOMPurify) for hyperclayjs. Generated; do not edit. */
2
- var richclay=(()=>{var Sn=Object.defineProperty;var Zo=Object.getOwnPropertyDescriptor;var Jo=Object.getOwnPropertyNames;var es=Object.prototype.hasOwnProperty;var ts=(e,t)=>{for(var n in t)Sn(e,n,{get:t[n],enumerable:!0})},ns=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Jo(t))!es.call(e,r)&&r!==n&&Sn(e,r,{get:()=>t[r],enumerable:!(i=Zo(t,r))||i.enumerable});return e};var is=e=>ns(Sn({},"__esModule",{value:!0}),e);var fl={};ts(fl,{RichClay:()=>We,default:()=>hl});var rs=()=>!0,ne=class{constructor(e,t,n){this.root=e,this.currentNode=e,this.nodeType=t,this.filter=n||rs}isAcceptableNode(e){let t=e.nodeType;return!!((t===Node.ELEMENT_NODE?1:t===Node.TEXT_NODE?4:0)&this.nodeType)&&this.filter(e)}nextNode(){let e=this.root,t=this.currentNode,n;for(;;){for(n=t.firstChild;!n&&t&&t!==e;)n=t.nextSibling,n||(t=t.parentNode);if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}previousNode(){let e=this.root,t=this.currentNode,n;for(;;){if(t===e)return null;if(n=t.previousSibling,n)for(;t=n.lastChild;)n=t;else n=t.parentNode;if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}previousPONode(){let e=this.root,t=this.currentNode,n;for(;;){for(n=t.lastChild;!n&&t&&t!==e;)n=t.previousSibling,n||(t=t.parentNode);if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}},ze=navigator.userAgent,On=/Mac OS X/.test(ze),Xi=/Windows NT/.test(ze),Qi=/iP(?:ad|hone|od)/.test(ze)||On&&!!navigator.maxTouchPoints,ml=/Android/.test(ze),os=/Gecko\//.test(ze),Ft=/Edge\//.test(ze),ss=!Ft&&/WebKit\//.test(ze),J=On||Qi?"Meta-":"Ctrl-",Ut=ss,as="onbeforeinput"in document&&"inputType"in new InputEvent("input"),fe=/[^ \t\r\n\u200B]/,ls=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,cs=new Set(["BR","HR","IFRAME","IMG","INPUT"]),us=0,xn=1,Zi=2,Ji=3,Bt=new WeakMap,er=()=>{Bt=new WeakMap},we=e=>cs.has(e.nodeName),Dn=e=>{switch(e.nodeType){case 8:case 3:return xn;case 1:case 11:if(Bt.has(e))return Bt.get(e);break;default:return us}let t;return Array.from(e.childNodes).every(x)?ls.test(e.nodeName)?t=xn:t=Zi:t=Ji,Bt.set(e,t),t},x=e=>Dn(e)===xn,Le=e=>Dn(e)===Zi,Ze=e=>Dn(e)===Ji,_=(e,t,n)=>{let i=document.createElement(e);if(t instanceof Array&&(n=t,t=null),t)for(let r in t){let o=t[r];o!==void 0&&i.setAttribute(r,o)}return n&&n.forEach(r=>i.appendChild(r)),i},tr=(e,t)=>we(e)||e.nodeType!==t.nodeType||e.nodeName!==t.nodeName?!1:e instanceof HTMLElement&&t instanceof HTMLElement?e.nodeName!=="A"&&e.className===t.className&&e.style.cssText===t.style.cssText:!0,Nn=(e,t,n)=>{if(e.nodeName!==t)return!1;for(let i in n)if(!("getAttribute"in e)||e.getAttribute(i)!==n[i])return!1;return!0},L=(e,t,n,i)=>{for(;e&&e!==t;){if(Nn(e,n,i))return e;e=e.parentNode}return null},In=(e,t)=>{let n=e.childNodes;for(;t&&e instanceof Element;)e=n[t-1],n=e.childNodes,t=n.length;return e},nr=(e,t)=>{let n=e;if(n instanceof Element){let i=n.childNodes;if(t<i.length)n=i[t];else{for(;n&&!n.nextSibling;)n=n.parentNode;n&&(n=n.nextSibling)}}return n},re=e=>e instanceof Element||e instanceof DocumentFragment?e.childNodes.length:e instanceof CharacterData?e.length:0,D=e=>{let t=document.createDocumentFragment(),n=e.firstChild;for(;n;)t.appendChild(n),n=e.firstChild;return t},H=e=>{let t=e.parentNode;return t&&t.removeChild(e),e},V=(e,t)=>{let n=e.parentNode;n&&n.replaceChild(t,e)},ds=e=>e instanceof Element?e.nodeName==="BR":fe.test(e.data),zt=(e,t)=>{let n=e.parentNode;for(;x(n);)n=n.parentNode;let i=new ne(n,5,ds);return i.currentNode=e,!!i.nextNode()||t&&!i.previousNode()},Mt=(e,t)=>{let n=new ne(e,4),i,r;for(;i=n.nextNode();)for(;(r=i.data.indexOf("\u200B"))>-1&&(!t||i.parentNode!==t);)if(i.length===1){let o=i,s=o.parentNode;for(;s&&(s.removeChild(o),n.currentNode=s,!(!x(s)||re(s)));)o=s,s=o.parentNode;break}else i.deleteData(r,1)},hs=0,fs=1,ps=2,ms=3,Ne=(e,t,n)=>{let i=document.createRange();if(i.selectNode(t),n){let r=e.compareBoundaryPoints(ms,i)>-1,o=e.compareBoundaryPoints(fs,i)<1;return!r&&!o}else{let r=e.compareBoundaryPoints(hs,i)<1,o=e.compareBoundaryPoints(ps,i)>-1;return r&&o}},j=e=>{let{startContainer:t,startOffset:n,endContainer:i,endOffset:r}=e;for(;!(t instanceof Text);){let o=t.childNodes[n];if(!o||we(o)){if(n&&(o=t.childNodes[n-1],o instanceof Text)){let s=o,a;for(;!s.length&&(a=s.previousSibling)&&a instanceof Text;)s.remove(),s=a;t=s,n=s.data.length}break}t=o,n=0}if(r)for(;!(i instanceof Text);){let o=i.childNodes[r-1];if(!o||we(o)){if(o&&o.nodeName==="BR"&&!zt(o,!1)){r-=1;continue}break}i=o,r=re(i)}else for(;!(i instanceof Text);){let o=i.firstChild;if(!o||we(o))break;i=o}e.setStart(t,n),e.setEnd(i,r)},Fe=(e,t,n,i)=>{let r=e.startContainer,o=e.startOffset,s=e.endContainer,a=e.endOffset,c;for(t||(t=e.commonAncestorContainer),n||(n=t);!o&&r!==t&&r!==i;)c=r.parentNode,o=Array.from(c.childNodes).indexOf(r),r=c;for(;!(s===n||s===i||(s.nodeType!==3&&s.childNodes[a]&&s.childNodes[a].nodeName==="BR"&&!zt(s.childNodes[a],!1)&&(a+=1),a!==re(s)));)c=s.parentNode,a=Array.from(c.childNodes).indexOf(s)+1,s=c;e.setStart(r,o),e.setEnd(s,a)},qi=(e,t,n)=>{let i=L(e.endContainer,n,t);if(i&&(i=i.parentNode)){let r=e.cloneRange();Fe(r,i,i,n),r.endContainer===i&&(e.setStart(r.endContainer,r.endOffset),e.setEnd(r.endContainer,r.endOffset))}return e},z=e=>{let t=null;if(e instanceof Text)return e;if(x(e)){let n=e.firstChild;if(Ut)for(;n&&n instanceof Text&&!n.data;)e.removeChild(n),n=e.firstChild;n||(Ut?t=document.createTextNode("\u200B"):t=document.createTextNode(""))}else if((e instanceof Element||e instanceof DocumentFragment)&&!e.querySelector("BR")&&!fe.test(e.textContent||"")){t=_("BR");let n=e,i;for(;(i=n.lastElementChild)&&!x(i);)n=i;e=n,e instanceof HTMLElement&&e.contentEditable==="true"&&(e=_("DIV"),n.appendChild(e))}if(t)try{e.appendChild(t)}catch{}return e},pe=(e,t)=>{let n=null;return/^(?:TABLE|TBODY|TR|TH|TD|P)/.test(e.nodeName)||(Array.from(e.childNodes).forEach(i=>{let r=i.nodeName==="BR";!r&&x(i)?(n||(n=_("DIV")),n.appendChild(i)):(r||n)&&(n||(n=_("DIV")),z(n),r?e.replaceChild(n,i):e.insertBefore(n,i),n=null),Ze(i)&&pe(i,t)}),n&&e.appendChild(z(n))),e},se=(e,t,n,i)=>{if(!n.contains(e))throw new Error("split: stopNode does not contain node");if(e instanceof Text&&e!==n){if(typeof t!="number")throw new Error("Offset must be a number to split text node!");if(!e.parentNode)throw new Error("Cannot split text node with no parent!");return se(e.parentNode,e.splitText(t),n,i)}let r=typeof t=="number"?t<e.childNodes.length?e.childNodes[t]:null:t,o=e.parentNode;if(!o||e===n||!(e instanceof Element))return r;let s=e.cloneNode(!1);for(;r;){let a=r.nextSibling;s.appendChild(r),r=a}return e instanceof HTMLOListElement&&L(e,i,"BLOCKQUOTE")&&(s.start=(+e.start||1)+e.childNodes.length-1),z(e),z(s),o.insertBefore(s,e.nextSibling),se(o,s,n,i)},ir=(e,t)=>{let n=e.childNodes,i=n.length,r=[];for(;i--;){let o=n[i],s=i?n[i-1]:null;if(s&&x(o)&&tr(o,s))t.startContainer===o&&(t.startContainer=s,t.startOffset+=re(s)),t.endContainer===o&&(t.endContainer=s,t.endOffset+=re(s)),t.startContainer===e&&(t.startOffset>i?t.startOffset-=1:t.startOffset===i&&(t.startContainer=s,t.startOffset=re(s))),t.endContainer===e&&(t.endOffset>i?t.endOffset-=1:t.endOffset===i&&(t.endContainer=s,t.endOffset=re(s))),H(o),o instanceof Text?s.appendData(o.data):r.push(D(o));else if(o instanceof Element){let a;for(;a=r.pop();)o.appendChild(a);ir(o,t)}}},Qe=(e,t)=>{let n=e instanceof Text?e.parentNode:e;if(n instanceof Element){let i={startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset};ir(n,i),t.setStart(i.startContainer,i.startOffset),t.setEnd(i.endContainer,i.endOffset)}},ft=(e,t,n,i)=>{let r=t,o,s;for(;(o=r.parentNode)&&o!==i&&o instanceof Element&&o.childNodes.length===1;)r=o;H(r),s=e.childNodes.length;let a=e.lastChild;a&&a.nodeName==="BR"&&(e.removeChild(a),s-=1),e.appendChild(D(t)),n.setStart(e,s),n.collapse(!0),Qe(e,n)},Te=(e,t)=>{let n=e.previousSibling,i=e.firstChild,r=e.nodeName==="LI";if(!(r&&(!i||!/^[OU]L$/.test(i.nodeName)))){if(n&&tr(n,e)){if(!Ze(n))if(r){let s=_("DIV");s.appendChild(D(n)),n.appendChild(s)}else return;H(e);let o=!Ze(e);n.appendChild(D(e)),o&&pe(n,t),i&&Te(i,t)}else if(r){let o=_("DIV");e.insertBefore(o,i),z(o)}}},$i={"font-weight":{regexp:/^bold|^700/i,replace(){return _("B")}},"font-style":{regexp:/^italic/i,replace(){return _("I")}},"font-family":{regexp:fe,replace(e,t){let n=_("SPAN",{class:e.fontFamily});return n.style.fontFamily=t,n}},"font-size":{regexp:fe,replace(e,t){let n=_("SPAN",{class:e.fontSize});return n.style.fontSize=t,n}},"text-decoration":{regexp:/^underline/i,replace(){return _("U")}}},gs=(e,t,n)=>{let i=e.style,r,o;for(let s in $i){let a=$i[s],c=i.getPropertyValue(s);if(c&&a.regexp.test(c)){let u=a.replace(n.classNames,c);if(u.nodeName===e.nodeName&&u.className===e.className)continue;o||(o=u),r&&r.appendChild(u),r=u,e.style.removeProperty(s)}}return o&&r&&(r.appendChild(D(e)),e.style.cssText?e.appendChild(o):V(e,o)),r||e},Pt=e=>(t,n)=>{let i=_(e),r=t.attributes;for(let o=0,s=r.length;o<s;o+=1){let a=r[o];i.setAttribute(a.name,a.value)}return n.replaceChild(i,t),i.appendChild(D(t)),i},ys={1:"10",2:"13",3:"16",4:"18",5:"24",6:"32",7:"48"},bs={STRONG:Pt("B"),EM:Pt("I"),INS:Pt("U"),STRIKE:Pt("S"),SPAN:gs,FONT:(e,t,n)=>{let i=e,r=i.face,o=i.size,s=i.color,a=n.classNames,c,u,h,f,g;return r&&(c=_("SPAN",{class:a.fontFamily}),c.style.fontFamily=r,g=c,f=c),o&&(u=_("SPAN",{class:a.fontSize}),u.style.fontSize=ys[o]+"px",g||(g=u),f&&f.appendChild(u),f=u),s&&/^#?([\dA-F]{3}){1,2}$/i.test(s)&&(s.charAt(0)!=="#"&&(s="#"+s),h=_("SPAN",{class:a.color}),h.style.color=s,g||(g=h),f&&f.appendChild(h),f=h),(!g||!f)&&(g=f=_("SPAN")),t.replaceChild(g,i),f.appendChild(D(i)),f},TT:(e,t,n)=>{let i=_("SPAN",{class:n.classNames.fontFamily,style:'font-family:menlo,consolas,"courier new",monospace'});return t.replaceChild(i,e),i.appendChild(D(e)),i}},_s=/^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|COL(?:GROUP)?|UL)$/,Ts=/^(?:HEAD|META|STYLE)/,Ln=(e,t,n)=>{let i=e.childNodes,r=e;for(;x(r);)r=r.parentNode;let o=new ne(r,5);for(let s=0,a=i.length;s<a;s+=1){let c=i[s],u=c.nodeName,h=bs[u];if(c instanceof HTMLElement){let f=c.childNodes.length;if(h)c=h(c,e,t);else if(Ts.test(u)){e.removeChild(c),s-=1,a-=1;continue}else if(!_s.test(u)&&!x(c)){s-=1,a+=f-1,e.replaceChild(D(c),c);continue}f&&Ln(c,t,n||u==="PRE")}else{if(c instanceof Text){let f=c.data,g=!fe.test(f.charAt(0)),y=!fe.test(f.charAt(f.length-1));if(n||!g&&!y)continue;if(g){o.currentNode=c;let S;for(;(S=o.previousPONode())&&!(S.nodeName==="IMG"||S instanceof Text&&fe.test(S.data));)if(!x(S)){S=null;break}f=f.replace(/^[ \t\r\n]+/g,S?" ":"")}if(y){o.currentNode=c;let S;for(;(S=o.nextNode())&&!(S.nodeName==="IMG"||S instanceof Text&&fe.test(S.data));)if(!x(S)){S=null;break}f=f.replace(/[ \t\r\n]+$/g,S?" ":"")}if(f){c.data=f;continue}}e.removeChild(c),s-=1,a-=1}}return e},wn=e=>{let t=e.childNodes,n=t.length;for(;n--;){let i=t[n];i instanceof Element&&!we(i)?(wn(i),x(i)&&!i.firstChild&&e.removeChild(i)):i instanceof Text&&!i.data&&e.removeChild(i)}},Rn=(e,t,n)=>{let i=e.querySelectorAll("BR"),r=[],o=i.length;for(let s=0;s<o;s+=1)r[s]=zt(i[s],n);for(;o--;){let s=i[o],a=s.parentNode;a&&(r[o]?x(a)||pe(a,t):H(s))}},Wi=e=>e.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;").split('"').join("&quot;"),Ht=(e,t)=>{let n=new ne(t,1,Le);return n.currentNode=e,n},Ue=(e,t)=>{let n=Ht(e,t).previousNode();return n!==t?n:null},Ee=(e,t)=>{let n=Ht(e,t).nextNode();return n!==t?n:null},kn=e=>!e.textContent&&!e.querySelector("IMG"),ie=(e,t)=>{let n=e.startContainer,i;if(x(n))i=Ue(n,t);else if(n!==t&&n instanceof HTMLElement&&Le(n))i=n;else{let r=In(n,e.startOffset);i=Ee(r,t)}return i&&Ne(e,i,!0)?i:null},He=(e,t)=>{let n=e.endContainer,i;if(x(n))i=Ue(n,t);else if(n!==t&&n instanceof HTMLElement&&Le(n))i=n;else{let r=nr(n,e.endOffset);if(!r||!t.contains(r)){r=t;let o;for(;o=r.lastChild;)r=o}i=Ue(r,t)}return i&&Ne(e,i,!0)?i:null},rr=e=>e instanceof Text?fe.test(e.data):e.nodeName==="IMG",pt=(e,t)=>{let n=e.startContainer,i=e.startOffset,r;if(n instanceof Text){let a=n.data;for(let c=i;c>0;c-=1)if(a.charAt(c-1)!=="\u200B")return!1;r=n}else if(r=nr(n,i),r&&!t.contains(r)&&(r=null),!r&&(r=In(n,i),r instanceof Text&&r.length))return!1;let o=ie(e,t);if(!o)return!1;let s=new ne(o,5,rr);return s.currentNode=r,!s.previousNode()},mt=(e,t)=>{let n=e.endContainer,i=e.endOffset,r;if(n instanceof Text){let a=n.data,c=a.length;for(let u=i;u<c;u+=1)if(a.charAt(u)!=="\u200B")return!1;r=n}else r=In(n,i);let o=He(e,t);if(!o)return!1;let s=new ne(o,5,rr);return s.currentNode=r,!s.nextNode()},Gi=(e,t)=>{let n=ie(e,t),i=He(e,t),r;n&&i&&(r=n.parentNode,e.setStart(r,Array.from(r.childNodes).indexOf(n)),r=i.parentNode,e.setEnd(r,Array.from(r.childNodes).indexOf(i)+1))};function Be(e,t,n,i){let r=document.createRange();return r.setStart(e,t),n&&typeof i=="number"?r.setEnd(n,i):r.setEnd(e,t),r}var _e=(e,t)=>{let{startContainer:n,startOffset:i,endContainer:r,endOffset:o}=e,s;if(n instanceof Text){let c=n.parentNode;if(s=c.childNodes,i===n.length)i=Array.from(s).indexOf(n)+1,e.collapsed&&(r=c,o=i);else{if(i){let u=n.splitText(i);r===n?(o-=i,r=u):r===c&&(o+=1),n=u}i=Array.from(s).indexOf(n)}n=c}else s=n.childNodes;let a=s.length;i===a?n.appendChild(t):n.insertBefore(t,s[i]),n===r&&(o+=s.length-a),e.setStart(n,i),e.setEnd(r,o)},or=(e,t,n)=>{let i=document.createDocumentFragment();if(e.collapsed)return i;t||(t=e.commonAncestorContainer),t instanceof Text&&(t=t.parentNode);let r=e.startContainer,o=e.startOffset,s=se(e.endContainer,e.endOffset,t,n),a=0,c=se(r,o,t,n);for(;c&&c!==s;){let u=c.nextSibling;i.appendChild(c),c=u}return c=s&&s.previousSibling,c&&c instanceof Text&&s instanceof Text&&(a=c.length,c.appendData(s.data),H(s),s=c),e.setStart(r,o),s?e.setEnd(s,a):e.setEnd(t,t.childNodes.length),z(t),i},Ki=(e,t,n)=>{e.currentNode=n;let i;for(;i=e[t]();){if(i instanceof Text||we(i))return i;if(!x(i))return null}return null},qe=(e,t)=>{let n=ie(e,t),i=He(e,t),r=n!==i;n&&i&&(j(e),Fe(e,n,i,t));let o=or(e,null,t);j(e),r&&(i=He(e,t),n&&i&&n!==i&&ft(n,i,e,t)),n&&z(n);let s=t.firstChild;(!s||s.nodeName==="BR")&&(z(t),t.firstChild&&e.selectNodeContents(t.firstChild)),e.collapse(!0);let a=e.startContainer,c=e.startOffset,u=new ne(t,5),h=a,f=c;(!(h instanceof Text)||f===h.data.length)&&(h=Ki(u,"nextNode",h),f=0);let g=a,y=c-1;(!(g instanceof Text)||y===-1)&&(g=Ki(u,"previousPONode",h||(a instanceof Text?a:a.childNodes[c]||a)),g instanceof Text&&(y=g.data.length));let S=null,N=0;return h instanceof Text&&h.data.charAt(f)===" "&&pt(e,t)?(S=h,N=f):g instanceof Text&&g.data.charAt(y)===" "&&(h instanceof Text&&h.data.charAt(f)===" "||mt(e,t))&&(S=g,N=y),S&&S.replaceData(N,1,"\xA0"),e.setStart(a,c),e.collapse(!0),o},Es=(e,t,n)=>{let i=t.firstChild&&x(t.firstChild),r;for(pe(t,n),r=t;r=Ee(r,n);)z(r);e.collapsed||qe(e,n),j(e),e.collapse(!1);let o=L(e.endContainer,n,"BLOCKQUOTE")||n,s=ie(e,n),a=null,c=Ee(t,t),u=!i&&!!s&&kn(s);if(s&&c&&!u&&!L(c,t,"PRE")&&!L(c,t,"TABLE")){Fe(e,s,s,n),e.collapse(!0);let h=e.endContainer,f=e.endOffset;if(Rn(s,n,!1),x(h)){let g=se(h,f,Ue(h,n)||n,n);h=g.parentNode,f=Array.from(h.childNodes).indexOf(g)}if(f!==re(h))for(a=document.createDocumentFragment();r=h.childNodes[f];)a.appendChild(r);ft(h,c,e,n),h===n?e.setEnd(n,re(n)):(f=Array.from(h.parentNode.childNodes).indexOf(h)+1,h=h.parentNode,e.setEnd(h,f))}if(re(t)){u&&s&&(e.setEndBefore(s),e.collapse(!1),H(s)),o.contains(e.endContainer)||(n.contains(e.endContainer)||(e.setEnd(n,re(n)),e.collapse(!1)),o=L(e.endContainer,n,"BLOCKQUOTE")||n),Fe(e,o,o,n);let h=se(e.endContainer,e.endOffset,o,n),f=h?h.previousSibling:o.lastChild;o.insertBefore(t,h),h?e.setEndBefore(h):e.setEnd(o,re(o)),s=He(e,n),j(e);let g=e.endContainer,y=e.endOffset;h&&Ze(h)&&Te(h,n),h=f&&f.nextSibling,h&&Ze(h)&&Te(h,n),e.setEnd(g,y)}if(a&&s){let h=e.cloneRange();z(a),ft(s,a,h,n),e.setEnd(h.endContainer,h.endOffset)}j(e)},sr=e=>{if(e.collapsed)return"";let t=e.startContainer,n=e.endContainer,i=new ne(e.commonAncestorContainer,5,c=>Ne(e,c,!0));i.currentNode=t;let r=t,o="",s=!1,a;for((!(r instanceof Element)&&!(r instanceof Text)||!i.filter(r))&&(r=i.nextNode());r;)r instanceof Text?(a=r.data,a&&/\S/.test(a)&&(r===n&&(a=a.slice(0,e.endOffset)),r===t&&(a=a.slice(e.startOffset)),o+=a,s=!0)):(r.nodeName==="BR"||s&&!x(r))&&(o+=`
3
- `,s=!1),r=i.nextNode();return o=o.replace(/ /g," "),o},An=Array.prototype.indexOf,ar=(e,t,n,i,r)=>{let o=r?"":sr(e),s=ie(e,t),a=He(e,t),c=e.commonAncestorContainer,u=t;s===a&&s?.contains(c)&&(u=s);let h;for(n?(h=qe(e,t),c.isConnected||(c=e.commonAncestorContainer)):h=e.cloneContents(),c instanceof Text&&(c=c.parentNode);c&&c!==u;){let g=c.cloneNode(!1);g.appendChild(h),h=g,c=c.parentNode}let f;if(h.childNodes.length===1&&h.childNodes[0]instanceof Text)o=h.childNodes[0].data.replace(/ /g," "),f=void 0;else{let g=_("DIV");g.appendChild(h),f=g.innerHTML,i&&(f=i(f))}return r&&f!==void 0&&(o=r(f)),o===f&&(f=void 0),Xi&&(o=o.replace(/\r?\n/g,`\r
4
- `)),f&&(f="<!-- squire -->"+f),[o,f]},lr=(e,t,n,i,r,o,s)=>{let a=e.clipboardData;if(Ft||!a)return!1;let[c,u]=ar(t,n,i,r,o);return e.preventDefault(),!s&&u&&a.setData("text/html",u),a.setData("text/plain",c),!0},Ss=function(e){let t=this.getSelection(),n=this._root;if(t.collapsed){e.preventDefault();return}this.saveUndoState(t),lr(e,t,n,!0,this._config.willCutCopy,this._config.toPlainText,!1)||setTimeout(()=>{try{this._ensureBottomLine()}catch(i){this._config.didError(i)}},0),this.setSelection(t)},As=function(e){lr(e,this.getSelection(),this._root,!1,this._config.willCutCopy,this._config.toPlainText,!1)},Vi=function(e){this._isShiftDown=e.shiftKey},vs=function(e){let t=e.clipboardData,n=t?.items,i=this._isShiftDown,r=!1,o=!1,s=null,a=null;if(n){let C=n.length;for(;C--;){let M=n[C],$=M.type;$==="text/html"?a=M:$==="text/plain"||$==="text/uri-list"?s=M:$==="text/rtf"?r=!0:/^image\/.*/.test($)&&(o=!0)}if(o&&!(r&&a)&&!s){e.preventDefault(),this.fireEvent("pasteImage",{clipboardData:t});return}if(!Ft){e.preventDefault(),a&&(!i||!s)?a.getAsString(M=>{this.insertHTML(M,!0)}):s&&s.getAsString(M=>{let $=this.getSelection();if(!$.collapsed&&fe.test($.toString())){let le=this.linkRegExp.exec(M);if(le&&le[0].length===M.length){let Q=le[1]?/^(?:ht|f)tps?:/i.test(le[1])?le[1]:"http://"+le[1]:"mailto:"+le[0];this.makeLink(Q);return}}this.insertPlainText(M,!0)});return}}let c=t?.types;if(!Ft&&c&&(An.call(c,"text/html")>-1||!os&&An.call(c,"text/plain")>-1&&An.call(c,"text/rtf")<0)){e.preventDefault();let C;!i&&(C=t.getData("text/html"))?this.insertHTML(C,!0):((C=t.getData("text/plain"))||(C=t.getData("text/uri-list")))&&this.insertPlainText(C,!0);return}let u=document.body,h=this.getSelection(),f=h.startContainer,g=h.startOffset,y=h.endContainer,S=h.endOffset,N=_("DIV",{contenteditable:"true",style:"position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;"});u.appendChild(N),h.selectNodeContents(N),this.setSelection(h),setTimeout(()=>{try{let C="",M=N,$;for(;N=M;)M=N.nextSibling,H(N),$=N.firstChild,$&&$===N.lastChild&&$ instanceof HTMLDivElement&&(N=$),C+=N.innerHTML;this.setSelection(Be(f,g,y,S)),C&&this.insertHTML(C,!0)}catch(C){this._config.didError(C)}},0)},Cs=function(){let e=this.getSelection();e&&!e.collapsed&&this._root.contains(e.commonAncestorContainer)?this._dragRange=e.cloneRange():this._dragRange=null},xs=function(){this._dragRange=null},Ns=(e,t,n)=>{let i=null,r=document;if(r.caretPositionFromPoint){let o=r.caretPositionFromPoint(e,t);o&&(i=document.createRange(),i.setStart(o.offsetNode,o.offset),i.collapse(!0))}else r.caretRangeFromPoint&&(i=r.caretRangeFromPoint(e,t));return i&&!n.contains(i.commonAncestorContainer)?null:i},Ls=(e,t)=>e.compareBoundaryPoints(Range.START_TO_START,t)>=0&&e.compareBoundaryPoints(Range.END_TO_END,t)<=0,ws=function(e){let t=e.dataTransfer;if(!t)return;let n=t.types,i=!1,r=!1;for(let h=0,f=n.length;h<f;h+=1)switch(n[h]){case"text/plain":i=!0;break;case"text/html":r=!0;break}if(!i&&!r)return;e.preventDefault();let o=this._root,s=Ns(e.clientX,e.clientY,o),a=this._dragRange;if(this._dragRange=null,!s)return;let c,u;if(a){if(Ls(s,a))return;this._recordUndoState(a,this._isInUndoState);let h=document.createComment("");s.insertNode(h),this._getRangeAndRemoveBookmark(a),[c,u]=ar(a,o,t.dropEffect!=="copy",this._config.willCutCopy,this._config.toPlainText),h.replaceWith(_("INPUT",{id:this.startSelectionId,type:"hidden"}),_("INPUT",{id:this.endSelectionId,type:"hidden"})),this._getRangeAndRemoveBookmark(s),er()}else this.saveUndoState(s),r?u=t.getData("text/html"):c=t.getData("text/plain");this.setSelection(s),u!==void 0?this.insertHTML(u,!0):c!==void 0&&this.insertPlainText(c,!0)},ji=(e,t,n)=>{t.preventDefault(),e.splitBlock(t.shiftKey,n)},ht=(e,t)=>{try{t||(t=e.getSelection());let n=t.startContainer;n instanceof Text&&(n=n.parentNode);let i=n;for(;i!==e._root&&x(i)&&(!i.textContent||i.textContent==="\u200B");)n=i,i=n.parentNode;n!==i&&(t.setStart(i,Array.from(i.childNodes).indexOf(n)),t.collapse(!0),i.removeChild(n),Le(i)||(i=Ue(i,e._root)||e._root),z(i),j(t)),n===e._root&&(n=n.firstChild)&&n.nodeName==="BR"&&H(n),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(n){e._config.didError(n)}},cr=(e,t)=>{let n;for(;(n=e.parentNode)&&!(n===t||n.isContentEditable);)e=n;H(e)},ur=(e,t,n)=>{if(L(t,e._root,"A"))return;let i=t.data||"",r=Math.max(i.lastIndexOf(" ",n-1),i.lastIndexOf("\xA0",n-1))+1,o=i.slice(r,n),s=e.linkRegExp.exec(o);if(s){let a=e.getSelection();e._docWasChanged(),e._recordUndoState(a),e._getRangeAndRemoveBookmark(a);let c=r+s.index,u=c+s[0].length,h=a.startContainer===t,f=a.startOffset-u;c&&(t=t.splitText(c));let g=e._config.tagAttributes.a,y=_("A",Object.assign({href:s[1]?/^(?:ht|f)tps?:/i.test(s[1])?s[1]:"http://"+s[1]:"mailto:"+s[0]},g));y.textContent=i.slice(c,u),t.parentNode.insertBefore(y,t),t.data=i.slice(u),h&&(a.setStart(t,f),a.setEnd(t,f)),e.setSelection(a)}},Rs=(e,t,n)=>{let i=e._root;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),qe(n,i),ht(e,n);else if(pt(n,i)){t.preventDefault();let r=ie(n,i);if(!r)return;let o=r;pe(o.parentNode,i);let s=Ue(o,i);if(s){if(!s.isContentEditable){cr(s,i);return}for(ft(s,o,n,i),o=s.parentNode;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(o=o.nextSibling)&&Te(o,i),e.setSelection(n)}else if(o){if(L(o,i,"UL")||L(o,i,"OL")){e.decreaseListLevel(n);return}else if(L(o,i,"BLOCKQUOTE")){e.removeQuote(n);return}e.setSelection(n),e._updatePath(n,!0)}}else{j(n);let r=n.startContainer,o=n.startOffset,s=r.parentNode;r instanceof Text&&s instanceof HTMLAnchorElement&&o&&s.href.includes(r.data)?(r.deleteData(o-1,1),e.setSelection(n),e.removeLink(),t.preventDefault()):(e.setSelection(n),setTimeout(()=>{ht(e)},0))}},ks=(e,t,n)=>{let i=e._root,r,o,s,a,c,u;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),qe(n,i),ht(e,n);else if(mt(n,i)){if(t.preventDefault(),r=ie(n,i),!r)return;if(pe(r.parentNode,i),o=Ee(r,i),o){if(!o.isContentEditable){cr(o,i);return}for(ft(r,o,n,i),o=r.parentNode;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(o=o.nextSibling)&&Te(o,i),e.setSelection(n),e._updatePath(n,!0)}}else{if(s=n.cloneRange(),Fe(n,i,i,i),a=n.endContainer,c=n.endOffset,a instanceof Element&&(u=a.childNodes[c],u&&u.nodeName==="IMG")){t.preventDefault(),H(u),j(n),ht(e,n);return}e.setSelection(s),setTimeout(()=>{ht(e)},0)}},Os=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&pt(n,i)){let r=ie(n,i),o;for(;o=r.parentNode;){if(o.nodeName==="UL"||o.nodeName==="OL"){t.preventDefault(),e.increaseListLevel(n);break}r=o}}},Ds=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&pt(n,i)){let r=n.startContainer;(L(r,i,"UL")||L(r,i,"OL"))&&(t.preventDefault(),e.decreaseListLevel(n))}},Is=(e,t,n)=>{let i,r=e._root;if(e._recordUndoState(n),e._getRangeAndRemoveBookmark(n),!n.collapsed)qe(n,r),e._ensureBottomLine(),e.setSelection(n),e._updatePath(n,!0);else if(mt(n,r)){let o=ie(n,r);if(o&&o.nodeName!=="PRE"){let s=o.textContent?.trimEnd().replace("\u200B","");if(s==="*"||s==="1."){t.preventDefault(),e.insertPlainText(" ",!1),e._docWasChanged(),e.saveUndoState(n);let a=new ne(o,4),c;for(;c=a.nextNode();)H(c);s==="*"?e.makeUnorderedList():e.makeOrderedList();return}}}if(i=n.endContainer,n.endOffset===re(i))do if(i.nodeName==="A"){n.setStartAfter(i);break}while(!i.nextSibling&&(i=i.parentNode)&&i!==r);if(e._config.addLinks){let o=n.cloneRange();j(o);let s=o.startContainer,a=o.startOffset;setTimeout(()=>{ur(e,s,a)},0)}e.setSelection(n)},Ms=function(e){if(e.defaultPrevented||e.isComposing)return;let t=e.key,n="",i=e.code;/^Digit\d$/.test(i)&&(t=i.slice(-1)),t!=="Backspace"&&t!=="Delete"&&(e.altKey&&(n+="Alt-"),e.ctrlKey&&(n+="Ctrl-"),e.metaKey&&(n+="Meta-"),e.shiftKey&&(n+="Shift-")),Xi&&e.shiftKey&&t==="Delete"&&(n+="Shift-"),t=n+t;let r=this.getSelection(),o=this._keyHandlers[t];o?o(this,e,r):!r.collapsed&&!e.ctrlKey&&!e.metaKey&&t.length===1&&(this.saveUndoState(r),qe(r,this._root),this._ensureBottomLine(),this.setSelection(r),this._updatePath(r,!0))},B={Backspace:Rs,Delete:ks,Tab:Os,"Shift-Tab":Ds," ":Is,ArrowLeft(e){e._removeZWS()},ArrowRight(e,t,n){e._removeZWS();let i=e.getRoot();if(mt(n,i)){j(n);let r=n.endContainer;do if(r.nodeName==="CODE"){let o=r.nextSibling;if(!(o instanceof Text)||o.length===0){let s=document.createTextNode("\xA0");r.parentNode.insertBefore(s,o),o=s}n.setStart(o,1),e.setSelection(n),t.preventDefault();break}while(!r.nextSibling&&(r=r.parentNode)&&r!==i)}}};as||(B.Enter=ji,B["Shift-Enter"]=ji);!On&&!Qi&&(B.PageUp=e=>{e.moveCursorToStart()},B.PageDown=e=>{e.moveCursorToEnd()});var Je=(e,t)=>(t=t||null,(n,i)=>{i.preventDefault();let r=n.getSelection();n.hasFormat(e,null,r)?n.changeFormat(null,{tag:e},r):n.changeFormat({tag:e},t,r)});B[J+"b"]=Je("B");B[J+"i"]=Je("I");B[J+"u"]=Je("U");B[J+"Shift-7"]=Je("S");B[J+"Shift-5"]=Je("SUB",{tag:"SUP"});B[J+"Shift-6"]=Je("SUP",{tag:"SUB"});B[J+"Shift-8"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)UL/.test(n)?e.removeList():e.makeUnorderedList()};B[J+"Shift-9"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)OL/.test(n)?e.removeList():e.makeOrderedList()};B[J+"["]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.decreaseQuoteLevel():e.decreaseListLevel()};B[J+"]"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.increaseQuoteLevel():e.increaseListLevel()};B[J+"d"]=(e,t)=>{t.preventDefault(),e.toggleCode()};B[J+"z"]=(e,t)=>{t.preventDefault(),e.undo()};B[J+"y"]=B[J+"Shift-z"]=B[J+"Shift-Z"]=(e,t)=>{t.preventDefault(),e.redo()};var vn=8,Yi=40,Cn=1200,Ps=[{pos:"nw",cursor:"nwse-resize"},{pos:"n",cursor:"ns-resize"},{pos:"ne",cursor:"nesw-resize"},{pos:"e",cursor:"ew-resize"},{pos:"se",cursor:"nwse-resize"},{pos:"s",cursor:"ns-resize"},{pos:"sw",cursor:"nesw-resize"},{pos:"w",cursor:"ew-resize"}],Bs={ArrowUp:(e,t,n)=>{let i=ie(t,n);if(i){let r=Ue(i,n);r&&(t.selectNodeContents(r),t.collapse(!1),e.setSelection(t).focus())}},ArrowDown:(e,t,n)=>{let i=ie(t,n);if(i){let r=Ee(i,n);r&&(t.selectNodeContents(r),t.collapse(!0),e.setSelection(t).focus())}},Delete:(e,t)=>{e.replaceWithBlankLine(t)},Backspace:(e,t)=>{e.replaceWithBlankLine(t)}},Fs=class{constructor(e,t){this._currentImage=null,this._resizeContainer=null,this._handles=null,this._currentHandle=null,this._startX=0,this._startY=0,this._startWidth=0,this._startHeight=0,this._maxWidth=Cn,this._originalRatio=1,this._editor=t,this._root=e,document.addEventListener("click",this),t.addEventListener("drop",this)}destroy(){this._deselectImage(),this._editor.removeEventListener("drop",this),document.removeEventListener("click",this)}handleEvent(e){switch(e.type){case"click":this._onClick(e);break;case"pointerdown":this._onPointerDown(e);break;case"pointermove":this._onPointerMove(e);break;case"pointercancel":case"pointerup":this._onPointerUp(e);break;case"keydown":this._onKeyDown(e);break;case"drop":this._deselectImage();break}}_onClick(e){let t=e.target;t.nodeName==="IMG"&&this._root.contains(t)?(e.stopPropagation(),this._selectImage(t)):this._currentImage&&this._handles&&!this._handles.some(n=>n.element===t)&&this._deselectImage()}_deselectImage(){this._currentImage&&(document.removeEventListener("keydown",this,!0),this._currentHandle&&this._onPointerUp({preventDefault(){},target:this._currentHandle.element}),this._handles&&this._handles.forEach(({element:e})=>e.removeEventListener("pointerdown",this)),this._resizeContainer&&this._resizeContainer.remove(),this._currentImage.removeAttribute("tabindex"),this._handles=null,this._resizeContainer=null,this._currentImage=null)}_selectImage(e){if(this._currentImage===e)return;this._deselectImage(),this._root.blur();let t=Ps.map(({pos:r,cursor:o})=>{let s=vn/2,a="";switch(r){case"nw":a=`left: -${s}px; top: -${s}px;`;break;case"n":a=`left: calc(50% - ${s}px); top: -${s}px;`;break;case"ne":a=`right: -${s}px; top: -${s}px;`;break;case"e":a=`right: -${s}px; top: calc(50% - ${s}px);`;break;case"se":a=`right: -${s}px; bottom: -${s}px;`;break;case"s":a=`left: calc(50% - ${s}px); bottom: -${s}px;`;break;case"sw":a=`left: -${s}px; bottom: -${s}px;`;break;case"w":a=`left: -${s}px; top: calc(50% - ${s}px);`;break}let c=_("div",{class:`squire-resize-handle squire-resize-handle-${r}`,style:`
2
+ var richclay=(()=>{var vn=Object.defineProperty;var us=Object.getOwnPropertyDescriptor;var ds=Object.getOwnPropertyNames;var hs=Object.prototype.hasOwnProperty;var fs=(e,t)=>{for(var n in t)vn(e,n,{get:t[n],enumerable:!0})},ps=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ds(t))!hs.call(e,r)&&r!==n&&vn(e,r,{get:()=>t[r],enumerable:!(i=us(t,r))||i.enumerable});return e};var ms=e=>ps(vn({},"__esModule",{value:!0}),e);var kl={};fs(kl,{RichClay:()=>We,default:()=>Ol});var gs=()=>!0,ne=class{constructor(e,t,n){this.root=e,this.currentNode=e,this.nodeType=t,this.filter=n||gs}isAcceptableNode(e){let t=e.nodeType;return!!((t===Node.ELEMENT_NODE?1:t===Node.TEXT_NODE?4:0)&this.nodeType)&&this.filter(e)}nextNode(){let e=this.root,t=this.currentNode,n;for(;;){for(n=t.firstChild;!n&&t&&t!==e;)n=t.nextSibling,n||(t=t.parentNode);if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}previousNode(){let e=this.root,t=this.currentNode,n;for(;;){if(t===e)return null;if(n=t.previousSibling,n)for(;t=n.lastChild;)n=t;else n=t.parentNode;if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}previousPONode(){let e=this.root,t=this.currentNode,n;for(;;){for(n=t.lastChild;!n&&t&&t!==e;)n=t.previousSibling,n||(t=t.parentNode);if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}},ze=navigator.userAgent,In=/Mac OS X/.test(ze),nr=/Windows NT/.test(ze),ir=/iP(?:ad|hone|od)/.test(ze)||In&&!!navigator.maxTouchPoints,Il=/Android/.test(ze),ys=/Gecko\//.test(ze),Ht=/Edge\//.test(ze),bs=!Ht&&/WebKit\//.test(ze),J=In||ir?"Meta-":"Ctrl-",zt=bs,Ts="onbeforeinput"in document&&"inputType"in new InputEvent("input"),fe=/[^ \t\r\n\u200B]/,_s=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,Es=new Set(["BR","HR","IFRAME","IMG","INPUT"]),Ss=0,Ln=1,rr=2,or=3,Ut=new WeakMap,sr=()=>{Ut=new WeakMap},Re=e=>Es.has(e.nodeName),Mn=e=>{switch(e.nodeType){case 8:case 3:return Ln;case 1:case 11:if(Ut.has(e))return Ut.get(e);break;default:return Ss}let t;return Array.from(e.childNodes).every(x)?_s.test(e.nodeName)?t=Ln:t=rr:t=or,Ut.set(e,t),t},x=e=>Mn(e)===Ln,we=e=>Mn(e)===rr,Ze=e=>Mn(e)===or,T=(e,t,n)=>{let i=document.createElement(e);if(t instanceof Array&&(n=t,t=null),t)for(let r in t){let o=t[r];o!==void 0&&i.setAttribute(r,o)}return n&&n.forEach(r=>i.appendChild(r)),i},ar=(e,t)=>Re(e)||e.nodeType!==t.nodeType||e.nodeName!==t.nodeName?!1:e instanceof HTMLElement&&t instanceof HTMLElement?e.nodeName!=="A"&&e.className===t.className&&e.style.cssText===t.style.cssText:!0,wn=(e,t,n)=>{if(e.nodeName!==t)return!1;for(let i in n)if(!("getAttribute"in e)||e.getAttribute(i)!==n[i])return!1;return!0},L=(e,t,n,i)=>{for(;e&&e!==t;){if(wn(e,n,i))return e;e=e.parentNode}return null},Pn=(e,t)=>{let n=e.childNodes;for(;t&&e instanceof Element;)e=n[t-1],n=e.childNodes,t=n.length;return e},lr=(e,t)=>{let n=e;if(n instanceof Element){let i=n.childNodes;if(t<i.length)n=i[t];else{for(;n&&!n.nextSibling;)n=n.parentNode;n&&(n=n.nextSibling)}}return n},re=e=>e instanceof Element||e instanceof DocumentFragment?e.childNodes.length:e instanceof CharacterData?e.length:0,D=e=>{let t=document.createDocumentFragment(),n=e.firstChild;for(;n;)t.appendChild(n),n=e.firstChild;return t},H=e=>{let t=e.parentNode;return t&&t.removeChild(e),e},j=(e,t)=>{let n=e.parentNode;n&&n.replaceChild(t,e)},As=e=>e instanceof Element?e.nodeName==="BR":fe.test(e.data),$t=(e,t)=>{let n=e.parentNode;for(;x(n);)n=n.parentNode;let i=new ne(n,5,As);return i.currentNode=e,!!i.nextNode()||t&&!i.previousNode()},Bt=(e,t)=>{let n=new ne(e,4),i,r;for(;i=n.nextNode();)for(;(r=i.data.indexOf("\u200B"))>-1&&(!t||i.parentNode!==t);)if(i.length===1){let o=i,s=o.parentNode;for(;s&&(s.removeChild(o),n.currentNode=s,!(!x(s)||re(s)));)o=s,s=o.parentNode;break}else i.deleteData(r,1)},vs=0,Cs=1,xs=2,Ns=3,Le=(e,t,n)=>{let i=document.createRange();if(i.selectNode(t),n){let r=e.compareBoundaryPoints(Ns,i)>-1,o=e.compareBoundaryPoints(Cs,i)<1;return!r&&!o}else{let r=e.compareBoundaryPoints(vs,i)<1,o=e.compareBoundaryPoints(xs,i)>-1;return r&&o}},V=e=>{let{startContainer:t,startOffset:n,endContainer:i,endOffset:r}=e;for(;!(t instanceof Text);){let o=t.childNodes[n];if(!o||Re(o)){if(n&&(o=t.childNodes[n-1],o instanceof Text)){let s=o,a;for(;!s.length&&(a=s.previousSibling)&&a instanceof Text;)s.remove(),s=a;t=s,n=s.data.length}break}t=o,n=0}if(r)for(;!(i instanceof Text);){let o=i.childNodes[r-1];if(!o||Re(o)){if(o&&o.nodeName==="BR"&&!$t(o,!1)){r-=1;continue}break}i=o,r=re(i)}else for(;!(i instanceof Text);){let o=i.firstChild;if(!o||Re(o))break;i=o}e.setStart(t,n),e.setEnd(i,r)},Fe=(e,t,n,i)=>{let r=e.startContainer,o=e.startOffset,s=e.endContainer,a=e.endOffset,l;for(t||(t=e.commonAncestorContainer),n||(n=t);!o&&r!==t&&r!==i;)l=r.parentNode,o=Array.from(l.childNodes).indexOf(r),r=l;for(;!(s===n||s===i||(s.nodeType!==3&&s.childNodes[a]&&s.childNodes[a].nodeName==="BR"&&!$t(s.childNodes[a],!1)&&(a+=1),a!==re(s)));)l=s.parentNode,a=Array.from(l.childNodes).indexOf(s)+1,s=l;e.setStart(r,o),e.setEnd(s,a)},Vi=(e,t,n)=>{let i=L(e.endContainer,n,t);if(i&&(i=i.parentNode)){let r=e.cloneRange();Fe(r,i,i,n),r.endContainer===i&&(e.setStart(r.endContainer,r.endOffset),e.setEnd(r.endContainer,r.endOffset))}return e},z=e=>{let t=null;if(e instanceof Text)return e;if(x(e)){let n=e.firstChild;if(zt)for(;n&&n instanceof Text&&!n.data;)e.removeChild(n),n=e.firstChild;n||(zt?t=document.createTextNode("\u200B"):t=document.createTextNode(""))}else if((e instanceof Element||e instanceof DocumentFragment)&&!e.querySelector("BR")&&!fe.test(e.textContent||"")){t=T("BR");let n=e,i;for(;(i=n.lastElementChild)&&!x(i);)n=i;e=n,e instanceof HTMLElement&&e.contentEditable==="true"&&(e=T("DIV"),n.appendChild(e))}if(t)try{e.appendChild(t)}catch{}return e},pe=(e,t)=>{let n=null;return/^(?:TABLE|TBODY|TR|TH|TD|P)/.test(e.nodeName)||(Array.from(e.childNodes).forEach(i=>{let r=i.nodeName==="BR";!r&&x(i)?(n||(n=T("DIV")),n.appendChild(i)):(r||n)&&(n||(n=T("DIV")),z(n),r?e.replaceChild(n,i):e.insertBefore(n,i),n=null),Ze(i)&&pe(i,t)}),n&&e.appendChild(z(n))),e},se=(e,t,n,i)=>{if(!n.contains(e))throw new Error("split: stopNode does not contain node");if(e instanceof Text&&e!==n){if(typeof t!="number")throw new Error("Offset must be a number to split text node!");if(!e.parentNode)throw new Error("Cannot split text node with no parent!");return se(e.parentNode,e.splitText(t),n,i)}let r=typeof t=="number"?t<e.childNodes.length?e.childNodes[t]:null:t,o=e.parentNode;if(!o||e===n||!(e instanceof Element))return r;let s=e.cloneNode(!1);for(;r;){let a=r.nextSibling;s.appendChild(r),r=a}return e instanceof HTMLOListElement&&L(e,i,"BLOCKQUOTE")&&(s.start=(+e.start||1)+e.childNodes.length-1),z(e),z(s),o.insertBefore(s,e.nextSibling),se(o,s,n,i)},cr=(e,t)=>{let n=e.childNodes,i=n.length,r=[];for(;i--;){let o=n[i],s=i?n[i-1]:null;if(s&&x(o)&&ar(o,s))t.startContainer===o&&(t.startContainer=s,t.startOffset+=re(s)),t.endContainer===o&&(t.endContainer=s,t.endOffset+=re(s)),t.startContainer===e&&(t.startOffset>i?t.startOffset-=1:t.startOffset===i&&(t.startContainer=s,t.startOffset=re(s))),t.endContainer===e&&(t.endOffset>i?t.endOffset-=1:t.endOffset===i&&(t.endContainer=s,t.endOffset=re(s))),H(o),o instanceof Text?s.appendData(o.data):r.push(D(o));else if(o instanceof Element){let a;for(;a=r.pop();)o.appendChild(a);cr(o,t)}}},Qe=(e,t)=>{let n=e instanceof Text?e.parentNode:e;if(n instanceof Element){let i={startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset};cr(n,i),t.setStart(i.startContainer,i.startOffset),t.setEnd(i.endContainer,i.endOffset)}},ft=(e,t,n,i)=>{let r=t,o,s;for(;(o=r.parentNode)&&o!==i&&o instanceof Element&&o.childNodes.length===1;)r=o;H(r),s=e.childNodes.length;let a=e.lastChild;a&&a.nodeName==="BR"&&(e.removeChild(a),s-=1),e.appendChild(D(t)),n.setStart(e,s),n.collapse(!0),Qe(e,n)},_e=(e,t)=>{let n=e.previousSibling,i=e.firstChild,r=e.nodeName==="LI";if(!(r&&(!i||!/^[OU]L$/.test(i.nodeName)))){if(n&&ar(n,e)){if(!Ze(n))if(r){let s=T("DIV");s.appendChild(D(n)),n.appendChild(s)}else return;H(e);let o=!Ze(e);n.appendChild(D(e)),o&&pe(n,t),i&&_e(i,t)}else if(r){let o=T("DIV");e.insertBefore(o,i),z(o)}}},Yi={"font-weight":{regexp:/^bold|^700/i,replace(){return T("B")}},"font-style":{regexp:/^italic/i,replace(){return T("I")}},"font-family":{regexp:fe,replace(e,t){let n=T("SPAN",{class:e.fontFamily});return n.style.fontFamily=t,n}},"font-size":{regexp:fe,replace(e,t){let n=T("SPAN",{class:e.fontSize});return n.style.fontSize=t,n}},"text-decoration":{regexp:/^underline/i,replace(){return T("U")}}},Ls=(e,t,n)=>{let i=e.style,r,o;for(let s in Yi){let a=Yi[s],l=i.getPropertyValue(s);if(l&&a.regexp.test(l)){let u=a.replace(n.classNames,l);if(u.nodeName===e.nodeName&&u.className===e.className)continue;o||(o=u),r&&r.appendChild(u),r=u,e.style.removeProperty(s)}}return o&&r&&(r.appendChild(D(e)),e.style.cssText?e.appendChild(o):j(e,o)),r||e},Ft=e=>(t,n)=>{let i=T(e),r=t.attributes;for(let o=0,s=r.length;o<s;o+=1){let a=r[o];i.setAttribute(a.name,a.value)}return n.replaceChild(i,t),i.appendChild(D(t)),i},ws={1:"10",2:"13",3:"16",4:"18",5:"24",6:"32",7:"48"},Rs={STRONG:Ft("B"),EM:Ft("I"),INS:Ft("U"),STRIKE:Ft("S"),SPAN:Ls,FONT:(e,t,n)=>{let i=e,r=i.face,o=i.size,s=i.color,a=n.classNames,l,u,d,f,p;return r&&(l=T("SPAN",{class:a.fontFamily}),l.style.fontFamily=r,p=l,f=l),o&&(u=T("SPAN",{class:a.fontSize}),u.style.fontSize=ws[o]+"px",p||(p=u),f&&f.appendChild(u),f=u),s&&/^#?([\dA-F]{3}){1,2}$/i.test(s)&&(s.charAt(0)!=="#"&&(s="#"+s),d=T("SPAN",{class:a.color}),d.style.color=s,p||(p=d),f&&f.appendChild(d),f=d),(!p||!f)&&(p=f=T("SPAN")),t.replaceChild(p,i),f.appendChild(D(i)),f},TT:(e,t,n)=>{let i=T("SPAN",{class:n.classNames.fontFamily,style:'font-family:menlo,consolas,"courier new",monospace'});return t.replaceChild(i,e),i.appendChild(D(e)),i}},Os=/^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|COL(?:GROUP)?|UL)$/,ks=/^(?:HEAD|META|STYLE)/,Rn=(e,t,n)=>{let i=e.childNodes,r=e;for(;x(r);)r=r.parentNode;let o=new ne(r,5);for(let s=0,a=i.length;s<a;s+=1){let l=i[s],u=l.nodeName,d=Rs[u];if(l instanceof HTMLElement){let f=l.childNodes.length;if(d)l=d(l,e,t);else if(ks.test(u)){e.removeChild(l),s-=1,a-=1;continue}else if(!Os.test(u)&&!x(l)){s-=1,a+=f-1,e.replaceChild(D(l),l);continue}f&&Rn(l,t,n||u==="PRE")}else{if(l instanceof Text){let f=l.data,p=!fe.test(f.charAt(0)),y=!fe.test(f.charAt(f.length-1));if(n||!p&&!y)continue;if(p){o.currentNode=l;let E;for(;(E=o.previousPONode())&&!(E.nodeName==="IMG"||E instanceof Text&&fe.test(E.data));)if(!x(E)){E=null;break}f=f.replace(/^[ \t\r\n]+/g,E?" ":"")}if(y){o.currentNode=l;let E;for(;(E=o.nextNode())&&!(E.nodeName==="IMG"||E instanceof Text&&fe.test(E.data));)if(!x(E)){E=null;break}f=f.replace(/[ \t\r\n]+$/g,E?" ":"")}if(f){l.data=f;continue}}e.removeChild(l),s-=1,a-=1}}return e},On=e=>{let t=e.childNodes,n=t.length;for(;n--;){let i=t[n];i instanceof Element&&!Re(i)?(On(i),x(i)&&!i.firstChild&&e.removeChild(i)):i instanceof Text&&!i.data&&e.removeChild(i)}},kn=(e,t,n)=>{let i=e.querySelectorAll("BR"),r=[],o=i.length;for(let s=0;s<o;s+=1)r[s]=$t(i[s],n);for(;o--;){let s=i[o],a=s.parentNode;a&&(r[o]?x(a)||pe(a,t):H(s))}},Xi=e=>e.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;").split('"').join("&quot;"),qt=(e,t)=>{let n=new ne(t,1,we);return n.currentNode=e,n},Ue=(e,t)=>{let n=qt(e,t).previousNode();return n!==t?n:null},Ee=(e,t)=>{let n=qt(e,t).nextNode();return n!==t?n:null},Dn=e=>!e.textContent&&!e.querySelector("IMG"),ie=(e,t)=>{let n=e.startContainer,i;if(x(n))i=Ue(n,t);else if(n!==t&&n instanceof HTMLElement&&we(n))i=n;else{let r=Pn(n,e.startOffset);i=Ee(r,t)}return i&&Le(e,i,!0)?i:null},He=(e,t)=>{let n=e.endContainer,i;if(x(n))i=Ue(n,t);else if(n!==t&&n instanceof HTMLElement&&we(n))i=n;else{let r=lr(n,e.endOffset);if(!r||!t.contains(r)){r=t;let o;for(;o=r.lastChild;)r=o}i=Ue(r,t)}return i&&Le(e,i,!0)?i:null},ur=e=>e instanceof Text?fe.test(e.data):e.nodeName==="IMG",pt=(e,t)=>{let n=e.startContainer,i=e.startOffset,r;if(n instanceof Text){let a=n.data;for(let l=i;l>0;l-=1)if(a.charAt(l-1)!=="\u200B")return!1;r=n}else if(r=lr(n,i),r&&!t.contains(r)&&(r=null),!r&&(r=Pn(n,i),r instanceof Text&&r.length))return!1;let o=ie(e,t);if(!o)return!1;let s=new ne(o,5,ur);return s.currentNode=r,!s.previousNode()},mt=(e,t)=>{let n=e.endContainer,i=e.endOffset,r;if(n instanceof Text){let a=n.data,l=a.length;for(let u=i;u<l;u+=1)if(a.charAt(u)!=="\u200B")return!1;r=n}else r=Pn(n,i);let o=He(e,t);if(!o)return!1;let s=new ne(o,5,ur);return s.currentNode=r,!s.nextNode()},Qi=(e,t)=>{let n=ie(e,t),i=He(e,t),r;n&&i&&(r=n.parentNode,e.setStart(r,Array.from(r.childNodes).indexOf(n)),r=i.parentNode,e.setEnd(r,Array.from(r.childNodes).indexOf(i)+1))};function Be(e,t,n,i){let r=document.createRange();return r.setStart(e,t),n&&typeof i=="number"?r.setEnd(n,i):r.setEnd(e,t),r}var Te=(e,t)=>{let{startContainer:n,startOffset:i,endContainer:r,endOffset:o}=e,s;if(n instanceof Text){let l=n.parentNode;if(s=l.childNodes,i===n.length)i=Array.from(s).indexOf(n)+1,e.collapsed&&(r=l,o=i);else{if(i){let u=n.splitText(i);r===n?(o-=i,r=u):r===l&&(o+=1),n=u}i=Array.from(s).indexOf(n)}n=l}else s=n.childNodes;let a=s.length;i===a?n.appendChild(t):n.insertBefore(t,s[i]),n===r&&(o+=s.length-a),e.setStart(n,i),e.setEnd(r,o)},dr=(e,t,n)=>{let i=document.createDocumentFragment();if(e.collapsed)return i;t||(t=e.commonAncestorContainer),t instanceof Text&&(t=t.parentNode);let r=e.startContainer,o=e.startOffset,s=se(e.endContainer,e.endOffset,t,n),a=0,l=se(r,o,t,n);for(;l&&l!==s;){let u=l.nextSibling;i.appendChild(l),l=u}return l=s&&s.previousSibling,l&&l instanceof Text&&s instanceof Text&&(a=l.length,l.appendData(s.data),H(s),s=l),e.setStart(r,o),s?e.setEnd(s,a):e.setEnd(t,t.childNodes.length),z(t),i},Zi=(e,t,n)=>{e.currentNode=n;let i;for(;i=e[t]();){if(i instanceof Text||Re(i))return i;if(!x(i))return null}return null},qe=(e,t)=>{let n=ie(e,t),i=He(e,t),r=n!==i;n&&i&&(V(e),Fe(e,n,i,t));let o=dr(e,null,t);V(e),r&&(i=He(e,t),n&&i&&n!==i&&ft(n,i,e,t)),n&&z(n);let s=t.firstChild;(!s||s.nodeName==="BR")&&(z(t),t.firstChild&&e.selectNodeContents(t.firstChild)),e.collapse(!0);let a=e.startContainer,l=e.startOffset,u=new ne(t,5),d=a,f=l;(!(d instanceof Text)||f===d.data.length)&&(d=Zi(u,"nextNode",d),f=0);let p=a,y=l-1;(!(p instanceof Text)||y===-1)&&(p=Zi(u,"previousPONode",d||(a instanceof Text?a:a.childNodes[l]||a)),p instanceof Text&&(y=p.data.length));let E=null,N=0;return d instanceof Text&&d.data.charAt(f)===" "&&pt(e,t)?(E=d,N=f):p instanceof Text&&p.data.charAt(y)===" "&&(d instanceof Text&&d.data.charAt(f)===" "||mt(e,t))&&(E=p,N=y),E&&E.replaceData(N,1,"\xA0"),e.setStart(a,l),e.collapse(!0),o},Ds=(e,t,n)=>{let i=t.firstChild&&x(t.firstChild),r;for(pe(t,n),r=t;r=Ee(r,n);)z(r);e.collapsed||qe(e,n),V(e),e.collapse(!1);let o=L(e.endContainer,n,"BLOCKQUOTE")||n,s=ie(e,n),a=null,l=Ee(t,t),u=!i&&!!s&&Dn(s);if(s&&l&&!u&&!L(l,t,"PRE")&&!L(l,t,"TABLE")){Fe(e,s,s,n),e.collapse(!0);let d=e.endContainer,f=e.endOffset;if(kn(s,n,!1),x(d)){let p=se(d,f,Ue(d,n)||n,n);d=p.parentNode,f=Array.from(d.childNodes).indexOf(p)}if(f!==re(d))for(a=document.createDocumentFragment();r=d.childNodes[f];)a.appendChild(r);ft(d,l,e,n),d===n?e.setEnd(n,re(n)):(f=Array.from(d.parentNode.childNodes).indexOf(d)+1,d=d.parentNode,e.setEnd(d,f))}if(re(t)){u&&s&&(e.setEndBefore(s),e.collapse(!1),H(s)),o.contains(e.endContainer)||(n.contains(e.endContainer)||(e.setEnd(n,re(n)),e.collapse(!1)),o=L(e.endContainer,n,"BLOCKQUOTE")||n),Fe(e,o,o,n);let d=se(e.endContainer,e.endOffset,o,n),f=d?d.previousSibling:o.lastChild;o.insertBefore(t,d),d?e.setEndBefore(d):e.setEnd(o,re(o)),s=He(e,n),V(e);let p=e.endContainer,y=e.endOffset;d&&Ze(d)&&_e(d,n),d=f&&f.nextSibling,d&&Ze(d)&&_e(d,n),e.setEnd(p,y)}if(a&&s){let d=e.cloneRange();z(a),ft(s,a,d,n),e.setEnd(d.endContainer,d.endOffset)}V(e)},hr=e=>{if(e.collapsed)return"";let t=e.startContainer,n=e.endContainer,i=new ne(e.commonAncestorContainer,5,l=>Le(e,l,!0));i.currentNode=t;let r=t,o="",s=!1,a;for((!(r instanceof Element)&&!(r instanceof Text)||!i.filter(r))&&(r=i.nextNode());r;)r instanceof Text?(a=r.data,a&&/\S/.test(a)&&(r===n&&(a=a.slice(0,e.endOffset)),r===t&&(a=a.slice(e.startOffset)),o+=a,s=!0)):(r.nodeName==="BR"||s&&!x(r))&&(o+=`
3
+ `,s=!1),r=i.nextNode();return o=o.replace(/ /g," "),o},Cn=Array.prototype.indexOf,fr=(e,t,n,i,r)=>{let o=r?"":hr(e),s=ie(e,t),a=He(e,t),l=e.commonAncestorContainer,u=t;s===a&&s?.contains(l)&&(u=s);let d;for(n?(d=qe(e,t),l.isConnected||(l=e.commonAncestorContainer)):d=e.cloneContents(),l instanceof Text&&(l=l.parentNode);l&&l!==u;){let p=l.cloneNode(!1);p.appendChild(d),d=p,l=l.parentNode}let f;if(d.childNodes.length===1&&d.childNodes[0]instanceof Text)o=d.childNodes[0].data.replace(/ /g," "),f=void 0;else{let p=T("DIV");p.appendChild(d),f=p.innerHTML,i&&(f=i(f))}return r&&f!==void 0&&(o=r(f)),o===f&&(f=void 0),nr&&(o=o.replace(/\r?\n/g,`\r
4
+ `)),f&&(f="<!-- squire -->"+f),[o,f]},pr=(e,t,n,i,r,o,s)=>{let a=e.clipboardData;if(Ht||!a)return!1;let[l,u]=fr(t,n,i,r,o);return e.preventDefault(),!s&&u&&a.setData("text/html",u),a.setData("text/plain",l),!0},Is=function(e){let t=this.getSelection(),n=this._root;if(t.collapsed){e.preventDefault();return}this.saveUndoState(t),pr(e,t,n,!0,this._config.willCutCopy,this._config.toPlainText,!1)||setTimeout(()=>{try{this._ensureBottomLine()}catch(i){this._config.didError(i)}},0),this.setSelection(t)},Ms=function(e){pr(e,this.getSelection(),this._root,!1,this._config.willCutCopy,this._config.toPlainText,!1)},Ji=function(e){this._isShiftDown=e.shiftKey},Ps=function(e){let t=e.clipboardData,n=t?.items,i=this._isShiftDown,r=!1,o=!1,s=null,a=null;if(n){let C=n.length;for(;C--;){let M=n[C],$=M.type;$==="text/html"?a=M:$==="text/plain"||$==="text/uri-list"?s=M:$==="text/rtf"?r=!0:/^image\/.*/.test($)&&(o=!0)}if(o&&!(r&&a)&&!s){e.preventDefault(),this.fireEvent("pasteImage",{clipboardData:t});return}if(!Ht){e.preventDefault(),a&&(!i||!s)?a.getAsString(M=>{this.insertHTML(M,!0)}):s&&s.getAsString(M=>{let $=this.getSelection();if(!$.collapsed&&fe.test($.toString())){let le=this.linkRegExp.exec(M);if(le&&le[0].length===M.length){let Q=le[1]?/^(?:ht|f)tps?:/i.test(le[1])?le[1]:"http://"+le[1]:"mailto:"+le[0];this.makeLink(Q);return}}this.insertPlainText(M,!0)});return}}let l=t?.types;if(!Ht&&l&&(Cn.call(l,"text/html")>-1||!ys&&Cn.call(l,"text/plain")>-1&&Cn.call(l,"text/rtf")<0)){e.preventDefault();let C;!i&&(C=t.getData("text/html"))?this.insertHTML(C,!0):((C=t.getData("text/plain"))||(C=t.getData("text/uri-list")))&&this.insertPlainText(C,!0);return}let u=document.body,d=this.getSelection(),f=d.startContainer,p=d.startOffset,y=d.endContainer,E=d.endOffset,N=T("DIV",{contenteditable:"true",style:"position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;"});u.appendChild(N),d.selectNodeContents(N),this.setSelection(d),setTimeout(()=>{try{let C="",M=N,$;for(;N=M;)M=N.nextSibling,H(N),$=N.firstChild,$&&$===N.lastChild&&$ instanceof HTMLDivElement&&(N=$),C+=N.innerHTML;this.setSelection(Be(f,p,y,E)),C&&this.insertHTML(C,!0)}catch(C){this._config.didError(C)}},0)},Bs=function(){let e=this.getSelection();e&&!e.collapsed&&this._root.contains(e.commonAncestorContainer)?this._dragRange=e.cloneRange():this._dragRange=null},Fs=function(){this._dragRange=null},Us=(e,t,n)=>{let i=null,r=document;if(r.caretPositionFromPoint){let o=r.caretPositionFromPoint(e,t);o&&(i=document.createRange(),i.setStart(o.offsetNode,o.offset),i.collapse(!0))}else r.caretRangeFromPoint&&(i=r.caretRangeFromPoint(e,t));return i&&!n.contains(i.commonAncestorContainer)?null:i},Hs=(e,t)=>e.compareBoundaryPoints(Range.START_TO_START,t)>=0&&e.compareBoundaryPoints(Range.END_TO_END,t)<=0,zs=function(e){let t=e.dataTransfer;if(!t)return;let n=t.types,i=!1,r=!1;for(let d=0,f=n.length;d<f;d+=1)switch(n[d]){case"text/plain":i=!0;break;case"text/html":r=!0;break}if(!i&&!r)return;e.preventDefault();let o=this._root,s=Us(e.clientX,e.clientY,o),a=this._dragRange;if(this._dragRange=null,!s)return;let l,u;if(a){if(Hs(s,a))return;this._recordUndoState(a,this._isInUndoState);let d=document.createComment("");s.insertNode(d),this._getRangeAndRemoveBookmark(a),[l,u]=fr(a,o,t.dropEffect!=="copy",this._config.willCutCopy,this._config.toPlainText),d.replaceWith(T("INPUT",{id:this.startSelectionId,type:"hidden"}),T("INPUT",{id:this.endSelectionId,type:"hidden"})),this._getRangeAndRemoveBookmark(s),sr()}else this.saveUndoState(s),r?u=t.getData("text/html"):l=t.getData("text/plain");this.setSelection(s),u!==void 0?this.insertHTML(u,!0):l!==void 0&&this.insertPlainText(l,!0)},er=(e,t,n)=>{t.preventDefault(),e.splitBlock(t.shiftKey,n)},ht=(e,t)=>{try{t||(t=e.getSelection());let n=t.startContainer;n instanceof Text&&(n=n.parentNode);let i=n;for(;i!==e._root&&x(i)&&(!i.textContent||i.textContent==="\u200B");)n=i,i=n.parentNode;n!==i&&(t.setStart(i,Array.from(i.childNodes).indexOf(n)),t.collapse(!0),i.removeChild(n),we(i)||(i=Ue(i,e._root)||e._root),z(i),V(t)),n===e._root&&(n=n.firstChild)&&n.nodeName==="BR"&&H(n),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(n){e._config.didError(n)}},mr=(e,t)=>{let n;for(;(n=e.parentNode)&&!(n===t||n.isContentEditable);)e=n;H(e)},gr=(e,t,n)=>{if(L(t,e._root,"A"))return;let i=t.data||"",r=Math.max(i.lastIndexOf(" ",n-1),i.lastIndexOf("\xA0",n-1))+1,o=i.slice(r,n),s=e.linkRegExp.exec(o);if(s){let a=e.getSelection();e._docWasChanged(),e._recordUndoState(a),e._getRangeAndRemoveBookmark(a);let l=r+s.index,u=l+s[0].length,d=a.startContainer===t,f=a.startOffset-u;l&&(t=t.splitText(l));let p=e._config.tagAttributes.a,y=T("A",Object.assign({href:s[1]?/^(?:ht|f)tps?:/i.test(s[1])?s[1]:"http://"+s[1]:"mailto:"+s[0]},p));y.textContent=i.slice(l,u),t.parentNode.insertBefore(y,t),t.data=i.slice(u),d&&(a.setStart(t,f),a.setEnd(t,f)),e.setSelection(a)}},qs=(e,t,n)=>{let i=e._root;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),qe(n,i),ht(e,n);else if(pt(n,i)){t.preventDefault();let r=ie(n,i);if(!r)return;let o=r;pe(o.parentNode,i);let s=Ue(o,i);if(s){if(!s.isContentEditable){mr(s,i);return}for(ft(s,o,n,i),o=s.parentNode;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(o=o.nextSibling)&&_e(o,i),e.setSelection(n)}else if(o){if(L(o,i,"UL")||L(o,i,"OL")){e.decreaseListLevel(n);return}else if(L(o,i,"BLOCKQUOTE")){e.removeQuote(n);return}e.setSelection(n),e._updatePath(n,!0)}}else{V(n);let r=n.startContainer,o=n.startOffset,s=r.parentNode;r instanceof Text&&s instanceof HTMLAnchorElement&&o&&s.href.includes(r.data)?(r.deleteData(o-1,1),e.setSelection(n),e.removeLink(),t.preventDefault()):(e.setSelection(n),setTimeout(()=>{ht(e)},0))}},$s=(e,t,n)=>{let i=e._root,r,o,s,a,l,u;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),qe(n,i),ht(e,n);else if(mt(n,i)){if(t.preventDefault(),r=ie(n,i),!r)return;if(pe(r.parentNode,i),o=Ee(r,i),o){if(!o.isContentEditable){mr(o,i);return}for(ft(r,o,n,i),o=r.parentNode;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(o=o.nextSibling)&&_e(o,i),e.setSelection(n),e._updatePath(n,!0)}}else{if(s=n.cloneRange(),Fe(n,i,i,i),a=n.endContainer,l=n.endOffset,a instanceof Element&&(u=a.childNodes[l],u&&u.nodeName==="IMG")){t.preventDefault(),H(u),V(n),ht(e,n);return}e.setSelection(s),setTimeout(()=>{ht(e)},0)}},Ws=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&pt(n,i)){let r=ie(n,i),o;for(;o=r.parentNode;){if(o.nodeName==="UL"||o.nodeName==="OL"){t.preventDefault(),e.increaseListLevel(n);break}r=o}}},Gs=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&pt(n,i)){let r=n.startContainer;(L(r,i,"UL")||L(r,i,"OL"))&&(t.preventDefault(),e.decreaseListLevel(n))}},Ks=(e,t,n)=>{let i,r=e._root;if(e._recordUndoState(n),e._getRangeAndRemoveBookmark(n),!n.collapsed)qe(n,r),e._ensureBottomLine(),e.setSelection(n),e._updatePath(n,!0);else if(mt(n,r)){let o=ie(n,r);if(o&&o.nodeName!=="PRE"){let s=o.textContent?.trimEnd().replace("\u200B","");if(s==="*"||s==="1."){t.preventDefault(),e.insertPlainText(" ",!1),e._docWasChanged(),e.saveUndoState(n);let a=new ne(o,4),l;for(;l=a.nextNode();)H(l);s==="*"?e.makeUnorderedList():e.makeOrderedList();return}}}if(i=n.endContainer,n.endOffset===re(i))do if(i.nodeName==="A"){n.setStartAfter(i);break}while(!i.nextSibling&&(i=i.parentNode)&&i!==r);if(e._config.addLinks){let o=n.cloneRange();V(o);let s=o.startContainer,a=o.startOffset;setTimeout(()=>{gr(e,s,a)},0)}e.setSelection(n)},js=function(e){if(e.defaultPrevented||e.isComposing)return;let t=e.key,n="",i=e.code;/^Digit\d$/.test(i)&&(t=i.slice(-1)),t!=="Backspace"&&t!=="Delete"&&(e.altKey&&(n+="Alt-"),e.ctrlKey&&(n+="Ctrl-"),e.metaKey&&(n+="Meta-"),e.shiftKey&&(n+="Shift-")),nr&&e.shiftKey&&t==="Delete"&&(n+="Shift-"),t=n+t;let r=this.getSelection(),o=this._keyHandlers[t];o?o(this,e,r):!r.collapsed&&!e.ctrlKey&&!e.metaKey&&t.length===1&&(this.saveUndoState(r),qe(r,this._root),this._ensureBottomLine(),this.setSelection(r),this._updatePath(r,!0))},B={Backspace:qs,Delete:$s,Tab:Ws,"Shift-Tab":Gs," ":Ks,ArrowLeft(e){e._removeZWS()},ArrowRight(e,t,n){e._removeZWS();let i=e.getRoot();if(mt(n,i)){V(n);let r=n.endContainer;do if(r.nodeName==="CODE"){let o=r.nextSibling;if(!(o instanceof Text)||o.length===0){let s=document.createTextNode("\xA0");r.parentNode.insertBefore(s,o),o=s}n.setStart(o,1),e.setSelection(n),t.preventDefault();break}while(!r.nextSibling&&(r=r.parentNode)&&r!==i)}}};Ts||(B.Enter=er,B["Shift-Enter"]=er);!In&&!ir&&(B.PageUp=e=>{e.moveCursorToStart()},B.PageDown=e=>{e.moveCursorToEnd()});var Je=(e,t)=>(t=t||null,(n,i)=>{i.preventDefault();let r=n.getSelection();n.hasFormat(e,null,r)?n.changeFormat(null,{tag:e},r):n.changeFormat({tag:e},t,r)});B[J+"b"]=Je("B");B[J+"i"]=Je("I");B[J+"u"]=Je("U");B[J+"Shift-7"]=Je("S");B[J+"Shift-5"]=Je("SUB",{tag:"SUP"});B[J+"Shift-6"]=Je("SUP",{tag:"SUB"});B[J+"Shift-8"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)UL/.test(n)?e.removeList():e.makeUnorderedList()};B[J+"Shift-9"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)OL/.test(n)?e.removeList():e.makeOrderedList()};B[J+"["]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.decreaseQuoteLevel():e.decreaseListLevel()};B[J+"]"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.increaseQuoteLevel():e.increaseListLevel()};B[J+"d"]=(e,t)=>{t.preventDefault(),e.toggleCode()};B[J+"z"]=(e,t)=>{t.preventDefault(),e.undo()};B[J+"y"]=B[J+"Shift-z"]=B[J+"Shift-Z"]=(e,t)=>{t.preventDefault(),e.redo()};var xn=8,tr=40,Nn=1200,Vs=[{pos:"nw",cursor:"nwse-resize"},{pos:"n",cursor:"ns-resize"},{pos:"ne",cursor:"nesw-resize"},{pos:"e",cursor:"ew-resize"},{pos:"se",cursor:"nwse-resize"},{pos:"s",cursor:"ns-resize"},{pos:"sw",cursor:"nesw-resize"},{pos:"w",cursor:"ew-resize"}],Ys={ArrowUp:(e,t,n)=>{let i=ie(t,n);if(i){let r=Ue(i,n);r&&(t.selectNodeContents(r),t.collapse(!1),e.setSelection(t).focus())}},ArrowDown:(e,t,n)=>{let i=ie(t,n);if(i){let r=Ee(i,n);r&&(t.selectNodeContents(r),t.collapse(!0),e.setSelection(t).focus())}},Delete:(e,t)=>{e.replaceWithBlankLine(t)},Backspace:(e,t)=>{e.replaceWithBlankLine(t)}},Xs=class{constructor(e,t){this._currentImage=null,this._resizeContainer=null,this._handles=null,this._currentHandle=null,this._startX=0,this._startY=0,this._startWidth=0,this._startHeight=0,this._maxWidth=Nn,this._originalRatio=1,this._editor=t,this._root=e,document.addEventListener("click",this),t.addEventListener("drop",this)}destroy(){this._deselectImage(),this._editor.removeEventListener("drop",this),document.removeEventListener("click",this)}handleEvent(e){switch(e.type){case"click":this._onClick(e);break;case"pointerdown":this._onPointerDown(e);break;case"pointermove":this._onPointerMove(e);break;case"pointercancel":case"pointerup":this._onPointerUp(e);break;case"keydown":this._onKeyDown(e);break;case"drop":this._deselectImage();break}}_onClick(e){let t=e.target;t.nodeName==="IMG"&&this._root.contains(t)?(e.stopPropagation(),this._selectImage(t)):this._currentImage&&this._handles&&!this._handles.some(n=>n.element===t)&&this._deselectImage()}_deselectImage(){this._currentImage&&(document.removeEventListener("keydown",this,!0),this._currentHandle&&this._onPointerUp({preventDefault(){},target:this._currentHandle.element}),this._handles&&this._handles.forEach(({element:e})=>e.removeEventListener("pointerdown",this)),this._resizeContainer&&this._resizeContainer.remove(),this._currentImage.removeAttribute("tabindex"),this._handles=null,this._resizeContainer=null,this._currentImage=null)}_selectImage(e){if(this._currentImage===e)return;this._deselectImage(),this._root.blur();let t=Vs.map(({pos:r,cursor:o})=>{let s=xn/2,a="";switch(r){case"nw":a=`left: -${s}px; top: -${s}px;`;break;case"n":a=`left: calc(50% - ${s}px); top: -${s}px;`;break;case"ne":a=`right: -${s}px; top: -${s}px;`;break;case"e":a=`right: -${s}px; top: calc(50% - ${s}px);`;break;case"se":a=`right: -${s}px; bottom: -${s}px;`;break;case"s":a=`left: calc(50% - ${s}px); bottom: -${s}px;`;break;case"sw":a=`left: -${s}px; bottom: -${s}px;`;break;case"w":a=`left: -${s}px; top: calc(50% - ${s}px);`;break}let l=T("div",{class:`squire-resize-handle squire-resize-handle-${r}`,style:`
5
5
  position: absolute;
6
- width: ${vn}px;
7
- height: ${vn}px;
6
+ width: ${xn}px;
7
+ height: ${xn}px;
8
8
  background: #0067b9;
9
9
  border: 1px solid #fff;
10
10
  cursor: ${o};
@@ -12,16 +12,23 @@ var richclay=(()=>{var Sn=Object.defineProperty;var Zo=Object.getOwnPropertyDesc
12
12
  touch-action: none;
13
13
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
14
14
  ${a}
15
- `});return c.addEventListener("pointerdown",this),{element:c,cursor:o,position:r}}),n=_("div",{class:"squire-image-resize-container",style:"position: absolute; pointer-events: none; z-index: 1000;"},t.map(r=>r.element));this._currentImage=e,this._resizeContainer=n,this._handles=t,this._root.appendChild(this._resizeContainer);let i=e.naturalWidth;this._originalRatio=i/e.naturalHeight,this._maxWidth=Math.min(i*2,e.parentElement?e.parentElement.offsetWidth:Cn,Cn),this._positionResizeContainer(),e.tabIndex=-1,e.focus(),document.addEventListener("keydown",this,!0)}_positionResizeContainer(){let e=this._resizeContainer,t=this._root,n=this._currentImage;if(!e||!n)return;let i=t.getBoundingClientRect(),r=n.getBoundingClientRect(),o=r.top-i.top+t.scrollTop,s=r.left-i.left+t.scrollLeft,a=r.width,c=r.height;e.style.top=o+"px",e.style.left=s+"px",e.style.width=a+"px",e.style.height=c+"px"}_onPointerDown(e){if(this._currentHandle||!this._handles)return;let t=e.target,n=this._handles.find(o=>o.element===t)||null;if(!n)return;let i=this._currentImage;if(!i)return;e.preventDefault(),e.stopPropagation(),t.addEventListener("pointermove",this),t.addEventListener("pointerup",this),t.addEventListener("pointercancel",this),t.setPointerCapture(e.pointerId),this._currentHandle=n,this._startX=e.clientX,this._startY=e.clientY;let r=getComputedStyle(i);this._startWidth=parseFloat(r.width),this._startHeight=parseFloat(r.height),document.body.style.cursor=n.cursor}_onPointerMove(e){e.preventDefault();let t=this._currentHandle,n=this._currentImage;if(!t||!n)return;let i=e.clientX-this._startX,r=e.clientY-this._startY,o=this._maxWidth,s=this._originalRatio,a=this._startWidth,c=this._startHeight;switch(t.position){case"sw":case"nw":case"w":a-=2*i;break;case"se":case"ne":case"e":a+=2*i;break;case"n":c-=r,a=c*s;break;case"s":c+=r,a=c*s;break}a<Yi?a=Yi:a>o&&(a=o);let u=n.style;u.width=a+"px",u.height="auto",this._positionResizeContainer()}_onPointerUp(e){e.preventDefault();let t=e.target;t&&(t.removeEventListener("pointermove",this),t.removeEventListener("pointerup",this),t.removeEventListener("pointercancel",this)),this._currentHandle=null,document.body.style.cursor=""}_onKeyDown(e){e.preventDefault(),e.stopPropagation();let t=Bs[e.key];if(!t)return;let n=this._currentImage;if(!n)return;let i=this._editor,r=this._root;this._deselectImage();let o=i.getSelection();o.selectNode(n),t(i,o,r)}},Us=class{constructor(e,t){this.customEvents=new Set(["pathChange","select","input","pasteImage","undoStateChange"]),this.startSelectionId="squire-selection-start",this.endSelectionId="squire-selection-end",this.linkRegExp=/\b(?:((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9][a-z0-9.\-]*[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:[^\s?&`!()\[\]{};:'".,<>«»“”‘’]|\([^\s()<>]+\)))|([\w\-.%+]+@(?:[\w\-]+\.)+[a-z]{2,}\b(?:[?][^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+(?:&[^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+)*)?))/i,this.tagAfterSplit={DT:"DD",DD:"DT",LI:"LI",PRE:"PRE"},this._root=e,this._config=this._makeConfig(t),this._isFocused=!1,this._lastSelection=Be(e,0),this._willRestoreSelection=!1,this._mayHaveZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this._events=new Map,this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,this._ignoreAllChanges=!1,this.addEventListener("selectionchange",this._updatePathOnEvent),this.addEventListener("blur",this._enableRestoreSelection),this.addEventListener("mousedown",this._disableRestoreSelection),this.addEventListener("touchstart",this._disableRestoreSelection),this.addEventListener("focus",this._restoreSelection),this.addEventListener("blur",this._removeZWS),this._isShiftDown=!1,this.addEventListener("cut",Ss),this.addEventListener("copy",As),this.addEventListener("paste",vs),this._dragRange=null,this.addEventListener("dragstart",Cs),this.addEventListener("dragend",xs),this.addEventListener("drop",ws),this.addEventListener("keydown",Vi),this.addEventListener("keyup",Vi),this.addEventListener("keydown",Ms),this._keyHandlers=Object.create(B);let n=new MutationObserver(()=>this._docWasChanged());n.observe(e,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._mutation=n,e.setAttribute("contenteditable","true"),this.addEventListener("beforeinput",this._beforeInput),this._imageResizer=new Fs(e,this),this.setHTML("")}destroy(){this._events.forEach((e,t)=>{this.removeEventListener(t)}),this._mutation.disconnect(),this._imageResizer.destroy(),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0}_makeConfig(e){let t={blockTag:"DIV",blockAttributes:null,tagAttributes:{},classNames:{color:"color",fontFamily:"font",fontSize:"size",highlight:"highlight"},undo:{documentSizeThreshold:-1,undoLimit:-1},addLinks:!0,willCutCopy:null,toPlainText:null,sanitizeToDOMFragment:n=>{let i=DOMPurify.sanitize(n,{ALLOW_UNKNOWN_PROTOCOLS:!0,WHOLE_DOCUMENT:!1,RETURN_DOM:!0,RETURN_DOM_FRAGMENT:!0,FORCE_BODY:!1});return i?document.importNode(i,!0):document.createDocumentFragment()},didError:n=>console.log(n)};return e&&(Object.assign(t,e),t.blockTag=t.blockTag.toUpperCase()),t}setKeyHandler(e,t){return this._keyHandlers[e]=t,this}_beforeInput(e){switch(e.inputType){case"insertLineBreak":e.preventDefault(),this.splitBlock(!0);break;case"insertParagraph":e.preventDefault(),this.splitBlock(!1);break;case"insertOrderedList":e.preventDefault(),this.makeOrderedList();break;case"insertUnoderedList":e.preventDefault(),this.makeUnorderedList();break;case"historyUndo":e.preventDefault(),this.undo();break;case"historyRedo":e.preventDefault(),this.redo();break;case"formatBold":e.preventDefault(),this.bold();break;case"formatItalic":e.preventDefault(),this.italic();break;case"formatUnderline":e.preventDefault(),this.underline();break;case"formatStrikeThrough":e.preventDefault(),this.strikethrough();break;case"formatSuperscript":e.preventDefault(),this.superscript();break;case"formatSubscript":e.preventDefault(),this.subscript();break;case"formatJustifyFull":case"formatJustifyCenter":case"formatJustifyRight":case"formatJustifyLeft":{e.preventDefault();let t=e.inputType.slice(13).toLowerCase();t==="full"&&(t="justify"),this.setTextAlignment(t);break}case"formatRemove":e.preventDefault(),this.removeAllFormatting();break;case"formatSetBlockTextDirection":{e.preventDefault();let t=e.data;t==="null"&&(t=null),this.setTextDirection(t);break}case"formatBackColor":e.preventDefault(),this.setHighlightColor(e.data);break;case"formatFontColor":e.preventDefault(),this.setTextColor(e.data);break;case"formatFontName":e.preventDefault(),this.setFontFace(e.data);break}}handleEvent(e){this.fireEvent(e.type,e)}fireEvent(e,t){let n=this._events.get(e);if(/^(?:focus|blur)/.test(e)){let i=this._root===document.activeElement;if(e==="focus"){if(!i||this._isFocused)return this;this._isFocused=!0}else{if(i||!this._isFocused)return this;this._isFocused=!1}}if(n){let i=t instanceof Event?t:new CustomEvent(e,{detail:t});n=n.slice();for(let r of n)try{"handleEvent"in r?r.handleEvent(i):r.call(this,i)}catch(o){this._config.didError(o)}}return this}addEventListener(e,t){let n=this._events.get(e),i=this._root;return n||(n=[],this._events.set(e,n),this.customEvents.has(e)||(e==="selectionchange"&&(i=document),i.addEventListener(e,this,!0))),n.push(t),this}removeEventListener(e,t){let n=this._events.get(e),i=this._root;if(n){if(t){let r=n.length;for(;r--;)n[r]===t&&n.splice(r,1)}else n.length=0;n.length||(this._events.delete(e),this.customEvents.has(e)||(e==="selectionchange"&&(i=document),i.removeEventListener(e,this,!0)))}return this}focus(){return this._root.focus({preventScroll:!0}),this}blur(){return this._root.blur(),this}_enableRestoreSelection(){this._willRestoreSelection=!0}_disableRestoreSelection(){this._willRestoreSelection=!1}_restoreSelection(){this._willRestoreSelection&&this.setSelection(this._lastSelection)}_removeZWS(){this._mayHaveZWS&&(Mt(this._root),this._mayHaveZWS=!1)}_saveRangeToBookmark(e){let t=_("INPUT",{id:this.startSelectionId,type:"hidden"}),n=_("INPUT",{id:this.endSelectionId,type:"hidden"}),i;_e(e,t),e.collapse(!1),_e(e,n),t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING&&(t.id=this.endSelectionId,n.id=this.startSelectionId,i=t,t=n,n=i),e.setStartAfter(t),e.setEndBefore(n)}_getRangeAndRemoveBookmark(e){let t=this._root,n=t.querySelectorAll("#"+this.startSelectionId),i=t.querySelectorAll("#"+this.endSelectionId),r=n[0],o=i[0];if(r&&o&&r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING){let s=r.parentNode,a=o.parentNode,c=Array.from(s.childNodes).indexOf(r),u=Array.from(a.childNodes).indexOf(o);s===a&&(u-=1),r.remove(),o.remove(),e||(e=document.createRange()),e.setStart(s,c),e.setEnd(a,u),Qe(s,e),s!==a&&Qe(a,e),e.collapsed&&(s=e.startContainer,s instanceof Text&&(a=s.childNodes[e.startOffset],(!a||!(a instanceof Text))&&(a=s.childNodes[e.startOffset-1]),a&&a instanceof Text&&(e.setStart(a,0),e.collapse(!0))))}for(let s=0;s<n.length;s+=1)n[s].remove();for(let s=0;s<i.length;s+=1)i[s].remove();return e||null}getSelection(){let e=window.getSelection(),t=this._root,n=null;if(this._isFocused&&e&&e.rangeCount){n=e.getRangeAt(0).cloneRange();let i=n.startContainer,r=n.endContainer;i&&we(i)&&n.setStartBefore(i),r&&we(r)&&n.setEndBefore(r)}return n&&t.contains(n.commonAncestorContainer)?this._lastSelection=n:(n=this._lastSelection,document.contains(n.commonAncestorContainer)||(n=null)),n||(n=Be(t.firstElementChild||t,0)),n}setSelection(e){if(this._lastSelection=e,!this._isFocused)this._enableRestoreSelection();else{let t=window.getSelection();t&&("setBaseAndExtent"in Selection.prototype?t.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset):(t.removeAllRanges(),t.addRange(e)))}return this}_moveCursorTo(e){let t=this._root,n=Be(t,e?0:t.childNodes.length);return j(n),this.setSelection(n),this}moveCursorToStart(){return this._moveCursorTo(!0)}moveCursorToEnd(){return this._moveCursorTo(!1)}getCursorPosition(){let e=this.getSelection(),t=e.getBoundingClientRect();if(t&&!t.top){this._ignoreChange=!0;let n=_("SPAN");n.textContent="\u200B",_e(e,n),t=n.getBoundingClientRect();let i=n.parentNode;i.removeChild(n),Qe(i,e)}return t}getPath(){return this._path}_updatePathOnEvent(){this._isFocused&&this._updatePath(this.getSelection())}_updatePath(e,t){let n=e.startContainer,i=e.endContainer,r;(t||n!==this._lastAnchorNode||i!==this._lastFocusNode)&&(this._lastAnchorNode=n,this._lastFocusNode=i,r=n&&i?n===i?this._getPath(i):"(selection)":"",(this._path!==r||n!==i)&&(this._path=r,this.fireEvent("pathChange",{path:r}))),this.fireEvent(e.collapsed?"cursor":"select",{range:e})}_getPath(e){let t=this._root,n=this._config,i="";if(e&&e!==t){let r=e.parentNode;if(i=r?this._getPath(r):"",e instanceof HTMLElement){let o=e.id,s=e.classList,a=Array.from(s).sort(),c=e.dir,u=n.classNames;i+=(i?">":"")+e.nodeName,o&&(i+="#"+o),a.length&&(i+=".",i+=a.join(".")),c&&(i+="[dir="+c+"]"),s.contains(u.highlight)&&(i+="[backgroundColor="+e.style.backgroundColor.replace(/ /g,"")+"]"),s.contains(u.color)&&(i+="[color="+e.style.color.replace(/ /g,"")+"]"),s.contains(u.fontFamily)&&(i+="[fontFamily="+e.style.fontFamily.replace(/ /g,"")+"]"),s.contains(u.fontSize)&&(i+="[fontSize="+e.style.fontSize+"]")}}return i}modifyDocument(e){let t=this._mutation;return t&&(t.takeRecords().length&&this._docWasChanged(),t.disconnect()),this._ignoreAllChanges=!0,e(),this._ignoreAllChanges=!1,t&&(t.observe(this._root,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._ignoreChange=!1),this}_docWasChanged(){if(er(),this._mayHaveZWS=!0,!this._ignoreAllChanges){if(this._ignoreChange){this._ignoreChange=!1;return}this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),this.fireEvent("input")}}_recordUndoState(e,t){let n=this._isInUndoState;if(!n||t){let i=this._undoIndex+1,r=this._undoStack,o=this._config.undo,s=o.documentSizeThreshold,a=o.undoLimit;if(i<this._undoStackLength&&(r.length=this._undoStackLength=i),e&&this._saveRangeToBookmark(e),n)return this;let c=this._getRawHTML();t&&(i-=1),s>-1&&c.length*2>s&&a>-1&&i>a&&(r.splice(0,i-a),i=a,this._undoStackLength=a),r[i]=c,this._undoIndex=i,this._undoStackLength+=1,this._isInUndoState=!0}return this}saveUndoState(e){let t=!1;return e||(e=this.getSelection(),t=!0),this._recordUndoState(e,this._isInUndoState),this._getRangeAndRemoveBookmark(e),t&&this.setSelection(e),this}undo(){if(this._undoIndex!==0||!this._isInUndoState){this._recordUndoState(this.getSelection(),!1),this._undoIndex-=1,this._setRawHTML(this._undoStack[this._undoIndex]);let e=this._getRangeAndRemoveBookmark();e&&this.setSelection(e),this._isInUndoState=!0,this.fireEvent("undoStateChange",{canUndo:this._undoIndex!==0,canRedo:!0}),this.fireEvent("input")}return this.focus()}redo(){let e=this._undoIndex,t=this._undoStackLength;if(e+1<t&&this._isInUndoState){this._undoIndex+=1,this._setRawHTML(this._undoStack[this._undoIndex]);let n=this._getRangeAndRemoveBookmark();n&&this.setSelection(n),this.fireEvent("undoStateChange",{canUndo:!0,canRedo:e+2<t}),this.fireEvent("input")}return this.focus()}getRoot(){return this._root}_getRawHTML(){return this._root.innerHTML}_setRawHTML(e){let t=this._root;t.innerHTML=e;let n=t,i=n.firstChild;if(!i||i.nodeName==="BR"){let r=this.createDefaultBlock();i?n.replaceChild(r,i):n.appendChild(r)}else for(;n=Ee(n,t);)z(n);return this._ignoreChange=!0,this}getHTML(e){let t,n="";return this.modifyDocument(()=>{e&&(t=this.getSelection(),this._saveRangeToBookmark(t));let i=this._root.querySelector(".squire-image-resize-container");i&&i.remove(),n=this._getRawHTML().replace(/\u200B/g,""),i&&this._root.appendChild(i),e&&this._getRangeAndRemoveBookmark(t)}),n}setHTML(e){let t=this._config.sanitizeToDOMFragment(e,this),n=this._root;Ln(t,this._config),Rn(t,n,!1),pe(t,n);let i=t,r=i.firstChild;if(!r||r.nodeName==="BR"){let s=this.createDefaultBlock();r?i.replaceChild(s,r):i.appendChild(s)}else for(;i=Ee(i,n);)z(i);for(this._ignoreChange=!0;r=n.lastChild;)n.removeChild(r);n.appendChild(t),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;let o=this._getRangeAndRemoveBookmark()||Be(n.firstElementChild||n,0);return this.saveUndoState(o),this.setSelection(o),this._updatePath(o,!0),this}insertHTML(e,t){let n=this._config,i=n.sanitizeToDOMFragment(e,this),r=this.getSelection();this.saveUndoState(r);try{let o=this._root;n.addLinks&&this.addDetectedLinks(i,i),Ln(i,this._config),Rn(i,o,!1),wn(i),i.normalize();let s=i;for(;s=Ee(s,i);)z(s);let a=!0;if(t){let c=new CustomEvent("willPaste",{cancelable:!0,detail:{html:e,fragment:i}});this.fireEvent("willPaste",c),i=c.detail.fragment,a=!c.defaultPrevented}a&&(Es(r,i,o),r.collapse(!1),qi(r,"A",o),this._ensureBottomLine()),this.setSelection(r),this._updatePath(r,!0),t&&this.focus()}catch(o){this._config.didError(o)}return this}insertElement(e,t){if(t||(t=this.getSelection()),t.collapse(!0),x(e))_e(t,e),t.setStartAfter(e);else{let n=this._root,i=ie(t,n),r=i||n,o=null;for(;r!==n&&!r.nextSibling;)r=r.parentNode;if(r!==n){let a=r.parentNode;o=se(a,r.nextSibling,n,n)}i&&kn(i)&&H(i),n.insertBefore(e,o);let s=this.createDefaultBlock();n.insertBefore(s,o),t.setStart(s,0),t.setEnd(s,0),j(t)}return this.focus(),this.setSelection(t),this._updatePath(t),this}insertImage(e,t){let n=_("IMG",Object.assign({src:e},t));return this.insertElement(n),n}insertPlainText(e,t){let n=this.getSelection();if(n.collapsed&&L(n.startContainer,this._root,"PRE")){let u=n.startContainer,h=n.startOffset,f;if(!u||!(u instanceof Text)){let y=document.createTextNode("");u.insertBefore(y,u.childNodes[h]),f=y,h=0}else f=u;let g=!0;if(t){let y=new CustomEvent("willPaste",{cancelable:!0,detail:{text:e}});this.fireEvent("willPaste",y),e=y.detail.text,g=!y.defaultPrevented}return g&&(this.saveUndoState(n),f.insertData(h,e),n.setStart(f,h+e.length),n.collapse(!0)),this.setSelection(n),this}let i=e.split(`
16
- `),r=this._config,o=r.blockTag,s=r.blockAttributes,a="</"+o+">",c="<"+o;for(let u in s)c+=" "+u+'="'+Wi(s[u])+'"';c+=">";for(let u=0,h=i.length;u<h;u+=1){let f=i[u];f=Wi(f).replace(/ (?=(?: |$))/g,"&nbsp;"),u&&(f=c+(f||"<BR>")+a),i[u]=f}return this.insertHTML(i.join(""),t)}getSelectedText(e){return sr(e||this.getSelection())}getFontInfo(e){let t={color:void 0,backgroundColor:void 0,fontFamily:void 0,fontSize:void 0};e||(e=this.getSelection()),j(e);let n=0,i=e.commonAncestorContainer;if(e.collapsed||i instanceof Text)for(i instanceof Text&&(i=i.parentNode);n<4&&i;){let r=i.style;if(r){let o=r.color;!t.color&&o&&(t.color=o,n+=1);let s=r.backgroundColor;!t.backgroundColor&&s&&(t.backgroundColor=s,n+=1);let a=r.fontFamily;!t.fontFamily&&a&&(t.fontFamily=a,n+=1);let c=r.fontSize;!t.fontSize&&c&&(t.fontSize=c,n+=1)}i=i.parentNode}return t}hasFormat(e,t,n){e=e.toUpperCase(),t||(t={}),n||(n=this.getSelection()),!n.collapsed&&n.startContainer instanceof Text&&n.startOffset===n.startContainer.length&&n.startContainer.nextSibling&&n.setStartBefore(n.startContainer.nextSibling),!n.collapsed&&n.endContainer instanceof Text&&n.endOffset===0&&n.endContainer.previousSibling&&n.setEndAfter(n.endContainer.previousSibling);let i=this._root,r=n.commonAncestorContainer;if(L(r,i,e,t))return!0;if(r instanceof Text)return!1;let o=new ne(r,4,c=>Ne(n,c,!0)),s=!1,a;for(;a=o.nextNode();){if(!L(a,i,e,t))return!1;s=!0}return s}changeFormat(e,t,n,i){return n||(n=this.getSelection()),this.saveUndoState(n),t&&(n=this._removeFormat(t.tag.toUpperCase(),t.attributes||{},n,i)),e&&(n=this._addFormat(e.tag.toUpperCase(),e.attributes||{},n)),this.setSelection(n),this._updatePath(n,!0),this.focus()}_addFormat(e,t,n){let i=this._root;if(n.collapsed){let r=z(_(e,t));_e(n,r);let o=r.firstChild||r,s=o instanceof Text?o.length:0;n.setStart(o,s),n.collapse(!0);let a=r;for(;x(a);)a=a.parentNode;Mt(a,r)}else{let r=new ne(n.commonAncestorContainer,5,u=>(u instanceof Text||u.nodeName==="BR"||u.nodeName==="IMG")&&Ne(n,u,!0)),{startContainer:o,startOffset:s,endContainer:a,endOffset:c}=n;if(r.currentNode=o,!(o instanceof Element)&&!(o instanceof Text)||!r.filter(o)){let u=r.nextNode();if(!u)return n;o=u,s=0}do{let u=r.currentNode;if(!L(u,i,e,t)){u===a&&u.length>c&&u.splitText(c),u===o&&s&&(u=u.splitText(s),a===o?(a=u,c-=s):a===o.parentNode&&(c+=1),o=u,s=0);let h=_(e,t);V(u,h),h.appendChild(u)}}while(r.nextNode());n=Be(o,s,a,c)}return n}_removeFormat(e,t,n,i){this._saveRangeToBookmark(n);let r;n.collapsed&&(Ut?r=document.createTextNode("\u200B"):r=document.createTextNode(""),_e(n,r));let o=n.commonAncestorContainer;for(;o!==this._root&&x(o);)o=o.parentNode;let s=n.startContainer,a=n.startOffset,c=n.endContainer,u=n.endOffset,h=[],f=(y,S)=>{if(Ne(n,y,!1))return;let N,C;if(!Ne(n,y,!0)){!(y instanceof HTMLInputElement)&&(!(y instanceof Text)||y.data)&&h.push([S,y]);return}if(y instanceof Text)y===c&&u!==y.length&&h.push([S,y.splitText(u)]),y===s&&a&&(y.splitText(a),h.push([S,y]));else for(N=y.firstChild;N;N=C)C=N.nextSibling,f(N,S)},g=Array.from(o.getElementsByTagName(e)).filter(y=>Ne(n,y,!0)&&Nn(y,e,t));if(i||g.forEach(y=>{f(y,y)}),h.forEach(([y,S])=>{y=y.cloneNode(!1),V(S,y),y.appendChild(S)}),g.forEach(y=>{V(y,D(y))}),Ut&&r){r=r.parentNode;let y=r;for(;y&&x(y);)y=y.parentNode;y&&Mt(y,r)}return this._getRangeAndRemoveBookmark(n),r&&n.collapse(!1),Qe(o,n),n}bold(){return this.changeFormat({tag:"B"})}removeBold(){return this.changeFormat(null,{tag:"B"})}italic(){return this.changeFormat({tag:"I"})}removeItalic(){return this.changeFormat(null,{tag:"I"})}underline(){return this.changeFormat({tag:"U"})}removeUnderline(){return this.changeFormat(null,{tag:"U"})}strikethrough(){return this.changeFormat({tag:"S"})}removeStrikethrough(){return this.changeFormat(null,{tag:"S"})}subscript(){return this.changeFormat({tag:"SUB"},{tag:"SUP"})}removeSubscript(){return this.changeFormat(null,{tag:"SUB"})}superscript(){return this.changeFormat({tag:"SUP"},{tag:"SUB"})}removeSuperscript(){return this.changeFormat(null,{tag:"SUP"})}makeLink(e,t){let n=this.getSelection();if(n.collapsed){let i=e.indexOf(":")+1;if(i)for(;e[i]==="/";)i+=1;_e(n,document.createTextNode(e.slice(i)))}return t=Object.assign({href:e},this._config.tagAttributes.a,t),this.changeFormat({tag:"A",attributes:t},{tag:"A"},n)}removeLink(){return this.changeFormat(null,{tag:"A"},this.getSelection(),!0)}addDetectedLinks(e,t){let n=new ne(e,4,s=>!L(s,t||this._root,"A")),i=this.linkRegExp,r=this._config.tagAttributes.a,o;for(;o=n.nextNode();){let s=o.parentNode,a=o.data,c;for(;c=i.exec(a);){let u=c.index,h=u+c[0].length;u&&s.insertBefore(document.createTextNode(a.slice(0,u)),o);let f=_("A",Object.assign({href:c[1]?/^(?:ht|f)tps?:/i.test(c[1])?c[1]:"http://"+c[1]:"mailto:"+c[0]},r));f.textContent=a.slice(u,h),s.insertBefore(f,o),o.data=a=a.slice(h)}}return this}setFontFace(e){let t=this._config.classNames.fontFamily;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"font-family: "+e+", sans-serif;"}}:null,{tag:"SPAN",attributes:{class:t}})}setFontSize(e){let t=this._config.classNames.fontSize;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"font-size: "+(typeof e=="number"?e+"px":e)}}:null,{tag:"SPAN",attributes:{class:t}})}setTextColor(e){let t=this._config.classNames.color;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"color:"+e}}:null,{tag:"SPAN",attributes:{class:t}})}setHighlightColor(e){let t=this._config.classNames.highlight;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"background-color:"+e}}:null,{tag:"SPAN",attributes:{class:t}})}_ensureBottomLine(){let e=this._root,t=e.lastElementChild;(!t||t.nodeName!==this._config.blockTag||!Le(t))&&e.appendChild(this.createDefaultBlock())}createDefaultBlock(e){let t=this._config;return z(_(t.blockTag,t.blockAttributes,e))}splitBlock(e,t){t||(t=this.getSelection());let n=this._root,i,r,o,s;if(this._recordUndoState(t),this._removeZWS(),this._getRangeAndRemoveBookmark(t),t.collapsed||qe(t,n),this._config.addLinks){j(t);let f=t.startContainer,g=t.startOffset;setTimeout(()=>{ur(this,f,g)},0)}if(i=ie(t,n),i&&(r=L(i,n,"PRE"))){j(t),o=t.startContainer;let f=t.startOffset;return o instanceof Text||(o=document.createTextNode(""),r.insertBefore(o,r.firstChild),f=0),!e&&o instanceof Text&&(o.data.charAt(f-1)===`
15
+ `});return l.addEventListener("pointerdown",this),{element:l,cursor:o,position:r}}),n=T("div",{class:"squire-image-resize-container","editor-ui":"",style:"position: absolute; pointer-events: none; z-index: 1000;"},t.map(r=>r.element));this._currentImage=e,this._resizeContainer=n,this._handles=t,this._root.appendChild(this._resizeContainer);let i=e.naturalWidth;this._originalRatio=i/e.naturalHeight,this._maxWidth=Math.min(i*2,e.parentElement?e.parentElement.offsetWidth:Nn,Nn),this._positionResizeContainer(),e.tabIndex=-1,e.focus(),document.addEventListener("keydown",this,!0)}_positionResizeContainer(){let e=this._resizeContainer,t=this._root,n=this._currentImage;if(!e||!n)return;let i=t.getBoundingClientRect(),r=n.getBoundingClientRect(),o=r.top-i.top+t.scrollTop,s=r.left-i.left+t.scrollLeft,a=r.width,l=r.height;e.style.top=o+"px",e.style.left=s+"px",e.style.width=a+"px",e.style.height=l+"px"}_onPointerDown(e){if(this._currentHandle||!this._handles)return;let t=e.target,n=this._handles.find(o=>o.element===t)||null;if(!n)return;let i=this._currentImage;if(!i)return;e.preventDefault(),e.stopPropagation(),t.addEventListener("pointermove",this),t.addEventListener("pointerup",this),t.addEventListener("pointercancel",this),t.setPointerCapture(e.pointerId),this._currentHandle=n,this._startX=e.clientX,this._startY=e.clientY;let r=getComputedStyle(i);this._startWidth=parseFloat(r.width),this._startHeight=parseFloat(r.height),document.body.style.cursor=n.cursor}_onPointerMove(e){e.preventDefault();let t=this._currentHandle,n=this._currentImage;if(!t||!n)return;let i=e.clientX-this._startX,r=e.clientY-this._startY,o=this._maxWidth,s=this._originalRatio,a=this._startWidth,l=this._startHeight;switch(t.position){case"sw":case"nw":case"w":a-=2*i;break;case"se":case"ne":case"e":a+=2*i;break;case"n":l-=r,a=l*s;break;case"s":l+=r,a=l*s;break}a<tr?a=tr:a>o&&(a=o);let u=n.style;u.width=a+"px",u.height="auto",this._positionResizeContainer()}_onPointerUp(e){e.preventDefault();let t=e.target;t&&(t.removeEventListener("pointermove",this),t.removeEventListener("pointerup",this),t.removeEventListener("pointercancel",this)),this._currentHandle=null,document.body.style.cursor=""}_onKeyDown(e){e.preventDefault(),e.stopPropagation();let t=Ys[e.key];if(!t)return;let n=this._currentImage;if(!n)return;let i=this._editor,r=this._root;this._deselectImage();let o=i.getSelection();o.selectNode(n),t(i,o,r)}},Qs=class{constructor(e,t){this.customEvents=new Set(["pathChange","select","input","pasteImage","undoStateChange"]),this.startSelectionId="squire-selection-start",this.endSelectionId="squire-selection-end",this.linkRegExp=/\b(?:((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9][a-z0-9.\-]*[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:[^\s?&`!()\[\]{};:'".,<>«»“”‘’]|\([^\s()<>]+\)))|([\w\-.%+]+@(?:[\w\-]+\.)+[a-z]{2,}\b(?:[?][^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+(?:&[^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+)*)?))/i,this.tagAfterSplit={DT:"DD",DD:"DT",LI:"LI",PRE:"PRE"},this._root=e,this._config=this._makeConfig(t),this._isFocused=!1,this._lastSelection=Be(e,0),this._willRestoreSelection=!1,this._mayHaveZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this._events=new Map,this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,this._ignoreAllChanges=!1,this.addEventListener("selectionchange",this._updatePathOnEvent),this.addEventListener("blur",this._enableRestoreSelection),this.addEventListener("mousedown",this._disableRestoreSelection),this.addEventListener("touchstart",this._disableRestoreSelection),this.addEventListener("focus",this._restoreSelection),this.addEventListener("blur",this._removeZWS),this._isShiftDown=!1,this.addEventListener("cut",Is),this.addEventListener("copy",Ms),this.addEventListener("paste",Ps),this._dragRange=null,this.addEventListener("dragstart",Bs),this.addEventListener("dragend",Fs),this.addEventListener("drop",zs),this.addEventListener("keydown",Ji),this.addEventListener("keyup",Ji),this.addEventListener("keydown",js),this._keyHandlers=Object.create(B);let n=new MutationObserver(i=>this._onMutations(i));n.observe(e,{childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,subtree:!0}),this._mutation=n,e.setAttribute("contenteditable","true"),this.addEventListener("beforeinput",this._beforeInput),this._imageResizer=new Xs(e,this),this.setHTML("")}destroy(){this._events.forEach((e,t)=>{this.removeEventListener(t)}),this._mutation.disconnect(),this._imageResizer.destroy(),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0}_makeConfig(e){let t={blockTag:"DIV",blockAttributes:null,tagAttributes:{},classNames:{color:"color",fontFamily:"font",fontSize:"size",highlight:"highlight"},undo:{documentSizeThreshold:-1,undoLimit:-1},addLinks:!0,willCutCopy:null,toPlainText:null,sanitizeToDOMFragment:n=>{let i=DOMPurify.sanitize(n,{ALLOW_UNKNOWN_PROTOCOLS:!0,WHOLE_DOCUMENT:!1,RETURN_DOM:!0,RETURN_DOM_FRAGMENT:!0,FORCE_BODY:!1});return i?document.importNode(i,!0):document.createDocumentFragment()},didError:n=>console.log(n)};return e&&(Object.assign(t,e),t.blockTag=t.blockTag.toUpperCase()),t}setKeyHandler(e,t){return this._keyHandlers[e]=t,this}_beforeInput(e){switch(e.inputType){case"insertLineBreak":e.preventDefault(),this.splitBlock(!0);break;case"insertParagraph":e.preventDefault(),this.splitBlock(!1);break;case"insertOrderedList":e.preventDefault(),this.makeOrderedList();break;case"insertUnoderedList":e.preventDefault(),this.makeUnorderedList();break;case"historyUndo":e.preventDefault(),this.undo();break;case"historyRedo":e.preventDefault(),this.redo();break;case"formatBold":e.preventDefault(),this.bold();break;case"formatItalic":e.preventDefault(),this.italic();break;case"formatUnderline":e.preventDefault(),this.underline();break;case"formatStrikeThrough":e.preventDefault(),this.strikethrough();break;case"formatSuperscript":e.preventDefault(),this.superscript();break;case"formatSubscript":e.preventDefault(),this.subscript();break;case"formatJustifyFull":case"formatJustifyCenter":case"formatJustifyRight":case"formatJustifyLeft":{e.preventDefault();let t=e.inputType.slice(13).toLowerCase();t==="full"&&(t="justify"),this.setTextAlignment(t);break}case"formatRemove":e.preventDefault(),this.removeAllFormatting();break;case"formatSetBlockTextDirection":{e.preventDefault();let t=e.data;t==="null"&&(t=null),this.setTextDirection(t);break}case"formatBackColor":e.preventDefault(),this.setHighlightColor(e.data);break;case"formatFontColor":e.preventDefault(),this.setTextColor(e.data);break;case"formatFontName":e.preventDefault(),this.setFontFace(e.data);break}}handleEvent(e){this.fireEvent(e.type,e)}fireEvent(e,t){let n=this._events.get(e);if(/^(?:focus|blur)/.test(e)){let i=this._root===document.activeElement;if(e==="focus"){if(!i||this._isFocused)return this;this._isFocused=!0}else{if(i||!this._isFocused)return this;this._isFocused=!1}}if(n){let i=t instanceof Event?t:new CustomEvent(e,{detail:t});n=n.slice();for(let r of n)try{"handleEvent"in r?r.handleEvent(i):r.call(this,i)}catch(o){this._config.didError(o)}}return this}addEventListener(e,t){let n=this._events.get(e),i=this._root;return n||(n=[],this._events.set(e,n),this.customEvents.has(e)||(e==="selectionchange"&&(i=document),i.addEventListener(e,this,!0))),n.push(t),this}removeEventListener(e,t){let n=this._events.get(e),i=this._root;if(n){if(t){let r=n.length;for(;r--;)n[r]===t&&n.splice(r,1)}else n.length=0;n.length||(this._events.delete(e),this.customEvents.has(e)||(e==="selectionchange"&&(i=document),i.removeEventListener(e,this,!0)))}return this}focus(){return this._root.focus({preventScroll:!0}),this}blur(){return this._root.blur(),this}_enableRestoreSelection(){this._willRestoreSelection=!0}_disableRestoreSelection(){this._willRestoreSelection=!1}_restoreSelection(){this._willRestoreSelection&&this.setSelection(this._lastSelection)}_removeZWS(){this._mayHaveZWS&&(Bt(this._root),this._mayHaveZWS=!1)}_saveRangeToBookmark(e){let t=T("INPUT",{id:this.startSelectionId,type:"hidden"}),n=T("INPUT",{id:this.endSelectionId,type:"hidden"}),i;Te(e,t),e.collapse(!1),Te(e,n),t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING&&(t.id=this.endSelectionId,n.id=this.startSelectionId,i=t,t=n,n=i),e.setStartAfter(t),e.setEndBefore(n)}_getRangeAndRemoveBookmark(e){let t=this._root,n=t.querySelectorAll("#"+this.startSelectionId),i=t.querySelectorAll("#"+this.endSelectionId),r=n[0],o=i[0];if(r&&o&&r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING){let s=r.parentNode,a=o.parentNode,l=Array.from(s.childNodes).indexOf(r),u=Array.from(a.childNodes).indexOf(o);s===a&&(u-=1),r.remove(),o.remove(),e||(e=document.createRange()),e.setStart(s,l),e.setEnd(a,u),Qe(s,e),s!==a&&Qe(a,e),e.collapsed&&(s=e.startContainer,s instanceof Text&&(a=s.childNodes[e.startOffset],(!a||!(a instanceof Text))&&(a=s.childNodes[e.startOffset-1]),a&&a instanceof Text&&(e.setStart(a,0),e.collapse(!0))))}for(let s=0;s<n.length;s+=1)n[s].remove();for(let s=0;s<i.length;s+=1)i[s].remove();return e||null}getSelection(){let e=window.getSelection(),t=this._root,n=null;if(this._isFocused&&e&&e.rangeCount){n=e.getRangeAt(0).cloneRange();let i=n.startContainer,r=n.endContainer;i&&Re(i)&&n.setStartBefore(i),r&&Re(r)&&n.setEndBefore(r)}return n&&t.contains(n.commonAncestorContainer)?this._lastSelection=n:(n=this._lastSelection,document.contains(n.commonAncestorContainer)||(n=null)),n||(n=Be(t.firstElementChild||t,0)),n}setSelection(e){if(this._lastSelection=e,!this._isFocused)this._enableRestoreSelection();else{let t=window.getSelection();t&&("setBaseAndExtent"in Selection.prototype?t.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset):(t.removeAllRanges(),t.addRange(e)))}return this}_moveCursorTo(e){let t=this._root,n=Be(t,e?0:t.childNodes.length);return V(n),this.setSelection(n),this}moveCursorToStart(){return this._moveCursorTo(!0)}moveCursorToEnd(){return this._moveCursorTo(!1)}getCursorPosition(){let e=this.getSelection(),t=e.getBoundingClientRect();if(t&&!t.top){this._ignoreChange=!0;let n=T("SPAN");n.textContent="\u200B",Te(e,n),t=n.getBoundingClientRect();let i=n.parentNode;i.removeChild(n),Qe(i,e)}return t}getPath(){return this._path}_updatePathOnEvent(){this._isFocused&&this._updatePath(this.getSelection())}_updatePath(e,t){let n=e.startContainer,i=e.endContainer,r;(t||n!==this._lastAnchorNode||i!==this._lastFocusNode)&&(this._lastAnchorNode=n,this._lastFocusNode=i,r=n&&i?n===i?this._getPath(i):"(selection)":"",(this._path!==r||n!==i)&&(this._path=r,this.fireEvent("pathChange",{path:r}))),this.fireEvent(e.collapsed?"cursor":"select",{range:e})}_getPath(e){let t=this._root,n=this._config,i="";if(e&&e!==t){let r=e.parentNode;if(i=r?this._getPath(r):"",e instanceof HTMLElement){let o=e.id,s=e.classList,a=Array.from(s).sort(),l=e.dir,u=n.classNames;i+=(i?">":"")+e.nodeName,o&&(i+="#"+o),a.length&&(i+=".",i+=a.join(".")),l&&(i+="[dir="+l+"]"),s.contains(u.highlight)&&(i+="[backgroundColor="+e.style.backgroundColor.replace(/ /g,"")+"]"),s.contains(u.color)&&(i+="[color="+e.style.color.replace(/ /g,"")+"]"),s.contains(u.fontFamily)&&(i+="[fontFamily="+e.style.fontFamily.replace(/ /g,"")+"]"),s.contains(u.fontSize)&&(i+="[fontSize="+e.style.fontSize+"]")}}return i}modifyDocument(e){let t=this._mutation;return t&&((()=>{let n=t.takeRecords();n.length&&this._onMutations(n)})(),t.disconnect()),this._ignoreAllChanges=!0,e(),this._ignoreAllChanges=!1,t&&(t.observe(this._root,{childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,subtree:!0}),this._ignoreChange=!1),this}_onMutations(e){let t=this._config.onMutations;return t?t(e,this):this._docWasChanged()}_docWasChanged(){if(sr(),this._mayHaveZWS=!0,!this._ignoreAllChanges){if(this._ignoreChange){this._ignoreChange=!1;return}this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),this.fireEvent("input")}}_recordUndoState(e,t){let n=this._isInUndoState;if(!n||t){let i=this._undoIndex+1,r=this._undoStack,o=this._config.undo,s=o.documentSizeThreshold,a=o.undoLimit;if(i<this._undoStackLength&&(r.length=this._undoStackLength=i),e&&this._saveRangeToBookmark(e),n)return this;let l=this._getRawHTML();t&&(i-=1),s>-1&&l.length*2>s&&a>-1&&i>a&&(r.splice(0,i-a),i=a,this._undoStackLength=a),r[i]=l,this._undoIndex=i,this._undoStackLength+=1,this._isInUndoState=!0}return this}saveUndoState(e){let t=!1;return e||(e=this.getSelection(),t=!0),this._recordUndoState(e,this._isInUndoState),this._getRangeAndRemoveBookmark(e),t&&this.setSelection(e),this}undo(){if(this._undoIndex!==0||!this._isInUndoState){this._recordUndoState(this.getSelection(),!1),this._undoIndex-=1,this._setRawHTML(this._undoStack[this._undoIndex]);let e=this._getRangeAndRemoveBookmark();e&&this.setSelection(e),this._isInUndoState=!0,this.fireEvent("undoStateChange",{canUndo:this._undoIndex!==0,canRedo:!0}),this.fireEvent("input")}return this.focus()}redo(){let e=this._undoIndex,t=this._undoStackLength;if(e+1<t&&this._isInUndoState){this._undoIndex+=1,this._setRawHTML(this._undoStack[this._undoIndex]);let n=this._getRangeAndRemoveBookmark();n&&this.setSelection(n),this.fireEvent("undoStateChange",{canUndo:!0,canRedo:e+2<t}),this.fireEvent("input")}return this.focus()}getRoot(){return this._root}_getRawHTML(){let e=this._config.serializeRoot;return e?e(this._root,this):this._root.innerHTML}_setRawHTML(e){let t=this._root;this._config.replaceRoot?this._config.replaceRoot(t,e,this):t.innerHTML=e;let n=t,i=n.firstChild;if(!i||i.nodeName==="BR"){let r=this.createDefaultBlock();i?n.replaceChild(r,i):n.appendChild(r)}else for(;n=Ee(n,t);)z(n);return this._ignoreChange=!0,this}getHTML(e){if(this._config.serializeRoot)return this._config.serializeRoot(this._root,this,e?this.getSelection():null).replace(/\u200B/g,"");let t,n="";return this.modifyDocument(()=>{e&&(t=this.getSelection(),this._saveRangeToBookmark(t)),n=this._getRawHTML().replace(/\u200B/g,""),e&&this._getRangeAndRemoveBookmark(t)}),n}setHTML(e){let t=this._config.sanitizeToDOMFragment(e,this),n=this._root;Rn(t,this._config),kn(t,n,!1),pe(t,n);let i=t,r=i.firstChild;if(!r||r.nodeName==="BR"){let s=this.createDefaultBlock();r?i.replaceChild(s,r):i.appendChild(s)}else for(;i=Ee(i,n);)z(i);for(this._ignoreChange=!0;r=n.lastChild;)n.removeChild(r);n.appendChild(t),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;let o=this._getRangeAndRemoveBookmark()||Be(n.firstElementChild||n,0);return this.saveUndoState(o),this.setSelection(o),this._updatePath(o,!0),this}insertHTML(e,t){let n=this._config,i=n.sanitizeToDOMFragment(e,this),r=this.getSelection();this.saveUndoState(r);try{let o=this._root;n.addLinks&&this.addDetectedLinks(i,i),Rn(i,this._config),kn(i,o,!1),On(i),i.normalize();let s=i;for(;s=Ee(s,i);)z(s);let a=!0;if(t){let l=new CustomEvent("willPaste",{cancelable:!0,detail:{html:e,fragment:i}});this.fireEvent("willPaste",l),i=l.detail.fragment,a=!l.defaultPrevented}a&&(Ds(r,i,o),r.collapse(!1),Vi(r,"A",o),this._ensureBottomLine()),this.setSelection(r),this._updatePath(r,!0),t&&this.focus()}catch(o){this._config.didError(o)}return this}insertElement(e,t){if(t||(t=this.getSelection()),t.collapse(!0),x(e))Te(t,e),t.setStartAfter(e);else{let n=this._root,i=ie(t,n),r=i||n,o=null;for(;r!==n&&!r.nextSibling;)r=r.parentNode;if(r!==n){let a=r.parentNode;o=se(a,r.nextSibling,n,n)}i&&Dn(i)&&H(i),n.insertBefore(e,o);let s=this.createDefaultBlock();n.insertBefore(s,o),t.setStart(s,0),t.setEnd(s,0),V(t)}return this.focus(),this.setSelection(t),this._updatePath(t),this}insertImage(e,t){let n=T("IMG",Object.assign({src:e},t));return this.insertElement(n),n}insertPlainText(e,t){let n=this.getSelection();if(n.collapsed&&L(n.startContainer,this._root,"PRE")){let u=n.startContainer,d=n.startOffset,f;if(!u||!(u instanceof Text)){let y=document.createTextNode("");u.insertBefore(y,u.childNodes[d]),f=y,d=0}else f=u;let p=!0;if(t){let y=new CustomEvent("willPaste",{cancelable:!0,detail:{text:e}});this.fireEvent("willPaste",y),e=y.detail.text,p=!y.defaultPrevented}return p&&(this.saveUndoState(n),f.insertData(d,e),n.setStart(f,d+e.length),n.collapse(!0)),this.setSelection(n),this}let i=e.split(`
16
+ `),r=this._config,o=r.blockTag,s=r.blockAttributes,a="</"+o+">",l="<"+o;for(let u in s)l+=" "+u+'="'+Xi(s[u])+'"';l+=">";for(let u=0,d=i.length;u<d;u+=1){let f=i[u];f=Xi(f).replace(/ (?=(?: |$))/g,"&nbsp;"),u&&(f=l+(f||"<BR>")+a),i[u]=f}return this.insertHTML(i.join(""),t)}getSelectedText(e){return hr(e||this.getSelection())}getFontInfo(e){let t={color:void 0,backgroundColor:void 0,fontFamily:void 0,fontSize:void 0};e||(e=this.getSelection()),V(e);let n=0,i=e.commonAncestorContainer;if(e.collapsed||i instanceof Text)for(i instanceof Text&&(i=i.parentNode);n<4&&i;){let r=i.style;if(r){let o=r.color;!t.color&&o&&(t.color=o,n+=1);let s=r.backgroundColor;!t.backgroundColor&&s&&(t.backgroundColor=s,n+=1);let a=r.fontFamily;!t.fontFamily&&a&&(t.fontFamily=a,n+=1);let l=r.fontSize;!t.fontSize&&l&&(t.fontSize=l,n+=1)}i=i.parentNode}return t}hasFormat(e,t,n){e=e.toUpperCase(),t||(t={}),n||(n=this.getSelection()),!n.collapsed&&n.startContainer instanceof Text&&n.startOffset===n.startContainer.length&&n.startContainer.nextSibling&&n.setStartBefore(n.startContainer.nextSibling),!n.collapsed&&n.endContainer instanceof Text&&n.endOffset===0&&n.endContainer.previousSibling&&n.setEndAfter(n.endContainer.previousSibling);let i=this._root,r=n.commonAncestorContainer;if(L(r,i,e,t))return!0;if(r instanceof Text)return!1;let o=new ne(r,4,l=>Le(n,l,!0)),s=!1,a;for(;a=o.nextNode();){if(!L(a,i,e,t))return!1;s=!0}return s}changeFormat(e,t,n,i){return n||(n=this.getSelection()),this.saveUndoState(n),t&&(n=this._removeFormat(t.tag.toUpperCase(),t.attributes||{},n,i)),e&&(n=this._addFormat(e.tag.toUpperCase(),e.attributes||{},n)),this.setSelection(n),this._updatePath(n,!0),this.focus()}_addFormat(e,t,n){let i=this._root;if(n.collapsed){let r=z(T(e,t));Te(n,r);let o=r.firstChild||r,s=o instanceof Text?o.length:0;n.setStart(o,s),n.collapse(!0);let a=r;for(;x(a);)a=a.parentNode;Bt(a,r)}else{let r=new ne(n.commonAncestorContainer,5,u=>(u instanceof Text||u.nodeName==="BR"||u.nodeName==="IMG")&&Le(n,u,!0)),{startContainer:o,startOffset:s,endContainer:a,endOffset:l}=n;if(r.currentNode=o,!(o instanceof Element)&&!(o instanceof Text)||!r.filter(o)){let u=r.nextNode();if(!u)return n;o=u,s=0}do{let u=r.currentNode;if(!L(u,i,e,t)){u===a&&u.length>l&&u.splitText(l),u===o&&s&&(u=u.splitText(s),a===o?(a=u,l-=s):a===o.parentNode&&(l+=1),o=u,s=0);let d=T(e,t);j(u,d),d.appendChild(u)}}while(r.nextNode());n=Be(o,s,a,l)}return n}_removeFormat(e,t,n,i){this._saveRangeToBookmark(n);let r;n.collapsed&&(zt?r=document.createTextNode("\u200B"):r=document.createTextNode(""),Te(n,r));let o=n.commonAncestorContainer;for(;o!==this._root&&x(o);)o=o.parentNode;let s=n.startContainer,a=n.startOffset,l=n.endContainer,u=n.endOffset,d=[],f=(y,E)=>{if(Le(n,y,!1))return;let N,C;if(!Le(n,y,!0)){!(y instanceof HTMLInputElement)&&(!(y instanceof Text)||y.data)&&d.push([E,y]);return}if(y instanceof Text)y===l&&u!==y.length&&d.push([E,y.splitText(u)]),y===s&&a&&(y.splitText(a),d.push([E,y]));else for(N=y.firstChild;N;N=C)C=N.nextSibling,f(N,E)},p=Array.from(o.getElementsByTagName(e)).filter(y=>Le(n,y,!0)&&wn(y,e,t));if(i||p.forEach(y=>{f(y,y)}),d.forEach(([y,E])=>{y=y.cloneNode(!1),j(E,y),y.appendChild(E)}),p.forEach(y=>{j(y,D(y))}),zt&&r){r=r.parentNode;let y=r;for(;y&&x(y);)y=y.parentNode;y&&Bt(y,r)}return this._getRangeAndRemoveBookmark(n),r&&n.collapse(!1),Qe(o,n),n}bold(){return this.changeFormat({tag:"B"})}removeBold(){return this.changeFormat(null,{tag:"B"})}italic(){return this.changeFormat({tag:"I"})}removeItalic(){return this.changeFormat(null,{tag:"I"})}underline(){return this.changeFormat({tag:"U"})}removeUnderline(){return this.changeFormat(null,{tag:"U"})}strikethrough(){return this.changeFormat({tag:"S"})}removeStrikethrough(){return this.changeFormat(null,{tag:"S"})}subscript(){return this.changeFormat({tag:"SUB"},{tag:"SUP"})}removeSubscript(){return this.changeFormat(null,{tag:"SUB"})}superscript(){return this.changeFormat({tag:"SUP"},{tag:"SUB"})}removeSuperscript(){return this.changeFormat(null,{tag:"SUP"})}makeLink(e,t){let n=this.getSelection();if(n.collapsed){let i=e.indexOf(":")+1;if(i)for(;e[i]==="/";)i+=1;Te(n,document.createTextNode(e.slice(i)))}return t=Object.assign({href:e},this._config.tagAttributes.a,t),this.changeFormat({tag:"A",attributes:t},{tag:"A"},n)}removeLink(){return this.changeFormat(null,{tag:"A"},this.getSelection(),!0)}addDetectedLinks(e,t){let n=new ne(e,4,s=>!L(s,t||this._root,"A")),i=this.linkRegExp,r=this._config.tagAttributes.a,o;for(;o=n.nextNode();){let s=o.parentNode,a=o.data,l;for(;l=i.exec(a);){let u=l.index,d=u+l[0].length;u&&s.insertBefore(document.createTextNode(a.slice(0,u)),o);let f=T("A",Object.assign({href:l[1]?/^(?:ht|f)tps?:/i.test(l[1])?l[1]:"http://"+l[1]:"mailto:"+l[0]},r));f.textContent=a.slice(u,d),s.insertBefore(f,o),o.data=a=a.slice(d)}}return this}setFontFace(e){let t=this._config.classNames.fontFamily;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"font-family: "+e+", sans-serif;"}}:null,{tag:"SPAN",attributes:{class:t}})}setFontSize(e){let t=this._config.classNames.fontSize;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"font-size: "+(typeof e=="number"?e+"px":e)}}:null,{tag:"SPAN",attributes:{class:t}})}setTextColor(e){let t=this._config.classNames.color;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"color:"+e}}:null,{tag:"SPAN",attributes:{class:t}})}setHighlightColor(e){let t=this._config.classNames.highlight;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"background-color:"+e}}:null,{tag:"SPAN",attributes:{class:t}})}_ensureBottomLine(){let e=this._root,t=e.lastElementChild,n=null;for(;t&&(t.matches("[editor-ui],[clay~=editor-ui]")||t.closest("[editor-ui],[clay~=editor-ui]"));)n=t,t=t.previousElementSibling;(!t||t.nodeName!==this._config.blockTag||!we(t))&&e.insertBefore(this.createDefaultBlock(),n)}createDefaultBlock(e){let t=this._config;return z(T(t.blockTag,t.blockAttributes,e))}splitBlock(e,t){t||(t=this.getSelection());let n=this._root,i,r,o,s;if(this._recordUndoState(t),this._removeZWS(),this._getRangeAndRemoveBookmark(t),t.collapsed||qe(t,n),this._config.addLinks){V(t);let f=t.startContainer,p=t.startOffset;setTimeout(()=>{gr(this,f,p)},0)}if(i=ie(t,n),i&&(r=L(i,n,"PRE"))){V(t),o=t.startContainer;let f=t.startOffset;return o instanceof Text||(o=document.createTextNode(""),r.insertBefore(o,r.firstChild),f=0),!e&&o instanceof Text&&(o.data.charAt(f-1)===`
17
17
  `||pt(t,n))&&(o.data.charAt(f)===`
18
18
  `||mt(t,n))?(o.deleteData(f&&f-1,f?2:1),s=se(o,f&&f-1,n,n),o=s.previousSibling,o.textContent||H(o),o=this.createDefaultBlock(),s.parentNode.insertBefore(o,s),s.textContent||H(s),t.setStart(o,0)):(o.insertData(f,`
19
- `),o.nextSibling||r.appendChild(_("BR")),o.length===f+1?t.setStartAfter(o):t.setStart(o,f+1)),t.collapse(!0),this.setSelection(t),this._updatePath(t,!0),this._docWasChanged(),this}if(!i||e||/^T[HD]$/.test(i.nodeName))return qi(t,"A",n),_e(t,_("BR")),t.collapse(!1),this.setSelection(t),this._updatePath(t,!0),this;if((r=L(i,n,"LI"))&&(i=r),kn(i)){if(L(i,n,"UL")||L(i,n,"OL"))return this.decreaseListLevel(t),this;if(L(i,n,"BLOCKQUOTE"))return this.replaceWithBlankLine(t),this}o=t.startContainer;let a=t.startOffset,c=this.tagAfterSplit[i.nodeName];s=se(o,a,i.parentNode,this._root);let u=this._config,h=null;for(c||(c=u.blockTag,h=u.blockAttributes),Nn(s,c,h)||(i=_(c,h),s.dir&&(i.dir=s.dir),V(s,i),i.appendChild(D(s)),s=i),Mt(i),wn(i),z(i);s instanceof Element;){let f=s.firstChild,g;if(s.nodeName==="A"&&(!s.textContent||s.textContent==="\u200B")){f=document.createTextNode(""),V(s,f),s=f;break}for(;f&&f instanceof Text&&!f.data&&(g=f.nextSibling,!(!g||g.nodeName==="BR"));)H(f),f=g;if(!f||f.nodeName==="BR"||f instanceof Text)break;s=f}return t=Be(s,0),this.setSelection(t),this._updatePath(t,!0),this}forEachBlock(e,t,n){n||(n=this.getSelection()),t&&this.saveUndoState(n);let i=this._root,r=ie(n,i),o=He(n,i);if(r&&o)do if(e(r)||r===o)break;while(r=Ee(r,i));return t&&(this.setSelection(n),this._updatePath(n,!0)),this}modifyBlocks(e,t){t||(t=this.getSelection()),this._recordUndoState(t,this._isInUndoState);let n=this._root;Gi(t,n),Fe(t,n,n,n);let i=or(t,n,n);if(!t.collapsed){let r=t.endContainer;if(r===n)t.collapse(!1);else{for(;r.parentNode!==n;)r=r.parentNode;t.setStartBefore(r),t.collapse(!0)}}return _e(t,e.call(this,i)),t.endOffset<t.endContainer.childNodes.length&&Te(t.endContainer.childNodes[t.endOffset],n),Te(t.startContainer.childNodes[t.startOffset],n),this._getRangeAndRemoveBookmark(t),this.setSelection(t),this._updatePath(t,!0),this}setTextAlignment(e){return this.forEachBlock(t=>{let n=t.className.split(/\s+/).filter(i=>!!i&&!/^align/.test(i)).join(" ");e?(t.className=n+" align-"+e,t.style.textAlign=e):(t.className=n,t.style.textAlign="")},!0),this.focus()}setTextDirection(e){return this.forEachBlock(t=>{e?t.dir=e:t.removeAttribute("dir")},!0),this.focus()}_getListSelection(e,t){let n=e.commonAncestorContainer,i=e.startContainer,r=e.endContainer;for(;n&&n!==t&&!/^[OU]L$/.test(n.nodeName);)n=n.parentNode;if(!n||n===t)return null;for(i===n&&(i=i.childNodes[e.startOffset]),r===n&&(r=r.childNodes[e.endOffset]);i&&i.parentNode!==n;)i=i.parentNode;for(;r&&r.parentNode!==n;)r=r.parentNode;return[n,i,r]}increaseListLevel(e){e||(e=this.getSelection());let t=this._root,n=this._getListSelection(e,t);if(!n)return this.focus();let[i,r,o]=n;if(!r||r===i.firstChild)return this.focus();this._recordUndoState(e,this._isInUndoState);let s=i.nodeName,a=r.previousSibling,c,u;a.nodeName!==s&&(c=this._config.tagAttributes[s.toLowerCase()],a=_(s,c),i.insertBefore(a,r));do u=r===o?null:r.nextSibling,a.appendChild(r);while(r=u);return u=a.nextSibling,u&&Te(u,t),this._getRangeAndRemoveBookmark(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}decreaseListLevel(e){e||(e=this.getSelection());let t=this._root,n=this._getListSelection(e,t);if(!n)return this.focus();let[i,r,o]=n;r||(r=i.firstChild),o||(o=i.lastChild),this._recordUndoState(e,this._isInUndoState);let s,a=null;if(r){let c=i.parentNode;if(a=o.nextSibling?se(i,o.nextSibling,c,t):i.nextSibling,c!==t&&c.nodeName==="LI"){for(c=c.parentNode;a;)s=a.nextSibling,o.appendChild(a),a=s;a=i.parentNode.nextSibling}let u=!/^[OU]L$/.test(c.nodeName);do s=r===o?null:r.nextSibling,i.removeChild(r),u&&r.nodeName==="LI"&&(r=this.createDefaultBlock([D(r)])),c.insertBefore(r,a);while(r=s)}return i.firstChild||H(i),a&&Te(a,t),this._getRangeAndRemoveBookmark(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}_makeList(e,t){let n=Ht(e,this._root),i=this._config.tagAttributes,r=i[t.toLowerCase()],o=i.li,s;for(;s=n.nextNode();)if(s.parentNode instanceof HTMLLIElement&&(s=s.parentNode,n.currentNode=s.lastChild),s instanceof HTMLLIElement){s=s.parentNode;let a=s.nodeName;a!==t&&/^[OU]L$/.test(a)&&V(s,_(t,r,[D(s)]))}else{let a=_("LI",o);s.dir&&(a.dir=s.dir);let c=s.previousSibling;c&&c.nodeName===t?(c.appendChild(a),H(s)):V(s,_(t,r,[a])),a.appendChild(D(s)),n.currentNode=a}return e}makeUnorderedList(){return this.modifyBlocks(e=>this._makeList(e,"UL")),this.focus()}makeOrderedList(){return this.modifyBlocks(e=>this._makeList(e,"OL")),this.focus()}removeList(){return this.modifyBlocks(e=>{let t=e.querySelectorAll("UL, OL"),n=e.querySelectorAll("LI"),i=this._root;for(let r=0,o=t.length;r<o;r+=1){let s=t[r],a=D(s);pe(a,i),V(s,a)}for(let r=0,o=n.length;r<o;r+=1){let s=n[r];Le(s)?V(s,this.createDefaultBlock([D(s)])):(pe(s,i),V(s,D(s)))}return e}),this.focus()}increaseQuoteLevel(e){return this.modifyBlocks(t=>_("BLOCKQUOTE",this._config.tagAttributes.blockquote,[t]),e),this.focus()}decreaseQuoteLevel(e){return this.modifyBlocks(t=>(Array.from(t.querySelectorAll("blockquote")).filter(n=>!L(n.parentNode,t,"BLOCKQUOTE")).forEach(n=>{V(n,D(n))}),t),e),this.focus()}removeQuote(e){return this.modifyBlocks(t=>(Array.from(t.querySelectorAll("blockquote")).forEach(n=>{V(n,D(n))}),t),e),this.focus()}replaceWithBlankLine(e){return this.modifyBlocks(()=>this.createDefaultBlock([_("INPUT",{id:this.startSelectionId,type:"hidden"}),_("INPUT",{id:this.endSelectionId,type:"hidden"})]),e),this.focus()}code(){let e=this.getSelection();return e.collapsed||Ze(e.commonAncestorContainer)?(this.modifyBlocks(t=>{let n=this._root,i=document.createDocumentFragment(),r=Ht(t,n),o;for(;o=r.nextNode();){let a=o.querySelectorAll("BR"),c=[],u=a.length;for(let h=0;h<u;h+=1)c[h]=zt(a[h],!1);for(;u--;){let h=a[u];c[u]?V(h,document.createTextNode(`
20
- `)):H(h)}for(a=o.querySelectorAll("CODE"),u=a.length;u--;)V(a[u],D(a[u]));i.childNodes.length&&i.appendChild(document.createTextNode(`
21
- `)),i.appendChild(D(o))}let s=new ne(i,4);for(;o=s.nextNode();)o.data=o.data.replace(/ /g," ");return i.normalize(),z(_("PRE",this._config.tagAttributes.pre,[i]))},e),this.focus()):this.changeFormat({tag:"CODE",attributes:this._config.tagAttributes.code},null,e),this}removeCode(){let e=this.getSelection(),t=e.commonAncestorContainer;return L(t,this._root,"PRE")?(this.modifyBlocks(n=>{let i=this._root,r=n.querySelectorAll("PRE"),o=r.length;for(;o--;){let s=r[o],a=new ne(s,4),c;for(;c=a.nextNode();){let u=c.data;u=u.replace(/ (?= )/g,"\xA0");let h=document.createDocumentFragment(),f;for(;(f=u.indexOf(`
22
- `))>-1;)h.appendChild(document.createTextNode(u.slice(0,f))),h.appendChild(_("BR")),u=u.slice(f+1);c.parentNode.insertBefore(h,c),c.data=u}pe(s,i),V(s,D(s))}return n},e),this.focus()):this.changeFormat(null,{tag:"CODE"},e),this}toggleCode(){return this.hasFormat("PRE")||this.hasFormat("CODE")?this.removeCode():this.code(),this}_removeFormatting(e,t){for(let n=e.firstChild,i;n;n=i){if(i=n.nextSibling,x(n)){if(n instanceof Text||n.nodeName==="BR"||n.nodeName==="IMG"){t.appendChild(n);continue}}else if(Le(n)){t.appendChild(this.createDefaultBlock([this._removeFormatting(n,document.createDocumentFragment())]));continue}this._removeFormatting(n,t)}return t}removeAllFormatting(e){if(e||(e=this.getSelection()),e.collapsed)return this.focus();let t=this._root,n=e.commonAncestorContainer;for(;n&&n!==t&&!Le(n);)n=n.parentNode;if(n||(Gi(e,t),n=t),n instanceof Text)return this.focus();this.saveUndoState(e),Fe(e,n,n,t);let i=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,a=document.createDocumentFragment(),c=document.createDocumentFragment(),u=se(o,s,n,t),h=se(i,r,n,t),f;for(;h!==u;)f=h.nextSibling,a.appendChild(h),h=f;if(this._removeFormatting(a,c),c.normalize(),h=c.firstChild,f=c.lastChild,h){n.insertBefore(c,u);let g=Array.from(n.childNodes);r=g.indexOf(h),s=f?g.indexOf(f)+1:0}else u&&(r=Array.from(n.childNodes).indexOf(u),s=r);return e.setStart(n,r),e.setEnd(n,s),Qe(n,e),j(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}},dr=Us;function hr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function Hs(e){if(Array.isArray(e))return e}function zs(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,s,a=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(h){u=!0,r=h}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw r}}return a}}function qs(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
23
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $s(e,t){return Hs(e)||zs(e,t)||Ws(e,t)||qs()}function Ws(e,t){if(e){if(typeof e=="string")return hr(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?hr(e,t):void 0}}var xr=Object.entries,fr=Object.setPrototypeOf,Gs=Object.isFrozen,Ks=Object.getPrototypeOf,Vs=Object.getOwnPropertyDescriptor,G=Object.freeze,K=Object.seal,tt=Object.create,Nr=typeof Reflect<"u"&&Reflect,Hn=Nr.apply,zn=Nr.construct;G||(G=function(t){return t});K||(K=function(t){return t});Hn||(Hn=function(t,n){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return t.apply(n,r)});zn||(zn=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return new t(...i)});var gt=F(Array.prototype.forEach),js=F(Array.prototype.lastIndexOf),pr=F(Array.prototype.pop),et=F(Array.prototype.push),Ys=F(Array.prototype.splice),ke=Array.isArray,_t=F(String.prototype.toLowerCase),Mn=F(String.prototype.toString),mr=F(String.prototype.match),yt=F(String.prototype.replace),gr=F(String.prototype.indexOf),Xs=F(String.prototype.trim),Qs=F(Number.prototype.toString),Zs=F(Boolean.prototype.toString),yr=typeof BigInt>"u"?null:F(BigInt.prototype.toString),br=typeof Symbol>"u"?null:F(Symbol.prototype.toString),q=F(Object.prototype.hasOwnProperty),bt=F(Object.prototype.toString),W=F(RegExp.prototype.test),$e=Js(TypeError);function F(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return Hn(e,t,i)}}function Js(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return zn(e,n)}}function A(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_t;if(fr&&fr(e,null),!ke(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){let o=n(r);o!==r&&(Gs(t)||(t[i]=o),r=o)}e[r]=!0}return e}function ea(e){for(let t=0;t<e.length;t++)q(e,t)||(e[t]=null);return e}function ee(e){let t=tt(null);for(let i of xr(e)){var n=$s(i,2);let r=n[0],o=n[1];q(e,r)&&(ke(o)?t[r]=ea(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=ee(o):t[r]=o)}return t}function ta(e){switch(typeof e){case"string":return e;case"number":return Qs(e);case"boolean":return Zs(e);case"bigint":return yr?yr(e):"0";case"symbol":return br?br(e):"Symbol()";case"undefined":return bt(e);case"function":case"object":{if(e===null)return bt(e);let t=e,n=ge(t,"toString");if(typeof n=="function"){let i=n(t);return typeof i=="string"?i:bt(i)}return bt(e)}default:return bt(e)}}function ge(e,t){for(;e!==null;){let i=Vs(e,t);if(i){if(i.get)return F(i.get);if(typeof i.value=="function")return F(i.value)}e=Ks(e)}function n(){return null}return n}function na(e){try{return W(e,""),!0}catch{return!1}}var _r=G(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Pn=G(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Bn=G(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ia=G(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Fn=G(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ra=G(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Tr=G(["#text"]),Er=G(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Un=G(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Sr=G(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),qt=G(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),oa=K(/{{[\w\W]*|^[\w\W]*}}/g),sa=K(/<%[\w\W]*|^[\w\W]*%>/g),aa=K(/\${[\w\W]*/g),la=K(/^data-[\-\w.\u00B7-\uFFFF]+$/),ca=K(/^aria-[\-\w]+$/),Ar=K(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ua=K(/^(?:\w+script|data):/i),da=K(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ha=K(/^html$/i),fa=K(/^[a-z][.\w]*(-[.\w]+)+$/i),vr=K(/<[/\w!]/g),pa=K(/<[/\w]/g),ma=K(/<\/no(script|embed|frames)/i),ga=K(/\/>/i),me={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},ya=function(){return typeof window>"u"?null:window},ba=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(i=n.getAttribute(r));let o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Cr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Re=function(t,n,i,r){return q(t,n)&&ke(t[n])?A(r.base?ee(r.base):{},t[n],r.transform):i};function Lr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ya(),t=m=>Lr(m);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==me.document||!e.Element)return t.isSupported=!1,t;let n=e.document,i=n,r=i.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,s=e.Node,a=e.Element,c=e.NodeFilter,u=e.NamedNodeMap;u===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let h=e.DOMParser,f=e.trustedTypes,g=a.prototype,y=ge(g,"cloneNode"),S=ge(g,"remove"),N=ge(g,"nextSibling"),C=ge(g,"childNodes"),M=ge(g,"parentNode"),$=ge(g,"shadowRoot"),le=ge(g,"attributes"),Q=s&&s.prototype?ge(s.prototype,"nodeType"):null,Ae=s&&s.prototype?ge(s.prototype,"nodeName"):null;if(typeof o=="function"){let m=n.createElement("template");m.content&&m.content.ownerDocument&&(n=m.content.ownerDocument)}let te,Ie="",nn,fi=!1,at=0,pi=function(){if(at>0)throw $e('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ge=function(l){pi(),at++;try{return te.createHTML(l)}finally{at--}},vo=function(l){pi(),at++;try{return te.createScriptURL(l)}finally{at--}},Co=function(){return fi||(nn=ba(f,r),fi=!0),nn},Nt=n,rn=Nt.implementation,mi=Nt.createNodeIterator,xo=Nt.createDocumentFragment,No=Nt.getElementsByTagName,Lo=i.importNode,I=Cr();t.isSupported=typeof xr=="function"&&typeof M=="function"&&rn&&rn.createHTMLDocument!==void 0;let wo=oa,Ro=sa,ko=aa,Oo=la,Do=ca,Io=ua,gi=da,Mo=fa,yi=Ar,w=null,bi=A({},[..._r,...Pn,...Bn,...Fn,...Tr]),R=null,_i=A({},[...Er,...Un,...Sr,...qt]),k=Object.seal(tt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),lt=null,Ti=null,ve=Object.seal(tt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ei=!0,on=!0,Si=!1,Ai=!0,Ce=!1,ct=!0,Me=!1,sn=!1,an=null,ln=null,cn=!1,Ke=!1,Lt=!1,wt=!1,vi=!0,Ci=!1,xi="user-content-",un=!0,dn=!1,Ve={},de=null,hn=A({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Ni=null,Li=A({},["audio","video","img","source","image","track"]),fn=null,wi=A({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rt="http://www.w3.org/1998/Math/MathML",kt="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml",je=he,pn=!1,mn=null,Po=A({},[Rt,kt,he],Mn),Ri=G(["mi","mo","mn","ms","mtext"]),gn=A({},Ri),ki=G(["annotation-xml"]),yn=A({},ki),Bo=A({},["title","style","font","a","script"]),ut=null,Fo=["application/xhtml+xml","text/html"],Uo="text/html",O=null,Ye=null,Ho=n.createElement("form"),Oi=function(l){return l instanceof RegExp||l instanceof Function},bn=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ye&&Ye===l)return;(!l||typeof l!="object")&&(l={}),l=ee(l),ut=Fo.indexOf(l.PARSER_MEDIA_TYPE)===-1?Uo:l.PARSER_MEDIA_TYPE,O=ut==="application/xhtml+xml"?Mn:_t,w=Re(l,"ALLOWED_TAGS",bi,{transform:O}),R=Re(l,"ALLOWED_ATTR",_i,{transform:O}),mn=Re(l,"ALLOWED_NAMESPACES",Po,{transform:Mn}),fn=Re(l,"ADD_URI_SAFE_ATTR",wi,{transform:O,base:wi}),Ni=Re(l,"ADD_DATA_URI_TAGS",Li,{transform:O,base:Li}),de=Re(l,"FORBID_CONTENTS",hn,{transform:O}),lt=Re(l,"FORBID_TAGS",ee({}),{transform:O}),Ti=Re(l,"FORBID_ATTR",ee({}),{transform:O}),Ve=q(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?ee(l.USE_PROFILES):l.USE_PROFILES:!1,Ei=l.ALLOW_ARIA_ATTR!==!1,on=l.ALLOW_DATA_ATTR!==!1,Si=l.ALLOW_UNKNOWN_PROTOCOLS||!1,Ai=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ce=l.SAFE_FOR_TEMPLATES||!1,ct=l.SAFE_FOR_XML!==!1,Me=l.WHOLE_DOCUMENT||!1,Ke=l.RETURN_DOM||!1,Lt=l.RETURN_DOM_FRAGMENT||!1,wt=l.RETURN_TRUSTED_TYPE||!1,cn=l.FORCE_BODY||!1,vi=l.SANITIZE_DOM!==!1,Ci=l.SANITIZE_NAMED_PROPS||!1,un=l.KEEP_CONTENT!==!1,dn=l.IN_PLACE||!1,yi=na(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:Ar,je=typeof l.NAMESPACE=="string"?l.NAMESPACE:he,gn=q(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?ee(l.MATHML_TEXT_INTEGRATION_POINTS):A({},Ri),yn=q(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?ee(l.HTML_INTEGRATION_POINTS):A({},ki);let d=q(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?ee(l.CUSTOM_ELEMENT_HANDLING):tt(null);if(k=tt(null),q(d,"tagNameCheck")&&Oi(d.tagNameCheck)&&(k.tagNameCheck=d.tagNameCheck),q(d,"attributeNameCheck")&&Oi(d.attributeNameCheck)&&(k.attributeNameCheck=d.attributeNameCheck),q(d,"allowCustomizedBuiltInElements")&&typeof d.allowCustomizedBuiltInElements=="boolean"&&(k.allowCustomizedBuiltInElements=d.allowCustomizedBuiltInElements),K(k),Ce&&(on=!1),Lt&&(Ke=!0),Ve&&(w=A({},Tr),R=tt(null),Ve.html===!0&&(A(w,_r),A(R,Er)),Ve.svg===!0&&(A(w,Pn),A(R,Un),A(R,qt)),Ve.svgFilters===!0&&(A(w,Bn),A(R,Un),A(R,qt)),Ve.mathMl===!0&&(A(w,Fn),A(R,Sr),A(R,qt))),ve.tagCheck=null,ve.attributeCheck=null,q(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?ve.tagCheck=l.ADD_TAGS:ke(l.ADD_TAGS)&&(w===bi&&(w=ee(w)),A(w,l.ADD_TAGS,O))),q(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?ve.attributeCheck=l.ADD_ATTR:ke(l.ADD_ATTR)&&(R===_i&&(R=ee(R)),A(R,l.ADD_ATTR,O))),q(l,"ADD_URI_SAFE_ATTR")&&ke(l.ADD_URI_SAFE_ATTR)&&A(fn,l.ADD_URI_SAFE_ATTR,O),q(l,"FORBID_CONTENTS")&&ke(l.FORBID_CONTENTS)&&(de===hn&&(de=ee(de)),A(de,l.FORBID_CONTENTS,O)),q(l,"ADD_FORBID_CONTENTS")&&ke(l.ADD_FORBID_CONTENTS)&&(de===hn&&(de=ee(de)),A(de,l.ADD_FORBID_CONTENTS,O)),un&&(w["#text"]=!0),Me&&A(w,["html","head","body"]),w.table&&(A(w,["tbody"]),delete lt.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw $e('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw $e('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let p=te;te=l.TRUSTED_TYPES_POLICY;try{Ie=Ge("")}catch(b){throw te=p,b}}else l.TRUSTED_TYPES_POLICY===null?(te=void 0,Ie=""):(te===void 0&&(te=Co()),te&&typeof Ie=="string"&&(Ie=Ge("")));G&&G(l),Ye=l},Di=A({},[...Pn,...Bn,...ia]),Ii=A({},[...Fn,...ra]),zo=function(l,d,p){return d.namespaceURI===he?l==="svg":d.namespaceURI===Rt?l==="svg"&&(p==="annotation-xml"||gn[p]):!!Di[l]},qo=function(l,d,p){return d.namespaceURI===he?l==="math":d.namespaceURI===kt?l==="math"&&yn[p]:!!Ii[l]},$o=function(l,d,p){return d.namespaceURI===kt&&!yn[p]||d.namespaceURI===Rt&&!gn[p]?!1:!Ii[l]&&(Bo[l]||!Di[l])},Wo=function(l){let d=M(l);(!d||!d.tagName)&&(d={namespaceURI:je,tagName:"template"});let p=_t(l.tagName),b=_t(d.tagName);return mn[l.namespaceURI]?l.namespaceURI===kt?zo(p,d,b):l.namespaceURI===Rt?qo(p,d,b):l.namespaceURI===he?$o(p,d,b):!!(ut==="application/xhtml+xml"&&mn[l.namespaceURI]):!1},xe=function(l){et(t.removed,{element:l});try{M(l).removeChild(l)}catch{if(S(l),!M(l))throw $e("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Mi=function(l){let d=C(l);if(d){let b=[];gt(d,E=>{et(b,E)}),gt(b,E=>{try{S(E)}catch{}})}let p=le(l);if(p)for(let b=p.length-1;b>=0;--b){let E=p[b],v=E&&E.name;if(typeof v=="string")try{l.removeAttribute(v)}catch{}}},Pe=function(l,d){try{et(t.removed,{attribute:d.getAttributeNode(l),from:d})}catch{et(t.removed,{attribute:null,from:d})}if(d.removeAttribute(l),l==="is")if(Ke||Lt)try{xe(d)}catch{}else try{d.setAttribute(l,"")}catch{}},Go=function(l){let d=le(l);if(d)for(let p=d.length-1;p>=0;--p){let b=d[p],E=b&&b.name;if(!(typeof E!="string"||R[O(E)]))try{l.removeAttribute(E)}catch{}}},Ko=function(l){let d=[l];for(;d.length>0;){let p=d.pop();(Q?Q(p):p.nodeType)===me.element&&Go(p);let E=C(p);if(E)for(let v=E.length-1;v>=0;--v)d.push(E[v])}},Pi=function(l){let d=null,p=null;if(cn)l="<remove></remove>"+l;else{let v=mr(l,/^[\r\n\t ]+/);p=v&&v[0]}ut==="application/xhtml+xml"&&je===he&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");let b=te?Ge(l):l;if(je===he)try{d=new h().parseFromString(b,ut)}catch{}if(!d||!d.documentElement){d=rn.createDocument(je,"template",null);try{d.documentElement.innerHTML=pn?Ie:b}catch{}}let E=d.body||d.documentElement;return l&&p&&E.insertBefore(n.createTextNode(p),E.childNodes[0]||null),je===he?No.call(d,Me?"html":"body")[0]:Me?d.documentElement:E},Bi=function(l){return mi.call(l.ownerDocument||l,l,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ot=function(l){return l=yt(l,wo," "),l=yt(l,Ro," "),l=yt(l,ko," "),l},_n=function(l){var d;l.normalize();let p=mi.call(l.ownerDocument||l,l,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),b=p.nextNode();for(;b;)b.data=Ot(b.data),b=p.nextNode();let E=(d=l.querySelectorAll)===null||d===void 0?void 0:d.call(l,"template");E&&gt(E,v=>{Xe(v.content)&&_n(v.content)})},Dt=function(l){let d=Ae?Ae(l):null;return typeof d!="string"||O(d)!=="form"?!1:typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||l.attributes!==le(l)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function"||l.nodeType!==Q(l)||l.childNodes!==C(l)},Xe=function(l){if(!Q||typeof l!="object"||l===null)return!1;try{return Q(l)===me.documentFragment}catch{return!1}},dt=function(l){if(!Q||typeof l!="object"||l===null)return!1;try{return typeof Q(l)=="number"}catch{return!1}};function be(m,l,d){m.length!==0&&gt(m,p=>{p.call(t,l,d,Ye)})}let Vo=function(l,d){return!!(ct&&l.hasChildNodes()&&!dt(l.firstElementChild)&&W(vr,l.textContent)&&W(vr,l.innerHTML)||ct&&l.namespaceURI===he&&d==="style"&&dt(l.firstElementChild)||l.nodeType===me.processingInstruction||ct&&l.nodeType===me.comment&&W(pa,l.data))},jo=function(l,d){if(!lt[d]&&Hi(d)&&(k.tagNameCheck instanceof RegExp&&W(k.tagNameCheck,d)||k.tagNameCheck instanceof Function&&k.tagNameCheck(d)))return!1;if(un&&!de[d]){let p=M(l),b=C(l);if(b&&p){let E=b.length;for(let v=E-1;v>=0;--v){let U=dn?b[v]:y(b[v],!0);p.insertBefore(U,N(l))}}}return xe(l),!0},Fi=function(l){if(be(I.beforeSanitizeElements,l,null),Dt(l))return xe(l),!0;let d=O(Ae?Ae(l):l.nodeName);if(be(I.uponSanitizeElement,l,{tagName:d,allowedTags:w}),Vo(l,d))return xe(l),!0;if(lt[d]||!(ve.tagCheck instanceof Function&&ve.tagCheck(d))&&!w[d])return jo(l,d);if((Q?Q(l):l.nodeType)===me.element&&!Wo(l)||(d==="noscript"||d==="noembed"||d==="noframes")&&W(ma,l.innerHTML))return xe(l),!0;if(Ce&&l.nodeType===me.text){let b=Ot(l.textContent);l.textContent!==b&&(et(t.removed,{element:l.cloneNode()}),l.textContent=b)}return be(I.afterSanitizeElements,l,null),!1},Ui=function(l,d,p){if(Ti[d]||vi&&(d==="id"||d==="name")&&(p in n||p in Ho))return!1;let b=R[d]||ve.attributeCheck instanceof Function&&ve.attributeCheck(d,l);if(!(on&&W(Oo,d))){if(!(Ei&&W(Do,d))){if(b){if(!fn[d]){if(!W(yi,yt(p,gi,""))){if(!((d==="src"||d==="xlink:href"||d==="href")&&l!=="script"&&gr(p,"data:")===0&&Ni[l])){if(!(Si&&!W(Io,yt(p,gi,"")))){if(p)return!1}}}}}else if(!(Hi(l)&&(k.tagNameCheck instanceof RegExp&&W(k.tagNameCheck,l)||k.tagNameCheck instanceof Function&&k.tagNameCheck(l))&&(k.attributeNameCheck instanceof RegExp&&W(k.attributeNameCheck,d)||k.attributeNameCheck instanceof Function&&k.attributeNameCheck(d,l))||d==="is"&&k.allowCustomizedBuiltInElements&&(k.tagNameCheck instanceof RegExp&&W(k.tagNameCheck,p)||k.tagNameCheck instanceof Function&&k.tagNameCheck(p))))return!1}}return!0},Yo=A({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Hi=function(l){return!Yo[_t(l)]&&W(Mo,l)},Xo=function(l,d,p,b){if(te&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!p)switch(f.getAttributeType(l,d)){case"TrustedHTML":return Ge(b);case"TrustedScriptURL":return vo(b)}return b},Qo=function(l,d,p,b){try{p?l.setAttributeNS(p,d,b):l.setAttribute(d,b),Dt(l)?xe(l):pr(t.removed)}catch{Pe(d,l)}},zi=function(l){be(I.beforeSanitizeAttributes,l,null);let d=l.attributes;if(!d||Dt(l))return;let p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},b=d.length,E=O(l.nodeName);for(;b--;){let v=d[b],U=v.name,P=v.namespaceURI,oe=v.value,ce=O(U),En=oe,Z=U==="value"?En:Xs(En);if(p.attrName=ce,p.attrValue=Z,p.keepAttr=!0,p.forceKeepAttr=void 0,be(I.uponSanitizeAttribute,l,p),Z=p.attrValue,Ci&&(ce==="id"||ce==="name")&&gr(Z,xi)!==0&&(Pe(U,l),Z=xi+Z),ct&&W(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Z)){Pe(U,l);continue}if(ce==="attributename"&&mr(Z,"href")){Pe(U,l);continue}if(!p.forceKeepAttr){if(!p.keepAttr){Pe(U,l);continue}if(!Ai&&W(ga,Z)){Pe(U,l);continue}if(Ce&&(Z=Ot(Z)),!Ui(E,ce,Z)){Pe(U,l);continue}Z=Xo(E,ce,P,Z),Z!==En&&Qo(l,U,P,Z)}}be(I.afterSanitizeAttributes,l,null)},It=function(l){let d=null,p=Bi(l);for(be(I.beforeSanitizeShadowDOM,l,null);d=p.nextNode();)if(be(I.uponSanitizeShadowNode,d,null),Fi(d),zi(d),Xe(d.content)&&It(d.content),(Q?Q(d):d.nodeType)===me.element){let E=$(d);Xe(E)&&(Tn(E),It(E))}be(I.afterSanitizeShadowDOM,l,null)},Tn=function(l){let d=[{node:l,shadow:null}];for(;d.length>0;){let p=d.pop();if(p.shadow){It(p.shadow);continue}let b=p.node,v=(Q?Q(b):b.nodeType)===me.element,U=C(b);if(U)for(let P=U.length-1;P>=0;--P)d.push({node:U[P],shadow:null});if(v){let P=Ae?Ae(b):null;if(typeof P=="string"&&O(P)==="template"){let oe=b.content;Xe(oe)&&d.push({node:oe,shadow:null})}}if(v){let P=$(b);Xe(P)&&d.push({node:null,shadow:P},{node:P,shadow:null})}}};return t.sanitize=function(m){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=null,p=null,b=null,E=null;if(pn=!m,pn&&(m="<!-->"),typeof m!="string"&&!dt(m)&&(m=ta(m),typeof m!="string"))throw $e("dirty is not a string, aborting");if(!t.isSupported)return m;sn?(w=an,R=ln):bn(l),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(w=ee(w)),I.uponSanitizeAttribute.length>0&&(R=ee(R)),t.removed=[];let v=dn&&typeof m!="string"&&dt(m);if(v){let oe=Ae?Ae(m):m.nodeName;if(typeof oe=="string"){let ce=O(oe);if(!w[ce]||lt[ce])throw $e("root node is forbidden and cannot be sanitized in-place")}if(Dt(m))throw $e("root node is clobbered and cannot be sanitized in-place");try{Tn(m)}catch(ce){throw Mi(m),ce}}else if(dt(m))d=Pi("<!---->"),p=d.ownerDocument.importNode(m,!0),p.nodeType===me.element&&p.nodeName==="BODY"||p.nodeName==="HTML"?d=p:d.appendChild(p),Tn(p);else{if(!Ke&&!Ce&&!Me&&m.indexOf("<")===-1)return te&&wt?Ge(m):m;if(d=Pi(m),!d)return Ke?null:wt?Ie:""}d&&cn&&xe(d.firstChild);let U=Bi(v?m:d);try{for(;b=U.nextNode();)Fi(b),zi(b),Xe(b.content)&&It(b.content)}catch(oe){throw v&&Mi(m),oe}if(v)return gt(t.removed,oe=>{oe.element&&Ko(oe.element)}),Ce&&_n(m),m;if(Ke){if(Ce&&_n(d),Lt)for(E=xo.call(d.ownerDocument);d.firstChild;)E.appendChild(d.firstChild);else E=d;return(R.shadowroot||R.shadowrootmode)&&(E=Lo.call(i,E,!0)),E}let P=Me?d.outerHTML:d.innerHTML;return Me&&w["!doctype"]&&d.ownerDocument&&d.ownerDocument.doctype&&d.ownerDocument.doctype.name&&W(ha,d.ownerDocument.doctype.name)&&(P="<!DOCTYPE "+d.ownerDocument.doctype.name+`>
24
- `+P),Ce&&(P=Ot(P)),te&&wt?Ge(P):P},t.setConfig=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};bn(m),sn=!0,an=w,ln=R},t.clearConfig=function(){Ye=null,sn=!1,an=null,ln=null,te=nn,Ie=""},t.isValidAttribute=function(m,l,d){Ye||bn({});let p=O(m),b=O(l);return Ui(p,b,d)},t.addHook=function(m,l){typeof l=="function"&&q(I,m)&&et(I[m],l)},t.removeHook=function(m,l){if(q(I,m)){if(l!==void 0){let d=js(I[m],l);return d===-1?void 0:Ys(I[m],d,1)[0]}return pr(I[m])}},t.removeHooks=function(m){q(I,m)&&(I[m]=[])},t.removeAllHooks=function(){I=Cr()},t}var wr=Lr();var T='stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"',qn='stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"',Tt='fill="currentColor"',Y=(e,t="0 0 18 18")=>`<svg viewBox="${t}" width="18" height="18" aria-hidden="true" focusable="false">${e}</svg>`,Rr=`<line ${T} x1="7" x2="11" y1="7" y2="11"/><path ${T} d="M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z"/><path ${T} d="M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z"/>`,X={bold:Y(`<path ${T} d="M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z"/><path ${T} d="M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z"/>`),italic:Y(`<line ${T} x1="7" x2="13" y1="4" y2="4"/><line ${T} x1="5" x2="11" y1="14" y2="14"/><line ${T} x1="8" x2="10" y1="14" y2="4"/>`),underline:Y(`<path ${T} d="M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3"/><rect ${Tt} height="1" rx="0.5" ry="0.5" width="12" x="3" y="15"/>`),strike:Y(`<path ${Tt} d="M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z"/><path ${Tt} d="M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z"/><line x1="2" y1="9" x2="16" y2="9" stroke="currentColor" fill="none" stroke-linecap="round" stroke-width="1.5"/>`),link:Y(Rr),unlink:Y(`${Rr}<line class="richclay-cut" x1="2.5" y1="15.5" x2="15.5" y2="2.5" stroke-linecap="round" stroke-width="3.5"/><line x1="4.06" y1="13.94" x2="13.94" y2="4.06" stroke="currentColor" fill="none" stroke-linecap="round" stroke-width="1.5"/>`),ul:Y(`<line ${T} x1="6" x2="15" y1="4" y2="4"/><line ${T} x1="6" x2="15" y1="9" y2="9"/><line ${T} x1="6" x2="15" y1="14" y2="14"/><line ${T} x1="3" x2="3" y1="4" y2="4"/><line ${T} x1="3" x2="3" y1="9" y2="9"/><line ${T} x1="3" x2="3" y1="14" y2="14"/>`),ol:Y(`<line ${T} x1="7" x2="15" y1="4" y2="4"/><line ${T} x1="7" x2="15" y1="9" y2="9"/><line ${T} x1="7" x2="15" y1="14" y2="14"/><line ${qn} x1="2.5" x2="4.5" y1="5.5" y2="5.5"/><path ${Tt} d="M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z"/><path ${qn} d="M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156"/><path ${qn} d="M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109"/>`),quote:Y(`<path ${T} d="M10 10.8182L9 10.8182C8.80222 10.8182 8.60888 10.7649 8.44443 10.665C8.27998 10.5651 8.15181 10.4231 8.07612 10.257C8.00043 10.0909 7.98063 9.90808 8.01922 9.73174C8.0578 9.55539 8.15304 9.39341 8.29289 9.26627C8.43275 9.13913 8.61093 9.05255 8.80491 9.01747C8.99889 8.98239 9.19996 9.00039 9.38268 9.0692C9.56541 9.13801 9.72159 9.25453 9.83147 9.40403C9.94135 9.55353 10 9.72929 10 9.90909L10 12.1818C10 12.664 9.78929 13.1265 9.41421 13.4675C9.03914 13.8084 8.53043 14 8 14"/><path ${T} d="M16 10.8182L15 10.8182C14.8022 10.8182 14.6089 10.7649 14.4444 10.665C14.28 10.5651 14.1518 10.4231 14.0761 10.257C14.0004 10.0909 13.9806 9.90808 14.0192 9.73174C14.0578 9.55539 14.153 9.39341 14.2929 9.26627C14.4327 9.13913 14.6109 9.05255 14.8049 9.01747C14.9989 8.98239 15.2 9.00039 15.3827 9.0692C15.5654 9.13801 15.7216 9.25453 15.8315 9.40403C15.9414 9.55353 16 9.72929 16 9.90909L16 12.1818C16 12.664 15.7893 13.1265 15.4142 13.4675C15.0391 13.8084 14.5304 14 14 14"/>`,"2 2 20 20"),undo:Y(`<polyline ${T} points="6.5 4 3.5 7 6.5 10"/><path ${T} d="M3.5 7H10a3.5 3.5 0 0 1 0 7H7"/>`),redo:Y(`<polyline ${T} points="11.5 4 14.5 7 11.5 10"/><path ${T} d="M14.5 7H8a3.5 3.5 0 0 0 0 7h3"/>`),clear:Y(`<line ${T} x1="5" x2="13" y1="3" y2="3"/><line ${T} x1="6" x2="9.35" y1="12" y2="3"/><line ${T} x1="11" x2="15" y1="11" y2="15"/><line ${T} x1="15" x2="11" y1="11" y2="15"/><rect ${Tt} height="1" rx="0.5" ry="0.5" width="7" x="2" y="14"/>`),code:Y(`<polyline ${T} points="5 7 3 9 5 11"/><polyline ${T} points="13 7 15 9 13 11"/><line ${T} x1="10" x2="8" y1="5" y2="13"/>`),indent:Y(`<line ${T} x1="3" x2="15" y1="4" y2="4"/><line ${T} x1="8" x2="15" y1="9" y2="9"/><line ${T} x1="3" x2="15" y1="14" y2="14"/><polyline ${T} points="3 7 5.5 9 3 11"/>`),outdent:Y(`<line ${T} x1="3" x2="15" y1="4" y2="4"/><line ${T} x1="8" x2="15" y1="9" y2="9"/><line ${T} x1="3" x2="15" y1="14" y2="14"/><polyline ${T} points="5.5 7 3 9 5.5 11"/>`),blocks:Y(`<line ${T} x1="3" x2="15" y1="4" y2="4"/><line ${T} x1="3" x2="15" y1="9" y2="9"/><line ${T} x1="3" x2="10" y1="14" y2="14"/>`)},Se=e=>e.blocksStayOut(),_a=e=>!!e.element.closest("a"),Et={minimal:["bold","italic","link","unorderedList"],inline:["bold","italic","underline","strikethrough","code","link","unlink","undo","redo","clearFormatting"],standard:["blockMenu","bold","italic","underline","strikethrough","code","link","unlink","unorderedList","orderedList","quote","outdent","indent","undo","redo","clearFormatting"]};function kr(){return new Map(Ta.map(e=>[e.id,e]))}function nt(e=globalThis){let t=e?.navigator;return t?/Mac|iPhone|iPad|iPod/.test(t.platform||t.userAgent||""):!1}function Or(e,t=globalThis){return e?e.replace("Mod",nt(t)?"Cmd":"Ctrl"):""}var Ta=[Oe("bold","Bold",X.bold,"Mod+B","inline",e=>e.toggleFormat("B","bold","removeBold")),Oe("italic","Italic",X.italic,"Mod+I","inline",e=>e.toggleFormat("I","italic","removeItalic")),Oe("underline","Underline",X.underline,"Mod+U","inline",e=>e.toggleFormat("U","underline","removeUnderline")),Oe("strikethrough","Strikethrough",X.strike,"Mod+Shift+7","inline",e=>e.toggleFormat("S","strikethrough","removeStrikethrough")),Oe("code","Code",X.code,null,"inline",e=>e.toggleCode(),e=>e.selectionHasFormat("CODE")||e.selectionHasFormat("PRE")),{id:"link",label:"Link",ariaLabel:"Insert or edit link",icon:X.link,group:"links",shortcut:"Mod+K",mutates:!1,isDisabled:_a,run:e=>e.openLinkDialog(),isActive:e=>e.selectionHasFormat("A")},{id:"unlink",label:"Remove link",ariaLabel:"Remove link",icon:X.unlink,group:"links",run:e=>e.squire.removeLink()},Oe("unorderedList","Bulleted list",X.ul,"Mod+Shift+8","lists",e=>e.toggleList("UL"),e=>e.pathHas("UL"),Se),Oe("orderedList","Numbered list",X.ol,"Mod+Shift+9","lists",e=>e.toggleList("OL"),e=>e.pathHas("OL"),Se),Oe("quote","Quote",X.quote,null,"blocks",e=>e.pathHas("BLOCKQUOTE")?e.squire.decreaseQuoteLevel():e.squire.increaseQuoteLevel(),e=>e.pathHas("BLOCKQUOTE"),Se),{id:"outdent",label:"Outdent",ariaLabel:"Decrease indent",icon:X.outdent,group:"blocks",shortcut:"Mod+[",isDisabled:Se,run:e=>e.outdent()},{id:"indent",label:"Indent",ariaLabel:"Increase indent",icon:X.indent,group:"blocks",shortcut:"Mod+]",isDisabled:Se,run:e=>e.indent()},{id:"undo",label:"Undo",ariaLabel:"Undo",icon:X.undo,group:"history",shortcut:"Mod+Z",mutates:!1,run:e=>e.squire.undo()},{id:"redo",label:"Redo",ariaLabel:"Redo",icon:X.redo,group:"history",shortcut:"Mod+Shift+Z",mutates:!1,run:e=>e.squire.redo()},{id:"clearFormatting",label:"Clear formatting",ariaLabel:"Clear formatting",icon:X.clear,group:"cleanup",run:e=>e.squire.removeAllFormatting()},{id:"blockMenu",type:"menu",label:"Block style",ariaLabel:"Choose block style",icon:X.blocks,group:"blocks",isDisabled:Se,options:[$t("Paragraph","P"),$t("Heading 1","H1"),$t("Heading 2","H2"),$t("Heading 3","H3"),{label:"Quote",value:"BLOCKQUOTE",isDisabled:Se,run:e=>e.squire.increaseQuoteLevel(),isActive:e=>e.pathHas("BLOCKQUOTE")},{label:"Code block",value:"PRE",isDisabled:Se,run:e=>e.setBlockType("PRE"),isActive:e=>e.pathHas("PRE")}]}];function Oe(e,t,n,i,r,o,s=c=>c.selectionHasFormat(Ea(e)),a){return{id:e,label:t,ariaLabel:t,icon:n,group:r,shortcut:i,isDisabled:a,run:o,isActive:s}}function Ea(e){return{bold:"B",italic:"I",underline:"U",strikethrough:"S"}[e]}function $t(e,t){return{label:e,value:t,isDisabled:Se,run:n=>n.setBlockType(t),isActive:n=>n.pathHas(t)}}var Wn=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,Gt=/[^ \t\r\n]/;var Sa=new Set(["BR","HR","IFRAME","IMG","INPUT","WBR"]),At=new Set(["svg","math"]);function Kt(e){let t=e.nodeType;return t===3||t===8?!0:t!==1?!1:At.has(e.nodeName)?!0:Wn.test(e.nodeName)?Array.from(e.childNodes).every(Kt):!1}function vt(e){return Array.from(e.childNodes).some(t=>!Kt(t))}var $n=e=>e?.nodeType===1&&!At.has(e.nodeName)&&!Wn.test(e.nodeName);function Ct(e,t){let n=Array.from(e.childNodes),i=0;return n.forEach((r,o)=>{if(!(r.nodeType!==1||At.has(r.nodeName))&&(i+=Ct(r,t),!!$n(r))){for($n(n[o-1])&&e.insertBefore(t(),r);r.firstChild;)e.insertBefore(r.firstChild,r);r.remove(),i+=1}}),i}var Gn=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","COLGROUP"]);function Vt(e){return!!e.closest?.("p")||Gn.has(e.nodeName)}var Aa=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","LABEL","LEGEND","LI","TD","TH","DT","DD","FIGCAPTION","SUMMARY","CAPTION"]);function Pr(e){return Aa.has(e.nodeName)||jt(e)}var Br=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),va=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","IFRAME","NOSCRIPT","XMP"]),Fr="http://www.w3.org/1999/xhtml";function Ur(e){return Gn.has(e.nodeName)||Br.has(e.nodeName)||va.has(e.nodeName)||e.nodeName==="TEMPLATE"||!!e.namespaceURI&&e.namespaceURI!==Fr}function Hr(e){return Gn.has(e.nodeName)?"a table element cannot be an editable region. Move the editable attribute to a <td>, a <th>, or an element inside one.":e.namespaceURI&&e.namespaceURI!==Fr?"an SVG or MathML element cannot be an editable region: an edit puts an HTML block inside it, and the next page load moves that text out of the graphic entirely. Put a <foreignObject> in the SVG and mark an HTML element inside it instead.":Br.has(e.nodeName)?"this element cannot contain anything, so there is nothing to edit. Move the editable attribute to an element that holds text.":e.nodeName==="TEMPLATE"?"a <template> keeps its content out of the document, so edits to it are never saved.":"this element treats its content as plain text, so any edit would be saved as visible markup rather than formatting."}function jt(e){return e.nodeType===1&&!At.has(e.nodeName)&&Wn.test(e.nodeName)}function Yt(e){return Array.from(e.querySelectorAll("*")).some($n)}function zr(e,t={}){let{blockTag:n="DIV",wrapBareRoot:i=!1,onBareRootWrapped:r,blocksAllowed:o=!Vt(e)}=t;return Wr(e),o&&Na(e,n,i,r),e}var Ca=e=>Kt(e)&&e.nodeType!==8,xa=e=>e.nodeType!==8&&!(e.nodeType===3&&!Gt.test(e.nodeValue));function qr(e,{wrapBareRoot:t=!1,blocksAllowed:n=!Vt(e)}={}){return n?vt(e)?Array.from(e.childNodes).some(Ca)||$r(e):t:!1}function $r(e){return Array.from(e.children).some(t=>vt(t)?!Kn(t)&&Array.from(t.childNodes).some(i=>i.nodeType===3&&!Gt.test(i.nodeValue))||$r(t):!1)}function Wr(e){vt(e)&&(Kn(e)||Array.from(e.childNodes).forEach(t=>{t.nodeType===3&&!Gt.test(t.nodeValue)&&t.remove()}),Array.from(e.children).forEach(Wr))}function Na(e,t,n,i){if(!vt(e)){if(!n)return;let s=e.ownerDocument.createElement(t);if(!Array.from(e.childNodes).some(xa)){s.appendChild(e.ownerDocument.createElement("BR")),e.appendChild(s);return}for(;e.firstChild;)s.appendChild(e.firstChild);e.appendChild(s),i?.(e,s);return}let r=[],o=()=>{let s=r;if(r=[],!s.some(c=>c.nodeType!==8))return;let a=e.ownerDocument.createElement(t);e.insertBefore(a,s[0]),s.forEach(c=>a.appendChild(c))};Array.from(e.childNodes).forEach(s=>{Kt(s)?r.push(s):o()}),o()}function Kn(e){return e.nodeName==="PRE"}function Gr(e,t){return{start:Dr(e,t.startContainer,t.startOffset),end:Dr(e,t.endContainer,t.endOffset),collapsed:t.collapsed}}function Kr(e,t,n){Mr(t,"setStart",e,n.start),n.collapsed?t.collapse(!0):Mr(t,"setEnd",e,n.end)}function Dr(e,t,n){if(!e.contains(t))return{scope:e,after:[],before:[]};if(t.nodeType===3){if(!La(t))return{container:t,offset:n};let i=t.parentNode;return Ir(i,Array.from(i.childNodes).indexOf(t))}return{container:t,offset:n,childCount:t.childNodes.length,...Ir(t,n)}}function Ir(e,t){let n=Array.from(e.childNodes),i=Math.max(0,t);return{scope:e,after:n.slice(i),before:n.slice(0,i).reverse()}}function Mr(e,t,n,i){let{container:r,childCount:o}=i;if(r&&n.contains(r)&&(o===void 0||o===r.childNodes.length)){e[t](r,Math.min(i.offset,Wt(r)));return}let s=i.after?.find(u=>n.contains(u));if(s){e[t](St(s,!0),0);return}let a=i.before?.find(u=>n.contains(u));if(a){let u=St(a,!1);e[t](u,Wt(u));return}let c=i.scope&&n.contains(i.scope)?i.scope:n;e[t](c,0)}function La(e){return e.nodeType===3&&!Gt.test(e.nodeValue)&&!!e.parentNode&&e.parentNode.nodeType===1&&vt(e.parentNode)&&!Kn(e.parentNode)}var it=e=>e.nodeType===1||e.nodeType===3;function St(e,t=!0){let n=e;for(;n.nodeType===1&&!At.has(n.nodeName);){let i=Array.from(n.childNodes).filter(it),r=t?i[0]:i[i.length-1];if(!r||Sa.has(r.nodeName))break;n=r}return n}function Wt(e){return e.nodeType===3?e.nodeValue.length:e.childNodes.length}var ue="[data-richclay], [richclay], [editable], [clay-editable]",wa="[data-richclay], [richclay], [clay-editable]",Ra=["editable","clay-editable"],Yn=':is([editable~="single-line"], [clay-editable~="single-line"])';function Qn(e){return!e||typeof e.matches!="function"?!1:e.tagName.includes("-")?e.matches(wa):!0}var ka="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-live], [data-richclay-float]",Oa=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],Xn=new WeakSet,Vr=new WeakSet,jr=["clay:ready","hyperclay:ready"];function Yr(e){return[e.clay?.ready,e.hyperclay?.ready].find(t=>t&&typeof t.then=="function")||null}function Xr(e){return typeof e.clay?.isEditMode=="boolean"?e.clay.isEditMode:typeof e.hyperclay?.isEditMode=="boolean"?e.hyperclay.isEditMode:null}function Da(e){let t=e.hyperclayModules,n=e.__hyperclayNoAutoExport===!1&&t&&typeof t=="object"&&typeof t.nodeType!="number";return Xr(e)!==null||!!Yr(e)||!!n}function Ia(e){return e.clay?.addDocumentTransform||e.hyperclay?.beforeSave||null}var Ma={boxSizing:"border-box",minWidth:"100%",overflow:"auto",width:"0"};function Xt(e={},t=window){return e.hyperclay===!1?!1:e.hyperclay===!0?!0:!!(Da(t)||$a(t))}function Zn(e=window){let t=eo(e);if(t!==null)return t;if(typeof e.__hyperclayEditMode=="boolean")return e.__hyperclayEditMode;let n=Xr(e);return n!==null?n:Wa(e)}function Qr(e={},t=window){return e.readOnly?!1:Xt(e,t)?Zn(t):!0}function Zr(e){let t=Ra.find(r=>e.hasAttribute(r));if(!t)return null;let n=new Set((e.getAttribute(t)||"").trim().split(/\s+/).filter(Boolean)),i={inline:!0,singleLine:n.has("single-line"),toolbarOnSelect:n.has("toolbar-on-select")};return n.has("no-toolbar")&&(i.toolbar=!1),i}function Jn(e=window){if(Xn.has(e))return;let t=Ia(e);if(typeof t!="function"){Pa(e);return}t(n=>ei(n)),Xn.add(e)}function Pa(e){if(Vr.has(e))return;let t=e.document,n=Yr(e);if(!t&&!n)return;Vr.add(e);let i=()=>{Jn(e),Xn.has(e)&&r()},r=()=>{t&&jr.forEach(o=>t.removeEventListener(o,i))};t&&jr.forEach(o=>t.addEventListener(o,i)),n&&n.then(i,()=>{})}function ei(e){e.querySelectorAll?.(ka).forEach(t=>t.remove()),e.querySelectorAll?.(ue).forEach(t=>{if(t.getAttribute("data-richclay-active")!=="true")return;if(ti(t,"save"),Ha(t)){let i=t.ownerDocument,r=!!t.matches?.(Yn);Ct(t,()=>r?i.createTextNode(" "):i.createElement("br")),t.querySelectorAll(t.localName).forEach(o=>{for(;o.firstChild;)o.parentNode.insertBefore(o.firstChild,o);o.remove()})}t.matches?.(Yn)&&qa(t),t.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(i=>{i.remove()}),t.querySelectorAll(".squire-image-resize-container").forEach(i=>i.remove()),za(t),(t.matches?.("pre")?[t,...t.querySelectorAll("pre")]:Array.from(t.querySelectorAll("pre"))).filter(i=>i.hasAttribute("data-richclay-pre")).forEach(i=>{Object.entries(Ma).forEach(([r,o])=>{i.style[r]||(i.style[r]=o)}),i.removeAttribute("data-richclay-pre")})}),e.querySelectorAll?.("#squire-selection-start, #squire-selection-end").forEach(t=>t.remove())}var Ba="p, td, th, li, dl, dt, dd, table, blockquote, div, section, article, aside, main, header, footer, figure, figcaption",Vn="data-richclay-measure";function Fa(e){let t=e.ownerDocument,n=e.closest(Ba)||e;e.setAttribute(Vn,"");let i=t.createElement("div");try{i.innerHTML=n.outerHTML}finally{e.removeAttribute(Vn)}let r=i.querySelector(`[${Vn}]`);return!r||r.textContent!==e.textContent}var Ua=e=>!!e.querySelector(e.localName),Ha=e=>!!e.matches?.(Yn)||(Yt(e)||Ua(e))&&Fa(e);function ti(e,t){let n=e.getAttribute("data-richclay-runtime-contenteditable");e.hasAttribute("contenteditable")&&(n==="true"?e.removeAttribute("contenteditable"):n?t==="destroy"?e.setAttribute("contenteditable",n):(e.setAttribute("inert-contenteditable",n),e.removeAttribute("contenteditable")):t==="save"&&(e.setAttribute("inert-contenteditable",e.getAttribute("contenteditable")),e.removeAttribute("contenteditable"))),Oa.forEach(i=>e.classList.remove(i)),e.getAttribute("class")===""&&e.removeAttribute("class"),jn(e,"role","data-richclay-runtime-role"),jn(e,"aria-multiline","data-richclay-runtime-aria-multiline"),jn(e,"no-undo","data-richclay-runtime-no-undo"),e.getAttribute("data-richclay-runtime-display")==="true"&&(e.style.removeProperty("display"),e.getAttribute("style")===""&&e.removeAttribute("style")),Ga(e),e.removeAttribute("data-richclay-active"),e.removeAttribute("data-richclay-placeholder"),e.removeAttribute("data-richclay-pre"),e.removeAttribute("data-richclay-runtime-role"),e.removeAttribute("data-richclay-runtime-aria-multiline"),e.removeAttribute("data-richclay-runtime-no-undo"),e.removeAttribute("data-richclay-runtime-describedby"),e.removeAttribute("data-richclay-runtime-contenteditable"),e.removeAttribute("data-richclay-runtime-display")}function za(e){let n=[e];for(;n.length;)n.pop().childNodes.forEach(r=>{r.nodeType===3?r.nodeValue.includes("\u200B")&&(r.nodeValue=r.nodeValue.split("\u200B").join("")):r.nodeType===1&&n.push(r)});e.querySelectorAll("b, i, u, s, em, strong, code, sub, sup, span").forEach(i=>{i.children.length===0&&(i.textContent||"")===""&&i.attributes.length===0&&i.remove()})}function qa(e){let t=Array.from(e.childNodes).filter(i=>i.nodeType!==3||(i.nodeValue||"").trim()!=="");if(t.length!==1)return;let n=t[0];if(!(n.nodeType!==1||n.nodeName!=="P"||n.attributes.length>0)){for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove()}}function Jr(e){if(!e.hasAttribute("inert-contenteditable"))return null;let t=e.getAttribute("inert-contenteditable");return["false","plaintext-only"].includes(t)||(t="true"),e.setAttribute("contenteditable",t),e.removeAttribute("inert-contenteditable"),t==="true"&&e.setAttribute("data-richclay-runtime-contenteditable","true"),t}function ye(e){return e.setAttribute("snapshot-remove",""),e.setAttribute("no-watch",""),e}function eo(e){try{let t=new URLSearchParams(e.location?.search||"");if(t.get("editmode")==="true")return!0;if(t.get("editmode")==="false")return!1}catch{return null}return null}function $a(e){return eo(e)!==null||typeof e.__hyperclayEditMode=="boolean"}function Wa(e){let n=(e.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(n&&n[1]!=="")}function jn(e,t,n){e.hasAttribute(n)&&e.removeAttribute(t)}function Ga(e){let t=e.getAttribute("data-richclay-runtime-describedby");if(!t)return;let n=(e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean).filter(i=>i!==t);n.length?e.setAttribute("aria-describedby",n.join(" ")):e.removeAttribute("aria-describedby")}var Ka=0;function to(e=document){let t=e.createElement("div");return t.id=`richclay-live-${++Ka}`,t.className="richclay-sr-only",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("data-richclay-live",""),ye(t),e.body.appendChild(t),t}function xt(e,t){!e||!t||(e.textContent="",e.ownerDocument.defaultView.setTimeout(()=>{e.textContent=t},20))}function ni(e){e.preventDefault()}function ii(e){try{return e?.cloneRange?.()||null}catch{return null}}function rt(e){try{return ii(e?.getSelection?.())}catch{return null}}function Qt(e,t){if(!e||!t)return!1;try{return e.setSelection(t),!0}catch{return!1}}function Zt(e,t,n,i){e.hasAttribute(t)||e.setAttribute(i,"true"),e.setAttribute(t,n)}function no(e,t){let n=new Set((e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));n.add(t.id),e.setAttribute("aria-describedby",Array.from(n).join(" ")),e.setAttribute("data-richclay-runtime-describedby",t.id)}var Va=0,ot=class{constructor(t,n,i={}){this.editor=t,this.controls=n,this.options=i,this.id=++Va,this.items=[],this.menus=new Map,this.activeIndex=0,this.root=this.createRoot(),this.onRootKeydown=r=>this.handleRootKeydown(r),this.onRootClick=r=>this.handleRootClick(r),this.onRootPointerDown=r=>this.handleRootPointerDown(r),this.onDocumentPointerDown=r=>this.handleDocumentPointerDown(r),this.render(),this.root.addEventListener("keydown",this.onRootKeydown),this.root.addEventListener("click",this.onRootClick),this.root.addEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.addEventListener("mousedown",this.onDocumentPointerDown)}destroy(){this.closeMenus(),this.root.removeEventListener("keydown",this.onRootKeydown),this.root.removeEventListener("click",this.onRootClick),this.root.removeEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.removeEventListener("mousedown",this.onDocumentPointerDown),this.root.remove()}update(){this.items.forEach(t=>{let{def:n,button:i}=t;if(typeof n.isActive=="function"){let r=!!n.isActive(this.editor);i.setAttribute("aria-pressed",r?"true":"false"),i.classList.toggle("is-active",r)}typeof n.isDisabled=="function"&&(i.disabled=!!n.isDisabled(this.editor))}),this.ensureSingleTabStop()}focusFirst(){this.activeIndex=0,this.ensureSingleTabStop(),this.items[0]?.button.focus()}createRoot(){let t=this.editor.element.ownerDocument,n=t.createElement("div");n.className="richclay-toolbar",n.setAttribute("role","toolbar"),n.setAttribute("aria-label",this.options.ariaLabel||"Rich text formatting"),n.setAttribute("data-richclay-toolbar",""),ye(n);let i=ja(this.options.toolbarContainer,t);return i?i.appendChild(n):this.editor.element.insertAdjacentElement("beforebegin",n),n}render(){this.root.textContent="",this.items=[],this.menus.clear();let t=null;this.visibleControls().forEach((n,i)=>{if(n.type==="separator"){this.root.appendChild(ro(this.root.ownerDocument)),t=null;return}t&&n.group&&n.group!==t&&this.root.appendChild(ro(this.root.ownerDocument)),t=n.group||t,n.type==="menu"?this.renderMenu(n,i):this.renderButton(n,i)}),this.ensureSingleTabStop(),this.update()}visibleControls(){let t=this.controls.filter(i=>i.type==="separator"||!i.isDisabled?.(this.editor)),n=[];for(t.forEach(i=>{let r=n[n.length-1];i.type==="separator"&&(!r||r.type==="separator")||n.push(i)});n[n.length-1]?.type==="separator";)n.pop();return n}renderButton(t,n){let i=io(this.root.ownerDocument,t);i.dataset.richclayControl=t.id,i.dataset.richclayIndex=String(n),typeof t.isActive=="function"&&i.setAttribute("aria-pressed","false"),this.root.appendChild(i),this.items.push({def:t,button:i,type:"button"})}renderMenu(t,n){let i=this.root.ownerDocument,r=io(i,t),o=`richclay-menu-${this.id}-${t.id}`;r.dataset.richclayControl=t.id,r.dataset.richclayIndex=String(n),r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",o);let s=i.createElement("div");s.id=o,s.className="richclay-menu",s.hidden=!0,s.setAttribute("role","menu"),s.setAttribute("data-richclay-menu",""),ye(s),t.options.forEach((c,u)=>{let h=i.createElement("button");h.type="button",h.className="richclay-menu-item",h.setAttribute("role","menuitemradio"),h.setAttribute("tabindex","-1"),h.dataset.richclayMenuItem=t.id,h.dataset.richclayOptionIndex=String(u),h.textContent=c.label,h.addEventListener("mousedown",ni),h.addEventListener("click",f=>{f.preventDefault(),this.chooseMenuItem(t,c,r)}),h.addEventListener("keydown",f=>this.handleMenuKeydown(f,t,r)),s.appendChild(h)});let a=i.createElement("span");a.className="richclay-menu-wrap",a.append(r,s),this.root.appendChild(a),this.items.push({def:t,button:r,type:"menu",menu:s}),this.menus.set(t.id,{def:t,button:r,menu:s})}handleRootPointerDown(t){let n=t.target.closest?.("[data-richclay-control]");!n||!this.root.contains(n)||(ni(t),this.editor.saveSelection())}handleRootClick(t){let n=t.target.closest?.("[data-richclay-control]");if(!n||!this.root.contains(n))return;t.preventDefault();let i=this.items.find(r=>r.button===n);if(!(!i||n.disabled)){if(this.activeIndex=this.items.indexOf(i),this.ensureSingleTabStop(),i.type==="menu"){this.toggleMenu(i.def.id);return}this.closeMenus(),this.editor.runControl(i.def)}}handleRootKeydown(t){let n=t.key,i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};if(n in i){t.preventDefault(),this.moveFocus(i[n]);return}if(n==="Home"){t.preventDefault(),this.setFocusIndex(0);return}if(n==="End"){t.preventDefault(),this.setFocusIndex(this.items.length-1);return}let r=this.items[this.activeIndex];if(r&&((n==="Enter"||n===" ")&&r.type==="menu"&&(t.preventDefault(),this.openMenu(r.def.id,"first")),n==="Escape")){let o=Array.from(this.menus.values()).some(s=>!s.menu.hidden);this.closeMenus(),o?r.button.focus():this.editor.focus()}}handleMenuKeydown(t,n,i){t.stopPropagation();let r=this.menus.get(n.id)?.menu,o=Array.from(r.querySelectorAll(".richclay-menu-item")),s=o.indexOf(t.currentTarget),a=s;if(t.key==="ArrowDown"&&(a=(s+1)%o.length),t.key==="ArrowUp"&&(a=(s-1+o.length)%o.length),t.key==="Home"&&(a=0),t.key==="End"&&(a=o.length-1),a!==s){t.preventDefault(),o[a].focus();return}if(t.key==="Escape"){t.preventDefault(),this.closeMenus(),i.focus();return}if(t.key==="Enter"||t.key===" "){t.preventDefault();let c=n.options[s];this.chooseMenuItem(n,c,i)}}handleDocumentPointerDown(t){this.root.contains(t.target)||this.closeMenus()}chooseMenuItem(t,n,i){this.closeMenus(),this.editor.runControl({...n,id:`${t.id}:${n.value}`,ariaLabel:n.label}),i.focus()}toggleMenu(t){let n=this.menus.get(t);n&&(n.menu.hidden?this.openMenu(t,"first"):this.closeMenus())}openMenu(t,n="first"){this.closeMenus(t);let i=this.menus.get(t);if(!i)return;i.menu.hidden=!1,i.button.setAttribute("aria-expanded","true"),this.updateMenuState(i);let r=Array.from(i.menu.querySelectorAll(".richclay-menu-item")),o=r.find(a=>a.getAttribute("aria-checked")==="true");(n==="active"&&o||r[0])?.focus()}closeMenus(t=null){this.menus.forEach((n,i)=>{i!==t&&(n.menu.hidden=!0,n.button.setAttribute("aria-expanded","false"))})}updateMenuState(t){Array.from(t.menu.querySelectorAll(".richclay-menu-item")).forEach((i,r)=>{let s=!!t.def.options[r].isActive?.(this.editor);i.setAttribute("aria-checked",s?"true":"false"),i.classList.toggle("is-active",s)})}moveFocus(t){if(!this.items.length)return;let n=this.activeIndex;do n=(n+t+this.items.length)%this.items.length;while(this.items[n].button.disabled&&n!==this.activeIndex);this.setFocusIndex(n)}setFocusIndex(t){this.activeIndex=Math.max(0,Math.min(t,this.items.length-1)),this.ensureSingleTabStop(),this.items[this.activeIndex]?.button.focus()}ensureSingleTabStop(){let t=this.items.filter(n=>!n.button.disabled);t.length&&(t.includes(this.items[this.activeIndex])||(this.activeIndex=this.items.indexOf(t[0])),this.items.forEach((n,i)=>{n.button.tabIndex=i===this.activeIndex?0:-1}))}};function io(e,t){let n=e.createElement("button");n.type="button",n.className="richclay-button";let i=Or(t.shortcut,e.defaultView),r=i?`${t.ariaLabel||t.label} (${i})`:t.ariaLabel||t.label;return n.setAttribute("aria-label",r),n.title=r,n.innerHTML=`${t.icon||""}<span class="richclay-sr-only">${t.label}</span>`,n}function ro(e){let t=e.createElement("span");return t.className="richclay-separator",t.setAttribute("role","separator"),t.setAttribute("aria-orientation","vertical"),t}function ja(e,t){return e?typeof e=="string"?t.querySelector(e):e:null}var oo=16,Ya=[16,8,0],ae=8,Xa=4;function Qa({anchor:e,bar:t,rail:n,viewport:i,current:r=null}){let o=g=>r===g?Xa:0;if(e.bottom<=0||e.top>=i.height||e.right<=0||e.left>=i.width)return{mode:"hidden",x:0,y:0};let s=g=>Math.max(ae,Math.min(e.left,i.width-g-ae)),a=e.top-oo-t.height;if(a>=ae-o("above"))return{mode:"above",x:s(t.width),y:a};let c=e.bottom+oo;if(c+t.height<=i.height-ae+o("below"))return{mode:"below",x:s(t.width),y:c};let u=i.width-e.right-ae,h=e.left-ae,f=u>=h?[["rail-right",u],["rail-left",h]]:[["rail-left",h],["rail-right",u]];for(let[g,y]of f)for(let S of Ya){if(n.width+S>y+o(g))continue;let N=g==="rail-right"?Math.min(e.right+S,i.width-n.width-ae):Math.max(e.left-S-n.width,ae),C=Math.min(e.bottom,i.height-ae)-n.height,M=Math.max(ae,Math.min(Math.max(e.top,ae),C));return{mode:g,x:N,y:M,gap:S}}return{mode:"pinned",x:s(t.width),y:ae}}var Jt=class{constructor(t,n){this.editor=t,this.mode=null,this.hidden=!1,this.frame=0,this.bar={width:0,height:0},this.rail={width:0,height:0};let i=t.element.ownerDocument;this.doc=i,this.win=i.defaultView||globalThis,this.root=i.createElement("div"),this.root.className="richclay-float",this.root.setAttribute("data-richclay-float",""),this.root.setAttribute("save-remove",""),ye(this.root),i.body.appendChild(this.root),this.toolbar=new ot(t,n,{toolbarContainer:this.root}),this.onScroll=()=>this.schedule(),this.onResize=()=>{this.measure(),this.schedule()},i.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),this.win.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("scroll",this.onScroll,{passive:!0}),this.resizeObserver=typeof this.win.ResizeObserver=="function"?new this.win.ResizeObserver(()=>this.schedule()):null,this.resizeObserver?.observe(t.element),this.measure(),this.reposition()}measure(){let t=this.root.classList.contains("richclay-float-rail");this.root.style.visibility="hidden",this.root.classList.remove("richclay-float-rail"),this.bar={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.add("richclay-float-rail"),this.rail={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.toggle("richclay-float-rail",t),this.root.style.visibility=""}schedule(){if(!this.win.requestAnimationFrame){this.reposition();return}this.frame||(this.frame=this.win.requestAnimationFrame(()=>{this.frame=0,this.reposition()}))}setVisible(t){this.hidden=!t,this.reposition()}reposition(){if(this.hidden){this.root.style.display="none";return}let t=this.editor.element.getBoundingClientRect(),n={width:this.win.visualViewport?.width??this.win.innerWidth,height:this.win.visualViewport?.height??this.win.innerHeight},i=Qa({anchor:t,bar:this.bar,rail:this.rail,viewport:n,current:this.mode});if(this.mode=i.mode,i.mode==="hidden"){this.root.style.display="none";return}this.root.style.display="",this.root.classList.toggle("richclay-float-rail",i.mode==="rail-left"||i.mode==="rail-right"),this.root.classList.toggle("richclay-float-pinned",i.mode==="pinned"),this.root.style.transform=`translate(${Math.round(i.x)}px, ${Math.round(i.y)}px)`}destroy(){this.frame&&this.win.cancelAnimationFrame?.(this.frame),this.frame=0,this.doc.removeEventListener("scroll",this.onScroll,{capture:!0}),this.win.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onScroll),this.resizeObserver?.disconnect(),this.toolbar.destroy(),this.root.remove()}};var Za={ALLOWED_TAGS:["a","b","blockquote","br","code","div","em","h1","h2","h3","h4","h5","h6","i","li","ol","p","pre","s","span","strong","sub","sup","u","ul"],ALLOWED_ATTR:["aria-label","href","rel","target","title"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,FORBID_TAGS:["script","style","iframe","object","embed","form","input"],FORBID_ATTR:["style","srcset","onerror","onclick","onload"]};function lo(e={},t=document){let n=en(t);return{sanitizeHTML(i){return ri(i,e,t,n)},sanitizeElement(i){return oi(i,e,n)},sanitizeToDOMFragment(i,r){let o=r?.getRoot?.().ownerDocument||t;return Ja(i,e,o,n)}}}function ri(e,t={},n=document,i=en(n)){let r=n.createElement("template");return r.innerHTML=i.sanitize(String(e||""),si(t)),ai(r.content),r.innerHTML}function oi(e,t={},n=en(e.ownerDocument)){let r=e.ownerDocument.createElement("div");for(;e.firstChild;)r.appendChild(e.firstChild);for(n.sanitize(r,{...si(t),IN_PLACE:!0}),ai(r);r.firstChild;)e.appendChild(r.firstChild);return e}function Ja(e,t={},n=document,i=en(n)){let r=i.sanitize(String(e||""),{...si(t),RETURN_DOM_FRAGMENT:!0}),o=r?.ownerDocument===n?r:n.importNode(r,!0);return ai(o),o||n.createDocumentFragment()}function si(e){return{...Za,...e}}var el=new Set(["http","https","mailto","tel"]),tl=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function nl(e){let n=(String(e??"").replace(tl,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!n||el.has(n.toLowerCase())}function co(e){let t=String(e??"").trim();return!t||!nl(t)?"":/^(?:https?:|mailto:|tel:)/i.test(t)?t:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:/^(?:[#?]|\/|\.{1,2}\/)/.test(t)?t:`https://${t}`}function en(e){let t=globalThis.DOMPurify;if(t?.sanitize)return t;if(typeof t=="function")return t(e.defaultView||globalThis);throw new Error("RichClay requires DOMPurify. Load vendor/purify.min.js before richclay.js or provide globalThis.DOMPurify.")}function ai(e){e.querySelectorAll?.("a[href]").forEach(t=>{let n=t.getAttribute("href")||"";if(/^\s*javascript:/i.test(n)&&t.removeAttribute("href"),t.getAttribute("target")==="_blank"){let i=new Set((t.getAttribute("rel")||"").split(/\s+/).filter(Boolean));i.add("noopener"),i.add("noreferrer"),t.setAttribute("rel",Array.from(i).join(" "))}})}var so={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function uo(e={}){return{...e,ADD_TAGS:[...new Set([...so.ADD_TAGS,...e.ADD_TAGS||[]])],ADD_ATTR:[...new Set([...so.ADD_ATTR,...e.ADD_ATTR||[]])],ALLOW_DATA_ATTR:e.ALLOW_DATA_ATTR??!0}}var ao="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function ho(e){let t=e.ownerDocument||document;e.querySelectorAll?.("br").forEach(i=>i.replaceWith(t.createTextNode(" ")));let n=e.querySelector?.(ao);for(;n;){let i=n.parentNode;for(i.insertBefore(t.createTextNode(" "),n);n.firstChild;)i.insertBefore(n.firstChild,n);i.insertBefore(t.createTextNode(" "),n),n.remove(),n=e.querySelector(ao)}return il(e,t),e}function il(e,t){e.normalize?.();let n=t.createTreeWalker(e,4),i=[];for(;n.nextNode();)i.push(n.currentNode);i.forEach(s=>{s.nodeValue=s.nodeValue.replace(/\s+/g," ")});let r=e.firstChild;r?.nodeType===3&&(r.nodeValue=r.nodeValue.replace(/^\s+/,""));let o=e.lastChild;o?.nodeType===3&&(o.nodeValue=o.nodeValue.replace(/\s+$/,""))}var fo="richclay-styles",li=new WeakSet,ci="";function po(e){ci=e||""}function mo(e=document){if(!e||li.has(e))return;if(e.getElementById(fo)){li.add(e);return}if(!ci)return;let t=e.createElement("style");t.id=fo,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=ci,(e.head||e.documentElement).appendChild(t),li.add(e)}var De=new WeakMap,go=new WeakSet,yo=new WeakSet,ui=kr(),bo=Symbol("richclay-keep-focus"),_o=["cut","paste","drop"],rl=["Alt","Ctrl","Meta","Shift"],To=0,ol={toolbar:"standard",toolbarContainer:null,sanitize:{},placeholder:"",readOnly:!1,hyperclay:"auto",onChange:null,Squire:null,inline:!1,singleLine:!1,toolbarOnSelect:!1},We=class e{static presets=Et;static selector=ue;constructor(t,n={}){if(!t)throw new Error("RichClay requires an element.");let i=De.get(t);if(i)return i;this.element=t,this.unsupported=di(t)||ll(t);let r={...Zr(t),...n};this.options={...ol,...r},this.options.singleLine&&!("toolbar"in r)&&(this.options.toolbar="inline"),this._blockTag=this.options.inline?"DIV":"P",this.registry=new Map(ui),this.toolbar=null,this.float=null,this._onToolbarKey=null,this._onFloatFocusOut=null,this._onDocPointerDown=null,this.liveRegion=null,this.description=null,this.dialog=null,this.savedSelection=null,this.path="",this.active=!1,this._squire=null,this._squireListeners=[],this._onBeforeInput=null,this._onRootBeforeInput=null,this._onRootKeydown=null,this._onRootTransfer=null,this._shortcutKeys=[],this._appleDeleteKeys=new Set,this._authoredPres=new WeakSet,this._warnedInlineBlock=!1,this._onFocus=()=>{this.element.classList.add("richclay-focused"),this.options.inline&&this.ensureFloatingToolbar()},this._onBlur=o=>{this.element.classList.remove("richclay-focused"),this.options.inline&&this.scheduleFloatTeardown(o)},this.ensureMarker(),this.hyperclay=Xt(this.options,this.window),this.hyperclay&&Jn(this.window),De.set(t,this),this.sanitizeConfig=this.options.inline?uo(this.options.sanitize):this.options.sanitize,this.sanitizer=lo(this.sanitizeConfig,this.element.ownerDocument),this.options.inline||oi(this.element,this.sanitizeConfig),Qr(this.options,this.window)&&this.activate()}get squire(){return this._squire}get window(){return this.element.ownerDocument.defaultView||window}static init(t=ue,n={}){let i=t===ue?Qn:()=>!0;return sl(t).filter(i).filter(o=>!di(o)).map(o=>new e(o,n))}static autoInit(t=typeof window<"u"?window:void 0){if(!t||!t.document||go.has(t))return;go.add(t);let n=()=>{Xt({},t)&&Zn(t)&&(e.init(),e.watch(t))};t.document.readyState==="loading"?t.document.addEventListener("DOMContentLoaded",n,{once:!0}):n()}static watch(t=typeof window<"u"?window:void 0,n={}){if(!t||!t.document||yo.has(t))return;yo.add(t);let i=s=>{tn(s)&&!De.has(s)&&!di(s)&&new e(s,n)},r=s=>De.get(s)?.destroy();new t.MutationObserver(s=>{s.forEach(a=>{if(a.type==="attributes"){let c=a.target;tn(c)?i(c):r(c);return}a.addedNodes.forEach(c=>{c.nodeType===1&&(c.matches?.(ue)&&i(c),c.querySelectorAll?.(ue).forEach(i))}),a.removedNodes.forEach(c=>{if(c.nodeType!==1)return;let u=h=>{h.isConnected||De.get(h)?.destroy()};c.matches?.(ue)&&u(c),c.querySelectorAll?.(ue).forEach(u)})})}).observe(t.document.documentElement||t.document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["editable","clay-editable","data-richclay","richclay"]})}static registerButton(t){return hi(t),ui.set(t.id,t),e}static unregisterButton(t){return ui.delete(t),e}static stripFromClone(t){ei(t)}registerButton(t){return hi(t),this.registry.set(t.id,t),this.active&&this.renderToolbar(),this}unregisterButton(t){return this.registry.delete(t),this.active&&this.renderToolbar(),this}activate(){if(this.unsupported||this.active)return;this.active=!0,jt(this.element)&&!this.element.style.display&&(this.element.style.display="inline-block",this.element.setAttribute("data-richclay-runtime-display","true")),mo(this.element.ownerDocument),Jr(this.element);let t=this.options.inline?Array.from(this.element.childNodes):null,n=this.options.inline?null:this.element.innerHTML,i=this.options.Squire||this.window.Squire||globalThis.Squire;if(!i)throw new Error("RichClay requires Squire. Load vendor/squire.js before richclay.js.");if(this.setupEditorAttributes(),this.liveRegion=to(this.element.ownerDocument),this._squire=new i(this.element,{blockTag:this._blockTag,sanitizeToDOMFragment:(r,o)=>{let s=this.sanitizer.sanitizeToDOMFragment(r,o);return this.options.singleLine?ho(s):s},didError:r=>{console.error("RichClay/Squire error",r)}}),this.options.inline?(this.element.replaceChildren(...t),this.resetSquireUndoBaseline()):this._squire.setHTML(n),this.bindSquire(),this.options.singleLine&&this.installSingleLineGuards(),this.options.inline&&!this.options.singleLine&&this.installRootGuards(),this.installAppleDeleteKeys(),this.blocksStayOut()&&(this._squire._ensureBottomLine=()=>{}),this.maskSquireCodeShortcut(),this.maskSquireBlockShortcuts(),this.installShortcuts(),this.options.inline&&(this._onToolbarKey=r=>{r.altKey&&r.key==="F10"&&(r.preventDefault(),this.ensureFloatingToolbar(),this.float?.toolbar.focusFirst())},this.element.addEventListener("keydown",this._onToolbarKey)),this.blocksStayOut()){let r=o=>{let s=o.detail?.fragment;if(!s)return;let a=this.element.ownerDocument;Ct(s,()=>this.options.singleLine?a.createTextNode(" "):a.createElement("br"))};this._squire.addEventListener("willPaste",r),this._squireListeners.push(["willPaste",r])}this.renderToolbar(),this.updatePlaceholder(),this.warnOnBlockInInlineRegion(),this.element.querySelectorAll("pre").forEach(r=>this._authoredPres.add(r))}getHTML(){return this._squire?this._squire.getHTML():this.element.innerHTML}setHTML(t){return this._squire?this._squire.setHTML(String(t||"")):this.element.innerHTML=ri(t,this.sanitizeConfig,this.element.ownerDocument),this.updatePlaceholder(),this.toolbar?.update(),this.options.onChange?.(this.getHTML()),this}focus(){return this._squire?this._squire.focus():this.element.focus(),this}destroy(){this.closeLinkDialog(),this.teardownFloatingToolbar(),this.toolbar?.destroy(),this.toolbar=null,this._onToolbarKey&&(this.element.removeEventListener("keydown",this._onToolbarKey),this._onToolbarKey=null),this.liveRegion?.remove(),this.liveRegion=null,this.description?.remove(),this.description=null,this._shortcutKeys.forEach(n=>this._squire?.setKeyHandler?.(n,null)),this._squireListeners.forEach(([n,i])=>{this._squire?.removeEventListener?.(n,i)}),this._squireListeners=[],this._shortcutKeys=[],this._onBeforeInput&&(this.element.ownerDocument.removeEventListener("beforeinput",this._onBeforeInput,!0),this._onBeforeInput=null);let t=this.element.ownerDocument;this._onRootBeforeInput&&(t.removeEventListener("beforeinput",this._onRootBeforeInput,!0),this._onRootBeforeInput=null),this._onRootKeydown&&(t.removeEventListener("keydown",this._onRootKeydown,!0),this._onRootKeydown=null),this._onRootTransfer&&(_o.forEach(n=>t.removeEventListener(n,this._onRootTransfer,!0)),this._onRootTransfer=null),this._squire?.destroy?.(),this._squire=null,this.cleanupEditorAttributes(),De.delete(this.element)}saveSelection(){return this.savedSelection=rt(this._squire)||this.savedSelection,this.savedSelection}restoreSelection(){return Qt(this._squire,this.savedSelection)}installRootGuards(){let t=this.element.ownerDocument,n=i=>this.element.contains(i.target);this._onRootBeforeInput=i=>{!n(i)||i.isComposing||/^history/.test(i.inputType||"")||this.ensureRootIsEditable()},this._onRootKeydown=i=>{!n(i)||i.defaultPrevented||i.isComposing||this.isEditingKey(i)&&this.ensureRootIsEditable()},this._onRootTransfer=i=>{n(i)&&this.ensureRootIsEditable()},t.addEventListener("beforeinput",this._onRootBeforeInput,!0),t.addEventListener("keydown",this._onRootKeydown,!0),_o.forEach(i=>{t.addEventListener(i,this._onRootTransfer,!0)})}ensureRootIsEditable(){if(!this._squire||this.options.singleLine)return;let t=this.options.inline,n=!this.blocksStayOut();if(!qr(this.element,{wrapBareRoot:t,blocksAllowed:n}))return;let i=rt(this._squire),r=i?Gr(this.element,i):null,o=()=>{zr(this.element,{blockTag:this._blockTag,wrapBareRoot:t,blocksAllowed:n,onBareRootWrapped:(s,a)=>{console.warn(`richclay: wrapped this region's loose text in a <div> so multi-line editing works. Wrap the content in your own block element to keep the markup you wrote, or use editable="single-line" if it is meant to be one line.`,s,a)}})};typeof this._squire.modifyDocument=="function"?this._squire.modifyDocument(o):o(),r&&(Kr(this.element,i,r),Qt(this._squire,i),this.savedSelection=ii(i))}isEditingKey(t){return["Backspace","Delete","Enter"].includes(t.key)?!0:t.key==="Tab"?this.caretIsInList():t.key.length!==1?!1:!t.ctrlKey&&!t.metaKey&&!t.altKey?!0:t.ctrlKey&&!t.metaKey&&!t.altKey&&this._appleDeleteKeys.has(t.key.toLowerCase())}caretIsInList(){let n=this._squire?.getSelection()?.startContainer;if(!n)return!1;let i=n.nodeType===1?n:n.parentElement;return!!(i&&this.element.contains(i)&&i.closest("ul, ol"))}runControl(t){if(!this._squire||typeof t.run!="function"||t.isDisabled?.(this))return;this.restoreSelection(),t.mutates!==!1&&this.ensureRootIsEditable();let n=t.run(this);this.element.querySelectorAll("pre:not([data-richclay-pre])").forEach(i=>{this._authoredPres.has(i)||i.setAttribute("data-richclay-pre","")}),t.mutates!==!1&&(this.ensureRootIsEditable(),this.anchorSelectionInBlock()),this.saveSelection(),this.toolbar?.update(),this.updatePlaceholder(),this.announceControl(t),n!==bo&&this.focus(),this.warnOnBlockInInlineRegion()}anchorSelectionInBlock(){let t=rt(this._squire);if(!t?.collapsed||t.startContainer!==this.element)return;let n=Array.from(this.element.childNodes),i=t.startOffset>=n.length,r=i?n.filter(it).pop():n.slice(t.startOffset).find(it)||n.slice(0,t.startOffset).filter(it).pop();if(!r)return;let o=St(r,!i);t.setStart(o,i?Wt(o):0),t.collapse(!0),Qt(this._squire,t)}selectionHasFormat(t){if(!t||!this._squire?.hasFormat)return!1;try{return this._squire.hasFormat(t)}catch{return!1}}pathHas(t){let n=rt(this._squire);if(!n)return!1;let i=t.toLowerCase(),r=Eo(this.element,n.startContainer,n.startOffset,!0,i);return!!r&&r===Eo(this.element,n.endContainer,n.endOffset,!1,i)}blocksStayOut(){return this.options.singleLine||Vt(this.element)||Pr(this.element)}warnOnBlockInInlineRegion(){if(this._warnedInlineBlock||!jt(this.element)||!Yt(this.element))return;this._warnedInlineBlock=!0;let t=this.element.nodeName.toLowerCase();console.warn(`richclay: a block element inside <${t} editable> is not valid HTML. It stays where it is and saves correctly, but a validator will flag it. Put the editable attribute on a block element if you want blocks here.`,this.element)}toggleFormat(t,n,i){return this.selectionHasFormat(t)?this._squire[i]():this._squire[n]()}toggleList(t){return this.pathHas(t)?this._squire.removeList():t==="UL"?this._squire.makeUnorderedList():this._squire.makeOrderedList()}indent(){return this.pathHas("UL")||this.pathHas("OL")?this._squire.increaseListLevel():this._squire.increaseQuoteLevel()}outdent(){return this.pathHas("UL")||this.pathHas("OL")?this._squire.decreaseListLevel():this._squire.decreaseQuoteLevel()}setBlockType(t){let n=t.toUpperCase();return n==="BLOCKQUOTE"?this._squire.increaseQuoteLevel():this._squire.modifyBlocks(i=>{let r=this.element.ownerDocument,o=r.createDocumentFragment();return Array.from(i.childNodes).forEach(s=>{if(s.nodeType!==1){o.appendChild(s);return}if(s.nodeName===n){o.appendChild(s);return}let a=r.createElement(n);for(;s.firstChild;)a.appendChild(s.firstChild);o.appendChild(a)}),o})}openLinkDialog(){this.saveSelection(),this.closeLinkDialog();let t=this.element.ownerDocument,n=this.currentLinkHref(),i=t.createElement("form"),r=`richclay-link-label-${++To}`;i.className="richclay-dialog",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-labelledby",r),i.setAttribute("data-richclay-dialog",""),ye(i),i.innerHTML=`
19
+ `),o.nextSibling||r.appendChild(T("BR")),o.length===f+1?t.setStartAfter(o):t.setStart(o,f+1)),t.collapse(!0),this.setSelection(t),this._updatePath(t,!0),this._docWasChanged(),this}if(!i||e||/^T[HD]$/.test(i.nodeName))return Vi(t,"A",n),Te(t,T("BR")),t.collapse(!1),this.setSelection(t),this._updatePath(t,!0),this;if((r=L(i,n,"LI"))&&(i=r),Dn(i)){if(L(i,n,"UL")||L(i,n,"OL"))return this.decreaseListLevel(t),this;if(L(i,n,"BLOCKQUOTE"))return this.replaceWithBlankLine(t),this}o=t.startContainer;let a=t.startOffset,l=this.tagAfterSplit[i.nodeName];s=se(o,a,i.parentNode,this._root);let u=this._config,d=null;for(l||(l=u.blockTag,d=u.blockAttributes),wn(s,l,d)||(i=T(l,d),s.dir&&(i.dir=s.dir),j(s,i),i.appendChild(D(s)),s=i),Bt(i),On(i),z(i);s instanceof Element;){let f=s.firstChild,p;if(s.nodeName==="A"&&(!s.textContent||s.textContent==="\u200B")){f=document.createTextNode(""),j(s,f),s=f;break}for(;f&&f instanceof Text&&!f.data&&(p=f.nextSibling,!(!p||p.nodeName==="BR"));)H(f),f=p;if(!f||f.nodeName==="BR"||f instanceof Text)break;s=f}return t=Be(s,0),this.setSelection(t),this._updatePath(t,!0),this}forEachBlock(e,t,n){n||(n=this.getSelection()),t&&this.saveUndoState(n);let i=this._root,r=ie(n,i),o=He(n,i);if(r&&o)do if(e(r)||r===o)break;while(r=Ee(r,i));return t&&(this.setSelection(n),this._updatePath(n,!0)),this}modifyBlocks(e,t){t||(t=this.getSelection()),this._recordUndoState(t,this._isInUndoState);let n=this._root;Qi(t,n),Fe(t,n,n,n);let i=dr(t,n,n);if(!t.collapsed){let r=t.endContainer;if(r===n)t.collapse(!1);else{for(;r.parentNode!==n;)r=r.parentNode;t.setStartBefore(r),t.collapse(!0)}}return Te(t,e.call(this,i)),t.endOffset<t.endContainer.childNodes.length&&_e(t.endContainer.childNodes[t.endOffset],n),_e(t.startContainer.childNodes[t.startOffset],n),this._getRangeAndRemoveBookmark(t),this.setSelection(t),this._updatePath(t,!0),this}setTextAlignment(e){return this.forEachBlock(t=>{let n=t.className.split(/\s+/).filter(i=>!!i&&!/^align/.test(i)).join(" ");e?(t.className=n+" align-"+e,t.style.textAlign=e):(t.className=n,t.style.textAlign="")},!0),this.focus()}setTextDirection(e){return this.forEachBlock(t=>{e?t.dir=e:t.removeAttribute("dir")},!0),this.focus()}_getListSelection(e,t){let n=e.commonAncestorContainer,i=e.startContainer,r=e.endContainer;for(;n&&n!==t&&!/^[OU]L$/.test(n.nodeName);)n=n.parentNode;if(!n||n===t)return null;for(i===n&&(i=i.childNodes[e.startOffset]),r===n&&(r=r.childNodes[e.endOffset]);i&&i.parentNode!==n;)i=i.parentNode;for(;r&&r.parentNode!==n;)r=r.parentNode;return[n,i,r]}increaseListLevel(e){e||(e=this.getSelection());let t=this._root,n=this._getListSelection(e,t);if(!n)return this.focus();let[i,r,o]=n;if(!r||r===i.firstChild)return this.focus();this._recordUndoState(e,this._isInUndoState);let s=i.nodeName,a=r.previousSibling,l,u;a.nodeName!==s&&(l=this._config.tagAttributes[s.toLowerCase()],a=T(s,l),i.insertBefore(a,r));do u=r===o?null:r.nextSibling,a.appendChild(r);while(r=u);return u=a.nextSibling,u&&_e(u,t),this._getRangeAndRemoveBookmark(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}decreaseListLevel(e){e||(e=this.getSelection());let t=this._root,n=this._getListSelection(e,t);if(!n)return this.focus();let[i,r,o]=n;r||(r=i.firstChild),o||(o=i.lastChild),this._recordUndoState(e,this._isInUndoState);let s,a=null;if(r){let l=i.parentNode;if(a=o.nextSibling?se(i,o.nextSibling,l,t):i.nextSibling,l!==t&&l.nodeName==="LI"){for(l=l.parentNode;a;)s=a.nextSibling,o.appendChild(a),a=s;a=i.parentNode.nextSibling}let u=!/^[OU]L$/.test(l.nodeName);do s=r===o?null:r.nextSibling,i.removeChild(r),u&&r.nodeName==="LI"&&(r=this.createDefaultBlock([D(r)])),l.insertBefore(r,a);while(r=s)}return i.firstChild||H(i),a&&_e(a,t),this._getRangeAndRemoveBookmark(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}_makeList(e,t){let n=qt(e,this._root),i=this._config.tagAttributes,r=i[t.toLowerCase()],o=i.li,s;for(;s=n.nextNode();)if(s.parentNode instanceof HTMLLIElement&&(s=s.parentNode,n.currentNode=s.lastChild),s instanceof HTMLLIElement){s=s.parentNode;let a=s.nodeName;a!==t&&/^[OU]L$/.test(a)&&j(s,T(t,r,[D(s)]))}else{let a=T("LI",o);s.dir&&(a.dir=s.dir);let l=s.previousSibling;l&&l.nodeName===t?(l.appendChild(a),H(s)):j(s,T(t,r,[a])),a.appendChild(D(s)),n.currentNode=a}return e}makeUnorderedList(){return this.modifyBlocks(e=>this._makeList(e,"UL")),this.focus()}makeOrderedList(){return this.modifyBlocks(e=>this._makeList(e,"OL")),this.focus()}removeList(){return this.modifyBlocks(e=>{let t=e.querySelectorAll("UL, OL"),n=e.querySelectorAll("LI"),i=this._root;for(let r=0,o=t.length;r<o;r+=1){let s=t[r],a=D(s);pe(a,i),j(s,a)}for(let r=0,o=n.length;r<o;r+=1){let s=n[r];we(s)?j(s,this.createDefaultBlock([D(s)])):(pe(s,i),j(s,D(s)))}return e}),this.focus()}increaseQuoteLevel(e){return this.modifyBlocks(t=>T("BLOCKQUOTE",this._config.tagAttributes.blockquote,[t]),e),this.focus()}decreaseQuoteLevel(e){return this.modifyBlocks(t=>(Array.from(t.querySelectorAll("blockquote")).filter(n=>!L(n.parentNode,t,"BLOCKQUOTE")).forEach(n=>{j(n,D(n))}),t),e),this.focus()}removeQuote(e){return this.modifyBlocks(t=>(Array.from(t.querySelectorAll("blockquote")).forEach(n=>{j(n,D(n))}),t),e),this.focus()}replaceWithBlankLine(e){return this.modifyBlocks(()=>this.createDefaultBlock([T("INPUT",{id:this.startSelectionId,type:"hidden"}),T("INPUT",{id:this.endSelectionId,type:"hidden"})]),e),this.focus()}code(){let e=this.getSelection();return e.collapsed||Ze(e.commonAncestorContainer)?(this.modifyBlocks(t=>{let n=this._root,i=document.createDocumentFragment(),r=qt(t,n),o;for(;o=r.nextNode();){let a=o.querySelectorAll("BR"),l=[],u=a.length;for(let d=0;d<u;d+=1)l[d]=$t(a[d],!1);for(;u--;){let d=a[u];l[u]?j(d,document.createTextNode(`
20
+ `)):H(d)}for(a=o.querySelectorAll("CODE"),u=a.length;u--;)j(a[u],D(a[u]));i.childNodes.length&&i.appendChild(document.createTextNode(`
21
+ `)),i.appendChild(D(o))}let s=new ne(i,4);for(;o=s.nextNode();)o.data=o.data.replace(/ /g," ");return i.normalize(),z(T("PRE",this._config.tagAttributes.pre,[i]))},e),this.focus()):this.changeFormat({tag:"CODE",attributes:this._config.tagAttributes.code},null,e),this}removeCode(){let e=this.getSelection(),t=e.commonAncestorContainer;return L(t,this._root,"PRE")?(this.modifyBlocks(n=>{let i=this._root,r=n.querySelectorAll("PRE"),o=r.length;for(;o--;){let s=r[o],a=new ne(s,4),l;for(;l=a.nextNode();){let u=l.data;u=u.replace(/ (?= )/g,"\xA0");let d=document.createDocumentFragment(),f;for(;(f=u.indexOf(`
22
+ `))>-1;)d.appendChild(document.createTextNode(u.slice(0,f))),d.appendChild(T("BR")),u=u.slice(f+1);l.parentNode.insertBefore(d,l),l.data=u}pe(s,i),j(s,D(s))}return n},e),this.focus()):this.changeFormat(null,{tag:"CODE"},e),this}toggleCode(){return this.hasFormat("PRE")||this.hasFormat("CODE")?this.removeCode():this.code(),this}_removeFormatting(e,t){for(let n=e.firstChild,i;n;n=i){if(i=n.nextSibling,x(n)){if(n instanceof Text||n.nodeName==="BR"||n.nodeName==="IMG"){t.appendChild(n);continue}}else if(we(n)){t.appendChild(this.createDefaultBlock([this._removeFormatting(n,document.createDocumentFragment())]));continue}this._removeFormatting(n,t)}return t}removeAllFormatting(e){if(e||(e=this.getSelection()),e.collapsed)return this.focus();let t=this._root,n=e.commonAncestorContainer;for(;n&&n!==t&&!we(n);)n=n.parentNode;if(n||(Qi(e,t),n=t),n instanceof Text)return this.focus();this.saveUndoState(e),Fe(e,n,n,t);let i=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,a=document.createDocumentFragment(),l=document.createDocumentFragment(),u=se(o,s,n,t),d=se(i,r,n,t),f;for(;d!==u;)f=d.nextSibling,a.appendChild(d),d=f;if(this._removeFormatting(a,l),l.normalize(),d=l.firstChild,f=l.lastChild,d){n.insertBefore(l,u);let p=Array.from(n.childNodes);r=p.indexOf(d),s=f?p.indexOf(f)+1:0}else u&&(r=Array.from(n.childNodes).indexOf(u),s=r);return e.setStart(n,r),e.setEnd(n,s),Qe(n,e),V(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}},yr=Qs;function br(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function Zs(e){if(Array.isArray(e))return e}function Js(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,s,a=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);l=!0);}catch(d){u=!0,r=d}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw r}}return a}}function ea(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
23
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ta(e,t){return Zs(e)||Js(e,t)||na(e,t)||ea()}function na(e,t){if(e){if(typeof e=="string")return br(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?br(e,t):void 0}}var kr=Object.entries,Tr=Object.setPrototypeOf,ia=Object.isFrozen,ra=Object.getPrototypeOf,oa=Object.getOwnPropertyDescriptor,G=Object.freeze,K=Object.seal,tt=Object.create,Dr=typeof Reflect<"u"&&Reflect,qn=Dr.apply,$n=Dr.construct;G||(G=function(t){return t});K||(K=function(t){return t});qn||(qn=function(t,n){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return t.apply(n,r)});$n||($n=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return new t(...i)});var gt=F(Array.prototype.forEach),sa=F(Array.prototype.lastIndexOf),_r=F(Array.prototype.pop),et=F(Array.prototype.push),aa=F(Array.prototype.splice),ke=Array.isArray,Tt=F(String.prototype.toLowerCase),Bn=F(String.prototype.toString),Er=F(String.prototype.match),yt=F(String.prototype.replace),Sr=F(String.prototype.indexOf),la=F(String.prototype.trim),ca=F(Number.prototype.toString),ua=F(Boolean.prototype.toString),Ar=typeof BigInt>"u"?null:F(BigInt.prototype.toString),vr=typeof Symbol>"u"?null:F(Symbol.prototype.toString),q=F(Object.prototype.hasOwnProperty),bt=F(Object.prototype.toString),W=F(RegExp.prototype.test),$e=da(TypeError);function F(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return qn(e,t,i)}}function da(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return $n(e,n)}}function A(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tt;if(Tr&&Tr(e,null),!ke(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){let o=n(r);o!==r&&(ia(t)||(t[i]=o),r=o)}e[r]=!0}return e}function ha(e){for(let t=0;t<e.length;t++)q(e,t)||(e[t]=null);return e}function ee(e){let t=tt(null);for(let i of kr(e)){var n=ta(i,2);let r=n[0],o=n[1];q(e,r)&&(ke(o)?t[r]=ha(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=ee(o):t[r]=o)}return t}function fa(e){switch(typeof e){case"string":return e;case"number":return ca(e);case"boolean":return ua(e);case"bigint":return Ar?Ar(e):"0";case"symbol":return vr?vr(e):"Symbol()";case"undefined":return bt(e);case"function":case"object":{if(e===null)return bt(e);let t=e,n=ge(t,"toString");if(typeof n=="function"){let i=n(t);return typeof i=="string"?i:bt(i)}return bt(e)}default:return bt(e)}}function ge(e,t){for(;e!==null;){let i=oa(e,t);if(i){if(i.get)return F(i.get);if(typeof i.value=="function")return F(i.value)}e=ra(e)}function n(){return null}return n}function pa(e){try{return W(e,""),!0}catch{return!1}}var Cr=G(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Fn=G(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Un=G(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ma=G(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Hn=G(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ga=G(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),xr=G(["#text"]),Nr=G(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),zn=G(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Lr=G(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wt=G(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ya=K(/{{[\w\W]*|^[\w\W]*}}/g),ba=K(/<%[\w\W]*|^[\w\W]*%>/g),Ta=K(/\${[\w\W]*/g),_a=K(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ea=K(/^aria-[\-\w]+$/),wr=K(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Sa=K(/^(?:\w+script|data):/i),Aa=K(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),va=K(/^html$/i),Ca=K(/^[a-z][.\w]*(-[.\w]+)+$/i),Rr=K(/<[/\w!]/g),xa=K(/<[/\w]/g),Na=K(/<\/no(script|embed|frames)/i),La=K(/\/>/i),me={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},wa=function(){return typeof window>"u"?null:window},Ra=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(i=n.getAttribute(r));let o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Or=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Oe=function(t,n,i,r){return q(t,n)&&ke(t[n])?A(r.base?ee(r.base):{},t[n],r.transform):i};function Ir(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:wa(),t=g=>Ir(g);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==me.document||!e.Element)return t.isSupported=!1,t;let n=e.document,i=n,r=i.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,s=e.Node,a=e.Element,l=e.NodeFilter,u=e.NamedNodeMap;u===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let d=e.DOMParser,f=e.trustedTypes,p=a.prototype,y=ge(p,"cloneNode"),E=ge(p,"remove"),N=ge(p,"nextSibling"),C=ge(p,"childNodes"),M=ge(p,"parentNode"),$=ge(p,"shadowRoot"),le=ge(p,"attributes"),Q=s&&s.prototype?ge(s.prototype,"nodeType"):null,ve=s&&s.prototype?ge(s.prototype,"nodeName"):null;if(typeof o=="function"){let g=n.createElement("template");g.content&&g.content.ownerDocument&&(n=g.content.ownerDocument)}let te,Ie="",on,Ti=!1,at=0,_i=function(){if(at>0)throw $e('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ge=function(c){_i(),at++;try{return te.createHTML(c)}finally{at--}},Po=function(c){_i(),at++;try{return te.createScriptURL(c)}finally{at--}},Bo=function(){return Ti||(on=Ra(f,r),Ti=!0),on},wt=n,sn=wt.implementation,Ei=wt.createNodeIterator,Fo=wt.createDocumentFragment,Uo=wt.getElementsByTagName,Ho=i.importNode,I=Or();t.isSupported=typeof kr=="function"&&typeof M=="function"&&sn&&sn.createHTMLDocument!==void 0;let zo=ya,qo=ba,$o=Ta,Wo=_a,Go=Ea,Ko=Sa,Si=Aa,jo=Ca,Ai=wr,w=null,vi=A({},[...Cr,...Fn,...Un,...Hn,...xr]),R=null,Ci=A({},[...Nr,...zn,...Lr,...Wt]),O=Object.seal(tt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),lt=null,xi=null,Ce=Object.seal(tt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ni=!0,an=!0,Li=!1,wi=!0,xe=!1,ct=!0,Me=!1,ln=!1,cn=null,un=null,dn=!1,Ke=!1,Rt=!1,Ot=!1,Ri=!0,Oi=!1,ki="user-content-",hn=!0,fn=!1,je={},de=null,pn=A({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Di=null,Ii=A({},["audio","video","img","source","image","track"]),mn=null,Mi=A({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",Dt="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml",Ve=he,gn=!1,yn=null,Vo=A({},[kt,Dt,he],Bn),Pi=G(["mi","mo","mn","ms","mtext"]),bn=A({},Pi),Bi=G(["annotation-xml"]),Tn=A({},Bi),Yo=A({},["title","style","font","a","script"]),ut=null,Xo=["application/xhtml+xml","text/html"],Qo="text/html",k=null,Ye=null,Zo=n.createElement("form"),Fi=function(c){return c instanceof RegExp||c instanceof Function},_n=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ye&&Ye===c)return;(!c||typeof c!="object")&&(c={}),c=ee(c),ut=Xo.indexOf(c.PARSER_MEDIA_TYPE)===-1?Qo:c.PARSER_MEDIA_TYPE,k=ut==="application/xhtml+xml"?Bn:Tt,w=Oe(c,"ALLOWED_TAGS",vi,{transform:k}),R=Oe(c,"ALLOWED_ATTR",Ci,{transform:k}),yn=Oe(c,"ALLOWED_NAMESPACES",Vo,{transform:Bn}),mn=Oe(c,"ADD_URI_SAFE_ATTR",Mi,{transform:k,base:Mi}),Di=Oe(c,"ADD_DATA_URI_TAGS",Ii,{transform:k,base:Ii}),de=Oe(c,"FORBID_CONTENTS",pn,{transform:k}),lt=Oe(c,"FORBID_TAGS",ee({}),{transform:k}),xi=Oe(c,"FORBID_ATTR",ee({}),{transform:k}),je=q(c,"USE_PROFILES")?c.USE_PROFILES&&typeof c.USE_PROFILES=="object"?ee(c.USE_PROFILES):c.USE_PROFILES:!1,Ni=c.ALLOW_ARIA_ATTR!==!1,an=c.ALLOW_DATA_ATTR!==!1,Li=c.ALLOW_UNKNOWN_PROTOCOLS||!1,wi=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xe=c.SAFE_FOR_TEMPLATES||!1,ct=c.SAFE_FOR_XML!==!1,Me=c.WHOLE_DOCUMENT||!1,Ke=c.RETURN_DOM||!1,Rt=c.RETURN_DOM_FRAGMENT||!1,Ot=c.RETURN_TRUSTED_TYPE||!1,dn=c.FORCE_BODY||!1,Ri=c.SANITIZE_DOM!==!1,Oi=c.SANITIZE_NAMED_PROPS||!1,hn=c.KEEP_CONTENT!==!1,fn=c.IN_PLACE||!1,Ai=pa(c.ALLOWED_URI_REGEXP)?c.ALLOWED_URI_REGEXP:wr,Ve=typeof c.NAMESPACE=="string"?c.NAMESPACE:he,bn=q(c,"MATHML_TEXT_INTEGRATION_POINTS")&&c.MATHML_TEXT_INTEGRATION_POINTS&&typeof c.MATHML_TEXT_INTEGRATION_POINTS=="object"?ee(c.MATHML_TEXT_INTEGRATION_POINTS):A({},Pi),Tn=q(c,"HTML_INTEGRATION_POINTS")&&c.HTML_INTEGRATION_POINTS&&typeof c.HTML_INTEGRATION_POINTS=="object"?ee(c.HTML_INTEGRATION_POINTS):A({},Bi);let h=q(c,"CUSTOM_ELEMENT_HANDLING")&&c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING=="object"?ee(c.CUSTOM_ELEMENT_HANDLING):tt(null);if(O=tt(null),q(h,"tagNameCheck")&&Fi(h.tagNameCheck)&&(O.tagNameCheck=h.tagNameCheck),q(h,"attributeNameCheck")&&Fi(h.attributeNameCheck)&&(O.attributeNameCheck=h.attributeNameCheck),q(h,"allowCustomizedBuiltInElements")&&typeof h.allowCustomizedBuiltInElements=="boolean"&&(O.allowCustomizedBuiltInElements=h.allowCustomizedBuiltInElements),K(O),xe&&(an=!1),Rt&&(Ke=!0),je&&(w=A({},xr),R=tt(null),je.html===!0&&(A(w,Cr),A(R,Nr)),je.svg===!0&&(A(w,Fn),A(R,zn),A(R,Wt)),je.svgFilters===!0&&(A(w,Un),A(R,zn),A(R,Wt)),je.mathMl===!0&&(A(w,Hn),A(R,Lr),A(R,Wt))),Ce.tagCheck=null,Ce.attributeCheck=null,q(c,"ADD_TAGS")&&(typeof c.ADD_TAGS=="function"?Ce.tagCheck=c.ADD_TAGS:ke(c.ADD_TAGS)&&(w===vi&&(w=ee(w)),A(w,c.ADD_TAGS,k))),q(c,"ADD_ATTR")&&(typeof c.ADD_ATTR=="function"?Ce.attributeCheck=c.ADD_ATTR:ke(c.ADD_ATTR)&&(R===Ci&&(R=ee(R)),A(R,c.ADD_ATTR,k))),q(c,"ADD_URI_SAFE_ATTR")&&ke(c.ADD_URI_SAFE_ATTR)&&A(mn,c.ADD_URI_SAFE_ATTR,k),q(c,"FORBID_CONTENTS")&&ke(c.FORBID_CONTENTS)&&(de===pn&&(de=ee(de)),A(de,c.FORBID_CONTENTS,k)),q(c,"ADD_FORBID_CONTENTS")&&ke(c.ADD_FORBID_CONTENTS)&&(de===pn&&(de=ee(de)),A(de,c.ADD_FORBID_CONTENTS,k)),hn&&(w["#text"]=!0),Me&&A(w,["html","head","body"]),w.table&&(A(w,["tbody"]),delete lt.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw $e('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw $e('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let m=te;te=c.TRUSTED_TYPES_POLICY;try{Ie=Ge("")}catch(b){throw te=m,b}}else c.TRUSTED_TYPES_POLICY===null?(te=void 0,Ie=""):(te===void 0&&(te=Bo()),te&&typeof Ie=="string"&&(Ie=Ge("")));G&&G(c),Ye=c},Ui=A({},[...Fn,...Un,...ma]),Hi=A({},[...Hn,...ga]),Jo=function(c,h,m){return h.namespaceURI===he?c==="svg":h.namespaceURI===kt?c==="svg"&&(m==="annotation-xml"||bn[m]):!!Ui[c]},es=function(c,h,m){return h.namespaceURI===he?c==="math":h.namespaceURI===Dt?c==="math"&&Tn[m]:!!Hi[c]},ts=function(c,h,m){return h.namespaceURI===Dt&&!Tn[m]||h.namespaceURI===kt&&!bn[m]?!1:!Hi[c]&&(Yo[c]||!Ui[c])},ns=function(c){let h=M(c);(!h||!h.tagName)&&(h={namespaceURI:Ve,tagName:"template"});let m=Tt(c.tagName),b=Tt(h.tagName);return yn[c.namespaceURI]?c.namespaceURI===Dt?Jo(m,h,b):c.namespaceURI===kt?es(m,h,b):c.namespaceURI===he?ts(m,h,b):!!(ut==="application/xhtml+xml"&&yn[c.namespaceURI]):!1},Ne=function(c){et(t.removed,{element:c});try{M(c).removeChild(c)}catch{if(E(c),!M(c))throw $e("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},zi=function(c){let h=C(c);if(h){let b=[];gt(h,S=>{et(b,S)}),gt(b,S=>{try{E(S)}catch{}})}let m=le(c);if(m)for(let b=m.length-1;b>=0;--b){let S=m[b],v=S&&S.name;if(typeof v=="string")try{c.removeAttribute(v)}catch{}}},Pe=function(c,h){try{et(t.removed,{attribute:h.getAttributeNode(c),from:h})}catch{et(t.removed,{attribute:null,from:h})}if(h.removeAttribute(c),c==="is")if(Ke||Rt)try{Ne(h)}catch{}else try{h.setAttribute(c,"")}catch{}},is=function(c){let h=le(c);if(h)for(let m=h.length-1;m>=0;--m){let b=h[m],S=b&&b.name;if(!(typeof S!="string"||R[k(S)]))try{c.removeAttribute(S)}catch{}}},rs=function(c){let h=[c];for(;h.length>0;){let m=h.pop();(Q?Q(m):m.nodeType)===me.element&&is(m);let S=C(m);if(S)for(let v=S.length-1;v>=0;--v)h.push(S[v])}},qi=function(c){let h=null,m=null;if(dn)c="<remove></remove>"+c;else{let v=Er(c,/^[\r\n\t ]+/);m=v&&v[0]}ut==="application/xhtml+xml"&&Ve===he&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");let b=te?Ge(c):c;if(Ve===he)try{h=new d().parseFromString(b,ut)}catch{}if(!h||!h.documentElement){h=sn.createDocument(Ve,"template",null);try{h.documentElement.innerHTML=gn?Ie:b}catch{}}let S=h.body||h.documentElement;return c&&m&&S.insertBefore(n.createTextNode(m),S.childNodes[0]||null),Ve===he?Uo.call(h,Me?"html":"body")[0]:Me?h.documentElement:S},$i=function(c){return Ei.call(c.ownerDocument||c,c,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},It=function(c){return c=yt(c,zo," "),c=yt(c,qo," "),c=yt(c,$o," "),c},En=function(c){var h;c.normalize();let m=Ei.call(c.ownerDocument||c,c,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),b=m.nextNode();for(;b;)b.data=It(b.data),b=m.nextNode();let S=(h=c.querySelectorAll)===null||h===void 0?void 0:h.call(c,"template");S&&gt(S,v=>{Xe(v.content)&&En(v.content)})},Mt=function(c){let h=ve?ve(c):null;return typeof h!="string"||k(h)!=="form"?!1:typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||c.attributes!==le(c)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function"||c.nodeType!==Q(c)||c.childNodes!==C(c)},Xe=function(c){if(!Q||typeof c!="object"||c===null)return!1;try{return Q(c)===me.documentFragment}catch{return!1}},dt=function(c){if(!Q||typeof c!="object"||c===null)return!1;try{return typeof Q(c)=="number"}catch{return!1}};function be(g,c,h){g.length!==0&&gt(g,m=>{m.call(t,c,h,Ye)})}let os=function(c,h){return!!(ct&&c.hasChildNodes()&&!dt(c.firstElementChild)&&W(Rr,c.textContent)&&W(Rr,c.innerHTML)||ct&&c.namespaceURI===he&&h==="style"&&dt(c.firstElementChild)||c.nodeType===me.processingInstruction||ct&&c.nodeType===me.comment&&W(xa,c.data))},ss=function(c,h){if(!lt[h]&&Ki(h)&&(O.tagNameCheck instanceof RegExp&&W(O.tagNameCheck,h)||O.tagNameCheck instanceof Function&&O.tagNameCheck(h)))return!1;if(hn&&!de[h]){let m=M(c),b=C(c);if(b&&m){let S=b.length;for(let v=S-1;v>=0;--v){let U=fn?b[v]:y(b[v],!0);m.insertBefore(U,N(c))}}}return Ne(c),!0},Wi=function(c){if(be(I.beforeSanitizeElements,c,null),Mt(c))return Ne(c),!0;let h=k(ve?ve(c):c.nodeName);if(be(I.uponSanitizeElement,c,{tagName:h,allowedTags:w}),os(c,h))return Ne(c),!0;if(lt[h]||!(Ce.tagCheck instanceof Function&&Ce.tagCheck(h))&&!w[h])return ss(c,h);if((Q?Q(c):c.nodeType)===me.element&&!ns(c)||(h==="noscript"||h==="noembed"||h==="noframes")&&W(Na,c.innerHTML))return Ne(c),!0;if(xe&&c.nodeType===me.text){let b=It(c.textContent);c.textContent!==b&&(et(t.removed,{element:c.cloneNode()}),c.textContent=b)}return be(I.afterSanitizeElements,c,null),!1},Gi=function(c,h,m){if(xi[h]||Ri&&(h==="id"||h==="name")&&(m in n||m in Zo))return!1;let b=R[h]||Ce.attributeCheck instanceof Function&&Ce.attributeCheck(h,c);if(!(an&&W(Wo,h))){if(!(Ni&&W(Go,h))){if(b){if(!mn[h]){if(!W(Ai,yt(m,Si,""))){if(!((h==="src"||h==="xlink:href"||h==="href")&&c!=="script"&&Sr(m,"data:")===0&&Di[c])){if(!(Li&&!W(Ko,yt(m,Si,"")))){if(m)return!1}}}}}else if(!(Ki(c)&&(O.tagNameCheck instanceof RegExp&&W(O.tagNameCheck,c)||O.tagNameCheck instanceof Function&&O.tagNameCheck(c))&&(O.attributeNameCheck instanceof RegExp&&W(O.attributeNameCheck,h)||O.attributeNameCheck instanceof Function&&O.attributeNameCheck(h,c))||h==="is"&&O.allowCustomizedBuiltInElements&&(O.tagNameCheck instanceof RegExp&&W(O.tagNameCheck,m)||O.tagNameCheck instanceof Function&&O.tagNameCheck(m))))return!1}}return!0},as=A({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ki=function(c){return!as[Tt(c)]&&W(jo,c)},ls=function(c,h,m,b){if(te&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!m)switch(f.getAttributeType(c,h)){case"TrustedHTML":return Ge(b);case"TrustedScriptURL":return Po(b)}return b},cs=function(c,h,m,b){try{m?c.setAttributeNS(m,h,b):c.setAttribute(h,b),Mt(c)?Ne(c):_r(t.removed)}catch{Pe(h,c)}},ji=function(c){be(I.beforeSanitizeAttributes,c,null);let h=c.attributes;if(!h||Mt(c))return;let m={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},b=h.length,S=k(c.nodeName);for(;b--;){let v=h[b],U=v.name,P=v.namespaceURI,oe=v.value,ce=k(U),An=oe,Z=U==="value"?An:la(An);if(m.attrName=ce,m.attrValue=Z,m.keepAttr=!0,m.forceKeepAttr=void 0,be(I.uponSanitizeAttribute,c,m),Z=m.attrValue,Oi&&(ce==="id"||ce==="name")&&Sr(Z,ki)!==0&&(Pe(U,c),Z=ki+Z),ct&&W(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Z)){Pe(U,c);continue}if(ce==="attributename"&&Er(Z,"href")){Pe(U,c);continue}if(!m.forceKeepAttr){if(!m.keepAttr){Pe(U,c);continue}if(!wi&&W(La,Z)){Pe(U,c);continue}if(xe&&(Z=It(Z)),!Gi(S,ce,Z)){Pe(U,c);continue}Z=ls(S,ce,P,Z),Z!==An&&cs(c,U,P,Z)}}be(I.afterSanitizeAttributes,c,null)},Pt=function(c){let h=null,m=$i(c);for(be(I.beforeSanitizeShadowDOM,c,null);h=m.nextNode();)if(be(I.uponSanitizeShadowNode,h,null),Wi(h),ji(h),Xe(h.content)&&Pt(h.content),(Q?Q(h):h.nodeType)===me.element){let S=$(h);Xe(S)&&(Sn(S),Pt(S))}be(I.afterSanitizeShadowDOM,c,null)},Sn=function(c){let h=[{node:c,shadow:null}];for(;h.length>0;){let m=h.pop();if(m.shadow){Pt(m.shadow);continue}let b=m.node,v=(Q?Q(b):b.nodeType)===me.element,U=C(b);if(U)for(let P=U.length-1;P>=0;--P)h.push({node:U[P],shadow:null});if(v){let P=ve?ve(b):null;if(typeof P=="string"&&k(P)==="template"){let oe=b.content;Xe(oe)&&h.push({node:oe,shadow:null})}}if(v){let P=$(b);Xe(P)&&h.push({node:null,shadow:P},{node:P,shadow:null})}}};return t.sanitize=function(g){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=null,m=null,b=null,S=null;if(gn=!g,gn&&(g="<!-->"),typeof g!="string"&&!dt(g)&&(g=fa(g),typeof g!="string"))throw $e("dirty is not a string, aborting");if(!t.isSupported)return g;ln?(w=cn,R=un):_n(c),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(w=ee(w)),I.uponSanitizeAttribute.length>0&&(R=ee(R)),t.removed=[];let v=fn&&typeof g!="string"&&dt(g);if(v){let oe=ve?ve(g):g.nodeName;if(typeof oe=="string"){let ce=k(oe);if(!w[ce]||lt[ce])throw $e("root node is forbidden and cannot be sanitized in-place")}if(Mt(g))throw $e("root node is clobbered and cannot be sanitized in-place");try{Sn(g)}catch(ce){throw zi(g),ce}}else if(dt(g))h=qi("<!---->"),m=h.ownerDocument.importNode(g,!0),m.nodeType===me.element&&m.nodeName==="BODY"||m.nodeName==="HTML"?h=m:h.appendChild(m),Sn(m);else{if(!Ke&&!xe&&!Me&&g.indexOf("<")===-1)return te&&Ot?Ge(g):g;if(h=qi(g),!h)return Ke?null:Ot?Ie:""}h&&dn&&Ne(h.firstChild);let U=$i(v?g:h);try{for(;b=U.nextNode();)Wi(b),ji(b),Xe(b.content)&&Pt(b.content)}catch(oe){throw v&&zi(g),oe}if(v)return gt(t.removed,oe=>{oe.element&&rs(oe.element)}),xe&&En(g),g;if(Ke){if(xe&&En(h),Rt)for(S=Fo.call(h.ownerDocument);h.firstChild;)S.appendChild(h.firstChild);else S=h;return(R.shadowroot||R.shadowrootmode)&&(S=Ho.call(i,S,!0)),S}let P=Me?h.outerHTML:h.innerHTML;return Me&&w["!doctype"]&&h.ownerDocument&&h.ownerDocument.doctype&&h.ownerDocument.doctype.name&&W(va,h.ownerDocument.doctype.name)&&(P="<!DOCTYPE "+h.ownerDocument.doctype.name+`>
24
+ `+P),xe&&(P=It(P)),te&&Ot?Ge(P):P},t.setConfig=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_n(g),ln=!0,cn=w,un=R},t.clearConfig=function(){Ye=null,ln=!1,cn=null,un=null,te=on,Ie=""},t.isValidAttribute=function(g,c,h){Ye||_n({});let m=k(g),b=k(c);return Gi(m,b,h)},t.addHook=function(g,c){typeof c=="function"&&q(I,g)&&et(I[g],c)},t.removeHook=function(g,c){if(q(I,g)){if(c!==void 0){let h=sa(I[g],c);return h===-1?void 0:aa(I[g],h,1)[0]}return _r(I[g])}},t.removeHooks=function(g){q(I,g)&&(I[g]=[])},t.removeAllHooks=function(){I=Or()},t}var Mr=Ir();var _='stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"',Wn='stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"',_t='fill="currentColor"',Y=(e,t="0 0 18 18")=>`<svg viewBox="${t}" width="18" height="18" aria-hidden="true" focusable="false">${e}</svg>`,Pr=`<line ${_} x1="7" x2="11" y1="7" y2="11"/><path ${_} d="M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z"/><path ${_} d="M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z"/>`,X={bold:Y(`<path ${_} d="M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z"/><path ${_} d="M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z"/>`),italic:Y(`<line ${_} x1="7" x2="13" y1="4" y2="4"/><line ${_} x1="5" x2="11" y1="14" y2="14"/><line ${_} x1="8" x2="10" y1="14" y2="4"/>`),underline:Y(`<path ${_} d="M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3"/><rect ${_t} height="1" rx="0.5" ry="0.5" width="12" x="3" y="15"/>`),strike:Y(`<path ${_t} d="M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z"/><path ${_t} d="M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z"/><line x1="2" y1="9" x2="16" y2="9" stroke="currentColor" fill="none" stroke-linecap="round" stroke-width="1.5"/>`),link:Y(Pr),unlink:Y(`${Pr}<line class="richclay-cut" x1="2.5" y1="15.5" x2="15.5" y2="2.5" stroke-linecap="round" stroke-width="3.5"/><line x1="4.06" y1="13.94" x2="13.94" y2="4.06" stroke="currentColor" fill="none" stroke-linecap="round" stroke-width="1.5"/>`),ul:Y(`<line ${_} x1="6" x2="15" y1="4" y2="4"/><line ${_} x1="6" x2="15" y1="9" y2="9"/><line ${_} x1="6" x2="15" y1="14" y2="14"/><line ${_} x1="3" x2="3" y1="4" y2="4"/><line ${_} x1="3" x2="3" y1="9" y2="9"/><line ${_} x1="3" x2="3" y1="14" y2="14"/>`),ol:Y(`<line ${_} x1="7" x2="15" y1="4" y2="4"/><line ${_} x1="7" x2="15" y1="9" y2="9"/><line ${_} x1="7" x2="15" y1="14" y2="14"/><line ${Wn} x1="2.5" x2="4.5" y1="5.5" y2="5.5"/><path ${_t} d="M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z"/><path ${Wn} d="M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156"/><path ${Wn} d="M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109"/>`),quote:Y(`<path ${_} d="M10 10.8182L9 10.8182C8.80222 10.8182 8.60888 10.7649 8.44443 10.665C8.27998 10.5651 8.15181 10.4231 8.07612 10.257C8.00043 10.0909 7.98063 9.90808 8.01922 9.73174C8.0578 9.55539 8.15304 9.39341 8.29289 9.26627C8.43275 9.13913 8.61093 9.05255 8.80491 9.01747C8.99889 8.98239 9.19996 9.00039 9.38268 9.0692C9.56541 9.13801 9.72159 9.25453 9.83147 9.40403C9.94135 9.55353 10 9.72929 10 9.90909L10 12.1818C10 12.664 9.78929 13.1265 9.41421 13.4675C9.03914 13.8084 8.53043 14 8 14"/><path ${_} d="M16 10.8182L15 10.8182C14.8022 10.8182 14.6089 10.7649 14.4444 10.665C14.28 10.5651 14.1518 10.4231 14.0761 10.257C14.0004 10.0909 13.9806 9.90808 14.0192 9.73174C14.0578 9.55539 14.153 9.39341 14.2929 9.26627C14.4327 9.13913 14.6109 9.05255 14.8049 9.01747C14.9989 8.98239 15.2 9.00039 15.3827 9.0692C15.5654 9.13801 15.7216 9.25453 15.8315 9.40403C15.9414 9.55353 16 9.72929 16 9.90909L16 12.1818C16 12.664 15.7893 13.1265 15.4142 13.4675C15.0391 13.8084 14.5304 14 14 14"/>`,"2 2 20 20"),undo:Y(`<polyline ${_} points="6.5 4 3.5 7 6.5 10"/><path ${_} d="M3.5 7H10a3.5 3.5 0 0 1 0 7H7"/>`),redo:Y(`<polyline ${_} points="11.5 4 14.5 7 11.5 10"/><path ${_} d="M14.5 7H8a3.5 3.5 0 0 0 0 7h3"/>`),clear:Y(`<line ${_} x1="5" x2="13" y1="3" y2="3"/><line ${_} x1="6" x2="9.35" y1="12" y2="3"/><line ${_} x1="11" x2="15" y1="11" y2="15"/><line ${_} x1="15" x2="11" y1="11" y2="15"/><rect ${_t} height="1" rx="0.5" ry="0.5" width="7" x="2" y="14"/>`),code:Y(`<polyline ${_} points="5 7 3 9 5 11"/><polyline ${_} points="13 7 15 9 13 11"/><line ${_} x1="10" x2="8" y1="5" y2="13"/>`),indent:Y(`<line ${_} x1="3" x2="15" y1="4" y2="4"/><line ${_} x1="8" x2="15" y1="9" y2="9"/><line ${_} x1="3" x2="15" y1="14" y2="14"/><polyline ${_} points="3 7 5.5 9 3 11"/>`),outdent:Y(`<line ${_} x1="3" x2="15" y1="4" y2="4"/><line ${_} x1="8" x2="15" y1="9" y2="9"/><line ${_} x1="3" x2="15" y1="14" y2="14"/><polyline ${_} points="5.5 7 3 9 5.5 11"/>`),blocks:Y(`<line ${_} x1="3" x2="15" y1="4" y2="4"/><line ${_} x1="3" x2="15" y1="9" y2="9"/><line ${_} x1="3" x2="10" y1="14" y2="14"/>`)},Se=e=>e.blocksStayOut(),Oa=e=>!!e.element.closest("a"),Et={minimal:["bold","italic","link","unorderedList"],inline:["bold","italic","underline","strikethrough","code","link","unlink","undo","redo","clearFormatting"],standard:["blockMenu","bold","italic","underline","strikethrough","code","link","unlink","unorderedList","orderedList","quote","outdent","indent","undo","redo","clearFormatting"]};function Br(){return new Map(ka.map(e=>[e.id,e]))}function nt(e=globalThis){let t=e?.navigator;return t?/Mac|iPhone|iPad|iPod/.test(t.platform||t.userAgent||""):!1}function Fr(e,t=globalThis){return e?e.replace("Mod",nt(t)?"Cmd":"Ctrl"):""}var ka=[De("bold","Bold",X.bold,"Mod+B","inline",e=>e.toggleFormat("B","bold","removeBold")),De("italic","Italic",X.italic,"Mod+I","inline",e=>e.toggleFormat("I","italic","removeItalic")),De("underline","Underline",X.underline,"Mod+U","inline",e=>e.toggleFormat("U","underline","removeUnderline")),De("strikethrough","Strikethrough",X.strike,"Mod+Shift+7","inline",e=>e.toggleFormat("S","strikethrough","removeStrikethrough")),De("code","Code",X.code,null,"inline",e=>e.toggleCode(),e=>e.selectionHasFormat("CODE")||e.selectionHasFormat("PRE")),{id:"link",label:"Link",ariaLabel:"Insert or edit link",icon:X.link,group:"links",shortcut:"Mod+K",mutates:!1,isDisabled:Oa,run:e=>e.openLinkDialog(),isActive:e=>e.selectionHasFormat("A")},{id:"unlink",label:"Remove link",ariaLabel:"Remove link",icon:X.unlink,group:"links",run:e=>e.squire.removeLink()},De("unorderedList","Bulleted list",X.ul,"Mod+Shift+8","lists",e=>e.toggleList("UL"),e=>e.pathHas("UL"),Se),De("orderedList","Numbered list",X.ol,"Mod+Shift+9","lists",e=>e.toggleList("OL"),e=>e.pathHas("OL"),Se),De("quote","Quote",X.quote,null,"blocks",e=>e.pathHas("BLOCKQUOTE")?e.squire.decreaseQuoteLevel():e.squire.increaseQuoteLevel(),e=>e.pathHas("BLOCKQUOTE"),Se),{id:"outdent",label:"Outdent",ariaLabel:"Decrease indent",icon:X.outdent,group:"blocks",shortcut:"Mod+[",isDisabled:Se,run:e=>e.outdent()},{id:"indent",label:"Indent",ariaLabel:"Increase indent",icon:X.indent,group:"blocks",shortcut:"Mod+]",isDisabled:Se,run:e=>e.indent()},{id:"undo",label:"Undo",ariaLabel:"Undo",icon:X.undo,group:"history",shortcut:"Mod+Z",mutates:!1,run:e=>e.squire.undo()},{id:"redo",label:"Redo",ariaLabel:"Redo",icon:X.redo,group:"history",shortcut:"Mod+Shift+Z",mutates:!1,run:e=>e.squire.redo()},{id:"clearFormatting",label:"Clear formatting",ariaLabel:"Clear formatting",icon:X.clear,group:"cleanup",run:e=>e.squire.removeAllFormatting()},{id:"blockMenu",type:"menu",label:"Block style",ariaLabel:"Choose block style",icon:X.blocks,group:"blocks",isDisabled:Se,options:[Gt("Paragraph","P"),Gt("Heading 1","H1"),Gt("Heading 2","H2"),Gt("Heading 3","H3"),{label:"Quote",value:"BLOCKQUOTE",isDisabled:Se,run:e=>e.squire.increaseQuoteLevel(),isActive:e=>e.pathHas("BLOCKQUOTE")},{label:"Code block",value:"PRE",isDisabled:Se,run:e=>e.setBlockType("PRE"),isActive:e=>e.pathHas("PRE")}]}];function De(e,t,n,i,r,o,s=l=>l.selectionHasFormat(Da(e)),a){return{id:e,label:t,ariaLabel:t,icon:n,group:r,shortcut:i,isDisabled:a,run:o,isActive:s}}function Da(e){return{bold:"B",italic:"I",underline:"U",strikethrough:"S"}[e]}function Gt(e,t){return{label:e,value:t,isDisabled:Se,run:n=>n.setBlockType(t),isActive:n=>n.pathHas(t)}}var Kn=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,jt=/[^ \t\r\n]/;var Ia=new Set(["BR","HR","IFRAME","IMG","INPUT","WBR"]),jn=e=>e?.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]'),At=new Set(["svg","math"]);function Vt(e){let t=e.nodeType;return t===3||t===8?!0:t!==1?!1:At.has(e.nodeName)?!0:Kn.test(e.nodeName)?Array.from(e.childNodes).every(Vt):!1}function vt(e){return Array.from(e.childNodes).some(t=>!Vt(t))}var Gn=e=>e?.nodeType===1&&!At.has(e.nodeName)&&!Kn.test(e.nodeName);function Ct(e,t){let n=Array.from(e.childNodes),i=0;return n.forEach((r,o)=>{if(!(r.nodeType!==1||At.has(r.nodeName))&&(i+=Ct(r,t),!!Gn(r))){for(Gn(n[o-1])&&e.insertBefore(t(),r);r.firstChild;)e.insertBefore(r.firstChild,r);r.remove(),i+=1}}),i}var Vn=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","COLGROUP"]);function Yt(e){return!!e.closest?.("p")||Vn.has(e.nodeName)}var Ma=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","LABEL","LEGEND","LI","TD","TH","DT","DD","FIGCAPTION","SUMMARY","CAPTION"]);function qr(e){return Ma.has(e.nodeName)||Xt(e)}var $r=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),Pa=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","IFRAME","NOSCRIPT","XMP"]),Wr="http://www.w3.org/1999/xhtml";function Gr(e){return Vn.has(e.nodeName)||$r.has(e.nodeName)||Pa.has(e.nodeName)||e.nodeName==="TEMPLATE"||!!e.namespaceURI&&e.namespaceURI!==Wr}function Kr(e){return Vn.has(e.nodeName)?"a table element cannot be an editable region. Move the editable attribute to a <td>, a <th>, or an element inside one.":e.namespaceURI&&e.namespaceURI!==Wr?"an SVG or MathML element cannot be an editable region: an edit puts an HTML block inside it, and the next page load moves that text out of the graphic entirely. Put a <foreignObject> in the SVG and mark an HTML element inside it instead.":$r.has(e.nodeName)?"this element cannot contain anything, so there is nothing to edit. Move the editable attribute to an element that holds text.":e.nodeName==="TEMPLATE"?"a <template> keeps its content out of the document, so edits to it are never saved.":"this element treats its content as plain text, so any edit would be saved as visible markup rather than formatting."}function Xt(e){return e.nodeType===1&&!At.has(e.nodeName)&&Kn.test(e.nodeName)}function Qt(e){return Array.from(e.querySelectorAll("*")).some(Gn)}function jr(e,t={}){let{blockTag:n="DIV",wrapBareRoot:i=!1,onBareRootWrapped:r,blocksAllowed:o=!Yt(e)}=t;return Xr(e),o&&Ua(e,n,i,r),e}var Ba=e=>Vt(e)&&e.nodeType!==8&&!jn(e),Fa=e=>e.nodeType!==8&&!jn(e)&&!(e.nodeType===3&&!jt.test(e.nodeValue));function Vr(e,{wrapBareRoot:t=!1,blocksAllowed:n=!Yt(e)}={}){return n?vt(e)?Array.from(e.childNodes).some(Ba)||Yr(e):t:!1}function Yr(e){return Array.from(e.children).some(t=>vt(t)?!Yn(t)&&Array.from(t.childNodes).some(i=>i.nodeType===3&&!jt.test(i.nodeValue))||Yr(t):!1)}function Xr(e){vt(e)&&(Yn(e)||Array.from(e.childNodes).forEach(t=>{t.nodeType===3&&!jt.test(t.nodeValue)&&t.remove()}),Array.from(e.children).forEach(Xr))}function Ua(e,t,n,i){if(!vt(e)){if(!n)return;let s=e.ownerDocument.createElement(t);if(!Array.from(e.childNodes).some(Fa)){s.appendChild(e.ownerDocument.createElement("BR")),e.appendChild(s);return}for(;e.firstChild;)s.appendChild(e.firstChild);e.appendChild(s),i?.(e,s);return}let r=[],o=()=>{let s=r;if(r=[],!s.some(l=>l.nodeType!==8))return;let a=e.ownerDocument.createElement(t);e.insertBefore(a,s[0]),s.forEach(l=>a.appendChild(l))};Array.from(e.childNodes).forEach(s=>{jn(s)?o():Vt(s)?r.push(s):o()}),o()}function Yn(e){return e.nodeName==="PRE"}function Qr(e,t){return{start:Ur(e,t.startContainer,t.startOffset),end:Ur(e,t.endContainer,t.endOffset),collapsed:t.collapsed}}function Zr(e,t,n){zr(t,"setStart",e,n.start),n.collapsed?t.collapse(!0):zr(t,"setEnd",e,n.end)}function Ur(e,t,n){if(!e.contains(t))return{scope:e,after:[],before:[]};if(t.nodeType===3){if(!Ha(t))return{container:t,offset:n};let i=t.parentNode;return Hr(i,Array.from(i.childNodes).indexOf(t))}return{container:t,offset:n,childCount:t.childNodes.length,...Hr(t,n)}}function Hr(e,t){let n=Array.from(e.childNodes),i=Math.max(0,t);return{scope:e,after:n.slice(i),before:n.slice(0,i).reverse()}}function zr(e,t,n,i){let{container:r,childCount:o}=i;if(r&&n.contains(r)&&(o===void 0||o===r.childNodes.length)){e[t](r,Math.min(i.offset,Kt(r)));return}let s=i.after?.find(u=>n.contains(u));if(s){e[t](St(s,!0),0);return}let a=i.before?.find(u=>n.contains(u));if(a){let u=St(a,!1);e[t](u,Kt(u));return}let l=i.scope&&n.contains(i.scope)?i.scope:n;e[t](l,0)}function Ha(e){return e.nodeType===3&&!jt.test(e.nodeValue)&&!!e.parentNode&&e.parentNode.nodeType===1&&vt(e.parentNode)&&!Yn(e.parentNode)}var it=e=>e.nodeType===1||e.nodeType===3;function St(e,t=!0){let n=e;for(;n.nodeType===1&&!At.has(n.nodeName);){let i=Array.from(n.childNodes).filter(it),r=t?i[0]:i[i.length-1];if(!r||Ia.has(r.nodeName))break;n=r}return n}function Kt(e){return e.nodeType===3?e.nodeValue.length:e.childNodes.length}var ue="[data-richclay], [richclay], [editable], [clay-editable]",za="[data-richclay], [richclay], [clay-editable]",qa=["editable","clay-editable"],Zn=':is([editable~="single-line"], [clay-editable~="single-line"])';function ei(e){return!e||typeof e.matches!="function"?!1:e.tagName.includes("-")?e.matches(za):!0}var $a="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-live], [data-richclay-float]",Wa=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],Jn=new WeakSet,Jr=new WeakSet,eo=["clay:ready","hyperclay:ready"];function to(e){return[e.clay?.ready,e.hyperclay?.ready].find(t=>t&&typeof t.then=="function")||null}function no(e){return typeof e.clay?.isEditMode=="boolean"?e.clay.isEditMode:typeof e.hyperclay?.isEditMode=="boolean"?e.hyperclay.isEditMode:null}function Ga(e){let t=e.hyperclayModules,n=e.__hyperclayNoAutoExport===!1&&t&&typeof t=="object"&&typeof t.nodeType!="number";return no(e)!==null||!!to(e)||!!n}function Ka(e){return e.clay?.addDocumentTransform||e.hyperclay?.beforeSave||null}function ja(e){return e.clay?.onSnapshot||e.hyperclay?.onSnapshot||null}var Va={boxSizing:"border-box",minWidth:"100%",overflow:"auto",width:"0"};function Zt(e={},t=window){return e.hyperclay===!1?!1:e.hyperclay===!0?!0:!!(Ga(t)||nl(t))}function ti(e=window){let t=oo(e);if(t!==null)return t;if(typeof e.__hyperclayEditMode=="boolean")return e.__hyperclayEditMode;let n=no(e);return n!==null?n:il(e)}function io(e={},t=window){return e.readOnly?!1:Zt(e,t)?ti(t):!0}function ro(e){let t=qa.find(r=>e.hasAttribute(r));if(!t)return null;let n=new Set((e.getAttribute(t)||"").trim().split(/\s+/).filter(Boolean)),i={inline:!0,singleLine:n.has("single-line"),toolbarOnSelect:n.has("toolbar-on-select")};return n.has("no-toolbar")&&(i.toolbar=!1),i}function ni(e=window){if(Jn.has(e))return;let t=ja(e)||Ka(e);if(typeof t!="function"){Ya(e);return}t(n=>ii(n)),Jn.add(e)}function Ya(e){if(Jr.has(e))return;let t=e.document,n=to(e);if(!t&&!n)return;Jr.add(e);let i=()=>{ni(e),Jn.has(e)&&r()},r=()=>{t&&eo.forEach(o=>t.removeEventListener(o,i))};t&&eo.forEach(o=>t.addEventListener(o,i)),n&&n.then(i,()=>{})}function ii(e){e.querySelectorAll?.($a).forEach(t=>t.remove()),e.querySelectorAll?.(ue).forEach(t=>{if(t.getAttribute("data-richclay-active")!=="true")return;if(Jt(t,"save"),Ja(t)){let i=t.ownerDocument,r=!!t.matches?.(Zn);Ct(t,()=>r?i.createTextNode(" "):i.createElement("br")),t.querySelectorAll(t.localName).forEach(o=>{for(;o.firstChild;)o.parentNode.insertBefore(o.firstChild,o);o.remove()})}t.matches?.(Zn)&&tl(t),t.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(i=>{i.remove()}),t.querySelectorAll(".squire-image-resize-container").forEach(i=>i.remove()),el(t),(t.matches?.("pre")?[t,...t.querySelectorAll("pre")]:Array.from(t.querySelectorAll("pre"))).filter(i=>i.hasAttribute("data-richclay-pre")).forEach(i=>{Object.entries(Va).forEach(([r,o])=>{i.style[r]||(i.style[r]=o)}),i.removeAttribute("data-richclay-pre")})}),e.querySelectorAll?.("#squire-selection-start, #squire-selection-end").forEach(t=>t.remove())}var Xa="p, td, th, li, dl, dt, dd, table, blockquote, div, section, article, aside, main, header, footer, figure, figcaption",Xn="data-richclay-measure";function Qa(e){let t=e.ownerDocument,n=e.closest(Xa)||e;e.setAttribute(Xn,"");let i=t.createElement("div");try{i.innerHTML=n.outerHTML}finally{e.removeAttribute(Xn)}let r=i.querySelector(`[${Xn}]`);return!r||r.textContent!==e.textContent}var Za=e=>!!e.querySelector(e.localName),Ja=e=>!!e.matches?.(Zn)||(Qt(e)||Za(e))&&Qa(e);function Jt(e,t){let n=e.getAttribute("data-richclay-runtime-contenteditable");e.hasAttribute("contenteditable")&&(n==="true"?e.removeAttribute("contenteditable"):n?t==="destroy"?e.setAttribute("contenteditable",n):(e.setAttribute("inert-contenteditable",n),e.removeAttribute("contenteditable")):t==="save"&&(e.setAttribute("inert-contenteditable",e.getAttribute("contenteditable")),e.removeAttribute("contenteditable"))),Wa.forEach(i=>e.classList.remove(i)),e.getAttribute("class")===""&&e.removeAttribute("class"),Qn(e,"role","data-richclay-runtime-role"),Qn(e,"aria-multiline","data-richclay-runtime-aria-multiline"),Qn(e,"no-undo","data-richclay-runtime-no-undo"),e.getAttribute("data-richclay-runtime-display")==="true"&&(e.style.removeProperty("display"),e.getAttribute("style")===""&&e.removeAttribute("style")),rl(e),e.removeAttribute("data-richclay-active"),e.removeAttribute("data-richclay-placeholder"),e.removeAttribute("data-richclay-pre"),e.removeAttribute("data-richclay-runtime-role"),e.removeAttribute("data-richclay-runtime-aria-multiline"),e.removeAttribute("data-richclay-runtime-no-undo"),e.removeAttribute("data-richclay-runtime-describedby"),e.removeAttribute("data-richclay-runtime-contenteditable"),e.removeAttribute("data-richclay-runtime-display"),e.getAttribute("data-richclay-runtime-marker")==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute("data-richclay-runtime-marker")}function el(e){let n=[e];for(;n.length;)n.pop().childNodes.forEach(r=>{r.nodeType===3?r.nodeValue.includes("\u200B")&&(r.nodeValue=r.nodeValue.split("\u200B").join("")):r.nodeType===1&&n.push(r)});e.querySelectorAll("b, i, u, s, em, strong, code, sub, sup, span").forEach(i=>{i.children.length===0&&(i.textContent||"")===""&&i.attributes.length===0&&i.remove()})}function tl(e){let t=Array.from(e.childNodes).filter(i=>i.nodeType!==3||(i.nodeValue||"").trim()!=="");if(t.length!==1)return;let n=t[0];if(!(n.nodeType!==1||n.nodeName!=="P"||n.attributes.length>0)){for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove()}}function ri(e){if(!e.hasAttribute("inert-contenteditable"))return null;let t=e.getAttribute("inert-contenteditable");return["false","plaintext-only"].includes(t)||(t="true"),e.setAttribute("contenteditable",t),e.removeAttribute("inert-contenteditable"),t==="true"&&e.setAttribute("data-richclay-runtime-contenteditable","true"),t}function ye(e){return e.setAttribute("snapshot-remove",""),e.setAttribute("no-watch",""),e}function oo(e){try{let t=new URLSearchParams(e.location?.search||"");if(t.get("editmode")==="true")return!0;if(t.get("editmode")==="false")return!1}catch{return null}return null}function nl(e){return oo(e)!==null||typeof e.__hyperclayEditMode=="boolean"}function il(e){let n=(e.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(n&&n[1]!=="")}function Qn(e,t,n){e.hasAttribute(n)&&e.removeAttribute(t)}function rl(e){let t=e.getAttribute("data-richclay-runtime-describedby");if(!t)return;let n=(e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean).filter(i=>i!==t);n.length?e.setAttribute("aria-describedby",n.join(" ")):e.removeAttribute("aria-describedby")}var ol=0;function so(e=document){let t=e.createElement("div");return t.id=`richclay-live-${++ol}`,t.className="richclay-sr-only",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("data-richclay-live",""),ye(t),e.body.appendChild(t),t}function xt(e,t){!e||!t||(e.textContent="",e.ownerDocument.defaultView.setTimeout(()=>{e.textContent=t},20))}function oi(e){e.preventDefault()}function si(e){try{return e?.cloneRange?.()||null}catch{return null}}function rt(e){try{return si(e?.getSelection?.())}catch{return null}}function en(e,t){if(!e||!t)return!1;try{return e.setSelection(t),!0}catch{return!1}}function tn(e,t,n,i){e.hasAttribute(t)||e.setAttribute(i,"true"),e.setAttribute(t,n)}function ao(e,t){let n=new Set((e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));n.add(t.id),e.setAttribute("aria-describedby",Array.from(n).join(" ")),e.setAttribute("data-richclay-runtime-describedby",t.id)}var sl=0,ot=class{constructor(t,n,i={}){this.editor=t,this.controls=n,this.options=i,this.id=++sl,this.items=[],this.menus=new Map,this.activeIndex=0,this.root=this.createRoot(),this.onRootKeydown=r=>this.handleRootKeydown(r),this.onRootClick=r=>this.handleRootClick(r),this.onRootPointerDown=r=>this.handleRootPointerDown(r),this.onDocumentPointerDown=r=>this.handleDocumentPointerDown(r),this.render(),this.root.addEventListener("keydown",this.onRootKeydown),this.root.addEventListener("click",this.onRootClick),this.root.addEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.addEventListener("mousedown",this.onDocumentPointerDown)}destroy(){this.closeMenus(),this.root.removeEventListener("keydown",this.onRootKeydown),this.root.removeEventListener("click",this.onRootClick),this.root.removeEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.removeEventListener("mousedown",this.onDocumentPointerDown),this.root.remove()}update(){this.items.forEach(t=>{let{def:n,button:i}=t;if(typeof n.isActive=="function"){let r=!!n.isActive(this.editor);i.setAttribute("aria-pressed",r?"true":"false"),i.classList.toggle("is-active",r)}typeof n.isDisabled=="function"&&(i.disabled=!!n.isDisabled(this.editor))}),this.ensureSingleTabStop()}focusFirst(){this.activeIndex=0,this.ensureSingleTabStop(),this.items[0]?.button.focus()}createRoot(){let t=this.editor.element.ownerDocument,n=t.createElement("div");n.className="richclay-toolbar",n.setAttribute("role","toolbar"),n.setAttribute("aria-label",this.options.ariaLabel||"Rich text formatting"),n.setAttribute("data-richclay-toolbar",""),ye(n);let i=al(this.options.toolbarContainer,t);return i?i.appendChild(n):this.editor.element.insertAdjacentElement("beforebegin",n),n}render(){this.root.textContent="",this.items=[],this.menus.clear();let t=null;this.visibleControls().forEach((n,i)=>{if(n.type==="separator"){this.root.appendChild(co(this.root.ownerDocument)),t=null;return}t&&n.group&&n.group!==t&&this.root.appendChild(co(this.root.ownerDocument)),t=n.group||t,n.type==="menu"?this.renderMenu(n,i):this.renderButton(n,i)}),this.ensureSingleTabStop(),this.update()}visibleControls(){let t=this.controls.filter(i=>i.type==="separator"||!i.isDisabled?.(this.editor)),n=[];for(t.forEach(i=>{let r=n[n.length-1];i.type==="separator"&&(!r||r.type==="separator")||n.push(i)});n[n.length-1]?.type==="separator";)n.pop();return n}renderButton(t,n){let i=lo(this.root.ownerDocument,t);i.dataset.richclayControl=t.id,i.dataset.richclayIndex=String(n),typeof t.isActive=="function"&&i.setAttribute("aria-pressed","false"),this.root.appendChild(i),this.items.push({def:t,button:i,type:"button"})}renderMenu(t,n){let i=this.root.ownerDocument,r=lo(i,t),o=`richclay-menu-${this.id}-${t.id}`;r.dataset.richclayControl=t.id,r.dataset.richclayIndex=String(n),r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",o);let s=i.createElement("div");s.id=o,s.className="richclay-menu",s.hidden=!0,s.setAttribute("role","menu"),s.setAttribute("data-richclay-menu",""),ye(s),t.options.forEach((l,u)=>{let d=i.createElement("button");d.type="button",d.className="richclay-menu-item",d.setAttribute("role","menuitemradio"),d.setAttribute("tabindex","-1"),d.dataset.richclayMenuItem=t.id,d.dataset.richclayOptionIndex=String(u),d.textContent=l.label,d.addEventListener("mousedown",oi),d.addEventListener("click",f=>{f.preventDefault(),this.chooseMenuItem(t,l,r)}),d.addEventListener("keydown",f=>this.handleMenuKeydown(f,t,r)),s.appendChild(d)});let a=i.createElement("span");a.className="richclay-menu-wrap",a.append(r,s),this.root.appendChild(a),this.items.push({def:t,button:r,type:"menu",menu:s}),this.menus.set(t.id,{def:t,button:r,menu:s})}handleRootPointerDown(t){let n=t.target.closest?.("[data-richclay-control]");!n||!this.root.contains(n)||(oi(t),this.editor.saveSelection())}handleRootClick(t){let n=t.target.closest?.("[data-richclay-control]");if(!n||!this.root.contains(n))return;t.preventDefault();let i=this.items.find(r=>r.button===n);if(!(!i||n.disabled)){if(this.activeIndex=this.items.indexOf(i),this.ensureSingleTabStop(),i.type==="menu"){this.toggleMenu(i.def.id);return}this.closeMenus(),this.editor.runControl(i.def)}}handleRootKeydown(t){let n=t.key,i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};if(n in i){t.preventDefault(),this.moveFocus(i[n]);return}if(n==="Home"){t.preventDefault(),this.setFocusIndex(0);return}if(n==="End"){t.preventDefault(),this.setFocusIndex(this.items.length-1);return}let r=this.items[this.activeIndex];if(r&&((n==="Enter"||n===" ")&&r.type==="menu"&&(t.preventDefault(),this.openMenu(r.def.id,"first")),n==="Escape")){let o=Array.from(this.menus.values()).some(s=>!s.menu.hidden);this.closeMenus(),o?r.button.focus():this.editor.focus()}}handleMenuKeydown(t,n,i){t.stopPropagation();let r=this.menus.get(n.id)?.menu,o=Array.from(r.querySelectorAll(".richclay-menu-item")),s=o.indexOf(t.currentTarget),a=s;if(t.key==="ArrowDown"&&(a=(s+1)%o.length),t.key==="ArrowUp"&&(a=(s-1+o.length)%o.length),t.key==="Home"&&(a=0),t.key==="End"&&(a=o.length-1),a!==s){t.preventDefault(),o[a].focus();return}if(t.key==="Escape"){t.preventDefault(),this.closeMenus(),i.focus();return}if(t.key==="Enter"||t.key===" "){t.preventDefault();let l=n.options[s];this.chooseMenuItem(n,l,i)}}handleDocumentPointerDown(t){this.root.contains(t.target)||this.closeMenus()}chooseMenuItem(t,n,i){this.closeMenus(),this.editor.runControl({...n,id:`${t.id}:${n.value}`,ariaLabel:n.label}),i.focus()}toggleMenu(t){let n=this.menus.get(t);n&&(n.menu.hidden?this.openMenu(t,"first"):this.closeMenus())}openMenu(t,n="first"){this.closeMenus(t);let i=this.menus.get(t);if(!i)return;i.menu.hidden=!1,i.button.setAttribute("aria-expanded","true"),this.updateMenuState(i);let r=Array.from(i.menu.querySelectorAll(".richclay-menu-item")),o=r.find(a=>a.getAttribute("aria-checked")==="true");(n==="active"&&o||r[0])?.focus()}closeMenus(t=null){this.menus.forEach((n,i)=>{i!==t&&(n.menu.hidden=!0,n.button.setAttribute("aria-expanded","false"))})}updateMenuState(t){Array.from(t.menu.querySelectorAll(".richclay-menu-item")).forEach((i,r)=>{let s=!!t.def.options[r].isActive?.(this.editor);i.setAttribute("aria-checked",s?"true":"false"),i.classList.toggle("is-active",s)})}moveFocus(t){if(!this.items.length)return;let n=this.activeIndex;do n=(n+t+this.items.length)%this.items.length;while(this.items[n].button.disabled&&n!==this.activeIndex);this.setFocusIndex(n)}setFocusIndex(t){this.activeIndex=Math.max(0,Math.min(t,this.items.length-1)),this.ensureSingleTabStop(),this.items[this.activeIndex]?.button.focus()}ensureSingleTabStop(){let t=this.items.filter(n=>!n.button.disabled);t.length&&(t.includes(this.items[this.activeIndex])||(this.activeIndex=this.items.indexOf(t[0])),this.items.forEach((n,i)=>{n.button.tabIndex=i===this.activeIndex?0:-1}))}};function lo(e,t){let n=e.createElement("button");n.type="button",n.className="richclay-button";let i=Fr(t.shortcut,e.defaultView),r=i?`${t.ariaLabel||t.label} (${i})`:t.ariaLabel||t.label;return n.setAttribute("aria-label",r),n.title=r,n.innerHTML=`${t.icon||""}<span class="richclay-sr-only">${t.label}</span>`,n}function co(e){let t=e.createElement("span");return t.className="richclay-separator",t.setAttribute("role","separator"),t.setAttribute("aria-orientation","vertical"),t}function al(e,t){return e?typeof e=="string"?t.querySelector(e):e:null}var uo=16,ll=[16,8,0],ae=8,cl=4;function ul({anchor:e,bar:t,rail:n,viewport:i,current:r=null}){let o=p=>r===p?cl:0;if(e.bottom<=0||e.top>=i.height||e.right<=0||e.left>=i.width)return{mode:"hidden",x:0,y:0};let s=p=>Math.max(ae,Math.min(e.left,i.width-p-ae)),a=e.top-uo-t.height;if(a>=ae-o("above"))return{mode:"above",x:s(t.width),y:a};let l=e.bottom+uo;if(l+t.height<=i.height-ae+o("below"))return{mode:"below",x:s(t.width),y:l};let u=i.width-e.right-ae,d=e.left-ae,f=u>=d?[["rail-right",u],["rail-left",d]]:[["rail-left",d],["rail-right",u]];for(let[p,y]of f)for(let E of ll){if(n.width+E>y+o(p))continue;let N=p==="rail-right"?Math.min(e.right+E,i.width-n.width-ae):Math.max(e.left-E-n.width,ae),C=Math.min(e.bottom,i.height-ae)-n.height,M=Math.max(ae,Math.min(Math.max(e.top,ae),C));return{mode:p,x:N,y:M,gap:E}}return{mode:"pinned",x:s(t.width),y:ae}}var nn=class{constructor(t,n){this.editor=t,this.mode=null,this.hidden=!1,this.frame=0,this.bar={width:0,height:0},this.rail={width:0,height:0};let i=t.element.ownerDocument;this.doc=i,this.win=i.defaultView||globalThis,this.root=i.createElement("div"),this.root.className="richclay-float",this.root.setAttribute("data-richclay-float",""),this.root.setAttribute("save-remove",""),ye(this.root),i.body.appendChild(this.root),this.toolbar=new ot(t,n,{toolbarContainer:this.root}),this.onScroll=()=>this.schedule(),this.onResize=()=>{this.measure(),this.schedule()},i.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),this.win.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("scroll",this.onScroll,{passive:!0}),this.resizeObserver=typeof this.win.ResizeObserver=="function"?new this.win.ResizeObserver(()=>this.schedule()):null,this.resizeObserver?.observe(t.element),this.measure(),this.reposition()}measure(){let t=this.root.classList.contains("richclay-float-rail");this.root.style.visibility="hidden",this.root.classList.remove("richclay-float-rail"),this.bar={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.add("richclay-float-rail"),this.rail={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.toggle("richclay-float-rail",t),this.root.style.visibility=""}schedule(){if(!this.win.requestAnimationFrame){this.reposition();return}this.frame||(this.frame=this.win.requestAnimationFrame(()=>{this.frame=0,this.reposition()}))}setVisible(t){this.hidden=!t,this.reposition()}reposition(){if(this.hidden){this.root.style.display="none";return}let t=this.editor.element.getBoundingClientRect(),n={width:this.win.visualViewport?.width??this.win.innerWidth,height:this.win.visualViewport?.height??this.win.innerHeight},i=ul({anchor:t,bar:this.bar,rail:this.rail,viewport:n,current:this.mode});if(this.mode=i.mode,i.mode==="hidden"){this.root.style.display="none";return}this.root.style.display="",this.root.classList.toggle("richclay-float-rail",i.mode==="rail-left"||i.mode==="rail-right"),this.root.classList.toggle("richclay-float-pinned",i.mode==="pinned"),this.root.style.transform=`translate(${Math.round(i.x)}px, ${Math.round(i.y)}px)`}destroy(){this.frame&&this.win.cancelAnimationFrame?.(this.frame),this.frame=0,this.doc.removeEventListener("scroll",this.onScroll,{capture:!0}),this.win.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onScroll),this.resizeObserver?.disconnect(),this.toolbar.destroy(),this.root.remove()}};var dl={ALLOWED_TAGS:["a","b","blockquote","br","code","div","em","h1","h2","h3","h4","h5","h6","i","li","ol","p","pre","s","span","strong","sub","sup","u","ul"],ALLOWED_ATTR:["aria-label","href","rel","target","title"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,FORBID_TAGS:["script","style","iframe","object","embed","form","input"],FORBID_ATTR:["style","srcset","onerror","onclick","onload"]};function po(e={},t=document){let n=rn(t);return{sanitizeHTML(i){return ai(i,e,t,n)},sanitizeElement(i){return li(i,e,n)},sanitizeToDOMFragment(i,r){let o=r?.getRoot?.().ownerDocument||t;return hl(i,e,o,n)}}}function ai(e,t={},n=document,i=rn(n)){let r=n.createElement("template");return r.innerHTML=i.sanitize(String(e||""),ci(t)),ui(r.content),r.innerHTML}function li(e,t={},n=rn(e.ownerDocument)){let r=e.ownerDocument.createElement("div");for(;e.firstChild;)r.appendChild(e.firstChild);for(n.sanitize(r,{...ci(t),IN_PLACE:!0}),ui(r);r.firstChild;)e.appendChild(r.firstChild);return e}function hl(e,t={},n=document,i=rn(n)){let r=i.sanitize(String(e||""),{...ci(t),RETURN_DOM_FRAGMENT:!0}),o=r?.ownerDocument===n?r:n.importNode(r,!0);return ui(o),o||n.createDocumentFragment()}function ci(e){return{...dl,...e}}var fl=new Set(["http","https","mailto","tel"]),pl=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function ml(e){let n=(String(e??"").replace(pl,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!n||fl.has(n.toLowerCase())}function mo(e){let t=String(e??"").trim();return!t||!ml(t)?"":/^(?:https?:|mailto:|tel:)/i.test(t)?t:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:/^(?:[#?]|\/|\.{1,2}\/)/.test(t)?t:`https://${t}`}function rn(e){let t=globalThis.DOMPurify;if(t?.sanitize)return t;if(typeof t=="function")return t(e.defaultView||globalThis);throw new Error("RichClay requires DOMPurify. Load vendor/purify.min.js before richclay.js or provide globalThis.DOMPurify.")}function ui(e){e.querySelectorAll?.("a[href]").forEach(t=>{let n=t.getAttribute("href")||"";if(/^\s*javascript:/i.test(n)&&t.removeAttribute("href"),t.getAttribute("target")==="_blank"){let i=new Set((t.getAttribute("rel")||"").split(/\s+/).filter(Boolean));i.add("noopener"),i.add("noreferrer"),t.setAttribute("rel",Array.from(i).join(" "))}})}var ho={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function go(e={}){return{...e,ADD_TAGS:[...new Set([...ho.ADD_TAGS,...e.ADD_TAGS||[]])],ADD_ATTR:[...new Set([...ho.ADD_ATTR,...e.ADD_ATTR||[]])],ALLOW_DATA_ATTR:e.ALLOW_DATA_ATTR??!0}}var fo="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function yo(e){let t=e.ownerDocument||document;e.querySelectorAll?.("br").forEach(i=>i.replaceWith(t.createTextNode(" ")));let n=e.querySelector?.(fo);for(;n;){let i=n.parentNode;for(i.insertBefore(t.createTextNode(" "),n);n.firstChild;)i.insertBefore(n.firstChild,n);i.insertBefore(t.createTextNode(" "),n),n.remove(),n=e.querySelector(fo)}return gl(e,t),e}function gl(e,t){e.normalize?.();let n=t.createTreeWalker(e,4),i=[];for(;n.nextNode();)i.push(n.currentNode);i.forEach(s=>{s.nodeValue=s.nodeValue.replace(/\s+/g," ")});let r=e.firstChild;r?.nodeType===3&&(r.nodeValue=r.nodeValue.replace(/^\s+/,""));let o=e.lastChild;o?.nodeType===3&&(o.nodeValue=o.nodeValue.replace(/\s+$/,""))}var bo="richclay-styles",di=new WeakSet,hi="";function To(e){hi=e||""}function _o(e=document){if(!e||di.has(e))return;if(e.getElementById(bo)){di.add(e);return}if(!hi)return;let t=e.createElement("style");t.id=bo,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=hi,(e.head||e.documentElement).appendChild(t),di.add(e)}var Eo=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),yl=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),nc=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function fi(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function bl(e,t){if(fi(e,t))return!0;for(let[n,i]of Object.entries(yl))if(i.includes(t)&&fi(e,n))return!0;return!1}function Nt(e){let t=Eo[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function pi(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=Eo[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>bl(n,r))||i.bundles.some(r=>fi(n,r)))return n;n=n.parentElement}return null}function So(e,t){return!!pi(e,t)}var Tl=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Ao(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let i=0;i<e.options.length;i++)t.options[i].selected=e.options[i].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function vo(e,t,n,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Co(e,t,n,i,r,o,s,a){if(e.nodeType===1&&((s?So(e,n):vo(e,i,o,!1))||r&&vo(e,r,o,s)))return null;let l=t.importNode(e,!1);a.cloneToLive.set(l,e),a.liveToClone.set(e,l);let u=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,d=l.nodeType===1&&l.tagName==="TEMPLATE"?l.content:l;u!==e&&(a.cloneToLive.set(d,u),a.liveToClone.set(u,d));for(let f of u.childNodes||[]){let p=Co(f,t,n,i,r,o,s,a);p&&(d.appendChild(p),f.nodeType===1&&Ao(f,p))}return e.nodeType===1&&Ao(e,l),l}function mi(e,{capability:t="data",exclude:n=null,inherit:i=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let o=r.implementation.createHTMLDocument(""),s=new WeakMap,a=new WeakMap,l=e.nodeType===9?e.documentElement:e;n&&o.documentElement.matches(n);let u=Nt(t),d=Co(l,o,t,u,n,l,i,{cloneToLive:s,liveToClone:a});e.nodeType===9&&d&&(o.replaceChild(d,o.documentElement),a.set(e,o),s.set(o,e));let f=p=>{if(Tl.test(p))throw new Error(`Filtered content queries do not support stateful selector: ${p}`)};return{root:d,document:o,capability:t,selector:Nt(t),cloneToLive:s,liveToClone:a,original(p){return s.get(p)||null},cloneOf(p){return a.get(p)||null},query(p,y=d){return f(p),Array.from(y.querySelectorAll(p),E=>s.get(E)||E)},text(p=d){return(p===d?d:a.get(p))?.textContent||""},html(p=d){return(p===d?d:a.get(p))?.innerHTML??""},clone(p=d){let y=p===d?d:a.get(p);return y?o.importNode(y,!0):null}}}var _l=Nt("history");function Do(e,t){let n=t.createElement("template");n.innerHTML=String(e||"");for(let i of n.content.querySelectorAll(_l))i.remove();return n.innerHTML}function Io(e,t){return Do(e,t)}function El(e,t){let n=t.createElement("template");n.innerHTML=Io(e,t);let i=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DIV","DL","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","TABLE","UL"]),r="",o=s=>{if(s.nodeType===3)r+=s.data;else if(s.nodeType===1&&s.tagName==="BR")r+=`
25
+ `;else{let a=s.nodeType===1&&i.has(s.tagName);a&&r&&!r.endsWith(`
26
+ `)&&(r+=`
27
+ `);for(let l of s.childNodes||[])o(l);a&&r&&!r.endsWith(`
28
+ `)&&(r+=`
29
+ `)}};return o(n.content),r.replace(/\n{3,}/g,`
30
+
31
+ `).replace(/^\n|\n$/g,"")}function Sl(e,t,n=null){let i=mi(e,{capability:"history",inherit:!1}),r=i.root,o=(a,l)=>{for(;a&&!i.cloneOf(a);){let f=a.parentNode;if(!f)return{container:r,offset:0};l=Array.from(f.childNodes).indexOf(a),a=f}let u=i.cloneOf(a)||r;if(a?.nodeType===3)return{container:u,offset:Math.min(l,u.length)};let d=Array.from(a?.childNodes||[]).slice(0,l).filter(f=>i.cloneOf(f)).length;return{container:u,offset:Math.min(d,u.childNodes.length)}},s=(a,l,u)=>{let d=o(l,u),f=r.ownerDocument.createElement("input");f.id=a,f.type="hidden";let p=r.ownerDocument.createRange();p.setStart(d.container,d.offset),p.collapse(!0),p.insertNode(f)};if(n)s(t.endSelectionId,n.endContainer,n.endOffset),s(t.startSelectionId,n.startContainer,n.startOffset);else for(let a of[t.startSelectionId,t.endSelectionId]){if(r.querySelector(`#${a}`))continue;let l=e.querySelector(`#${a}`);l&&s(a,l.parentNode,Array.from(l.parentNode.childNodes).indexOf(l))}return r.innerHTML}var Ae=new WeakMap,xo=new WeakSet,No=new WeakSet,gi=Br(),Lo=Symbol("richclay-keep-focus"),wo=["cut","paste","drop"],Al=["Alt","Ctrl","Meta","Shift"],Ro=0,vl={toolbar:"standard",toolbarContainer:null,sanitize:{},placeholder:"",readOnly:!1,hyperclay:"auto",onChange:null,Squire:null,inline:!1,singleLine:!1,toolbarOnSelect:!1},We=class e{static presets=Et;static selector=ue;constructor(t,n={}){if(!t)throw new Error("RichClay requires an element.");let i=Ae.get(t);if(i)return i;this.element=t,this.unsupported=yi(t)||Nl(t);let r={...ro(t),...n};this.options={...vl,...r},this.options.singleLine&&!("toolbar"in r)&&(this.options.toolbar="inline"),this._blockTag=this.options.inline?"DIV":"P",this.registry=new Map(gi),this.toolbar=null,this.float=null,this._onToolbarKey=null,this._onFloatFocusOut=null,this._onDocPointerDown=null,this.liveRegion=null,this.description=null,this.dialog=null,this.savedSelection=null,this.path="",this.active=!1,this._squire=null,this._squireListeners=[],this._onBeforeInput=null,this._onRootBeforeInput=null,this._onRootKeydown=null,this._onRootTransfer=null,this._shortcutKeys=[],this._appleDeleteKeys=new Set,this._authoredPres=new WeakSet,this._warnedInlineBlock=!1,this._onFocus=()=>{this.element.classList.add("richclay-focused"),this.options.inline&&this.ensureFloatingToolbar()},this._onBlur=o=>{this.element.classList.remove("richclay-focused"),this.options.inline&&this.scheduleFloatTeardown(o)},this.ensureMarker(),this.hyperclay=Zt(this.options,this.window),this.hyperclay&&ni(this.window),Ae.set(t,this),this.sanitizeConfig=this.options.inline?go(this.options.sanitize):this.options.sanitize,this.sanitizer=po(this.sanitizeConfig,this.element.ownerDocument),this.options.inline||li(this.element,this.sanitizeConfig),io(this.options,this.window)&&this.activate()}get squire(){return this._squire}get window(){return this.element.ownerDocument.defaultView||window}static init(t=ue,n={}){let i=t===ue?ei:()=>!0;return Cl(t).filter(i).filter(o=>!yi(o)).map(o=>new e(o,n))}static autoInit(t=typeof window<"u"?window:void 0){if(!t||!t.document||xo.has(t))return;xo.add(t);let n=()=>{Zt({},t)&&ti(t)&&(e.init(),e.watch(t))};t.document.readyState==="loading"?t.document.addEventListener("DOMContentLoaded",n,{once:!0}):n()}static watch(t=typeof window<"u"?window:void 0,n={}){if(!t||!t.document||No.has(t))return;No.add(t);let i=s=>{Lt(s)&&!Ae.has(s)&&!yi(s)&&new e(s,n)},r=s=>Ae.get(s)?.destroy();new t.MutationObserver(s=>{s.forEach(a=>{if(a.type==="attributes"){let l=a.target;Lt(l)?i(l):r(l);return}a.addedNodes.forEach(l=>{l.nodeType===1&&(l.matches?.(ue)&&i(l),l.querySelectorAll?.(ue).forEach(i))}),a.removedNodes.forEach(l=>{if(l.nodeType!==1)return;let u=d=>{d.isConnected||Ae.get(d)?.destroy()};l.matches?.(ue)&&u(l),l.querySelectorAll?.(ue).forEach(u)})})}).observe(t.document.documentElement||t.document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["editable","clay-editable","data-richclay","richclay"]})}static registerButton(t){return bi(t),gi.set(t.id,t),e}static unregisterButton(t){return gi.delete(t),e}static stripFromClone(t){ii(t)}static stripElement(t){if(!t||typeof t.getAttribute!="function")return;let n=Ae.get(t);if(n){n.destroy();return}Jt(t,"destroy")}registerButton(t){return bi(t),this.registry.set(t.id,t),this.active&&this.renderToolbar(),this}unregisterButton(t){return this.registry.delete(t),this.active&&this.renderToolbar(),this}activate(){if(this.unsupported||this.active)return;this.active=!0,this.applyInlineBox(),_o(this.element.ownerDocument),ri(this.element);let t=this.options.inline?Array.from(this.element.childNodes):null,n=this.options.inline?null:this.element.innerHTML,i=this.options.Squire||this.window.Squire||globalThis.Squire;if(!i)throw new Error("RichClay requires Squire. Load vendor/squire.js before richclay.js.");if(this.setupEditorAttributes(),this.liveRegion=so(this.element.ownerDocument),this._squire=new i(this.element,{blockTag:this._blockTag,serializeRoot:Sl,willCutCopy:r=>Io(r,this.element.ownerDocument),toPlainText:r=>El(r,this.element.ownerDocument),replaceRoot:(r,o,s)=>{let a=this.window.clay?.morph||this.window.hyperclay?.morph;if(typeof a!="function"){if(r.querySelector('[editor-ui], [clay~="editor-ui"]'))throw new Error("RichClay requires a retention-aware morph host to replay history containing editor-ui.");r.innerHTML=o;return}a(r,o,{morphStyle:"innerHTML",restoreFocus:!1,scripts:{handle:!1,merge:!1},policy:"history"}),s._ensureBottomLine(),s._mutation?.takeRecords()},onMutations:(r,o)=>{let s=(u,d)=>{let f=pi(u,d);return!!f&&f!==this.element&&this.element.contains(f)},a=!1,l=!1;for(let u of r){if(s(u.target,"history"))continue;let d=u.type==="childList"?[...u.addedNodes,...u.removedNodes]:[u.target];for(let f of d)s(f,"history")||(s(u.target,"undo")||s(f,"undo")?l=!0:a=!0)}if(a){let u=o._ignoreChange;o._docWasChanged(),l&&u&&o.fireEvent("input")}else l?(o._mayHaveZWS=!0,o.fireEvent("input")):o._ignoreChange=!1},sanitizeToDOMFragment:(r,o)=>{let s=this.sanitizer.sanitizeToDOMFragment(Do(r,this.element.ownerDocument),o);return this.options.singleLine?yo(s):s},didError:r=>{console.error("RichClay/Squire error",r)}}),this.options.inline?(this.element.replaceChildren(...t),this.resetSquireUndoBaseline()):this._squire.setHTML(n),this.bindSquire(),this.options.singleLine&&this.installSingleLineGuards(),this.options.inline&&!this.options.singleLine&&this.installRootGuards(),this.installAppleDeleteKeys(),this.blocksStayOut()&&(this._squire._ensureBottomLine=()=>{}),this.maskSquireCodeShortcut(),this.maskSquireBlockShortcuts(),this.installShortcuts(),this.options.inline&&(this._onToolbarKey=r=>{r.altKey&&r.key==="F10"&&(r.preventDefault(),this.ensureFloatingToolbar(),this.float?.toolbar.focusFirst())},this.element.addEventListener("keydown",this._onToolbarKey)),this.blocksStayOut()){let r=o=>{let s=o.detail?.fragment;if(!s)return;let a=this.element.ownerDocument;Ct(s,()=>this.options.singleLine?a.createTextNode(" "):a.createElement("br"))};this._squire.addEventListener("willPaste",r),this._squireListeners.push(["willPaste",r])}this.renderToolbar(),this.updatePlaceholder(),this.warnOnBlockInInlineRegion(),this.element.querySelectorAll("pre").forEach(r=>this._authoredPres.add(r))}reattach(){return this.unsupported||!this.active||this.element.getAttribute("contenteditable")==="true"&&this.element.getAttribute("data-richclay-active")==="true"&&Lt(this.element)?!1:(this.ensureMarker(),this.applyInlineBox(),ri(this.element),this.setupEditorAttributes(),!0)}applyInlineBox(){Xt(this.element)&&!this.element.style.display&&(this.element.style.display="inline-block",this.element.setAttribute("data-richclay-runtime-display","true"))}getHTML(){return this._squire?this._squire.getHTML():this.element.innerHTML}setHTML(t){return this._squire?this._squire.setHTML(String(t||"")):this.element.innerHTML=ai(t,this.sanitizeConfig,this.element.ownerDocument),this.updatePlaceholder(),this.toolbar?.update(),this.options.onChange?.(this.getHTML()),this}focus(){return this._squire?this._squire.focus():this.element.focus(),this}destroy(){this.closeLinkDialog(),this.teardownFloatingToolbar(),this.toolbar?.destroy(),this.toolbar=null,this._onToolbarKey&&(this.element.removeEventListener("keydown",this._onToolbarKey),this._onToolbarKey=null),this.liveRegion?.remove(),this.liveRegion=null,this.description?.remove(),this.description=null,this._shortcutKeys.forEach(n=>this._squire?.setKeyHandler?.(n,null)),this._squireListeners.forEach(([n,i])=>{this._squire?.removeEventListener?.(n,i)}),this._squireListeners=[],this._shortcutKeys=[],this._onBeforeInput&&(this.element.ownerDocument.removeEventListener("beforeinput",this._onBeforeInput,!0),this._onBeforeInput=null);let t=this.element.ownerDocument;this._onRootBeforeInput&&(t.removeEventListener("beforeinput",this._onRootBeforeInput,!0),this._onRootBeforeInput=null),this._onRootKeydown&&(t.removeEventListener("keydown",this._onRootKeydown,!0),this._onRootKeydown=null),this._onRootTransfer&&(wo.forEach(n=>t.removeEventListener(n,this._onRootTransfer,!0)),this._onRootTransfer=null),this._squire?.destroy?.(),this._squire=null,this.cleanupEditorAttributes(),Ae.delete(this.element)}saveSelection(){return this.savedSelection=rt(this._squire)||this.savedSelection,this.savedSelection}restoreSelection(){return en(this._squire,this.savedSelection)}installRootGuards(){let t=this.element.ownerDocument,n=i=>this.element.contains(i.target);this._onRootBeforeInput=i=>{!n(i)||i.isComposing||/^history/.test(i.inputType||"")||this.ensureRootIsEditable()},this._onRootKeydown=i=>{!n(i)||i.defaultPrevented||i.isComposing||this.isEditingKey(i)&&this.ensureRootIsEditable()},this._onRootTransfer=i=>{n(i)&&this.ensureRootIsEditable()},t.addEventListener("beforeinput",this._onRootBeforeInput,!0),t.addEventListener("keydown",this._onRootKeydown,!0),wo.forEach(i=>{t.addEventListener(i,this._onRootTransfer,!0)})}ensureRootIsEditable(){if(!this._squire||this.options.singleLine)return;let t=this.options.inline,n=!this.blocksStayOut();if(!Vr(this.element,{wrapBareRoot:t,blocksAllowed:n}))return;let i=rt(this._squire),r=i?Qr(this.element,i):null,o=()=>{jr(this.element,{blockTag:this._blockTag,wrapBareRoot:t,blocksAllowed:n,onBareRootWrapped:(s,a)=>{console.warn(`richclay: wrapped this region's loose text in a <div> so multi-line editing works. Wrap the content in your own block element to keep the markup you wrote, or use editable="single-line" if it is meant to be one line.`,s,a)}})};typeof this._squire.modifyDocument=="function"?this._squire.modifyDocument(o):o(),r&&(Zr(this.element,i,r),en(this._squire,i),this.savedSelection=si(i))}isEditingKey(t){return["Backspace","Delete","Enter"].includes(t.key)?!0:t.key==="Tab"?this.caretIsInList():t.key.length!==1?!1:!t.ctrlKey&&!t.metaKey&&!t.altKey?!0:t.ctrlKey&&!t.metaKey&&!t.altKey&&this._appleDeleteKeys.has(t.key.toLowerCase())}caretIsInList(){let n=this._squire?.getSelection()?.startContainer;if(!n)return!1;let i=n.nodeType===1?n:n.parentElement;return!!(i&&this.element.contains(i)&&i.closest("ul, ol"))}runControl(t){if(!this._squire||typeof t.run!="function"||t.isDisabled?.(this))return;this.restoreSelection(),t.mutates!==!1&&this.ensureRootIsEditable();let n=t.run(this);this.element.querySelectorAll("pre:not([data-richclay-pre])").forEach(i=>{this._authoredPres.has(i)||i.setAttribute("data-richclay-pre","")}),t.mutates!==!1&&(this.ensureRootIsEditable(),this.anchorSelectionInBlock()),this.saveSelection(),this.toolbar?.update(),this.updatePlaceholder(),this.announceControl(t),n!==Lo&&this.focus(),this.warnOnBlockInInlineRegion()}anchorSelectionInBlock(){let t=rt(this._squire);if(!t?.collapsed||t.startContainer!==this.element)return;let n=Array.from(this.element.childNodes),i=t.startOffset>=n.length,r=i?n.filter(it).pop():n.slice(t.startOffset).find(it)||n.slice(0,t.startOffset).filter(it).pop();if(!r)return;let o=St(r,!i);t.setStart(o,i?Kt(o):0),t.collapse(!0),en(this._squire,t)}selectionHasFormat(t){if(!t||!this._squire?.hasFormat)return!1;try{return this._squire.hasFormat(t)}catch{return!1}}pathHas(t){let n=rt(this._squire);if(!n)return!1;let i=t.toLowerCase(),r=Oo(this.element,n.startContainer,n.startOffset,!0,i);return!!r&&r===Oo(this.element,n.endContainer,n.endOffset,!1,i)}blocksStayOut(){return this.options.singleLine||Yt(this.element)||qr(this.element)}warnOnBlockInInlineRegion(){if(this._warnedInlineBlock||!Xt(this.element)||!Qt(this.element))return;this._warnedInlineBlock=!0;let t=this.element.nodeName.toLowerCase();console.warn(`richclay: a block element inside <${t} editable> is not valid HTML. It stays where it is and saves correctly, but a validator will flag it. Put the editable attribute on a block element if you want blocks here.`,this.element)}toggleFormat(t,n,i){return this.selectionHasFormat(t)?this._squire[i]():this._squire[n]()}toggleList(t){return this.pathHas(t)?this._squire.removeList():t==="UL"?this._squire.makeUnorderedList():this._squire.makeOrderedList()}indent(){return this.pathHas("UL")||this.pathHas("OL")?this._squire.increaseListLevel():this._squire.increaseQuoteLevel()}outdent(){return this.pathHas("UL")||this.pathHas("OL")?this._squire.decreaseListLevel():this._squire.decreaseQuoteLevel()}setBlockType(t){let n=t.toUpperCase();return n==="BLOCKQUOTE"?this._squire.increaseQuoteLevel():this._squire.modifyBlocks(i=>{let r=this.element.ownerDocument,o=r.createDocumentFragment();return Array.from(i.childNodes).forEach(s=>{if(s.nodeType!==1){o.appendChild(s);return}if(s.nodeName===n){o.appendChild(s);return}let a=r.createElement(n);for(;s.firstChild;)a.appendChild(s.firstChild);o.appendChild(a)}),o})}openLinkDialog(){this.saveSelection(),this.closeLinkDialog();let t=this.element.ownerDocument,n=this.currentLinkHref(),i=t.createElement("form"),r=`richclay-link-label-${++Ro}`;i.className="richclay-dialog",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-labelledby",r),i.setAttribute("data-richclay-dialog",""),ye(i),i.innerHTML=`
25
32
  <div class="richclay-dialog-title" id="${r}">${n?"Edit link":"Insert link"}</div>
26
33
  <label class="richclay-field">
27
34
  <span>URL</span>
@@ -31,7 +38,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
31
38
  <button type="button" class="richclay-secondary" data-richclay-cancel>Cancel</button>
32
39
  <button type="submit" class="richclay-primary">Apply</button>
33
40
  </div>
34
- `;let o=()=>{this.closeLinkDialog(),this.toolbar?.update(),this.focus()};i.addEventListener("submit",c=>{c.preventDefault();let u=new FormData(i),h=co(u.get("url"));if(!h){xt(this.liveRegion,"Enter a valid URL");return}this.restoreSelection();let f=this.currentLinkElement();f&&this.selectElement(f),this._squire.makeLink(h),xt(this.liveRegion,"Link applied"),o()}),i.querySelector("[data-richclay-cancel]").addEventListener("click",o),i.addEventListener("keydown",c=>{c.key==="Escape"?(c.preventDefault(),o()):c.key==="Tab"&&ul(c,i)}),(this.toolbar?.root||this.element).insertAdjacentElement("afterend",i),this.dialog=i;let a=i.querySelector("input");return a.value=n,a.focus(),a.select(),bo}currentLinkElement(){let n=rt(this._squire)?.commonAncestorContainer||null;return n&&n.nodeType!==1&&(n=n.parentElement),n?.closest?.("a[href]")||null}currentLinkHref(){let t=this.currentLinkElement();return t&&t.getAttribute("href")||""}selectElement(t){let n=t.ownerDocument.createRange();return n.selectNode(t),this._squire.setSelection(n),this.saveSelection(),n}closeLinkDialog(){this.dialog?.remove(),this.dialog=null}ensureMarker(){tn(this.element)||this.element.setAttribute("data-richclay","")}setupEditorAttributes(){if(this.element.classList.add(this.options.inline?"richclay-inline":"richclay-editor","richclay-active"),this.element.setAttribute("data-richclay-active","true"),!this.element.hasAttribute("data-richclay-runtime-contenteditable")){let t=this.element.getAttribute("contenteditable");t===null?this.element.setAttribute("data-richclay-runtime-contenteditable","true"):t!=="true"&&t!==""&&this.element.setAttribute("data-richclay-runtime-contenteditable",t)}this.element.setAttribute("contenteditable","true"),this.element.hasAttribute("role")||Zt(this.element,"role","textbox","data-richclay-runtime-role"),this.element.hasAttribute("aria-multiline")||Zt(this.element,"aria-multiline",this.options.singleLine?"false":"true","data-richclay-runtime-aria-multiline"),this.element.hasAttribute("no-undo")||Zt(this.element,"no-undo","","data-richclay-runtime-no-undo"),this.options.placeholder&&(this.element.setAttribute("data-richclay-placeholder",this.options.placeholder),this.description=this.element.ownerDocument.createElement("div"),this.description.id=`richclay-placeholder-${++To}`,this.description.className="richclay-sr-only",this.description.textContent=this.options.placeholder,this.description.setAttribute("data-richclay-live",""),ye(this.description),this.element.insertAdjacentElement("afterend",this.description),no(this.element,this.description)),this.element.addEventListener("focus",this._onFocus),this.element.addEventListener("blur",this._onBlur)}cleanupEditorAttributes(){ti(this.element,"destroy"),this.element.removeEventListener("focus",this._onFocus),this.element.removeEventListener("blur",this._onBlur)}bindSquire(){let t=()=>{this.saveSelection(),this.updatePlaceholder(),this.options.onChange?.(this.getHTML()),this.toolbar?.update()},n=o=>{this.path=o.detail?.path||this._squire.getPath?.()||"",this.saveSelection(),this.toolbar?.update()},i=()=>{this.saveSelection(),this.toolbar?.update(),this.options.toolbarOnSelect&&this.updateFloatVisibility()};[["input",t],["pathChange",n],["select",i],["cursor",i],["undoStateChange",()=>this.toolbar?.update()]].forEach(([o,s])=>{this._squire.addEventListener(o,s),this._squireListeners.push([o,s])})}renderToolbar(){if(!this.active||this.options.readOnly)return;if(this.options.inline){this.float&&(this.teardownFloatingToolbar(),this.ensureFloatingToolbar());return}this.toolbar?.destroy(),this.toolbar=null;let t=this.resolveToolbarControls(this.options.toolbar);t.length&&(this.toolbar=new ot(this,t,{toolbarContainer:this.options.toolbarContainer}))}ensureFloatingToolbar(){if(this.float||!this.active||this.options.readOnly)return;let t=this.resolveToolbarControls(this.options.toolbar);t.length&&(this.float=new Jt(this,t),this._onFloatFocusOut=n=>this.scheduleFloatTeardown(n),this.float.root.addEventListener("focusout",this._onFloatFocusOut),this._onDocPointerDown=n=>{if(this.ownsFocusTarget(n.target))return;let i=this.element.ownerDocument;i.activeElement&&this.ownsFocusTarget(i.activeElement)&&i.activeElement.blur?.(),this.teardownFloatingToolbar()},this.element.ownerDocument.addEventListener("pointerdown",this._onDocPointerDown,!0),this.toolbar=this.float.toolbar,this.toolbar.update(),this.options.toolbarOnSelect&&this.updateFloatVisibility())}teardownFloatingToolbar(){this.float&&(this._onFloatFocusOut&&(this.float.root.removeEventListener("focusout",this._onFloatFocusOut),this._onFloatFocusOut=null),this._onDocPointerDown&&(this.element.ownerDocument.removeEventListener("pointerdown",this._onDocPointerDown,!0),this._onDocPointerDown=null),this.float.destroy(),this.float=null,this.toolbar=null)}scheduleFloatTeardown(t){let n=t?.relatedTarget;if(n&&this.ownsFocusTarget(n))return;let i=this.element.ownerDocument;(i.defaultView||globalThis).setTimeout(()=>{let o=i.activeElement;o&&this.ownsFocusTarget(o)||this.teardownFloatingToolbar()},0)}ownsFocusTarget(t){return t===this.element||this.element.contains(t)||!!this.float?.root.contains(t)||!!this.dialog?.contains(t)}updateFloatVisibility(){if(!this.float)return;let t=this.savedSelection;this.float.setVisible(!!(t&&!t.collapsed))}resolveToolbarControls(t){return t===!1||t===null||t==="none"?[]:(Array.isArray(t)?t:Et[t]||Et.standard).map(i=>{if(typeof i=="string"){let r=this.registry.get(i);if(!r)throw new Error(`Unknown RichClay toolbar control: ${i}`);return r}return i?.type==="separator"||hi(i),i})}installShortcuts(){let t=new Set,n=[...this.registry.values()].filter(r=>!this.options.singleLine||Et.inline.includes(r.id));[...this.resolveToolbarControls(this.options.toolbar),...n].forEach(r=>{if(r.type==="menu"||r.type==="separator"||!r.shortcut||!r.id||t.has(r.id))return;if(r.isDisabled?.(this)){let s=So(r.shortcut,this.window);this._squire.setKeyHandler(s,null),this._shortcutKeys.push(s);return}t.add(r.id);let o=So(r.shortcut,this.window);this._squire.setKeyHandler(o,(s,a)=>{a.preventDefault(),this.runControl(r)}),this._shortcutKeys.push(o)})}maskSquireCodeShortcut(){let t=`${nt(this.window)?"Meta":"Ctrl"}-d`;this._squire.setKeyHandler(t,null),this._shortcutKeys.push(t)}maskSquireBlockShortcuts(){if(!this.blocksStayOut())return;let t=nt(this.window)?"Meta":"Ctrl";[`${t}-]`,`${t}-[`,`${t}-Shift-8`,`${t}-Shift-9`].forEach(n=>{this._squire.setKeyHandler(n,null),this._shortcutKeys.push(n)})}toggleCode(){return this.blocksStayOut()?this.selectionHasFormat("CODE")?this._squire.changeFormat(null,{tag:"CODE"}):this._squire.changeFormat({tag:"CODE"},null):this._squire.toggleCode()}installAppleDeleteKeys(){if(!nt(this.window))return;let t=this._squire._keyHandlers;t&&[["Ctrl-d","Delete"],["Ctrl-h","Backspace"]].forEach(([n,i])=>{typeof t[i]=="function"&&(this._squire.setKeyHandler(n,t[i]),this._shortcutKeys.push(n),this._appleDeleteKeys.add(n.slice(5)))})}installSingleLineGuards(){["Enter","Shift-Enter"].forEach(t=>{this._squire.setKeyHandler(t,(n,i)=>i.preventDefault()),this._shortcutKeys.push(t)}),this._onBeforeInput=t=>{this.element.contains(t.target)&&(t.inputType==="insertParagraph"||t.inputType==="insertLineBreak")&&(t.preventDefault(),t.stopPropagation())},this.element.ownerDocument.addEventListener("beforeinput",this._onBeforeInput,!0)}resetSquireUndoBaseline(){let t=this._squire;!t||!Array.isArray(t._undoStack)||typeof t.saveUndoState!="function"||(t._undoStack.length=0,t._undoStackLength=0,t._undoIndex=-1,t._isInUndoState=!1,t.saveUndoState())}updatePlaceholder(){let t=(this.element.textContent||"").replace(/\u200B/g,"").trim(),n=this.element.querySelector("img, video, audio, iframe, table"),i=!t&&!n;this.element.classList.toggle("richclay-empty",i)}announceControl(t){if(!this.liveRegion)return;let n=t.ariaLabel||t.label;n&&(typeof t.isActive=="function"?xt(this.liveRegion,`${n} ${t.isActive(this)?"on":"off"}`):xt(this.liveRegion,`${n} applied`))}};function sl(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)):e?.nodeType===1?[e]:Array.from(e||[])}function Eo(e,t,n,i,r){let o=t;if(o===e){let c=Array.from(e.childNodes).filter(it);if(!c.length)return null;let u=Math.min(i?n:Math.max(n-1,0),c.length-1);o=St(c[u],i)}let a=(o?.nodeType===1?o:o?.parentElement)?.closest?.(r);return a&&e.contains(a)&&a!==e?a:null}function al(e){let t=e.parentElement;for(;t;){if(De.has(t)||tn(t))return t;t=t.parentElement}return null}function tn(e){return!!e.matches?.(ue)&&Qn(e)}function di(e){let t=al(e),n=Array.from(e.querySelectorAll?.(ue)||[]).find(r=>De.has(r)),i=t||n;return i?(console.warn("richclay: nested editable regions are not supported, so this one was skipped. Remove the editable attribute from either it or the other region.",e,i),!0):!1}function ll(e){return Ur(e)?(console.warn(`richclay: ${Hr(e)} This region was skipped.`,e),!0):!1}function hi(e){if(!e||!e.id)throw new Error("RichClay button definitions require an id.");if(e.type!=="menu"&&typeof e.run!="function")throw new Error(`RichClay button "${e.id}" requires a run(editor) function.`)}function So(e,t){let n=e.split("+"),i=n[n.length-1],r=new Set(n.slice(0,-1).map(cl));r.delete("Mod")&&r.add(nt(t)?"Meta":"Ctrl");let o=i.length===1?r.has("Shift")?i.toUpperCase():i.toLowerCase():i,s=rl.filter(a=>r.has(a)).join("-");return`${s?`${s}-`:""}${o}`}function cl(e){return e==="Cmd"?"Meta":e}function ul(e,t){let n=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!n.length)return;let i=n[0],r=n[n.length-1],o=t.ownerDocument.activeElement;e.shiftKey&&o===i?(e.preventDefault(),r.focus()):!e.shiftKey&&o===r&&(e.preventDefault(),i.focus())}var Ao=`:root {
41
+ `;let o=()=>{this.closeLinkDialog(),this.toolbar?.update(),this.focus()};i.addEventListener("submit",l=>{l.preventDefault();let u=new FormData(i),d=mo(u.get("url"));if(!d){xt(this.liveRegion,"Enter a valid URL");return}this.restoreSelection();let f=this.currentLinkElement();f&&this.selectElement(f),this._squire.makeLink(d),xt(this.liveRegion,"Link applied"),o()}),i.querySelector("[data-richclay-cancel]").addEventListener("click",o),i.addEventListener("keydown",l=>{l.key==="Escape"?(l.preventDefault(),o()):l.key==="Tab"&&wl(l,i)}),(this.toolbar?.root||this.element).insertAdjacentElement("afterend",i),this.dialog=i;let a=i.querySelector("input");return a.value=n,a.focus(),a.select(),Lo}currentLinkElement(){let n=rt(this._squire)?.commonAncestorContainer||null;return n&&n.nodeType!==1&&(n=n.parentElement),n?.closest?.("a[href]")||null}currentLinkHref(){let t=this.currentLinkElement();return t&&t.getAttribute("href")||""}selectElement(t){let n=t.ownerDocument.createRange();return n.selectNode(t),this._squire.setSelection(n),this.saveSelection(),n}closeLinkDialog(){this.dialog?.remove(),this.dialog=null}ensureMarker(){Lt(this.element)||(this.element.setAttribute("data-richclay-runtime-marker","true"),this.element.setAttribute("data-richclay",""))}setupEditorAttributes(){if(this.element.classList.add(this.options.inline?"richclay-inline":"richclay-editor","richclay-active"),this.element.setAttribute("data-richclay-active","true"),!this.element.hasAttribute("data-richclay-runtime-contenteditable")){let t=this.element.getAttribute("contenteditable");t===null?this.element.setAttribute("data-richclay-runtime-contenteditable","true"):t!=="true"&&t!==""&&this.element.setAttribute("data-richclay-runtime-contenteditable",t)}this.element.setAttribute("contenteditable","true"),this.element.hasAttribute("role")||tn(this.element,"role","textbox","data-richclay-runtime-role"),this.element.hasAttribute("aria-multiline")||tn(this.element,"aria-multiline",this.options.singleLine?"false":"true","data-richclay-runtime-aria-multiline"),this.element.hasAttribute("no-undo")||tn(this.element,"no-undo","","data-richclay-runtime-no-undo"),this.options.placeholder&&(this.element.setAttribute("data-richclay-placeholder",this.options.placeholder),this.description||(this.description=this.element.ownerDocument.createElement("div"),this.description.id=`richclay-placeholder-${++Ro}`,this.description.className="richclay-sr-only",this.description.textContent=this.options.placeholder,this.description.setAttribute("data-richclay-live",""),ye(this.description)),this.description.isConnected||this.element.insertAdjacentElement("afterend",this.description),ao(this.element,this.description)),this.element.addEventListener("focus",this._onFocus),this.element.addEventListener("blur",this._onBlur)}cleanupEditorAttributes(){Jt(this.element,"destroy"),this.element.removeEventListener("focus",this._onFocus),this.element.removeEventListener("blur",this._onBlur)}bindSquire(){let t=()=>{this.saveSelection(),this.updatePlaceholder(),this.options.onChange?.(this.getHTML()),this.toolbar?.update()},n=o=>{this.path=o.detail?.path||this._squire.getPath?.()||"",this.saveSelection(),this.toolbar?.update()},i=()=>{this.saveSelection(),this.toolbar?.update(),this.options.toolbarOnSelect&&this.updateFloatVisibility()};[["input",t],["pathChange",n],["select",i],["cursor",i],["undoStateChange",()=>this.toolbar?.update()]].forEach(([o,s])=>{this._squire.addEventListener(o,s),this._squireListeners.push([o,s])})}renderToolbar(){if(!this.active||this.options.readOnly)return;if(this.options.inline){this.float&&(this.teardownFloatingToolbar(),this.ensureFloatingToolbar());return}this.toolbar?.destroy(),this.toolbar=null;let t=this.resolveToolbarControls(this.options.toolbar);t.length&&(this.toolbar=new ot(this,t,{toolbarContainer:this.options.toolbarContainer}))}ensureFloatingToolbar(){if(this.float||!this.active||this.options.readOnly)return;let t=this.resolveToolbarControls(this.options.toolbar);t.length&&(this.float=new nn(this,t),this._onFloatFocusOut=n=>this.scheduleFloatTeardown(n),this.float.root.addEventListener("focusout",this._onFloatFocusOut),this._onDocPointerDown=n=>{if(this.ownsFocusTarget(n.target))return;let i=this.element.ownerDocument;i.activeElement&&this.ownsFocusTarget(i.activeElement)&&i.activeElement.blur?.(),this.teardownFloatingToolbar()},this.element.ownerDocument.addEventListener("pointerdown",this._onDocPointerDown,!0),this.toolbar=this.float.toolbar,this.toolbar.update(),this.options.toolbarOnSelect&&this.updateFloatVisibility())}teardownFloatingToolbar(){this.float&&(this._onFloatFocusOut&&(this.float.root.removeEventListener("focusout",this._onFloatFocusOut),this._onFloatFocusOut=null),this._onDocPointerDown&&(this.element.ownerDocument.removeEventListener("pointerdown",this._onDocPointerDown,!0),this._onDocPointerDown=null),this.float.destroy(),this.float=null,this.toolbar=null)}scheduleFloatTeardown(t){let n=t?.relatedTarget;if(n&&this.ownsFocusTarget(n))return;let i=this.element.ownerDocument;(i.defaultView||globalThis).setTimeout(()=>{let o=i.activeElement;o&&this.ownsFocusTarget(o)||this.teardownFloatingToolbar()},0)}ownsFocusTarget(t){return t===this.element||this.element.contains(t)||!!this.float?.root.contains(t)||!!this.dialog?.contains(t)}updateFloatVisibility(){if(!this.float)return;let t=this.savedSelection;this.float.setVisible(!!(t&&!t.collapsed))}resolveToolbarControls(t){return t===!1||t===null||t==="none"?[]:(Array.isArray(t)?t:Et[t]||Et.standard).map(i=>{if(typeof i=="string"){let r=this.registry.get(i);if(!r)throw new Error(`Unknown RichClay toolbar control: ${i}`);return r}return i?.type==="separator"||bi(i),i})}installShortcuts(){let t=new Set,n=[...this.registry.values()].filter(r=>!this.options.singleLine||Et.inline.includes(r.id));[...this.resolveToolbarControls(this.options.toolbar),...n].forEach(r=>{if(r.type==="menu"||r.type==="separator"||!r.shortcut||!r.id||t.has(r.id))return;if(r.isDisabled?.(this)){let s=ko(r.shortcut,this.window);this._squire.setKeyHandler(s,null),this._shortcutKeys.push(s);return}t.add(r.id);let o=ko(r.shortcut,this.window);this._squire.setKeyHandler(o,(s,a)=>{a.preventDefault(),this.runControl(r)}),this._shortcutKeys.push(o)})}maskSquireCodeShortcut(){let t=`${nt(this.window)?"Meta":"Ctrl"}-d`;this._squire.setKeyHandler(t,null),this._shortcutKeys.push(t)}maskSquireBlockShortcuts(){if(!this.blocksStayOut())return;let t=nt(this.window)?"Meta":"Ctrl";[`${t}-]`,`${t}-[`,`${t}-Shift-8`,`${t}-Shift-9`].forEach(n=>{this._squire.setKeyHandler(n,null),this._shortcutKeys.push(n)})}toggleCode(){return this.blocksStayOut()?this.selectionHasFormat("CODE")?this._squire.changeFormat(null,{tag:"CODE"}):this._squire.changeFormat({tag:"CODE"},null):this._squire.toggleCode()}installAppleDeleteKeys(){if(!nt(this.window))return;let t=this._squire._keyHandlers;t&&[["Ctrl-d","Delete"],["Ctrl-h","Backspace"]].forEach(([n,i])=>{typeof t[i]=="function"&&(this._squire.setKeyHandler(n,t[i]),this._shortcutKeys.push(n),this._appleDeleteKeys.add(n.slice(5)))})}installSingleLineGuards(){["Enter","Shift-Enter"].forEach(t=>{this._squire.setKeyHandler(t,(n,i)=>i.preventDefault()),this._shortcutKeys.push(t)}),this._onBeforeInput=t=>{this.element.contains(t.target)&&(t.inputType==="insertParagraph"||t.inputType==="insertLineBreak")&&(t.preventDefault(),t.stopPropagation())},this.element.ownerDocument.addEventListener("beforeinput",this._onBeforeInput,!0)}resetSquireUndoBaseline(){let t=this._squire;!t||!Array.isArray(t._undoStack)||typeof t.saveUndoState!="function"||(t._undoStack.length=0,t._undoStackLength=0,t._undoIndex=-1,t._isInUndoState=!1,t.saveUndoState())}updatePlaceholder(){let t=mi(this.element,{capability:"history",inherit:!1}),n=t.text().replace(/\u200B/g,"").trim(),i=t.root.querySelector("img, video, audio, iframe, table"),r=!n&&!i;this.element.classList.toggle("richclay-empty",r)}announceControl(t){if(!this.liveRegion)return;let n=t.ariaLabel||t.label;n&&(typeof t.isActive=="function"?xt(this.liveRegion,`${n} ${t.isActive(this)?"on":"off"}`):xt(this.liveRegion,`${n} applied`))}};function Cl(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)):e?.nodeType===1?[e]:Array.from(e||[])}function Oo(e,t,n,i,r){let o=t;if(o===e){let l=Array.from(e.childNodes).filter(it);if(!l.length)return null;let u=Math.min(i?n:Math.max(n-1,0),l.length-1);o=St(l[u],i)}let a=(o?.nodeType===1?o:o?.parentElement)?.closest?.(r);return a&&e.contains(a)&&a!==e?a:null}function xl(e){let t=e.parentElement;for(;t;){if(Ae.has(t)||Lt(t))return t;t=t.parentElement}return null}function Lt(e){return!!e.matches?.(ue)&&ei(e)}function yi(e){let t=xl(e),n=Array.from(e.querySelectorAll?.(ue)||[]).find(r=>Ae.has(r)),i=t||n;return i?(console.warn("richclay: nested editable regions are not supported, so this one was skipped. Remove the editable attribute from either it or the other region.",e,i),!0):!1}function Nl(e){return Gr(e)?(console.warn(`richclay: ${Kr(e)} This region was skipped.`,e),!0):!1}function bi(e){if(!e||!e.id)throw new Error("RichClay button definitions require an id.");if(e.type!=="menu"&&typeof e.run!="function")throw new Error(`RichClay button "${e.id}" requires a run(editor) function.`)}function ko(e,t){let n=e.split("+"),i=n[n.length-1],r=new Set(n.slice(0,-1).map(Ll));r.delete("Mod")&&r.add(nt(t)?"Meta":"Ctrl");let o=i.length===1?r.has("Shift")?i.toUpperCase():i.toLowerCase():i,s=Al.filter(a=>r.has(a)).join("-");return`${s?`${s}-`:""}${o}`}function Ll(e){return e==="Cmd"?"Meta":e}function wl(e,t){let n=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!n.length)return;let i=n[0],r=n[n.length-1],o=t.ownerDocument.activeElement;e.shiftKey&&o===i?(e.preventDefault(),r.focus()):!e.shiftKey&&o===r&&(e.preventDefault(),i.focus())}var Mo=`:root {
35
42
  --richclay-surface: #ffffff;
36
43
  --richclay-surface-alt: #f6f7f9;
37
44
  --richclay-text: #0b0e14;
@@ -447,7 +454,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
447
454
  stroke: Canvas;
448
455
  }
449
456
  }
450
- `;var st=typeof globalThis<"u"?globalThis:self;st&&!st.Squire&&(st.Squire=dr);st&&!st.DOMPurify&&(st.DOMPurify=wr);po(Ao);We.autoInit();var hl=We;return is(fl);})();
457
+ `;var st=typeof globalThis<"u"?globalThis:self;st&&!st.Squire&&(st.Squire=yr);st&&!st.DOMPurify&&(st.DOMPurify=Mr);To(Mo);We.autoInit();var Ol=We;return ms(kl);})();
451
458
  /*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */
452
459
 
453
460
  // Auto-export to window unless suppressed by loader. The self-contained bundle