@panphora/clayjs 0.2.1 → 0.4.1
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.
- package/README.md +103 -7
- package/clay-data.js +1 -1
- package/clay-internals.js +19 -0
- package/clay.js +19 -3
- package/package.json +5 -2
- package/sap.js +5 -5
- package/src/attrs/onaftersave.js +12 -1
- package/src/attrs/refetch-on-save.js +4 -4
- package/src/attrs/save-freeze.js +47 -19
- package/src/core/admin-contenteditable.js +2 -2
- package/src/core/admin-inputs.js +2 -2
- package/src/core/admin-onclick.js +2 -2
- package/src/core/admin-resources.js +23 -14
- package/src/core/autosave.js +11 -1
- package/src/core/edit-mode.js +2 -2
- package/src/core/host-attrs.js +46 -0
- package/src/core/is-edit-mode.js +14 -6
- package/src/core/persist.js +12 -2
- package/src/core/save-core.js +199 -290
- package/src/core/save.js +121 -82
- package/src/core/snapshot.js +89 -36
- package/src/core/unsaved-warning.js +8 -2
- package/src/dom/all.js +4 -29
- package/src/dom/form-data.js +1 -1
- package/src/dom/nearest.js +11 -9
- package/src/internals/index.js +69 -0
- package/src/lib/cache-bust.js +10 -0
- package/src/lib/cookie.js +50 -15
- package/src/lib/extension-noise.js +5 -1
- package/src/lib/mutation.js +65 -18
- package/src/lib/region-policy.js +17 -2
- package/src/lib/root-attrs.js +45 -0
- package/src/lib/throttle.js +25 -13
- package/src/loader.js +18 -24
- package/src/options/options.js +1 -3
- package/src/plugins/demo.js +7 -1
- package/src/plugins/undo.js +3 -3
- package/src/sync/live-sync.js +77 -76
- package/src/ui/dialogs.js +10 -1
- package/src/ui/index.js +0 -10
- package/src/utils/debounce.js +24 -7
- package/src/vendor/control-serialize.vendor.js +2 -1
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +29 -16
- package/src/vendor/richclay.vendor.js +29 -22
|
@@ -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 ao=Object.getOwnPropertyDescriptor;var lo=Object.getOwnPropertyNames;var co=Object.prototype.hasOwnProperty;var ho=(e,t)=>{for(var n in t)sn(e,n,{get:t[n],enumerable:!0})},uo=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of lo(t))!co.call(e,r)&&r!==n&&sn(e,r,{get:()=>t[r],enumerable:!(i=ao(t,r))||i.enumerable});return e};var fo=e=>uo(sn({},"__esModule",{value:!0}),e);var ra={};ho(ra,{RichClay:()=>qe,default:()=>ia});var po=()=>!0,ne=class{constructor(e,t,n){this.root=e,this.currentNode=e,this.nodeType=t,this.filter=n||po}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}}},Ue=navigator.userAgent,gn=/Mac OS X/.test(Ue),Ai=/Windows NT/.test(Ue),xi=/iP(?:ad|hone|od)/.test(Ue)||gn&&!!navigator.maxTouchPoints,sa=/Android/.test(Ue),mo=/Gecko\//.test(Ue),kt=/Edge\//.test(Ue),go=!kt&&/WebKit\//.test(Ue),J=gn||xi?"Meta-":"Ctrl-",Dt=go,yo="onbeforeinput"in document&&"inputType"in new InputEvent("input"),ue=/[^ \t\r\n\u200B]/,bo=/^(?:#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)$/,_o=new Set(["BR","HR","IFRAME","IMG","INPUT"]),To=0,dn=1,Ci=2,Li=3,wt=new WeakMap,Ni=()=>{wt=new WeakMap},Ne=e=>_o.has(e.nodeName),yn=e=>{switch(e.nodeType){case 8:case 3:return dn;case 1:case 11:if(wt.has(e))return wt.get(e);break;default:return To}let t;return Array.from(e.childNodes).every(C)?bo.test(e.nodeName)?t=dn:t=Ci:t=Li,wt.set(e,t),t},C=e=>yn(e)===dn,Le=e=>yn(e)===Ci,Qe=e=>yn(e)===Li,_=(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},wi=(e,t)=>Ne(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,hn=(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},N=(e,t,n,i)=>{for(;e&&e!==t;){if(hn(e,n,i))return e;e=e.parentNode}return null},bn=(e,t)=>{let n=e.childNodes;for(;t&&e instanceof Element;)e=n[t-1],n=e.childNodes,t=n.length;return e},ki=(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,R=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)},So=e=>e instanceof Element?e.nodeName==="BR":ue.test(e.data),Rt=(e,t)=>{let n=e.parentNode;for(;C(n);)n=n.parentNode;let i=new ne(n,5,So);return i.currentNode=e,!!i.nextNode()||t&&!i.previousNode()},Lt=(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,!(!C(s)||re(s)));)o=s,s=o.parentNode;break}else i.deleteData(r,1)},vo=0,Eo=1,Ao=2,xo=3,Ce=(e,t,n)=>{let i=document.createRange();if(i.selectNode(t),n){let r=e.compareBoundaryPoints(xo,i)>-1,o=e.compareBoundaryPoints(Eo,i)<1;return!r&&!o}else{let r=e.compareBoundaryPoints(vo,i)<1,o=e.compareBoundaryPoints(Ao,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||Ne(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||Ne(o)){if(o&&o.nodeName==="BR"&&!Rt(o,!1)){r-=1;continue}break}i=o,r=re(i)}else for(;!(i instanceof Text);){let o=i.firstChild;if(!o||Ne(o))break;i=o}e.setStart(t,n),e.setEnd(i,r)},Pe=(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"&&!Rt(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)},gi=(e,t,n)=>{let i=N(e.endContainer,n,t);if(i&&(i=i.parentNode)){let r=e.cloneRange();Pe(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(C(e)){let n=e.firstChild;if(Dt)for(;n&&n instanceof Text&&!n.data;)e.removeChild(n),n=e.firstChild;n||(Dt?t=document.createTextNode("\u200B"):t=document.createTextNode(""))}else if((e instanceof Element||e instanceof DocumentFragment)&&!e.querySelector("BR")&&!ue.test(e.textContent||"")){t=_("BR");let n=e,i;for(;(i=n.lastElementChild)&&!C(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},fe=(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&&C(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),Qe(i)&&fe(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&&N(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)},Di=(e,t)=>{let n=e.childNodes,i=n.length,r=[];for(;i--;){let o=n[i],s=i?n[i-1]:null;if(s&&C(o)&&wi(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(R(o));else if(o instanceof Element){let a;for(;a=r.pop();)o.appendChild(a);Di(o,t)}}},Ye=(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};Di(n,i),t.setStart(i.startContainer,i.startOffset),t.setEnd(i.endContainer,i.endOffset)}},ct=(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(R(t)),n.setStart(e,s),n.collapse(!0),Ye(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&&wi(n,e)){if(!Qe(n))if(r){let s=_("DIV");s.appendChild(R(n)),n.appendChild(s)}else return;H(e);let o=!Qe(e);n.appendChild(R(e)),o&&fe(n,t),i&&_e(i,t)}else if(r){let o=_("DIV");e.insertBefore(o,i),z(o)}}},yi={"font-weight":{regexp:/^bold|^700/i,replace(){return _("B")}},"font-style":{regexp:/^italic/i,replace(){return _("I")}},"font-family":{regexp:ue,replace(e,t){let n=_("SPAN",{class:e.fontFamily});return n.style.fontFamily=t,n}},"font-size":{regexp:ue,replace(e,t){let n=_("SPAN",{class:e.fontSize});return n.style.fontSize=t,n}},"text-decoration":{regexp:/^underline/i,replace(){return _("U")}}},Co=(e,t,n)=>{let i=e.style,r,o;for(let s in yi){let a=yi[s],c=i.getPropertyValue(s);if(c&&a.regexp.test(c)){let d=a.replace(n.classNames,c);if(d.nodeName===e.nodeName&&d.className===e.className)continue;o||(o=d),r&&r.appendChild(d),r=d,e.style.removeProperty(s)}}return o&&r&&(r.appendChild(R(e)),e.style.cssText?e.appendChild(o):j(e,o)),r||e},Nt=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(R(t)),i},Lo={1:"10",2:"13",3:"16",4:"18",5:"24",6:"32",7:"48"},No={STRONG:Nt("B"),EM:Nt("I"),INS:Nt("U"),STRIKE:Nt("S"),SPAN:Co,FONT:(e,t,n)=>{let i=e,r=i.face,o=i.size,s=i.color,a=n.classNames,c,d,u,f,g;return r&&(c=_("SPAN",{class:a.fontFamily}),c.style.fontFamily=r,g=c,f=c),o&&(d=_("SPAN",{class:a.fontSize}),d.style.fontSize=Lo[o]+"px",g||(g=d),f&&f.appendChild(d),f=d),s&&/^#?([\dA-F]{3}){1,2}$/i.test(s)&&(s.charAt(0)!=="#"&&(s="#"+s),u=_("SPAN",{class:a.color}),u.style.color=s,g||(g=u),f&&f.appendChild(u),f=u),(!g||!f)&&(g=f=_("SPAN")),t.replaceChild(g,i),f.appendChild(R(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(R(e)),i}},wo=/^(?: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)$/,ko=/^(?:HEAD|META|STYLE)/,un=(e,t,n)=>{let i=e.childNodes,r=e;for(;C(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],d=c.nodeName,u=No[d];if(c instanceof HTMLElement){let f=c.childNodes.length;if(u)c=u(c,e,t);else if(ko.test(d)){e.removeChild(c),s-=1,a-=1;continue}else if(!wo.test(d)&&!C(c)){s-=1,a+=f-1,e.replaceChild(R(c),c);continue}f&&un(c,t,n||d==="PRE")}else{if(c instanceof Text){let f=c.data,g=!ue.test(f.charAt(0)),y=!ue.test(f.charAt(f.length-1));if(n||!g&&!y)continue;if(g){o.currentNode=c;let v;for(;(v=o.previousPONode())&&!(v.nodeName==="IMG"||v instanceof Text&&ue.test(v.data));)if(!C(v)){v=null;break}f=f.replace(/^[ \t\r\n]+/g,v?" ":"")}if(y){o.currentNode=c;let v;for(;(v=o.nextNode())&&!(v.nodeName==="IMG"||v instanceof Text&&ue.test(v.data));)if(!C(v)){v=null;break}f=f.replace(/[ \t\r\n]+$/g,v?" ":"")}if(f){c.data=f;continue}}e.removeChild(c),s-=1,a-=1}}return e},fn=e=>{let t=e.childNodes,n=t.length;for(;n--;){let i=t[n];i instanceof Element&&!Ne(i)?(fn(i),C(i)&&!i.firstChild&&e.removeChild(i)):i instanceof Text&&!i.data&&e.removeChild(i)}},pn=(e,t,n)=>{let i=e.querySelectorAll("BR"),r=[],o=i.length;for(let s=0;s<o;s+=1)r[s]=Rt(i[s],n);for(;o--;){let s=i[o],a=s.parentNode;a&&(r[o]?C(a)||fe(a,t):H(s))}},bi=e=>e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join("""),Ot=(e,t)=>{let n=new ne(t,1,Le);return n.currentNode=e,n},Fe=(e,t)=>{let n=Ot(e,t).previousNode();return n!==t?n:null},Te=(e,t)=>{let n=Ot(e,t).nextNode();return n!==t?n:null},mn=e=>!e.textContent&&!e.querySelector("IMG"),ie=(e,t)=>{let n=e.startContainer,i;if(C(n))i=Fe(n,t);else if(n!==t&&n instanceof HTMLElement&&Le(n))i=n;else{let r=bn(n,e.startOffset);i=Te(r,t)}return i&&Ce(e,i,!0)?i:null},Be=(e,t)=>{let n=e.endContainer,i;if(C(n))i=Fe(n,t);else if(n!==t&&n instanceof HTMLElement&&Le(n))i=n;else{let r=ki(n,e.endOffset);if(!r||!t.contains(r)){r=t;let o;for(;o=r.lastChild;)r=o}i=Fe(r,t)}return i&&Ce(e,i,!0)?i:null},Oi=e=>e instanceof Text?ue.test(e.data):e.nodeName==="IMG",dt=(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=ki(n,i),r&&!t.contains(r)&&(r=null),!r&&(r=bn(n,i),r instanceof Text&&r.length))return!1;let o=ie(e,t);if(!o)return!1;let s=new ne(o,5,Oi);return s.currentNode=r,!s.previousNode()},ht=(e,t)=>{let n=e.endContainer,i=e.endOffset,r;if(n instanceof Text){let a=n.data,c=a.length;for(let d=i;d<c;d+=1)if(a.charAt(d)!=="\u200B")return!1;r=n}else r=bn(n,i);let o=Be(e,t);if(!o)return!1;let s=new ne(o,5,Oi);return s.currentNode=r,!s.nextNode()},_i=(e,t)=>{let n=ie(e,t),i=Be(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 Me(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 be=(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 d=n.splitText(i);r===n?(o-=i,r=d):r===c&&(o+=1),n=d}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)},Ri=(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 d=c.nextSibling;i.appendChild(c),c=d}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},Ti=(e,t,n)=>{e.currentNode=n;let i;for(;i=e[t]();){if(i instanceof Text||Ne(i))return i;if(!C(i))return null}return null},He=(e,t)=>{let n=ie(e,t),i=Be(e,t),r=n!==i;n&&i&&(V(e),Pe(e,n,i,t));let o=Ri(e,null,t);V(e),r&&(i=Be(e,t),n&&i&&n!==i&&ct(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,d=new ne(t,5),u=a,f=c;(!(u instanceof Text)||f===u.data.length)&&(u=Ti(d,"nextNode",u),f=0);let g=a,y=c-1;(!(g instanceof Text)||y===-1)&&(g=Ti(d,"previousPONode",u||(a instanceof Text?a:a.childNodes[c]||a)),g instanceof Text&&(y=g.data.length));let v=null,L=0;return u instanceof Text&&u.data.charAt(f)===" "&&dt(e,t)?(v=u,L=f):g instanceof Text&&g.data.charAt(y)===" "&&(u instanceof Text&&u.data.charAt(f)===" "||ht(e,t))&&(v=g,L=y),v&&v.replaceData(L,1,"\xA0"),e.setStart(a,c),e.collapse(!0),o},Do=(e,t,n)=>{let i=t.firstChild&&C(t.firstChild),r;for(fe(t,n),r=t;r=Te(r,n);)z(r);e.collapsed||He(e,n),V(e),e.collapse(!1);let o=N(e.endContainer,n,"BLOCKQUOTE")||n,s=ie(e,n),a=null,c=Te(t,t),d=!i&&!!s&&mn(s);if(s&&c&&!d&&!N(c,t,"PRE")&&!N(c,t,"TABLE")){Pe(e,s,s,n),e.collapse(!0);let u=e.endContainer,f=e.endOffset;if(pn(s,n,!1),C(u)){let g=se(u,f,Fe(u,n)||n,n);u=g.parentNode,f=Array.from(u.childNodes).indexOf(g)}if(f!==re(u))for(a=document.createDocumentFragment();r=u.childNodes[f];)a.appendChild(r);ct(u,c,e,n),u===n?e.setEnd(n,re(n)):(f=Array.from(u.parentNode.childNodes).indexOf(u)+1,u=u.parentNode,e.setEnd(u,f))}if(re(t)){d&&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=N(e.endContainer,n,"BLOCKQUOTE")||n),Pe(e,o,o,n);let u=se(e.endContainer,e.endOffset,o,n),f=u?u.previousSibling:o.lastChild;o.insertBefore(t,u),u?e.setEndBefore(u):e.setEnd(o,re(o)),s=Be(e,n),V(e);let g=e.endContainer,y=e.endOffset;u&&Qe(u)&&_e(u,n),u=f&&f.nextSibling,u&&Qe(u)&&_e(u,n),e.setEnd(g,y)}if(a&&s){let u=e.cloneRange();z(a),ct(s,a,u,n),e.setEnd(u.endContainer,u.endOffset)}V(e)},Ii=e=>{if(e.collapsed)return"";let t=e.startContainer,n=e.endContainer,i=new ne(e.commonAncestorContainer,5,c=>Ce(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&&!C(r))&&(o+=`
|
|
3
|
-
`,s=!1),r=i.nextNode();return o=o.replace(/ /g," "),o},
|
|
4
|
-
`)),f&&(f="<!-- squire -->"+f),[o,f]},Pi=(e,t,n,i,r,o,s)=>{let a=e.clipboardData;if(kt||!a)return!1;let[c,d]=Mi(t,n,i,r,o);return e.preventDefault(),!s&&d&&a.setData("text/html",d),a.setData("text/plain",c),!0},Oo=function(e){let t=this.getSelection(),n=this._root;if(t.collapsed){e.preventDefault();return}this.saveUndoState(t),Pi(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)},Ro=function(e){Pi(e,this.getSelection(),this._root,!1,this._config.willCutCopy,this._config.toPlainText,!1)},Si=function(e){this._isShiftDown=e.shiftKey},Io=function(e){let t=e.clipboardData,n=t?.items,i=this._isShiftDown,r=!1,o=!1,s=null,a=null;if(n){let x=n.length;for(;x--;){let M=n[x],$=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(!kt){e.preventDefault(),a&&(!i||!s)?a.getAsString(M=>{this.insertHTML(M,!0)}):s&&s.getAsString(M=>{let $=this.getSelection();if(!$.collapsed&&ue.test($.toString())){let le=this.linkRegExp.exec(M);if(le&&le[0].length===M.length){let X=le[1]?/^(?:ht|f)tps?:/i.test(le[1])?le[1]:"http://"+le[1]:"mailto:"+le[0];this.makeLink(X);return}}this.insertPlainText(M,!0)});return}}let c=t?.types;if(!kt&&c&&(an.call(c,"text/html")>-1||!mo&&an.call(c,"text/plain")>-1&&an.call(c,"text/rtf")<0)){e.preventDefault();let x;!i&&(x=t.getData("text/html"))?this.insertHTML(x,!0):((x=t.getData("text/plain"))||(x=t.getData("text/uri-list")))&&this.insertPlainText(x,!0);return}let d=document.body,u=this.getSelection(),f=u.startContainer,g=u.startOffset,y=u.endContainer,v=u.endOffset,L=_("DIV",{contenteditable:"true",style:"position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;"});d.appendChild(L),u.selectNodeContents(L),this.setSelection(u),setTimeout(()=>{try{let x="",M=L,$;for(;L=M;)M=L.nextSibling,H(L),$=L.firstChild,$&&$===L.lastChild&&$ instanceof HTMLDivElement&&(L=$),x+=L.innerHTML;this.setSelection(Me(f,g,y,v)),x&&this.insertHTML(x,!0)}catch(x){this._config.didError(x)}},0)},Mo=function(){let e=this.getSelection();e&&!e.collapsed&&this._root.contains(e.commonAncestorContainer)?this._dragRange=e.cloneRange():this._dragRange=null},Po=function(){this._dragRange=null},Fo=(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},Bo=(e,t)=>e.compareBoundaryPoints(Range.START_TO_START,t)>=0&&e.compareBoundaryPoints(Range.END_TO_END,t)<=0,Uo=function(e){let t=e.dataTransfer;if(!t)return;let n=t.types,i=!1,r=!1;for(let u=0,f=n.length;u<f;u+=1)switch(n[u]){case"text/plain":i=!0;break;case"text/html":r=!0;break}if(!i&&!r)return;e.preventDefault();let o=this._root,s=Fo(e.clientX,e.clientY,o),a=this._dragRange;if(this._dragRange=null,!s)return;let c,d;if(a){if(Bo(s,a))return;this._recordUndoState(a,this._isInUndoState);let u=document.createComment("");s.insertNode(u),this._getRangeAndRemoveBookmark(a),[c,d]=Mi(a,o,t.dropEffect!=="copy",this._config.willCutCopy,this._config.toPlainText),u.replaceWith(_("INPUT",{id:this.startSelectionId,type:"hidden"}),_("INPUT",{id:this.endSelectionId,type:"hidden"})),this._getRangeAndRemoveBookmark(s),Ni()}else this.saveUndoState(s),r?d=t.getData("text/html"):c=t.getData("text/plain");this.setSelection(s),d!==void 0?this.insertHTML(d,!0):c!==void 0&&this.insertPlainText(c,!0)},vi=(e,t,n)=>{t.preventDefault(),e.splitBlock(t.shiftKey,n)},lt=(e,t)=>{try{t||(t=e.getSelection());let n=t.startContainer;n instanceof Text&&(n=n.parentNode);let i=n;for(;C(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=Fe(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)}},Fi=(e,t)=>{let n;for(;(n=e.parentNode)&&!(n===t||n.isContentEditable);)e=n;H(e)},Bi=(e,t,n)=>{if(N(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,d=c+s[0].length,u=a.startContainer===t,f=a.startOffset-d;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,d),t.parentNode.insertBefore(y,t),t.data=i.slice(d),u&&(a.setStart(t,f),a.setEnd(t,f)),e.setSelection(a)}},Ho=(e,t,n)=>{let i=e._root;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),He(n,i),lt(e,n);else if(dt(n,i)){t.preventDefault();let r=ie(n,i);if(!r)return;let o=r;fe(o.parentNode,i);let s=Fe(o,i);if(s){if(!s.isContentEditable){Fi(s,i);return}for(ct(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(N(o,i,"UL")||N(o,i,"OL")){e.decreaseListLevel(n);return}else if(N(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(()=>{lt(e)},0))}},zo=(e,t,n)=>{let i=e._root,r,o,s,a,c,d;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),He(n,i),lt(e,n);else if(ht(n,i)){if(t.preventDefault(),r=ie(n,i),!r)return;if(fe(r.parentNode,i),o=Te(r,i),o){if(!o.isContentEditable){Fi(o,i);return}for(ct(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(),Pe(n,i,i,i),a=n.endContainer,c=n.endOffset,a instanceof Element&&(d=a.childNodes[c],d&&d.nodeName==="IMG")){t.preventDefault(),H(d),V(n),lt(e,n);return}e.setSelection(s),setTimeout(()=>{lt(e)},0)}},qo=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&dt(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}}},$o=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&dt(n,i)){let r=n.startContainer;(N(r,i,"UL")||N(r,i,"OL"))&&(t.preventDefault(),e.decreaseListLevel(n))}},Wo=(e,t,n)=>{let i,r=e._root;if(e._recordUndoState(n),e._getRangeAndRemoveBookmark(n),!n.collapsed)He(n,r),e._ensureBottomLine(),e.setSelection(n),e._updatePath(n,!0);else if(ht(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();V(o);let s=o.startContainer,a=o.startOffset;setTimeout(()=>{Bi(e,s,a)},0)}e.setSelection(n)},Go=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-")),Ai&&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),He(r,this._root),this._ensureBottomLine(),this.setSelection(r),this._updatePath(r,!0))},F={Backspace:Ho,Delete:zo,Tab:qo,"Shift-Tab":$o," ":Wo,ArrowLeft(e){e._removeZWS()},ArrowRight(e,t,n){e._removeZWS();let i=e.getRoot();if(ht(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)}}};yo||(F.Enter=vi,F["Shift-Enter"]=vi);!gn&&!xi&&(F.PageUp=e=>{e.moveCursorToStart()},F.PageDown=e=>{e.moveCursorToEnd()});var Xe=(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)});F[J+"b"]=Xe("B");F[J+"i"]=Xe("I");F[J+"u"]=Xe("U");F[J+"Shift-7"]=Xe("S");F[J+"Shift-5"]=Xe("SUB",{tag:"SUP"});F[J+"Shift-6"]=Xe("SUP",{tag:"SUB"});F[J+"Shift-8"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)UL/.test(n)?e.removeList():e.makeUnorderedList()};F[J+"Shift-9"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)OL/.test(n)?e.removeList():e.makeOrderedList()};F[J+"["]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.decreaseQuoteLevel():e.decreaseListLevel()};F[J+"]"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.increaseQuoteLevel():e.increaseListLevel()};F[J+"d"]=(e,t)=>{t.preventDefault(),e.toggleCode()};F[J+"z"]=(e,t)=>{t.preventDefault(),e.undo()};F[J+"y"]=F[J+"Shift-z"]=F[J+"Shift-Z"]=(e,t)=>{t.preventDefault(),e.redo()};var ln=8,Ei=40,cn=1200,Ko=[{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"}],jo={ArrowUp:(e,t,n)=>{let i=ie(t,n);if(i){let r=Fe(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=Te(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)}},Vo=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=Ko.map(({pos:r,cursor:o})=>{let s=ln/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 En=Object.defineProperty;var Ko=Object.getOwnPropertyDescriptor;var Vo=Object.getOwnPropertyNames;var jo=Object.prototype.hasOwnProperty;var Yo=(e,t)=>{for(var n in t)En(e,n,{get:t[n],enumerable:!0})},Xo=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Vo(t))!jo.call(e,r)&&r!==n&&En(e,r,{get:()=>t[r],enumerable:!(i=Ko(t,r))||i.enumerable});return e};var Qo=e=>Xo(En({},"__esModule",{value:!0}),e);var il={};Yo(il,{RichClay:()=>We,default:()=>nl});var Zo=()=>!0,ne=class{constructor(e,t,n){this.root=e,this.currentNode=e,this.nodeType=t,this.filter=n||Zo}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}}},He=navigator.userAgent,Rn=/Mac OS X/.test(He),Gi=/Windows NT/.test(He),Ki=/iP(?:ad|hone|od)/.test(He)||Rn&&!!navigator.maxTouchPoints,ol=/Android/.test(He),Jo=/Gecko\//.test(He),Ft=/Edge\//.test(He),es=!Ft&&/WebKit\//.test(He),J=Rn||Ki?"Meta-":"Ctrl-",Ut=es,ts="onbeforeinput"in document&&"inputType"in new InputEvent("input"),fe=/[^ \t\r\n\u200B]/,ns=/^(?:#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)$/,is=new Set(["BR","HR","IFRAME","IMG","INPUT"]),rs=0,Cn=1,Vi=2,ji=3,Bt=new WeakMap,Yi=()=>{Bt=new WeakMap},we=e=>is.has(e.nodeName),On=e=>{switch(e.nodeType){case 8:case 3:return Cn;case 1:case 11:if(Bt.has(e))return Bt.get(e);break;default:return rs}let t;return Array.from(e.childNodes).every(x)?ns.test(e.nodeName)?t=Cn:t=Vi:t=ji,Bt.set(e,t),t},x=e=>On(e)===Cn,Le=e=>On(e)===Vi,Ze=e=>On(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},Xi=(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,xn=(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(xn(e,n,i))return e;e=e.parentNode}return null},Dn=(e,t)=>{let n=e.childNodes;for(;t&&e instanceof Element;)e=n[t-1],n=e.childNodes,t=n.length;return e},Qi=(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)},os=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,os);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)},ss=0,as=1,ls=2,cs=3,Ne=(e,t,n)=>{let i=document.createRange();if(i.selectNode(t),n){let r=e.compareBoundaryPoints(cs,i)>-1,o=e.compareBoundaryPoints(as,i)<1;return!r&&!o}else{let r=e.compareBoundaryPoints(ss,i)<1,o=e.compareBoundaryPoints(ls,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)},Be=(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)},Bi=(e,t,n)=>{let i=L(e.endContainer,n,t);if(i&&(i=i.parentNode)){let r=e.cloneRange();Be(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)},Zi=(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)&&Xi(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);Zi(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};Zi(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&&Xi(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)}}},Fi={"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")}}},us=(e,t,n)=>{let i=e.style,r,o;for(let s in Fi){let a=Fi[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},hs={1:"10",2:"13",3:"16",4:"18",5:"24",6:"32",7:"48"},ds={STRONG:Pt("B"),EM:Pt("I"),INS:Pt("U"),STRIKE:Pt("S"),SPAN:us,FONT:(e,t,n)=>{let i=e,r=i.face,o=i.size,s=i.color,a=n.classNames,c,u,d,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=hs[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),d=_("SPAN",{class:a.color}),d.style.color=s,g||(g=d),f&&f.appendChild(d),f=d),(!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}},fs=/^(?: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)$/,ps=/^(?:HEAD|META|STYLE)/,Nn=(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,d=ds[u];if(c instanceof HTMLElement){let f=c.childNodes.length;if(d)c=d(c,e,t);else if(ps.test(u)){e.removeChild(c),s-=1,a-=1;continue}else if(!fs.test(u)&&!x(c)){s-=1,a+=f-1,e.replaceChild(D(c),c);continue}f&&Nn(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},Ln=e=>{let t=e.childNodes,n=t.length;for(;n--;){let i=t[n];i instanceof Element&&!we(i)?(Ln(i),x(i)&&!i.firstChild&&e.removeChild(i)):i instanceof Text&&!i.data&&e.removeChild(i)}},wn=(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))}},Ui=e=>e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join("""),Ht=(e,t)=>{let n=new ne(t,1,Le);return n.currentNode=e,n},Fe=(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=Fe(n,t);else if(n!==t&&n instanceof HTMLElement&&Le(n))i=n;else{let r=Dn(n,e.startOffset);i=Ee(r,t)}return i&&Ne(e,i,!0)?i:null},Ue=(e,t)=>{let n=e.endContainer,i;if(x(n))i=Fe(n,t);else if(n!==t&&n instanceof HTMLElement&&Le(n))i=n;else{let r=Qi(n,e.endOffset);if(!r||!t.contains(r)){r=t;let o;for(;o=r.lastChild;)r=o}i=Fe(r,t)}return i&&Ne(e,i,!0)?i:null},Ji=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=Qi(n,i),r&&!t.contains(r)&&(r=null),!r&&(r=Dn(n,i),r instanceof Text&&r.length))return!1;let o=ie(e,t);if(!o)return!1;let s=new ne(o,5,Ji);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=Dn(n,i);let o=Ue(e,t);if(!o)return!1;let s=new ne(o,5,Ji);return s.currentNode=r,!s.nextNode()},Hi=(e,t)=>{let n=ie(e,t),i=Ue(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 Pe(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)},er=(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},zi=(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},ze=(e,t)=>{let n=ie(e,t),i=Ue(e,t),r=n!==i;n&&i&&(j(e),Be(e,n,i,t));let o=er(e,null,t);j(e),r&&(i=Ue(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),d=a,f=c;(!(d instanceof Text)||f===d.data.length)&&(d=zi(u,"nextNode",d),f=0);let g=a,y=c-1;(!(g instanceof Text)||y===-1)&&(g=zi(u,"previousPONode",d||(a instanceof Text?a:a.childNodes[c]||a)),g instanceof Text&&(y=g.data.length));let S=null,N=0;return d instanceof Text&&d.data.charAt(f)===" "&&pt(e,t)?(S=d,N=f):g instanceof Text&&g.data.charAt(y)===" "&&(d instanceof Text&&d.data.charAt(f)===" "||mt(e,t))&&(S=g,N=y),S&&S.replaceData(N,1,"\xA0"),e.setStart(a,c),e.collapse(!0),o},ms=(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||ze(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")){Be(e,s,s,n),e.collapse(!0);let d=e.endContainer,f=e.endOffset;if(wn(s,n,!1),x(d)){let g=se(d,f,Fe(d,n)||n,n);d=g.parentNode,f=Array.from(d.childNodes).indexOf(g)}if(f!==re(d))for(a=document.createDocumentFragment();r=d.childNodes[f];)a.appendChild(r);ft(d,c,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),Be(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=Ue(e,n),j(e);let g=e.endContainer,y=e.endOffset;d&&Ze(d)&&Te(d,n),d=f&&f.nextSibling,d&&Ze(d)&&Te(d,n),e.setEnd(g,y)}if(a&&s){let d=e.cloneRange();z(a),ft(s,a,d,n),e.setEnd(d.endContainer,d.endOffset)}j(e)},tr=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},Sn=Array.prototype.indexOf,nr=(e,t,n,i,r)=>{let o=r?"":tr(e),s=ie(e,t),a=Ue(e,t),c=e.commonAncestorContainer,u=t;s===a&&s?.contains(c)&&(u=s);let d;for(n?(d=ze(e,t),c.isConnected||(c=e.commonAncestorContainer)):d=e.cloneContents(),c instanceof Text&&(c=c.parentNode);c&&c!==u;){let g=c.cloneNode(!1);g.appendChild(d),d=g,c=c.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 g=_("DIV");g.appendChild(d),f=g.innerHTML,i&&(f=i(f))}return r&&f!==void 0&&(o=r(f)),o===f&&(f=void 0),Gi&&(o=o.replace(/\r?\n/g,`\r
|
|
4
|
+
`)),f&&(f="<!-- squire -->"+f),[o,f]},ir=(e,t,n,i,r,o,s)=>{let a=e.clipboardData;if(Ft||!a)return!1;let[c,u]=nr(t,n,i,r,o);return e.preventDefault(),!s&&u&&a.setData("text/html",u),a.setData("text/plain",c),!0},gs=function(e){let t=this.getSelection(),n=this._root;if(t.collapsed){e.preventDefault();return}this.saveUndoState(t),ir(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)},ys=function(e){ir(e,this.getSelection(),this._root,!1,this._config.willCutCopy,this._config.toPlainText,!1)},qi=function(e){this._isShiftDown=e.shiftKey},bs=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&&(Sn.call(c,"text/html")>-1||!Jo&&Sn.call(c,"text/plain")>-1&&Sn.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,d=this.getSelection(),f=d.startContainer,g=d.startOffset,y=d.endContainer,S=d.endOffset,N=_("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(Pe(f,g,y,S)),C&&this.insertHTML(C,!0)}catch(C){this._config.didError(C)}},0)},_s=function(){let e=this.getSelection();e&&!e.collapsed&&this._root.contains(e.commonAncestorContainer)?this._dragRange=e.cloneRange():this._dragRange=null},Ts=function(){this._dragRange=null},Es=(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},Ss=(e,t)=>e.compareBoundaryPoints(Range.START_TO_START,t)>=0&&e.compareBoundaryPoints(Range.END_TO_END,t)<=0,As=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=Es(e.clientX,e.clientY,o),a=this._dragRange;if(this._dragRange=null,!s)return;let c,u;if(a){if(Ss(s,a))return;this._recordUndoState(a,this._isInUndoState);let d=document.createComment("");s.insertNode(d),this._getRangeAndRemoveBookmark(a),[c,u]=nr(a,o,t.dropEffect!=="copy",this._config.willCutCopy,this._config.toPlainText),d.replaceWith(_("INPUT",{id:this.startSelectionId,type:"hidden"}),_("INPUT",{id:this.endSelectionId,type:"hidden"})),this._getRangeAndRemoveBookmark(s),Yi()}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)},$i=(e,t,n)=>{t.preventDefault(),e.splitBlock(t.shiftKey,n)},dt=(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=Fe(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)}},rr=(e,t)=>{let n;for(;(n=e.parentNode)&&!(n===t||n.isContentEditable);)e=n;H(e)},or=(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,d=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),d&&(a.setStart(t,f),a.setEnd(t,f)),e.setSelection(a)}},vs=(e,t,n)=>{let i=e._root;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),ze(n,i),dt(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=Fe(o,i);if(s){if(!s.isContentEditable){rr(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(()=>{dt(e)},0))}},Cs=(e,t,n)=>{let i=e._root,r,o,s,a,c,u;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),ze(n,i),dt(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){rr(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(),Be(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),dt(e,n);return}e.setSelection(s),setTimeout(()=>{dt(e)},0)}},xs=(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}}},Ns=(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))}},Ls=(e,t,n)=>{let i,r=e._root;if(e._recordUndoState(n),e._getRangeAndRemoveBookmark(n),!n.collapsed)ze(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(()=>{or(e,s,a)},0)}e.setSelection(n)},ws=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-")),Gi&&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),ze(r,this._root),this._ensureBottomLine(),this.setSelection(r),this._updatePath(r,!0))},B={Backspace:vs,Delete:Cs,Tab:xs,"Shift-Tab":Ns," ":Ls,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)}}};ts||(B.Enter=$i,B["Shift-Enter"]=$i);!Rn&&!Ki&&(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 An=8,Wi=40,vn=1200,ks=[{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"}],Rs={ArrowUp:(e,t,n)=>{let i=ie(t,n);if(i){let r=Fe(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)}},Os=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=vn,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=ks.map(({pos:r,cursor:o})=>{let s=An/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:`
|
|
5
5
|
position: absolute;
|
|
6
|
-
width: ${
|
|
7
|
-
height: ${
|
|
6
|
+
width: ${An}px;
|
|
7
|
+
height: ${An}px;
|
|
8
8
|
background: #0067b9;
|
|
9
9
|
border: 1px solid #fff;
|
|
10
10
|
cursor: ${o};
|
|
@@ -12,16 +12,16 @@ var richclay=(()=>{var sn=Object.defineProperty;var ao=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<Ei?a=Ei:a>o&&(a=o);let d=n.style;d.width=a+"px",d.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=jo[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)}},Yo=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=Me(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",Oo),this.addEventListener("copy",Ro),this.addEventListener("paste",Io),this._dragRange=null,this.addEventListener("dragstart",Mo),this.addEventListener("dragend",Po),this.addEventListener("drop",Uo),this.addEventListener("keydown",Si),this.addEventListener("keyup",Si),this.addEventListener("keydown",Go),this._keyHandlers=Object.create(F);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 Vo(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&&(Lt(this._root),this._mayHaveZWS=!1)}_saveRangeToBookmark(e){let t=_("INPUT",{id:this.startSelectionId,type:"hidden"}),n=_("INPUT",{id:this.endSelectionId,type:"hidden"}),i;be(e,t),e.collapse(!1),be(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),d=Array.from(a.childNodes).indexOf(o);s===a&&(d-=1),r.remove(),o.remove(),e||(e=document.createRange()),e.setStart(s,c),e.setEnd(a,d),Ye(s,e),s!==a&&Ye(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&&Ne(i)&&n.setStartBefore(i),r&&Ne(r)&&n.setEndBefore(r)}return n&&t.contains(n.commonAncestorContainer)?this._lastSelection=n:(n=this._lastSelection,document.contains(n.commonAncestorContainer)||(n=null)),n||(n=Me(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=Me(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=_("SPAN");n.textContent="\u200B",be(e,n),t=n.getBoundingClientRect();let i=n.parentNode;i.removeChild(n),Ye(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,d=n.classNames;i+=(i?">":"")+e.nodeName,o&&(i+="#"+o),a.length&&(i+=".",i+=a.join(".")),c&&(i+="[dir="+c+"]"),s.contains(d.highlight)&&(i+="[backgroundColor="+e.style.backgroundColor.replace(/ /g,"")+"]"),s.contains(d.color)&&(i+="[color="+e.style.color.replace(/ /g,"")+"]"),s.contains(d.fontFamily)&&(i+="[fontFamily="+e.style.fontFamily.replace(/ /g,"")+"]"),s.contains(d.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(Ni(),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=Te(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;un(t,this._config),pn(t,n,!1),fe(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=Te(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()||Me(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),un(i,this._config),pn(i,o,!1),fn(i),i.normalize();let s=i;for(;s=Te(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&&(Do(r,i,o),r.collapse(!1),gi(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),C(e))be(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&&mn(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=_("IMG",Object.assign({src:e},t));return this.insertElement(n),n}insertPlainText(e,t){let n=this.getSelection();if(n.collapsed&&N(n.startContainer,this._root,"PRE")){let d=n.startContainer,u=n.startOffset,f;if(!d||!(d instanceof Text)){let y=document.createTextNode("");d.insertBefore(y,d.childNodes[u]),f=y,u=0}else f=d;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(u,e),n.setStart(f,u+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
|
|
17
|
-
`||
|
|
18
|
-
`||
|
|
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
|
|
20
|
-
`)):H(
|
|
21
|
-
`)),i.appendChild(
|
|
22
|
-
`))>-1;)
|
|
23
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jo(e,t){return Qo(e)||Xo(e,t)||es(e,t)||Zo()}function es(e,t){if(e){if(typeof e=="string")return Hi(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)?Hi(e,t):void 0}}var er=Object.entries,zi=Object.setPrototypeOf,ts=Object.isFrozen,ns=Object.getPrototypeOf,is=Object.getOwnPropertyDescriptor,G=Object.freeze,K=Object.seal,Je=Object.create,tr=typeof Reflect<"u"&&Reflect,An=tr.apply,xn=tr.construct;G||(G=function(t){return t});K||(K=function(t){return t});An||(An=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)});xn||(xn=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 ut=B(Array.prototype.forEach),rs=B(Array.prototype.lastIndexOf),qi=B(Array.prototype.pop),Ze=B(Array.prototype.push),os=B(Array.prototype.splice),ke=Array.isArray,mt=B(String.prototype.toLowerCase),_n=B(String.prototype.toString),$i=B(String.prototype.match),ft=B(String.prototype.replace),Wi=B(String.prototype.indexOf),ss=B(String.prototype.trim),as=B(Number.prototype.toString),ls=B(Boolean.prototype.toString),Gi=typeof BigInt>"u"?null:B(BigInt.prototype.toString),Ki=typeof Symbol>"u"?null:B(Symbol.prototype.toString),q=B(Object.prototype.hasOwnProperty),pt=B(Object.prototype.toString),W=B(RegExp.prototype.test),ze=cs(TypeError);function B(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 An(e,t,i)}}function cs(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return xn(e,n)}}function E(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mt;if(zi&&zi(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&&(ts(t)||(t[i]=o),r=o)}e[r]=!0}return e}function ds(e){for(let t=0;t<e.length;t++)q(e,t)||(e[t]=null);return e}function ee(e){let t=Je(null);for(let i of er(e)){var n=Jo(i,2);let r=n[0],o=n[1];q(e,r)&&(ke(o)?t[r]=ds(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=ee(o):t[r]=o)}return t}function hs(e){switch(typeof e){case"string":return e;case"number":return as(e);case"boolean":return ls(e);case"bigint":return Gi?Gi(e):"0";case"symbol":return Ki?Ki(e):"Symbol()";case"undefined":return pt(e);case"function":case"object":{if(e===null)return pt(e);let t=e,n=me(t,"toString");if(typeof n=="function"){let i=n(t);return typeof i=="string"?i:pt(i)}return pt(e)}default:return pt(e)}}function me(e,t){for(;e!==null;){let i=is(e,t);if(i){if(i.get)return B(i.get);if(typeof i.value=="function")return B(i.value)}e=ns(e)}function n(){return null}return n}function us(e){try{return W(e,""),!0}catch{return!1}}var ji=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"]),Tn=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"]),Sn=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"]),fs=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"]),vn=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"]),ps=G(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Vi=G(["#text"]),Yi=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"]),En=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"]),Qi=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"]),It=G(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ms=K(/{{[\w\W]*|^[\w\W]*}}/g),gs=K(/<%[\w\W]*|^[\w\W]*%>/g),ys=K(/\${[\w\W]*/g),bs=K(/^data-[\-\w.\u00B7-\uFFFF]+$/),_s=K(/^aria-[\-\w]+$/),Xi=K(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ts=K(/^(?:\w+script|data):/i),Ss=K(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),vs=K(/^html$/i),Es=K(/^[a-z][.\w]*(-[.\w]+)+$/i),Zi=K(/<[/\w!]/g),As=K(/<[/\w]/g),xs=K(/<\/no(script|embed|frames)/i),Cs=K(/\/>/i),pe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ls=function(){return typeof window>"u"?null:window},Ns=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}},Ji=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},we=function(t,n,i,r){return q(t,n)&&ke(t[n])?E(r.base?ee(r.base):{},t[n],r.transform):i};function nr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ls(),t=m=>nr(m);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==pe.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,d=e.NamedNodeMap;d===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let u=e.DOMParser,f=e.trustedTypes,g=a.prototype,y=me(g,"cloneNode"),v=me(g,"remove"),L=me(g,"nextSibling"),x=me(g,"childNodes"),M=me(g,"parentNode"),$=me(g,"shadowRoot"),le=me(g,"attributes"),X=s&&s.prototype?me(s.prototype,"nodeType"):null,ve=s&&s.prototype?me(s.prototype,"nodeName"):null;if(typeof o=="function"){let m=n.createElement("template");m.content&&m.content.ownerDocument&&(n=m.content.ownerDocument)}let te,Oe="",Ht,zn=!1,it=0,qn=function(){if(it>0)throw ze('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.')},$e=function(l){qn(),it++;try{return te.createHTML(l)}finally{it--}},Rr=function(l){qn(),it++;try{return te.createScriptURL(l)}finally{it--}},Ir=function(){return zn||(Ht=Ns(f,r),zn=!0),Ht},_t=n,zt=_t.implementation,$n=_t.createNodeIterator,Mr=_t.createDocumentFragment,Pr=_t.getElementsByTagName,Fr=i.importNode,I=Ji();t.isSupported=typeof er=="function"&&typeof M=="function"&&zt&&zt.createHTMLDocument!==void 0;let Br=ms,Ur=gs,Hr=ys,zr=bs,qr=_s,$r=Ts,Wn=Ss,Wr=Es,Gn=Xi,w=null,Kn=E({},[...ji,...Tn,...Sn,...vn,...Vi]),k=null,jn=E({},[...Yi,...En,...Qi,...It]),D=Object.seal(Je(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}})),rt=null,Vn=null,Ee=Object.seal(Je(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Yn=!0,qt=!0,Qn=!1,Xn=!0,Ae=!1,ot=!0,Re=!1,$t=!1,Wt=null,Gt=null,Kt=!1,We=!1,Tt=!1,St=!1,Zn=!0,Jn=!1,ei="user-content-",jt=!0,Vt=!1,Ge={},de=null,Yt=E({},["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"]),ti=null,ni=E({},["audio","video","img","source","image","track"]),Qt=null,ii=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),vt="http://www.w3.org/1998/Math/MathML",Et="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml",Ke=he,Xt=!1,Zt=null,Gr=E({},[vt,Et,he],_n),ri=G(["mi","mo","mn","ms","mtext"]),Jt=E({},ri),oi=G(["annotation-xml"]),en=E({},oi),Kr=E({},["title","style","font","a","script"]),st=null,jr=["application/xhtml+xml","text/html"],Vr="text/html",O=null,je=null,Yr=n.createElement("form"),si=function(l){return l instanceof RegExp||l instanceof Function},tn=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(je&&je===l)return;(!l||typeof l!="object")&&(l={}),l=ee(l),st=jr.indexOf(l.PARSER_MEDIA_TYPE)===-1?Vr:l.PARSER_MEDIA_TYPE,O=st==="application/xhtml+xml"?_n:mt,w=we(l,"ALLOWED_TAGS",Kn,{transform:O}),k=we(l,"ALLOWED_ATTR",jn,{transform:O}),Zt=we(l,"ALLOWED_NAMESPACES",Gr,{transform:_n}),Qt=we(l,"ADD_URI_SAFE_ATTR",ii,{transform:O,base:ii}),ti=we(l,"ADD_DATA_URI_TAGS",ni,{transform:O,base:ni}),de=we(l,"FORBID_CONTENTS",Yt,{transform:O}),rt=we(l,"FORBID_TAGS",ee({}),{transform:O}),Vn=we(l,"FORBID_ATTR",ee({}),{transform:O}),Ge=q(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?ee(l.USE_PROFILES):l.USE_PROFILES:!1,Yn=l.ALLOW_ARIA_ATTR!==!1,qt=l.ALLOW_DATA_ATTR!==!1,Qn=l.ALLOW_UNKNOWN_PROTOCOLS||!1,Xn=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ae=l.SAFE_FOR_TEMPLATES||!1,ot=l.SAFE_FOR_XML!==!1,Re=l.WHOLE_DOCUMENT||!1,We=l.RETURN_DOM||!1,Tt=l.RETURN_DOM_FRAGMENT||!1,St=l.RETURN_TRUSTED_TYPE||!1,Kt=l.FORCE_BODY||!1,Zn=l.SANITIZE_DOM!==!1,Jn=l.SANITIZE_NAMED_PROPS||!1,jt=l.KEEP_CONTENT!==!1,Vt=l.IN_PLACE||!1,Gn=us(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:Xi,Ke=typeof l.NAMESPACE=="string"?l.NAMESPACE:he,Jt=q(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?ee(l.MATHML_TEXT_INTEGRATION_POINTS):E({},ri),en=q(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?ee(l.HTML_INTEGRATION_POINTS):E({},oi);let h=q(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?ee(l.CUSTOM_ELEMENT_HANDLING):Je(null);if(D=Je(null),q(h,"tagNameCheck")&&si(h.tagNameCheck)&&(D.tagNameCheck=h.tagNameCheck),q(h,"attributeNameCheck")&&si(h.attributeNameCheck)&&(D.attributeNameCheck=h.attributeNameCheck),q(h,"allowCustomizedBuiltInElements")&&typeof h.allowCustomizedBuiltInElements=="boolean"&&(D.allowCustomizedBuiltInElements=h.allowCustomizedBuiltInElements),K(D),Ae&&(qt=!1),Tt&&(We=!0),Ge&&(w=E({},Vi),k=Je(null),Ge.html===!0&&(E(w,ji),E(k,Yi)),Ge.svg===!0&&(E(w,Tn),E(k,En),E(k,It)),Ge.svgFilters===!0&&(E(w,Sn),E(k,En),E(k,It)),Ge.mathMl===!0&&(E(w,vn),E(k,Qi),E(k,It))),Ee.tagCheck=null,Ee.attributeCheck=null,q(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?Ee.tagCheck=l.ADD_TAGS:ke(l.ADD_TAGS)&&(w===Kn&&(w=ee(w)),E(w,l.ADD_TAGS,O))),q(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?Ee.attributeCheck=l.ADD_ATTR:ke(l.ADD_ATTR)&&(k===jn&&(k=ee(k)),E(k,l.ADD_ATTR,O))),q(l,"ADD_URI_SAFE_ATTR")&&ke(l.ADD_URI_SAFE_ATTR)&&E(Qt,l.ADD_URI_SAFE_ATTR,O),q(l,"FORBID_CONTENTS")&&ke(l.FORBID_CONTENTS)&&(de===Yt&&(de=ee(de)),E(de,l.FORBID_CONTENTS,O)),q(l,"ADD_FORBID_CONTENTS")&&ke(l.ADD_FORBID_CONTENTS)&&(de===Yt&&(de=ee(de)),E(de,l.ADD_FORBID_CONTENTS,O)),jt&&(w["#text"]=!0),Re&&E(w,["html","head","body"]),w.table&&(E(w,["tbody"]),delete rt.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw ze('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ze('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let p=te;te=l.TRUSTED_TYPES_POLICY;try{Oe=$e("")}catch(b){throw te=p,b}}else l.TRUSTED_TYPES_POLICY===null?(te=void 0,Oe=""):(te===void 0&&(te=Ir()),te&&typeof Oe=="string"&&(Oe=$e("")));G&&G(l),je=l},ai=E({},[...Tn,...Sn,...fs]),li=E({},[...vn,...ps]),Qr=function(l,h,p){return h.namespaceURI===he?l==="svg":h.namespaceURI===vt?l==="svg"&&(p==="annotation-xml"||Jt[p]):!!ai[l]},Xr=function(l,h,p){return h.namespaceURI===he?l==="math":h.namespaceURI===Et?l==="math"&&en[p]:!!li[l]},Zr=function(l,h,p){return h.namespaceURI===Et&&!en[p]||h.namespaceURI===vt&&!Jt[p]?!1:!li[l]&&(Kr[l]||!ai[l])},Jr=function(l){let h=M(l);(!h||!h.tagName)&&(h={namespaceURI:Ke,tagName:"template"});let p=mt(l.tagName),b=mt(h.tagName);return Zt[l.namespaceURI]?l.namespaceURI===Et?Qr(p,h,b):l.namespaceURI===vt?Xr(p,h,b):l.namespaceURI===he?Zr(p,h,b):!!(st==="application/xhtml+xml"&&Zt[l.namespaceURI]):!1},xe=function(l){Ze(t.removed,{element:l});try{M(l).removeChild(l)}catch{if(v(l),!M(l))throw ze("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ci=function(l){let h=x(l);if(h){let b=[];ut(h,S=>{Ze(b,S)}),ut(b,S=>{try{v(S)}catch{}})}let p=le(l);if(p)for(let b=p.length-1;b>=0;--b){let S=p[b],A=S&&S.name;if(typeof A=="string")try{l.removeAttribute(A)}catch{}}},Ie=function(l,h){try{Ze(t.removed,{attribute:h.getAttributeNode(l),from:h})}catch{Ze(t.removed,{attribute:null,from:h})}if(h.removeAttribute(l),l==="is")if(We||Tt)try{xe(h)}catch{}else try{h.setAttribute(l,"")}catch{}},eo=function(l){let h=le(l);if(h)for(let p=h.length-1;p>=0;--p){let b=h[p],S=b&&b.name;if(!(typeof S!="string"||k[O(S)]))try{l.removeAttribute(S)}catch{}}},to=function(l){let h=[l];for(;h.length>0;){let p=h.pop();(X?X(p):p.nodeType)===pe.element&&eo(p);let S=x(p);if(S)for(let A=S.length-1;A>=0;--A)h.push(S[A])}},di=function(l){let h=null,p=null;if(Kt)l="<remove></remove>"+l;else{let A=$i(l,/^[\r\n\t ]+/);p=A&&A[0]}st==="application/xhtml+xml"&&Ke===he&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");let b=te?$e(l):l;if(Ke===he)try{h=new u().parseFromString(b,st)}catch{}if(!h||!h.documentElement){h=zt.createDocument(Ke,"template",null);try{h.documentElement.innerHTML=Xt?Oe:b}catch{}}let S=h.body||h.documentElement;return l&&p&&S.insertBefore(n.createTextNode(p),S.childNodes[0]||null),Ke===he?Pr.call(h,Re?"html":"body")[0]:Re?h.documentElement:S},hi=function(l){return $n.call(l.ownerDocument||l,l,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},At=function(l){return l=ft(l,Br," "),l=ft(l,Ur," "),l=ft(l,Hr," "),l},nn=function(l){var h;l.normalize();let p=$n.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=At(b.data),b=p.nextNode();let S=(h=l.querySelectorAll)===null||h===void 0?void 0:h.call(l,"template");S&&ut(S,A=>{Ve(A.content)&&nn(A.content)})},xt=function(l){let h=ve?ve(l):null;return typeof h!="string"||O(h)!=="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!==X(l)||l.childNodes!==x(l)},Ve=function(l){if(!X||typeof l!="object"||l===null)return!1;try{return X(l)===pe.documentFragment}catch{return!1}},at=function(l){if(!X||typeof l!="object"||l===null)return!1;try{return typeof X(l)=="number"}catch{return!1}};function ye(m,l,h){m.length!==0&&ut(m,p=>{p.call(t,l,h,je)})}let no=function(l,h){return!!(ot&&l.hasChildNodes()&&!at(l.firstElementChild)&&W(Zi,l.textContent)&&W(Zi,l.innerHTML)||ot&&l.namespaceURI===he&&h==="style"&&at(l.firstElementChild)||l.nodeType===pe.processingInstruction||ot&&l.nodeType===pe.comment&&W(As,l.data))},io=function(l,h){if(!rt[h]&&pi(h)&&(D.tagNameCheck instanceof RegExp&&W(D.tagNameCheck,h)||D.tagNameCheck instanceof Function&&D.tagNameCheck(h)))return!1;if(jt&&!de[h]){let p=M(l),b=x(l);if(b&&p){let S=b.length;for(let A=S-1;A>=0;--A){let U=Vt?b[A]:y(b[A],!0);p.insertBefore(U,L(l))}}}return xe(l),!0},ui=function(l){if(ye(I.beforeSanitizeElements,l,null),xt(l))return xe(l),!0;let h=O(ve?ve(l):l.nodeName);if(ye(I.uponSanitizeElement,l,{tagName:h,allowedTags:w}),no(l,h))return xe(l),!0;if(rt[h]||!(Ee.tagCheck instanceof Function&&Ee.tagCheck(h))&&!w[h])return io(l,h);if((X?X(l):l.nodeType)===pe.element&&!Jr(l)||(h==="noscript"||h==="noembed"||h==="noframes")&&W(xs,l.innerHTML))return xe(l),!0;if(Ae&&l.nodeType===pe.text){let b=At(l.textContent);l.textContent!==b&&(Ze(t.removed,{element:l.cloneNode()}),l.textContent=b)}return ye(I.afterSanitizeElements,l,null),!1},fi=function(l,h,p){if(Vn[h]||Zn&&(h==="id"||h==="name")&&(p in n||p in Yr))return!1;let b=k[h]||Ee.attributeCheck instanceof Function&&Ee.attributeCheck(h,l);if(!(qt&&W(zr,h))){if(!(Yn&&W(qr,h))){if(b){if(!Qt[h]){if(!W(Gn,ft(p,Wn,""))){if(!((h==="src"||h==="xlink:href"||h==="href")&&l!=="script"&&Wi(p,"data:")===0&&ti[l])){if(!(Qn&&!W($r,ft(p,Wn,"")))){if(p)return!1}}}}}else if(!(pi(l)&&(D.tagNameCheck instanceof RegExp&&W(D.tagNameCheck,l)||D.tagNameCheck instanceof Function&&D.tagNameCheck(l))&&(D.attributeNameCheck instanceof RegExp&&W(D.attributeNameCheck,h)||D.attributeNameCheck instanceof Function&&D.attributeNameCheck(h,l))||h==="is"&&D.allowCustomizedBuiltInElements&&(D.tagNameCheck instanceof RegExp&&W(D.tagNameCheck,p)||D.tagNameCheck instanceof Function&&D.tagNameCheck(p))))return!1}}return!0},ro=E({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),pi=function(l){return!ro[mt(l)]&&W(Wr,l)},oo=function(l,h,p,b){if(te&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!p)switch(f.getAttributeType(l,h)){case"TrustedHTML":return $e(b);case"TrustedScriptURL":return Rr(b)}return b},so=function(l,h,p,b){try{p?l.setAttributeNS(p,h,b):l.setAttribute(h,b),xt(l)?xe(l):qi(t.removed)}catch{Ie(h,l)}},mi=function(l){ye(I.beforeSanitizeAttributes,l,null);let h=l.attributes;if(!h||xt(l))return;let p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:k,forceKeepAttr:void 0},b=h.length,S=O(l.nodeName);for(;b--;){let A=h[b],U=A.name,P=A.namespaceURI,oe=A.value,ce=O(U),on=oe,Z=U==="value"?on:ss(on);if(p.attrName=ce,p.attrValue=Z,p.keepAttr=!0,p.forceKeepAttr=void 0,ye(I.uponSanitizeAttribute,l,p),Z=p.attrValue,Jn&&(ce==="id"||ce==="name")&&Wi(Z,ei)!==0&&(Ie(U,l),Z=ei+Z),ot&&W(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Z)){Ie(U,l);continue}if(ce==="attributename"&&$i(Z,"href")){Ie(U,l);continue}if(!p.forceKeepAttr){if(!p.keepAttr){Ie(U,l);continue}if(!Xn&&W(Cs,Z)){Ie(U,l);continue}if(Ae&&(Z=At(Z)),!fi(S,ce,Z)){Ie(U,l);continue}Z=oo(S,ce,P,Z),Z!==on&&so(l,U,P,Z)}}ye(I.afterSanitizeAttributes,l,null)},Ct=function(l){let h=null,p=hi(l);for(ye(I.beforeSanitizeShadowDOM,l,null);h=p.nextNode();)if(ye(I.uponSanitizeShadowNode,h,null),ui(h),mi(h),Ve(h.content)&&Ct(h.content),(X?X(h):h.nodeType)===pe.element){let S=$(h);Ve(S)&&(rn(S),Ct(S))}ye(I.afterSanitizeShadowDOM,l,null)},rn=function(l){let h=[{node:l,shadow:null}];for(;h.length>0;){let p=h.pop();if(p.shadow){Ct(p.shadow);continue}let b=p.node,A=(X?X(b):b.nodeType)===pe.element,U=x(b);if(U)for(let P=U.length-1;P>=0;--P)h.push({node:U[P],shadow:null});if(A){let P=ve?ve(b):null;if(typeof P=="string"&&O(P)==="template"){let oe=b.content;Ve(oe)&&h.push({node:oe,shadow:null})}}if(A){let P=$(b);Ve(P)&&h.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]:{},h=null,p=null,b=null,S=null;if(Xt=!m,Xt&&(m="<!-->"),typeof m!="string"&&!at(m)&&(m=hs(m),typeof m!="string"))throw ze("dirty is not a string, aborting");if(!t.isSupported)return m;$t?(w=Wt,k=Gt):tn(l),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(w=ee(w)),I.uponSanitizeAttribute.length>0&&(k=ee(k)),t.removed=[];let A=Vt&&typeof m!="string"&&at(m);if(A){let oe=ve?ve(m):m.nodeName;if(typeof oe=="string"){let ce=O(oe);if(!w[ce]||rt[ce])throw ze("root node is forbidden and cannot be sanitized in-place")}if(xt(m))throw ze("root node is clobbered and cannot be sanitized in-place");try{rn(m)}catch(ce){throw ci(m),ce}}else if(at(m))h=di("<!---->"),p=h.ownerDocument.importNode(m,!0),p.nodeType===pe.element&&p.nodeName==="BODY"||p.nodeName==="HTML"?h=p:h.appendChild(p),rn(p);else{if(!We&&!Ae&&!Re&&m.indexOf("<")===-1)return te&&St?$e(m):m;if(h=di(m),!h)return We?null:St?Oe:""}h&&Kt&&xe(h.firstChild);let U=hi(A?m:h);try{for(;b=U.nextNode();)ui(b),mi(b),Ve(b.content)&&Ct(b.content)}catch(oe){throw A&&ci(m),oe}if(A)return ut(t.removed,oe=>{oe.element&&to(oe.element)}),Ae&&nn(m),m;if(We){if(Ae&&nn(h),Tt)for(S=Mr.call(h.ownerDocument);h.firstChild;)S.appendChild(h.firstChild);else S=h;return(k.shadowroot||k.shadowrootmode)&&(S=Fr.call(i,S,!0)),S}let P=Re?h.outerHTML:h.innerHTML;return Re&&w["!doctype"]&&h.ownerDocument&&h.ownerDocument.doctype&&h.ownerDocument.doctype.name&&W(vs,h.ownerDocument.doctype.name)&&(P="<!DOCTYPE "+h.ownerDocument.doctype.name+`>
|
|
24
|
-
`+P),Ae&&(P=At(P)),te&&St?$e(P):P},t.setConfig=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};tn(m),$t=!0,Wt=w,Gt=k},t.clearConfig=function(){je=null,$t=!1,Wt=null,Gt=null,te=Ht,Oe=""},t.isValidAttribute=function(m,l,h){je||tn({});let p=O(m),b=O(l);return fi(p,b,h)},t.addHook=function(m,l){typeof l=="function"&&q(I,m)&&Ze(I[m],l)},t.removeHook=function(m,l){if(q(I,m)){if(l!==void 0){let h=rs(I[m],l);return h===-1?void 0:os(I[m],h,1)[0]}return qi(I[m])}},t.removeHooks=function(m){q(I,m)&&(I[m]=[])},t.removeAllHooks=function(){I=Ji()},t}var ir=nr();var T='stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"',Cn='stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"',gt='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"/>`,Q={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 ${gt} height="1" rx="0.5" ry="0.5" width="12" x="3" y="15"/>`),strike:Y(`<path ${gt} 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 ${gt} 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 ${Cn} x1="2.5" x2="4.5" y1="5.5" y2="5.5"/><path ${gt} 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 ${Cn} 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 ${Cn} 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 ${gt} 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"/>`)},yt={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 or(){return new Map(ws.map(e=>[e.id,e]))}function sr(e){if(!e)return"";let t=globalThis.navigator?.platform||"",n=/Mac|iPhone|iPad|iPod/.test(t)?"Cmd":"Ctrl";return e.replace("Mod",n)}var ws=[De("bold","Bold",Q.bold,"Mod+B","inline",e=>e.toggleFormat("B","bold","removeBold")),De("italic","Italic",Q.italic,"Mod+I","inline",e=>e.toggleFormat("I","italic","removeItalic")),De("underline","Underline",Q.underline,"Mod+U","inline",e=>e.toggleFormat("U","underline","removeUnderline")),De("strikethrough","Strikethrough",Q.strike,"Mod+Shift+7","inline",e=>e.toggleFormat("S","strikethrough","removeStrikethrough")),De("code","Code",Q.code,"Mod+D","inline",e=>e.squire.toggleCode(),e=>e.selectionHasFormat("CODE")||e.selectionHasFormat("PRE")),{id:"link",label:"Link",ariaLabel:"Insert or edit link",icon:Q.link,group:"links",shortcut:"Mod+K",run:e=>e.openLinkDialog(),isActive:e=>e.selectionHasFormat("A")},{id:"unlink",label:"Remove link",ariaLabel:"Remove link",icon:Q.unlink,group:"links",run:e=>e.squire.removeLink()},De("unorderedList","Bulleted list",Q.ul,"Mod+Shift+8","lists",e=>e.toggleList("UL"),e=>e.pathHas("UL")),De("orderedList","Numbered list",Q.ol,"Mod+Shift+9","lists",e=>e.toggleList("OL"),e=>e.pathHas("OL")),De("quote","Quote",Q.quote,null,"blocks",e=>e.pathHas("BLOCKQUOTE")?e.squire.decreaseQuoteLevel():e.squire.increaseQuoteLevel(),e=>e.pathHas("BLOCKQUOTE")),{id:"outdent",label:"Outdent",ariaLabel:"Decrease indent",icon:Q.outdent,group:"blocks",shortcut:"Mod+[",run:e=>e.outdent()},{id:"indent",label:"Indent",ariaLabel:"Increase indent",icon:Q.indent,group:"blocks",shortcut:"Mod+]",run:e=>e.indent()},{id:"undo",label:"Undo",ariaLabel:"Undo",icon:Q.undo,group:"history",shortcut:"Mod+Z",run:e=>e.squire.undo()},{id:"redo",label:"Redo",ariaLabel:"Redo",icon:Q.redo,group:"history",shortcut:"Mod+Shift+Z",run:e=>e.squire.redo()},{id:"clearFormatting",label:"Clear formatting",ariaLabel:"Clear formatting",icon:Q.clear,group:"cleanup",run:e=>e.squire.removeAllFormatting()},{id:"blockMenu",type:"menu",label:"Block style",ariaLabel:"Choose block style",icon:Q.blocks,group:"blocks",options:[Mt("Paragraph","P"),Mt("Heading 1","H1"),Mt("Heading 2","H2"),Mt("Heading 3","H3"),{label:"Quote",value:"BLOCKQUOTE",run:e=>e.squire.increaseQuoteLevel(),isActive:e=>e.pathHas("BLOCKQUOTE")},{label:"Code block",value:"PRE",run:e=>e.setBlockType("PRE"),isActive:e=>e.pathHas("PRE")}]}];function De(e,t,n,i,r,o,s=a=>a.selectionHasFormat(ks(e))){return{id:e,label:t,ariaLabel:t,icon:n,group:r,shortcut:i,run:o,isActive:s}}function ks(e){return{bold:"B",italic:"I",underline:"U",strikethrough:"S"}[e]}function Mt(e,t){return{label:e,value:t,run:n=>n.setBlockType(t),isActive:n=>n.pathHas(t)}}var Se="[data-richclay], [richclay], [editable]",Ds="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-live], [data-richclay-float]",Os=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],ar=new WeakSet;function Pt(e={},t=window){return e.hyperclay===!1?!1:e.hyperclay===!0?!0:!!(t.hyperclay||Ms(t))}function Nn(e=window){let t=ur(e);return t!==null?t:typeof e.__hyperclayEditMode=="boolean"?e.__hyperclayEditMode:typeof e.hyperclay?.isEditMode=="boolean"?e.hyperclay.isEditMode:Ps(e)}function lr(e={},t=window){return e.readOnly?!1:Pt(e,t)?Nn(t):!0}function cr(e){if(!e.hasAttribute("editable"))return null;let t=new Set((e.getAttribute("editable")||"").trim().split(/\s+/).filter(Boolean)),n={inline:!0,singleLine:t.has("single-line"),toolbarOnSelect:t.has("toolbar-on-select")};return t.has("no-toolbar")&&(n.toolbar=!1),n}function dr(e=window){if(ar.has(e))return;let t=e.hyperclay?.beforeSave;typeof t=="function"&&(t(n=>wn(n)),ar.add(e))}function wn(e){e.querySelectorAll?.(Ds).forEach(t=>t.remove()),e.querySelectorAll?.(Se).forEach(t=>{kn(t,"save"),t.matches?.('[editable~="single-line"]')&&Is(t),t.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(n=>{n.remove()}),t.querySelectorAll(".squire-image-resize-container").forEach(n=>n.remove()),Rs(t)})}function kn(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"))),Os.forEach(i=>e.classList.remove(i)),e.getAttribute("class")===""&&e.removeAttribute("class"),Ln(e,"role","data-richclay-runtime-role"),Ln(e,"aria-multiline","data-richclay-runtime-aria-multiline"),Ln(e,"no-undo","data-richclay-runtime-no-undo"),Fs(e),e.removeAttribute("data-richclay-active"),e.removeAttribute("data-richclay-placeholder"),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")}function Rs(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 Is(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 hr(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 ge(e){return e.setAttribute("snapshot-remove",""),e.setAttribute("no-watch",""),e}function ur(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 Ms(e){return ur(e)!==null||typeof e.__hyperclayEditMode=="boolean"}function Ps(e){let n=(e.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(n&&n[1]!=="")}function Ln(e,t,n){e.hasAttribute(n)&&e.removeAttribute(t)}function Fs(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 Bs=0;function fr(e=document){let t=e.createElement("div");return t.id=`richclay-live-${++Bs}`,t.className="richclay-sr-only",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("data-richclay-live",""),ge(t),e.body.appendChild(t),t}function bt(e,t){!e||!t||(e.textContent="",e.ownerDocument.defaultView.setTimeout(()=>{e.textContent=t},20))}function Dn(e){e.preventDefault()}function Us(e){try{return e?.cloneRange?.()||null}catch{return null}}function On(e){try{return Us(e?.getSelection?.())}catch{return null}}function pr(e,t){if(!e||!t)return!1;try{return e.setSelection(t),!0}catch{return!1}}function Ft(e,t,n,i){e.hasAttribute(t)||e.setAttribute(i,"true"),e.setAttribute(t,n)}function mr(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 Hs=0,et=class{constructor(t,n,i={}){this.editor=t,this.controls=n,this.options=i,this.id=++Hs,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",""),ge(n);let i=zs(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.controls.forEach((n,i)=>{if(n.type==="separator"){this.root.appendChild(yr(this.root.ownerDocument)),t=null;return}t&&n.group&&n.group!==t&&this.root.appendChild(yr(this.root.ownerDocument)),t=n.group||t,n.type==="menu"?this.renderMenu(n,i):this.renderButton(n,i)}),this.ensureSingleTabStop(),this.update()}renderButton(t,n){let i=gr(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=gr(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",""),ge(s),t.options.forEach((c,d)=>{let u=i.createElement("button");u.type="button",u.className="richclay-menu-item",u.setAttribute("role","menuitemradio"),u.setAttribute("tabindex","-1"),u.dataset.richclayMenuItem=t.id,u.dataset.richclayOptionIndex=String(d),u.textContent=c.label,u.addEventListener("mousedown",Dn),u.addEventListener("click",f=>{f.preventDefault(),this.chooseMenuItem(t,c,r)}),u.addEventListener("keydown",f=>this.handleMenuKeydown(f,t,r)),s.appendChild(u)});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)||(Dn(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 gr(e,t){let n=e.createElement("button");n.type="button",n.className="richclay-button";let i=sr(t.shortcut),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 yr(e){let t=e.createElement("span");return t.className="richclay-separator",t.setAttribute("role","separator"),t.setAttribute("aria-orientation","vertical"),t}function zs(e,t){return e?typeof e=="string"?t.querySelector(e):e:null}var br=16,qs=[16,8,0],ae=8,$s=4;function Ws({anchor:e,bar:t,rail:n,viewport:i,current:r=null}){let o=g=>r===g?$s: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-br-t.height;if(a>=ae-o("above"))return{mode:"above",x:s(t.width),y:a};let c=e.bottom+br;if(c+t.height<=i.height-ae+o("below"))return{mode:"below",x:s(t.width),y:c};let d=i.width-e.right-ae,u=e.left-ae,f=d>=u?[["rail-right",d],["rail-left",u]]:[["rail-left",u],["rail-right",d]];for(let[g,y]of f)for(let v of qs){if(n.width+v>y+o(g))continue;let L=g==="rail-right"?Math.min(e.right+v,i.width-n.width-ae):Math.max(e.left-v-n.width,ae),x=Math.min(e.bottom,i.height-ae)-n.height,M=Math.max(ae,Math.min(Math.max(e.top,ae),x));return{mode:g,x:L,y:M,gap:v}}return{mode:"pinned",x:s(t.width),y:ae}}var Bt=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",""),ge(this.root),i.body.appendChild(this.root),this.toolbar=new et(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=Ws({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 Gs={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 Sr(e={},t=document){let n=Ut(t);return{sanitizeHTML(i){return Rn(i,e,t,n)},sanitizeElement(i){return In(i,e,n)},sanitizeToDOMFragment(i,r){let o=r?.getRoot?.().ownerDocument||t;return Ks(i,e,o,n)}}}function Rn(e,t={},n=document,i=Ut(n)){let r=n.createElement("template");return r.innerHTML=i.sanitize(String(e||""),Mn(t)),Pn(r.content),r.innerHTML}function In(e,t={},n=Ut(e.ownerDocument)){let r=e.ownerDocument.createElement("div");for(;e.firstChild;)r.appendChild(e.firstChild);for(n.sanitize(r,{...Mn(t),IN_PLACE:!0}),Pn(r);r.firstChild;)e.appendChild(r.firstChild);return e}function Ks(e,t={},n=document,i=Ut(n)){let r=i.sanitize(String(e||""),{...Mn(t),RETURN_DOM_FRAGMENT:!0}),o=r?.ownerDocument===n?r:n.importNode(r,!0);return Pn(o),o||n.createDocumentFragment()}function Mn(e){return{...Gs,...e}}var js=new Set(["http","https","mailto","tel"]),Vs=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function Ys(e){let n=(String(e??"").replace(Vs,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!n||js.has(n.toLowerCase())}function vr(e){let t=String(e??"").trim();return!t||!Ys(t)?"":/^(?:https?:|mailto:|tel:)/i.test(t)?t:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:/^(?:[#?]|\/|\.{1,2}\/)/.test(t)?t:`https://${t}`}function Ut(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 Pn(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 _r={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function Er(e={}){return{...e,ADD_TAGS:[...new Set([..._r.ADD_TAGS,...e.ADD_TAGS||[]])],ADD_ATTR:[...new Set([..._r.ADD_ATTR,...e.ADD_ATTR||[]])],ALLOW_DATA_ATTR:e.ALLOW_DATA_ATTR??!0}}var Tr="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function Ar(e){let t=e.ownerDocument||document;e.querySelectorAll?.("br").forEach(i=>i.replaceWith(t.createTextNode(" ")));let n=e.querySelector?.(Tr);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(Tr)}return Qs(e,t),e}function Qs(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 xr="richclay-styles",Fn=new WeakSet,Bn="";function Cr(e){Bn=e||""}function Lr(e=document){if(!e||Fn.has(e))return;if(e.getElementById(xr)){Fn.add(e);return}if(!Bn)return;let t=e.createElement("style");t.id=xr,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=Bn,(e.head||e.documentElement).appendChild(t),Fn.add(e)}var tt=new WeakMap,Nr=new WeakSet,wr=new WeakSet,Un=or(),kr=Symbol("richclay-keep-focus"),Dr=0,Xs={toolbar:"standard",toolbarContainer:null,sanitize:{},placeholder:"",readOnly:!1,hyperclay:"auto",onChange:null,Squire:null,inline:!1,singleLine:!1,toolbarOnSelect:!1},qe=class e{static presets=yt;static selector=Se;constructor(t,n={}){if(!t)throw new Error("RichClay requires an element.");let i=tt.get(t);if(i)return i;this.element=t;let r={...cr(t),...n};this.options={...Xs,...r},this.options.singleLine&&!("toolbar"in r)&&(this.options.toolbar="inline"),this.registry=new Map(Un),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._shortcutKeys=[],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=Pt(this.options,this.window),this.hyperclay&&dr(this.window),tt.set(t,this),this.sanitizeConfig=this.options.inline?Er(this.options.sanitize):this.options.sanitize,this.sanitizer=Sr(this.sanitizeConfig,this.element.ownerDocument),this.options.inline||In(this.element,this.sanitizeConfig),lr(this.options,this.window)&&this.activate()}get squire(){return this._squire}get window(){return this.element.ownerDocument.defaultView||window}static init(t=Se,n={}){return Zs(t).map(r=>new e(r,n))}static autoInit(t=typeof window<"u"?window:void 0){if(!t||!t.document||Nr.has(t))return;Nr.add(t);let n=()=>{Pt({},t)&&Nn(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||wr.has(t))return;wr.add(t);let i=s=>{tt.has(s)||new e(s,n)},r=s=>tt.get(s)?.destroy();new t.MutationObserver(s=>{s.forEach(a=>{if(a.type==="attributes"){let c=a.target;c.matches?.(Se)?i(c):r(c);return}a.addedNodes.forEach(c=>{c.nodeType===1&&(c.matches?.(Se)&&i(c),c.querySelectorAll?.(Se).forEach(i))}),a.removedNodes.forEach(c=>{if(c.nodeType!==1)return;let d=u=>{u.isConnected||tt.get(u)?.destroy()};c.matches?.(Se)&&d(c),c.querySelectorAll?.(Se).forEach(d)})})}).observe(t.document.documentElement||t.document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["editable","data-richclay","richclay"]})}static registerButton(t){return Hn(t),Un.set(t.id,t),e}static unregisterButton(t){return Un.delete(t),e}static stripFromClone(t){wn(t)}registerButton(t){return Hn(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.active)return;this.active=!0,Lr(this.element.ownerDocument),hr(this.element);let t=this.element.innerHTML,n=this.options.Squire||this.window.Squire||globalThis.Squire;if(!n)throw new Error("RichClay requires Squire. Load vendor/squire.js before richclay.js.");this.setupEditorAttributes(),this.liveRegion=fr(this.element.ownerDocument),this._squire=new n(this.element,{blockTag:"P",sanitizeToDOMFragment:(i,r)=>{let o=this.sanitizer.sanitizeToDOMFragment(i,r);return this.options.singleLine?Ar(o):o},didError:i=>{console.error("RichClay/Squire error",i)}}),this.options.inline?(this.element.innerHTML=t,this.resetSquireUndoBaseline()):this._squire.setHTML(t),this.bindSquire(),this.options.singleLine&&this.installSingleLineGuards(),this.installShortcuts(),this.options.inline&&(this._onToolbarKey=i=>{i.altKey&&i.key==="F10"&&(i.preventDefault(),this.ensureFloatingToolbar(),this.float?.toolbar.focusFirst())},this.element.addEventListener("keydown",this._onToolbarKey)),this.renderToolbar(),this.updatePlaceholder()}getHTML(){return this._squire?this._squire.getHTML():this.element.innerHTML}setHTML(t){return this._squire?this._squire.setHTML(String(t||"")):this.element.innerHTML=Rn(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(t=>this._squire?.setKeyHandler?.(t,null)),this._squireListeners.forEach(([t,n])=>{this._squire?.removeEventListener?.(t,n)}),this._squireListeners=[],this._shortcutKeys=[],this._onBeforeInput&&(this.element.ownerDocument.removeEventListener("beforeinput",this._onBeforeInput,!0),this._onBeforeInput=null),this._squire?.destroy?.(),this._squire=null,this.cleanupEditorAttributes(),tt.delete(this.element)}saveSelection(){return this.savedSelection=On(this._squire)||this.savedSelection,this.savedSelection}restoreSelection(){return pr(this._squire,this.savedSelection)}runControl(t){if(!this._squire||typeof t.run!="function")return;this.restoreSelection();let n=t.run(this);this.saveSelection(),this.toolbar?.update(),this.updatePlaceholder(),this.announceControl(t),n!==kr&&this.focus()}selectionHasFormat(t){if(!t||!this._squire?.hasFormat)return!1;try{return this._squire.hasFormat(t)}catch{return!1}}pathHas(t){let n=this._squire?.getPath?.()??this.path??"";return new RegExp(`(?:^|>)${t}(?:[.#\\[]|>|$)`,"i").test(n)}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-${++Dr}`;i.className="richclay-dialog",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-labelledby",r),i.setAttribute("data-richclay-dialog",""),ge(i),i.innerHTML=`
|
|
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:vn,vn),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<Wi?a=Wi: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=Rs[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)}},Ds=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=Pe(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",gs),this.addEventListener("copy",ys),this.addEventListener("paste",bs),this._dragRange=null,this.addEventListener("dragstart",_s),this.addEventListener("dragend",Ts),this.addEventListener("drop",As),this.addEventListener("keydown",qi),this.addEventListener("keyup",qi),this.addEventListener("keydown",ws),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 Os(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=Pe(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=Pe(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(Yi(),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;Nn(t,this._config),wn(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()||Pe(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),Nn(i,this._config),wn(i,o,!1),Ln(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&&(ms(r,i,o),r.collapse(!1),Bi(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,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 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(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+">",c="<"+o;for(let u in s)c+=" "+u+'="'+Ui(s[u])+'"';c+=">";for(let u=0,d=i.length;u<d;u+=1){let f=i[u];f=Ui(f).replace(/ (?=(?: |$))/g," "),u&&(f=c+(f||"<BR>")+a),i[u]=f}return this.insertHTML(i.join(""),t)}getSelectedText(e){return tr(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 d=_(e,t);V(u,d),d.appendChild(u)}}while(r.nextNode());n=Pe(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,d=[],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)&&d.push([S,y]);return}if(y instanceof Text)y===c&&u!==y.length&&d.push([S,y.splitText(u)]),y===s&&a&&(y.splitText(a),d.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)&&xn(y,e,t));if(i||g.forEach(y=>{f(y,y)}),d.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,d=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,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;(!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||ze(t,n),this._config.addLinks){j(t);let f=t.startContainer,g=t.startOffset;setTimeout(()=>{or(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)===`
|
|
17
|
+
`||pt(t,n))&&(o.data.charAt(f)===`
|
|
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 Bi(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,d=null;for(c||(c=u.blockTag,d=u.blockAttributes),xn(s,c,d)||(i=_(c,d),s.dir&&(i.dir=s.dir),V(s,i),i.appendChild(D(s)),s=i),Mt(i),Ln(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=Pe(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=Ue(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;Hi(t,n),Be(t,n,n,n);let i=er(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 d=0;d<u;d+=1)c[d]=zt(a[d],!1);for(;u--;){let d=a[u];c[u]?V(d,document.createTextNode(`
|
|
20
|
+
`)):H(d)}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 d=document.createDocumentFragment(),f;for(;(f=u.indexOf(`
|
|
22
|
+
`))>-1;)d.appendChild(document.createTextNode(u.slice(0,f))),d.appendChild(_("BR")),u=u.slice(f+1);c.parentNode.insertBefore(d,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||(Hi(e,t),n=t),n instanceof Text)return this.focus();this.saveUndoState(e),Be(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),d=se(i,r,n,t),f;for(;d!==u;)f=d.nextSibling,a.appendChild(d),d=f;if(this._removeFormatting(a,c),c.normalize(),d=c.firstChild,f=c.lastChild,d){n.insertBefore(c,u);let g=Array.from(n.childNodes);r=g.indexOf(d),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()}},sr=Ds;function ar(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 Is(e){if(Array.isArray(e))return e}function Ms(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(d){u=!0,r=d}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw r}}return a}}function Ps(){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 Bs(e,t){return Is(e)||Ms(e,t)||Fs(e,t)||Ps()}function Fs(e,t){if(e){if(typeof e=="string")return ar(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)?ar(e,t):void 0}}var Er=Object.entries,lr=Object.setPrototypeOf,Us=Object.isFrozen,Hs=Object.getPrototypeOf,zs=Object.getOwnPropertyDescriptor,G=Object.freeze,K=Object.seal,tt=Object.create,Sr=typeof Reflect<"u"&&Reflect,Un=Sr.apply,Hn=Sr.construct;G||(G=function(t){return t});K||(K=function(t){return t});Un||(Un=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)});Hn||(Hn=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),qs=F(Array.prototype.lastIndexOf),cr=F(Array.prototype.pop),et=F(Array.prototype.push),$s=F(Array.prototype.splice),Re=Array.isArray,_t=F(String.prototype.toLowerCase),In=F(String.prototype.toString),ur=F(String.prototype.match),yt=F(String.prototype.replace),hr=F(String.prototype.indexOf),Ws=F(String.prototype.trim),Gs=F(Number.prototype.toString),Ks=F(Boolean.prototype.toString),dr=typeof BigInt>"u"?null:F(BigInt.prototype.toString),fr=typeof Symbol>"u"?null:F(Symbol.prototype.toString),q=F(Object.prototype.hasOwnProperty),bt=F(Object.prototype.toString),W=F(RegExp.prototype.test),qe=Vs(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 Un(e,t,i)}}function Vs(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Hn(e,n)}}function A(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_t;if(lr&&lr(e,null),!Re(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){let o=n(r);o!==r&&(Us(t)||(t[i]=o),r=o)}e[r]=!0}return e}function js(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 Er(e)){var n=Bs(i,2);let r=n[0],o=n[1];q(e,r)&&(Re(o)?t[r]=js(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=ee(o):t[r]=o)}return t}function Ys(e){switch(typeof e){case"string":return e;case"number":return Gs(e);case"boolean":return Ks(e);case"bigint":return dr?dr(e):"0";case"symbol":return fr?fr(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=zs(e,t);if(i){if(i.get)return F(i.get);if(typeof i.value=="function")return F(i.value)}e=Hs(e)}function n(){return null}return n}function Xs(e){try{return W(e,""),!0}catch{return!1}}var pr=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"]),Mn=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"]),Pn=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"]),Qs=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"]),Bn=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"]),Zs=G(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),mr=G(["#text"]),gr=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"]),Fn=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"]),yr=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"]),Js=K(/{{[\w\W]*|^[\w\W]*}}/g),ea=K(/<%[\w\W]*|^[\w\W]*%>/g),ta=K(/\${[\w\W]*/g),na=K(/^data-[\-\w.\u00B7-\uFFFF]+$/),ia=K(/^aria-[\-\w]+$/),br=K(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ra=K(/^(?:\w+script|data):/i),oa=K(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),sa=K(/^html$/i),aa=K(/^[a-z][.\w]*(-[.\w]+)+$/i),_r=K(/<[/\w!]/g),la=K(/<[/\w]/g),ca=K(/<\/no(script|embed|frames)/i),ua=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},ha=function(){return typeof window>"u"?null:window},da=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}},Tr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},ke=function(t,n,i,r){return q(t,n)&&Re(t[n])?A(r.base?ee(r.base):{},t[n],r.transform):i};function Ar(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ha(),t=m=>Ar(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 d=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,De="",tn,li=!1,at=0,ci=function(){if(at>0)throw qe('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){ci(),at++;try{return te.createHTML(l)}finally{at--}},bo=function(l){ci(),at++;try{return te.createScriptURL(l)}finally{at--}},_o=function(){return li||(tn=da(f,r),li=!0),tn},Nt=n,nn=Nt.implementation,ui=Nt.createNodeIterator,To=Nt.createDocumentFragment,Eo=Nt.getElementsByTagName,So=i.importNode,I=Tr();t.isSupported=typeof Er=="function"&&typeof M=="function"&&nn&&nn.createHTMLDocument!==void 0;let Ao=Js,vo=ea,Co=ta,xo=na,No=ia,Lo=ra,hi=oa,wo=aa,di=br,w=null,fi=A({},[...pr,...Mn,...Pn,...Bn,...mr]),k=null,pi=A({},[...gr,...Fn,...yr,...qt]),R=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,mi=null,ve=Object.seal(tt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),gi=!0,rn=!0,yi=!1,bi=!0,Ce=!1,ct=!0,Ie=!1,on=!1,sn=null,an=null,ln=!1,Ke=!1,Lt=!1,wt=!1,_i=!0,Ti=!1,Ei="user-content-",cn=!0,un=!1,Ve={},he=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"]),Si=null,Ai=A({},["audio","video","img","source","image","track"]),dn=null,vi=A({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",Rt="http://www.w3.org/2000/svg",de="http://www.w3.org/1999/xhtml",je=de,fn=!1,pn=null,ko=A({},[kt,Rt,de],In),Ci=G(["mi","mo","mn","ms","mtext"]),mn=A({},Ci),xi=G(["annotation-xml"]),gn=A({},xi),Ro=A({},["title","style","font","a","script"]),ut=null,Oo=["application/xhtml+xml","text/html"],Do="text/html",O=null,Ye=null,Io=n.createElement("form"),Ni=function(l){return l instanceof RegExp||l instanceof Function},yn=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=Oo.indexOf(l.PARSER_MEDIA_TYPE)===-1?Do:l.PARSER_MEDIA_TYPE,O=ut==="application/xhtml+xml"?In:_t,w=ke(l,"ALLOWED_TAGS",fi,{transform:O}),k=ke(l,"ALLOWED_ATTR",pi,{transform:O}),pn=ke(l,"ALLOWED_NAMESPACES",ko,{transform:In}),dn=ke(l,"ADD_URI_SAFE_ATTR",vi,{transform:O,base:vi}),Si=ke(l,"ADD_DATA_URI_TAGS",Ai,{transform:O,base:Ai}),he=ke(l,"FORBID_CONTENTS",hn,{transform:O}),lt=ke(l,"FORBID_TAGS",ee({}),{transform:O}),mi=ke(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,gi=l.ALLOW_ARIA_ATTR!==!1,rn=l.ALLOW_DATA_ATTR!==!1,yi=l.ALLOW_UNKNOWN_PROTOCOLS||!1,bi=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ce=l.SAFE_FOR_TEMPLATES||!1,ct=l.SAFE_FOR_XML!==!1,Ie=l.WHOLE_DOCUMENT||!1,Ke=l.RETURN_DOM||!1,Lt=l.RETURN_DOM_FRAGMENT||!1,wt=l.RETURN_TRUSTED_TYPE||!1,ln=l.FORCE_BODY||!1,_i=l.SANITIZE_DOM!==!1,Ti=l.SANITIZE_NAMED_PROPS||!1,cn=l.KEEP_CONTENT!==!1,un=l.IN_PLACE||!1,di=Xs(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:br,je=typeof l.NAMESPACE=="string"?l.NAMESPACE:de,mn=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({},Ci),gn=q(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?ee(l.HTML_INTEGRATION_POINTS):A({},xi);let h=q(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?ee(l.CUSTOM_ELEMENT_HANDLING):tt(null);if(R=tt(null),q(h,"tagNameCheck")&&Ni(h.tagNameCheck)&&(R.tagNameCheck=h.tagNameCheck),q(h,"attributeNameCheck")&&Ni(h.attributeNameCheck)&&(R.attributeNameCheck=h.attributeNameCheck),q(h,"allowCustomizedBuiltInElements")&&typeof h.allowCustomizedBuiltInElements=="boolean"&&(R.allowCustomizedBuiltInElements=h.allowCustomizedBuiltInElements),K(R),Ce&&(rn=!1),Lt&&(Ke=!0),Ve&&(w=A({},mr),k=tt(null),Ve.html===!0&&(A(w,pr),A(k,gr)),Ve.svg===!0&&(A(w,Mn),A(k,Fn),A(k,qt)),Ve.svgFilters===!0&&(A(w,Pn),A(k,Fn),A(k,qt)),Ve.mathMl===!0&&(A(w,Bn),A(k,yr),A(k,qt))),ve.tagCheck=null,ve.attributeCheck=null,q(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?ve.tagCheck=l.ADD_TAGS:Re(l.ADD_TAGS)&&(w===fi&&(w=ee(w)),A(w,l.ADD_TAGS,O))),q(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?ve.attributeCheck=l.ADD_ATTR:Re(l.ADD_ATTR)&&(k===pi&&(k=ee(k)),A(k,l.ADD_ATTR,O))),q(l,"ADD_URI_SAFE_ATTR")&&Re(l.ADD_URI_SAFE_ATTR)&&A(dn,l.ADD_URI_SAFE_ATTR,O),q(l,"FORBID_CONTENTS")&&Re(l.FORBID_CONTENTS)&&(he===hn&&(he=ee(he)),A(he,l.FORBID_CONTENTS,O)),q(l,"ADD_FORBID_CONTENTS")&&Re(l.ADD_FORBID_CONTENTS)&&(he===hn&&(he=ee(he)),A(he,l.ADD_FORBID_CONTENTS,O)),cn&&(w["#text"]=!0),Ie&&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 qe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw qe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let p=te;te=l.TRUSTED_TYPES_POLICY;try{De=Ge("")}catch(b){throw te=p,b}}else l.TRUSTED_TYPES_POLICY===null?(te=void 0,De=""):(te===void 0&&(te=_o()),te&&typeof De=="string"&&(De=Ge("")));G&&G(l),Ye=l},Li=A({},[...Mn,...Pn,...Qs]),wi=A({},[...Bn,...Zs]),Mo=function(l,h,p){return h.namespaceURI===de?l==="svg":h.namespaceURI===kt?l==="svg"&&(p==="annotation-xml"||mn[p]):!!Li[l]},Po=function(l,h,p){return h.namespaceURI===de?l==="math":h.namespaceURI===Rt?l==="math"&&gn[p]:!!wi[l]},Bo=function(l,h,p){return h.namespaceURI===Rt&&!gn[p]||h.namespaceURI===kt&&!mn[p]?!1:!wi[l]&&(Ro[l]||!Li[l])},Fo=function(l){let h=M(l);(!h||!h.tagName)&&(h={namespaceURI:je,tagName:"template"});let p=_t(l.tagName),b=_t(h.tagName);return pn[l.namespaceURI]?l.namespaceURI===Rt?Mo(p,h,b):l.namespaceURI===kt?Po(p,h,b):l.namespaceURI===de?Bo(p,h,b):!!(ut==="application/xhtml+xml"&&pn[l.namespaceURI]):!1},xe=function(l){et(t.removed,{element:l});try{M(l).removeChild(l)}catch{if(S(l),!M(l))throw qe("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ki=function(l){let h=C(l);if(h){let b=[];gt(h,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{}}},Me=function(l,h){try{et(t.removed,{attribute:h.getAttributeNode(l),from:h})}catch{et(t.removed,{attribute:null,from:h})}if(h.removeAttribute(l),l==="is")if(Ke||Lt)try{xe(h)}catch{}else try{h.setAttribute(l,"")}catch{}},Uo=function(l){let h=le(l);if(h)for(let p=h.length-1;p>=0;--p){let b=h[p],E=b&&b.name;if(!(typeof E!="string"||k[O(E)]))try{l.removeAttribute(E)}catch{}}},Ho=function(l){let h=[l];for(;h.length>0;){let p=h.pop();(Q?Q(p):p.nodeType)===me.element&&Uo(p);let E=C(p);if(E)for(let v=E.length-1;v>=0;--v)h.push(E[v])}},Ri=function(l){let h=null,p=null;if(ln)l="<remove></remove>"+l;else{let v=ur(l,/^[\r\n\t ]+/);p=v&&v[0]}ut==="application/xhtml+xml"&&je===de&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");let b=te?Ge(l):l;if(je===de)try{h=new d().parseFromString(b,ut)}catch{}if(!h||!h.documentElement){h=nn.createDocument(je,"template",null);try{h.documentElement.innerHTML=fn?De:b}catch{}}let E=h.body||h.documentElement;return l&&p&&E.insertBefore(n.createTextNode(p),E.childNodes[0]||null),je===de?Eo.call(h,Ie?"html":"body")[0]:Ie?h.documentElement:E},Oi=function(l){return ui.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,Ao," "),l=yt(l,vo," "),l=yt(l,Co," "),l},bn=function(l){var h;l.normalize();let p=ui.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=(h=l.querySelectorAll)===null||h===void 0?void 0:h.call(l,"template");E&>(E,v=>{Xe(v.content)&&bn(v.content)})},Dt=function(l){let h=Ae?Ae(l):null;return typeof h!="string"||O(h)!=="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}},ht=function(l){if(!Q||typeof l!="object"||l===null)return!1;try{return typeof Q(l)=="number"}catch{return!1}};function be(m,l,h){m.length!==0&>(m,p=>{p.call(t,l,h,Ye)})}let zo=function(l,h){return!!(ct&&l.hasChildNodes()&&!ht(l.firstElementChild)&&W(_r,l.textContent)&&W(_r,l.innerHTML)||ct&&l.namespaceURI===de&&h==="style"&&ht(l.firstElementChild)||l.nodeType===me.processingInstruction||ct&&l.nodeType===me.comment&&W(la,l.data))},qo=function(l,h){if(!lt[h]&&Mi(h)&&(R.tagNameCheck instanceof RegExp&&W(R.tagNameCheck,h)||R.tagNameCheck instanceof Function&&R.tagNameCheck(h)))return!1;if(cn&&!he[h]){let p=M(l),b=C(l);if(b&&p){let E=b.length;for(let v=E-1;v>=0;--v){let U=un?b[v]:y(b[v],!0);p.insertBefore(U,N(l))}}}return xe(l),!0},Di=function(l){if(be(I.beforeSanitizeElements,l,null),Dt(l))return xe(l),!0;let h=O(Ae?Ae(l):l.nodeName);if(be(I.uponSanitizeElement,l,{tagName:h,allowedTags:w}),zo(l,h))return xe(l),!0;if(lt[h]||!(ve.tagCheck instanceof Function&&ve.tagCheck(h))&&!w[h])return qo(l,h);if((Q?Q(l):l.nodeType)===me.element&&!Fo(l)||(h==="noscript"||h==="noembed"||h==="noframes")&&W(ca,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},Ii=function(l,h,p){if(mi[h]||_i&&(h==="id"||h==="name")&&(p in n||p in Io))return!1;let b=k[h]||ve.attributeCheck instanceof Function&&ve.attributeCheck(h,l);if(!(rn&&W(xo,h))){if(!(gi&&W(No,h))){if(b){if(!dn[h]){if(!W(di,yt(p,hi,""))){if(!((h==="src"||h==="xlink:href"||h==="href")&&l!=="script"&&hr(p,"data:")===0&&Si[l])){if(!(yi&&!W(Lo,yt(p,hi,"")))){if(p)return!1}}}}}else if(!(Mi(l)&&(R.tagNameCheck instanceof RegExp&&W(R.tagNameCheck,l)||R.tagNameCheck instanceof Function&&R.tagNameCheck(l))&&(R.attributeNameCheck instanceof RegExp&&W(R.attributeNameCheck,h)||R.attributeNameCheck instanceof Function&&R.attributeNameCheck(h,l))||h==="is"&&R.allowCustomizedBuiltInElements&&(R.tagNameCheck instanceof RegExp&&W(R.tagNameCheck,p)||R.tagNameCheck instanceof Function&&R.tagNameCheck(p))))return!1}}return!0},$o=A({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Mi=function(l){return!$o[_t(l)]&&W(wo,l)},Wo=function(l,h,p,b){if(te&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!p)switch(f.getAttributeType(l,h)){case"TrustedHTML":return Ge(b);case"TrustedScriptURL":return bo(b)}return b},Go=function(l,h,p,b){try{p?l.setAttributeNS(p,h,b):l.setAttribute(h,b),Dt(l)?xe(l):cr(t.removed)}catch{Me(h,l)}},Pi=function(l){be(I.beforeSanitizeAttributes,l,null);let h=l.attributes;if(!h||Dt(l))return;let p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:k,forceKeepAttr:void 0},b=h.length,E=O(l.nodeName);for(;b--;){let v=h[b],U=v.name,P=v.namespaceURI,oe=v.value,ce=O(U),Tn=oe,Z=U==="value"?Tn:Ws(Tn);if(p.attrName=ce,p.attrValue=Z,p.keepAttr=!0,p.forceKeepAttr=void 0,be(I.uponSanitizeAttribute,l,p),Z=p.attrValue,Ti&&(ce==="id"||ce==="name")&&hr(Z,Ei)!==0&&(Me(U,l),Z=Ei+Z),ct&&W(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Z)){Me(U,l);continue}if(ce==="attributename"&&ur(Z,"href")){Me(U,l);continue}if(!p.forceKeepAttr){if(!p.keepAttr){Me(U,l);continue}if(!bi&&W(ua,Z)){Me(U,l);continue}if(Ce&&(Z=Ot(Z)),!Ii(E,ce,Z)){Me(U,l);continue}Z=Wo(E,ce,P,Z),Z!==Tn&&Go(l,U,P,Z)}}be(I.afterSanitizeAttributes,l,null)},It=function(l){let h=null,p=Oi(l);for(be(I.beforeSanitizeShadowDOM,l,null);h=p.nextNode();)if(be(I.uponSanitizeShadowNode,h,null),Di(h),Pi(h),Xe(h.content)&&It(h.content),(Q?Q(h):h.nodeType)===me.element){let E=$(h);Xe(E)&&(_n(E),It(E))}be(I.afterSanitizeShadowDOM,l,null)},_n=function(l){let h=[{node:l,shadow:null}];for(;h.length>0;){let p=h.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)h.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)&&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(m){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=null,p=null,b=null,E=null;if(fn=!m,fn&&(m="<!-->"),typeof m!="string"&&!ht(m)&&(m=Ys(m),typeof m!="string"))throw qe("dirty is not a string, aborting");if(!t.isSupported)return m;on?(w=sn,k=an):yn(l),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(w=ee(w)),I.uponSanitizeAttribute.length>0&&(k=ee(k)),t.removed=[];let v=un&&typeof m!="string"&&ht(m);if(v){let oe=Ae?Ae(m):m.nodeName;if(typeof oe=="string"){let ce=O(oe);if(!w[ce]||lt[ce])throw qe("root node is forbidden and cannot be sanitized in-place")}if(Dt(m))throw qe("root node is clobbered and cannot be sanitized in-place");try{_n(m)}catch(ce){throw ki(m),ce}}else if(ht(m))h=Ri("<!---->"),p=h.ownerDocument.importNode(m,!0),p.nodeType===me.element&&p.nodeName==="BODY"||p.nodeName==="HTML"?h=p:h.appendChild(p),_n(p);else{if(!Ke&&!Ce&&!Ie&&m.indexOf("<")===-1)return te&&wt?Ge(m):m;if(h=Ri(m),!h)return Ke?null:wt?De:""}h&&ln&&xe(h.firstChild);let U=Oi(v?m:h);try{for(;b=U.nextNode();)Di(b),Pi(b),Xe(b.content)&&It(b.content)}catch(oe){throw v&&ki(m),oe}if(v)return gt(t.removed,oe=>{oe.element&&Ho(oe.element)}),Ce&&bn(m),m;if(Ke){if(Ce&&bn(h),Lt)for(E=To.call(h.ownerDocument);h.firstChild;)E.appendChild(h.firstChild);else E=h;return(k.shadowroot||k.shadowrootmode)&&(E=So.call(i,E,!0)),E}let P=Ie?h.outerHTML:h.innerHTML;return Ie&&w["!doctype"]&&h.ownerDocument&&h.ownerDocument.doctype&&h.ownerDocument.doctype.name&&W(sa,h.ownerDocument.doctype.name)&&(P="<!DOCTYPE "+h.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]:{};yn(m),on=!0,sn=w,an=k},t.clearConfig=function(){Ye=null,on=!1,sn=null,an=null,te=tn,De=""},t.isValidAttribute=function(m,l,h){Ye||yn({});let p=O(m),b=O(l);return Ii(p,b,h)},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 h=qs(I[m],l);return h===-1?void 0:$s(I[m],h,1)[0]}return cr(I[m])}},t.removeHooks=function(m){q(I,m)&&(I[m]=[])},t.removeAllHooks=function(){I=Tr()},t}var vr=Ar();var T='stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"',zn='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>`,Cr=`<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(Cr),unlink:Y(`${Cr}<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 ${zn} 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 ${zn} 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 ${zn} 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(),fa=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 xr(){return new Map(pa.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 Nr(e,t=globalThis){return e?e.replace("Mod",nt(t)?"Cmd":"Ctrl"):""}var pa=[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:fa,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(ma(e)),a){return{id:e,label:t,ariaLabel:t,icon:n,group:r,shortcut:i,isDisabled:a,run:o,isActive:s}}function ma(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 $n=/^(?:#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 ga=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:$n.test(e.nodeName)?Array.from(e.childNodes).every(Kt):!1}function vt(e){return Array.from(e.childNodes).some(t=>!Kt(t))}var qn=e=>e?.nodeType===1&&!At.has(e.nodeName)&&!$n.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),!!qn(r))){for(qn(n[o-1])&&e.insertBefore(t(),r);r.firstChild;)e.insertBefore(r.firstChild,r);r.remove(),i+=1}}),i}var Wn=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","COLGROUP"]);function Vt(e){return!!e.closest?.("p")||Wn.has(e.nodeName)}var ya=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","LABEL","LEGEND","LI","TD","TH","DT","DD","FIGCAPTION","SUMMARY","CAPTION"]);function Rr(e){return ya.has(e.nodeName)||jt(e)}var Or=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),ba=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","IFRAME","NOSCRIPT","XMP"]),Dr="http://www.w3.org/1999/xhtml";function Ir(e){return Wn.has(e.nodeName)||Or.has(e.nodeName)||ba.has(e.nodeName)||e.nodeName==="TEMPLATE"||!!e.namespaceURI&&e.namespaceURI!==Dr}function Mr(e){return Wn.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!==Dr?"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.":Or.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)&&$n.test(e.nodeName)}function Yt(e){return Array.from(e.querySelectorAll("*")).some(qn)}function Pr(e,t={}){let{blockTag:n="DIV",wrapBareRoot:i=!1,onBareRootWrapped:r,blocksAllowed:o=!Vt(e)}=t;return Ur(e),o&&Ea(e,n,i,r),e}var _a=e=>Kt(e)&&e.nodeType!==8,Ta=e=>e.nodeType!==8&&!(e.nodeType===3&&!Gt.test(e.nodeValue));function Br(e,{wrapBareRoot:t=!1,blocksAllowed:n=!Vt(e)}={}){return n?vt(e)?Array.from(e.childNodes).some(_a)||Fr(e):t:!1}function Fr(e){return Array.from(e.children).some(t=>vt(t)?!Gn(t)&&Array.from(t.childNodes).some(i=>i.nodeType===3&&!Gt.test(i.nodeValue))||Fr(t):!1)}function Ur(e){vt(e)&&(Gn(e)||Array.from(e.childNodes).forEach(t=>{t.nodeType===3&&!Gt.test(t.nodeValue)&&t.remove()}),Array.from(e.children).forEach(Ur))}function Ea(e,t,n,i){if(!vt(e)){if(!n)return;let s=e.ownerDocument.createElement(t);if(!Array.from(e.childNodes).some(Ta)){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 Gn(e){return e.nodeName==="PRE"}function Hr(e,t){return{start:Lr(e,t.startContainer,t.startOffset),end:Lr(e,t.endContainer,t.endOffset),collapsed:t.collapsed}}function zr(e,t,n){kr(t,"setStart",e,n.start),n.collapsed?t.collapse(!0):kr(t,"setEnd",e,n.end)}function Lr(e,t,n){if(!e.contains(t))return{scope:e,after:[],before:[]};if(t.nodeType===3){if(!Sa(t))return{container:t,offset:n};let i=t.parentNode;return wr(i,Array.from(i.childNodes).indexOf(t))}return{container:t,offset:n,childCount:t.childNodes.length,...wr(t,n)}}function wr(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 kr(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 Sa(e){return e.nodeType===3&&!Gt.test(e.nodeValue)&&!!e.parentNode&&e.parentNode.nodeType===1&&vt(e.parentNode)&&!Gn(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||ga.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]",Aa="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-live], [data-richclay-float]",va=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],qr=new WeakSet;function $r(e){return typeof e.clay?.isEditMode=="boolean"?e.clay.isEditMode:typeof e.hyperclay?.isEditMode=="boolean"?e.hyperclay.isEditMode:null}function Ca(e){let t=[e.clay?.ready,e.hyperclay?.ready].some(r=>r&&typeof r.then=="function"),n=e.hyperclayModules,i=e.__hyperclayNoAutoExport===!1&&n&&typeof n=="object"&&typeof n.nodeType!="number";return $r(e)!==null||t||!!i}function xa(e){return e.clay?.addDocumentTransform||e.hyperclay?.beforeSave||null}var Na={boxSizing:"border-box",minWidth:"100%",overflow:"auto",width:"0"};function Xt(e={},t=window){return e.hyperclay===!1?!1:e.hyperclay===!0?!0:!!(Ca(t)||Ia(t))}function jn(e=window){let t=jr(e);if(t!==null)return t;if(typeof e.__hyperclayEditMode=="boolean")return e.__hyperclayEditMode;let n=$r(e);return n!==null?n:Ma(e)}function Wr(e={},t=window){return e.readOnly?!1:Xt(e,t)?jn(t):!0}function Gr(e){if(!e.hasAttribute("editable"))return null;let t=new Set((e.getAttribute("editable")||"").trim().split(/\s+/).filter(Boolean)),n={inline:!0,singleLine:t.has("single-line"),toolbarOnSelect:t.has("toolbar-on-select")};return t.has("no-toolbar")&&(n.toolbar=!1),n}function Kr(e=window){if(qr.has(e))return;let t=xa(e);typeof t=="function"&&(t(n=>Yn(n)),qr.add(e))}function Yn(e){e.querySelectorAll?.(Aa).forEach(t=>t.remove()),e.querySelectorAll?.(ue).forEach(t=>{if(t.getAttribute("data-richclay-active")!=="true")return;if(Xn(t,"save"),Ra(t)){let i=t.ownerDocument,r=!!t.matches?.('[editable~="single-line"]');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?.('[editable~="single-line"]')&&Da(t),t.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(i=>{i.remove()}),t.querySelectorAll(".squire-image-resize-container").forEach(i=>i.remove()),Oa(t),(t.matches?.("pre")?[t,...t.querySelectorAll("pre")]:Array.from(t.querySelectorAll("pre"))).filter(i=>i.hasAttribute("data-richclay-pre")).forEach(i=>{Object.entries(Na).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 La="p, td, th, li, dl, dt, dd, table, blockquote, div, section, article, aside, main, header, footer, figure, figcaption",Kn="data-richclay-measure";function wa(e){let t=e.ownerDocument,n=e.closest(La)||e;e.setAttribute(Kn,"");let i=t.createElement("div");try{i.innerHTML=n.outerHTML}finally{e.removeAttribute(Kn)}let r=i.querySelector(`[${Kn}]`);return!r||r.textContent!==e.textContent}var ka=e=>!!e.querySelector(e.localName),Ra=e=>!!e.matches?.('[editable~="single-line"]')||(Yt(e)||ka(e))&&wa(e);function Xn(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"))),va.forEach(i=>e.classList.remove(i)),e.getAttribute("class")===""&&e.removeAttribute("class"),Vn(e,"role","data-richclay-runtime-role"),Vn(e,"aria-multiline","data-richclay-runtime-aria-multiline"),Vn(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")),Pa(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 Oa(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 Da(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 Vr(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 jr(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 Ia(e){return jr(e)!==null||typeof e.__hyperclayEditMode=="boolean"}function Ma(e){let n=(e.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(n&&n[1]!=="")}function Vn(e,t,n){e.hasAttribute(n)&&e.removeAttribute(t)}function Pa(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 Ba=0;function Yr(e=document){let t=e.createElement("div");return t.id=`richclay-live-${++Ba}`,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 Qn(e){e.preventDefault()}function Zn(e){try{return e?.cloneRange?.()||null}catch{return null}}function rt(e){try{return Zn(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 Xr(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 Fa=0,ot=class{constructor(t,n,i={}){this.editor=t,this.controls=n,this.options=i,this.id=++Fa,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=Ua(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(Zr(this.root.ownerDocument)),t=null;return}t&&n.group&&n.group!==t&&this.root.appendChild(Zr(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=Qr(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=Qr(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 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=c.label,d.addEventListener("mousedown",Qn),d.addEventListener("click",f=>{f.preventDefault(),this.chooseMenuItem(t,c,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)||(Qn(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 Qr(e,t){let n=e.createElement("button");n.type="button",n.className="richclay-button";let i=Nr(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 Zr(e){let t=e.createElement("span");return t.className="richclay-separator",t.setAttribute("role","separator"),t.setAttribute("aria-orientation","vertical"),t}function Ua(e,t){return e?typeof e=="string"?t.querySelector(e):e:null}var Jr=16,Ha=[16,8,0],ae=8,za=4;function qa({anchor:e,bar:t,rail:n,viewport:i,current:r=null}){let o=g=>r===g?za: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-Jr-t.height;if(a>=ae-o("above"))return{mode:"above",x:s(t.width),y:a};let c=e.bottom+Jr;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,d=e.left-ae,f=u>=d?[["rail-right",u],["rail-left",d]]:[["rail-left",d],["rail-right",u]];for(let[g,y]of f)for(let S of Ha){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 $a={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 no(e={},t=document){let n=en(t);return{sanitizeHTML(i){return Jn(i,e,t,n)},sanitizeElement(i){return ei(i,e,n)},sanitizeToDOMFragment(i,r){let o=r?.getRoot?.().ownerDocument||t;return Wa(i,e,o,n)}}}function Jn(e,t={},n=document,i=en(n)){let r=n.createElement("template");return r.innerHTML=i.sanitize(String(e||""),ti(t)),ni(r.content),r.innerHTML}function ei(e,t={},n=en(e.ownerDocument)){let r=e.ownerDocument.createElement("div");for(;e.firstChild;)r.appendChild(e.firstChild);for(n.sanitize(r,{...ti(t),IN_PLACE:!0}),ni(r);r.firstChild;)e.appendChild(r.firstChild);return e}function Wa(e,t={},n=document,i=en(n)){let r=i.sanitize(String(e||""),{...ti(t),RETURN_DOM_FRAGMENT:!0}),o=r?.ownerDocument===n?r:n.importNode(r,!0);return ni(o),o||n.createDocumentFragment()}function ti(e){return{...$a,...e}}var Ga=new Set(["http","https","mailto","tel"]),Ka=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function Va(e){let n=(String(e??"").replace(Ka,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!n||Ga.has(n.toLowerCase())}function io(e){let t=String(e??"").trim();return!t||!Va(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 ni(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 eo={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function ro(e={}){return{...e,ADD_TAGS:[...new Set([...eo.ADD_TAGS,...e.ADD_TAGS||[]])],ADD_ATTR:[...new Set([...eo.ADD_ATTR,...e.ADD_ATTR||[]])],ALLOW_DATA_ATTR:e.ALLOW_DATA_ATTR??!0}}var to="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function oo(e){let t=e.ownerDocument||document;e.querySelectorAll?.("br").forEach(i=>i.replaceWith(t.createTextNode(" ")));let n=e.querySelector?.(to);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(to)}return ja(e,t),e}function ja(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 so="richclay-styles",ii=new WeakSet,ri="";function ao(e){ri=e||""}function lo(e=document){if(!e||ii.has(e))return;if(e.getElementById(so)){ii.add(e);return}if(!ri)return;let t=e.createElement("style");t.id=so,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=ri,(e.head||e.documentElement).appendChild(t),ii.add(e)}var $e=new WeakMap,co=new WeakSet,uo=new WeakSet,oi=xr(),ho=Symbol("richclay-keep-focus"),fo=["cut","paste","drop"],Ya=["Alt","Ctrl","Meta","Shift"],po=0,Xa={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=$e.get(t);if(i)return i;this.element=t,this.unsupported=si(t)||Za(t);let r={...Gr(t),...n};this.options={...Xa,...r},this.options.singleLine&&!("toolbar"in r)&&(this.options.toolbar="inline"),this._blockTag=this.options.inline?"DIV":"P",this.registry=new Map(oi),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&&Kr(this.window),$e.set(t,this),this.sanitizeConfig=this.options.inline?ro(this.options.sanitize):this.options.sanitize,this.sanitizer=no(this.sanitizeConfig,this.element.ownerDocument),this.options.inline||ei(this.element,this.sanitizeConfig),Wr(this.options,this.window)&&this.activate()}get squire(){return this._squire}get window(){return this.element.ownerDocument.defaultView||window}static init(t=ue,n={}){return Qa(t).filter(r=>!si(r)).map(r=>new e(r,n))}static autoInit(t=typeof window<"u"?window:void 0){if(!t||!t.document||co.has(t))return;co.add(t);let n=()=>{Xt({},t)&&jn(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||uo.has(t))return;uo.add(t);let i=s=>{!$e.has(s)&&!si(s)&&new e(s,n)},r=s=>$e.get(s)?.destroy();new t.MutationObserver(s=>{s.forEach(a=>{if(a.type==="attributes"){let c=a.target;c.matches?.(ue)?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=d=>{d.isConnected||$e.get(d)?.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","data-richclay","richclay"]})}static registerButton(t){return ai(t),oi.set(t.id,t),e}static unregisterButton(t){return oi.delete(t),e}static stripFromClone(t){Yn(t)}registerButton(t){return ai(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")),lo(this.element.ownerDocument),Vr(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=Yr(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?oo(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=Jn(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&&(fo.forEach(n=>t.removeEventListener(n,this._onRootTransfer,!0)),this._onRootTransfer=null),this._squire?.destroy?.(),this._squire=null,this.cleanupEditorAttributes(),$e.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),fo.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(!Br(this.element,{wrapBareRoot:t,blocksAllowed:n}))return;let i=rt(this._squire),r=i?Hr(this.element,i):null,o=()=>{Pr(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),Qt(this._squire,i),this.savedSelection=Zn(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!==ho&&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=mo(this.element,n.startContainer,n.startOffset,!0,i);return!!r&&r===mo(this.element,n.endContainer,n.endOffset,!1,i)}blocksStayOut(){return this.options.singleLine||Vt(this.element)||Rr(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-${++po}`;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
25
|
<div class="richclay-dialog-title" id="${r}">${n?"Edit link":"Insert link"}</div>
|
|
26
26
|
<label class="richclay-field">
|
|
27
27
|
<span>URL</span>
|
|
@@ -31,7 +31,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
31
31
|
<button type="button" class="richclay-secondary" data-richclay-cancel>Cancel</button>
|
|
32
32
|
<button type="submit" class="richclay-primary">Apply</button>
|
|
33
33
|
</div>
|
|
34
|
-
`;let o=()=>{this.closeLinkDialog(),this.toolbar?.update(),this.focus()};i.addEventListener("submit",c=>{c.preventDefault();let
|
|
34
|
+
`;let o=()=>{this.closeLinkDialog(),this.toolbar?.update(),this.focus()};i.addEventListener("submit",c=>{c.preventDefault();let u=new FormData(i),d=io(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",c=>{c.key==="Escape"?(c.preventDefault(),o()):c.key==="Tab"&&el(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(),ho}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(){!this.element.hasAttribute("data-richclay")&&!this.element.hasAttribute("richclay")&&!this.element.hasAttribute("editable")&&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-${++po}`,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),Xr(this.element,this.description)),this.element.addEventListener("focus",this._onFocus),this.element.addEventListener("blur",this._onBlur)}cleanupEditorAttributes(){Xn(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"||ai(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=go(r.shortcut,this.window);this._squire.setKeyHandler(s,null),this._shortcutKeys.push(s);return}t.add(r.id);let o=go(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 Qa(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)):e?.nodeType===1?[e]:Array.from(e||[])}function mo(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 si(e){let t=e.parentElement?.closest?.(ue),n=Array.from(e.querySelectorAll?.(ue)||[]).find(r=>$e.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 Za(e){return Ir(e)?(console.warn(`richclay: ${Mr(e)} This region was skipped.`,e),!0):!1}function ai(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 go(e,t){let n=e.split("+"),i=n[n.length-1],r=new Set(n.slice(0,-1).map(Ja));r.delete("Mod")&&r.add(nt(t)?"Meta":"Ctrl");let o=i.length===1?r.has("Shift")?i.toUpperCase():i.toLowerCase():i,s=Ya.filter(a=>r.has(a)).join("-");return`${s?`${s}-`:""}${o}`}function Ja(e){return e==="Cmd"?"Meta":e}function el(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 yo=`:root {
|
|
35
35
|
--richclay-surface: #ffffff;
|
|
36
36
|
--richclay-surface-alt: #f6f7f9;
|
|
37
37
|
--richclay-text: #0b0e14;
|
|
@@ -324,17 +324,24 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
324
324
|
\`width: 0; min-width: 100%\` zeroes the pre's intrinsic-width contribution so a
|
|
325
325
|
long unbreakable line can't push an intrinsically-sized ancestor (flex/grid
|
|
326
326
|
item, inline-block, table cell) wider, while still filling the editor and
|
|
327
|
-
scrolling its own overflow. box-sizing keeps padding inside that 100%.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
327
|
+
scrolling its own overflow. box-sizing keeps padding inside that 100%.
|
|
328
|
+
Containment applies to inline editors too: \`white-space: pre\` never wraps, so
|
|
329
|
+
without it one code block runs off the side of the page. Only the decoration
|
|
330
|
+
below stays card-scoped, since inline mode keeps the page's own typography. */
|
|
331
|
+
.richclay-editor pre,
|
|
332
|
+
.richclay-inline pre {
|
|
331
333
|
box-sizing: border-box;
|
|
332
334
|
min-width: 100%;
|
|
333
335
|
overflow: auto;
|
|
334
|
-
padding: 10px;
|
|
335
336
|
width: 0;
|
|
336
337
|
}
|
|
337
338
|
|
|
339
|
+
.richclay-editor pre {
|
|
340
|
+
background: var(--richclay-surface-alt);
|
|
341
|
+
border-radius: 4px;
|
|
342
|
+
padding: 10px;
|
|
343
|
+
}
|
|
344
|
+
|
|
338
345
|
.richclay-dialog {
|
|
339
346
|
background: var(--richclay-surface);
|
|
340
347
|
border: 1px solid var(--richclay-border);
|
|
@@ -440,7 +447,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
440
447
|
stroke: Canvas;
|
|
441
448
|
}
|
|
442
449
|
}
|
|
443
|
-
`;var
|
|
450
|
+
`;var st=typeof globalThis<"u"?globalThis:self;st&&!st.Squire&&(st.Squire=sr);st&&!st.DOMPurify&&(st.DOMPurify=vr);ao(yo);We.autoInit();var nl=We;return Qo(il);})();
|
|
444
451
|
/*! @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 */
|
|
445
452
|
|
|
446
453
|
// Auto-export to window unless suppressed by loader. The self-contained bundle
|