var Do=Object.defineProperty;var Po=(i,t,e)=>t in i?Do(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var w=(i,t,e)=>Po(i,typeof t!="symbol"?t+"":t,e);import{d as Vr,u as $o,o as Zt,y as ur,b as Uo}from"./links.Byq_3x2e.js";import{_ as Ae,c as Gt,g as Kr}from"./default-i18n.DXRQgkn2.js";import{i as Fi}from"./isEqual.DkU1ezAe.js";import{b as Ho}from"./_baseClone.Cq_cqRLS.js";import{B as jo,S as Fo}from"./index.Dbgw3oZ8.js";import{a as zo}from"./Caret.Ke5gylGO.js";import{_ as Gr}from"./_plugin-vue_export-helper.BN1snXvA.js";import{o as zt,c as Vt,a as et,v as Zs,G as Vo,b as Xs,m as hr,F as dr,J as Ko,M as is,t as Ys,B as rs,N as os}from"./runtime-dom.esm-bundler.tPRhSV4q.js";var Go=1,Wo=4;function Ie(i){return Ho(i,Go|Wo)}const Te="all-in-one-seo-pack",Zo=i=>{const t=Vr();if(!t.tags.length)return[];const e=t.context[i];if(!e)return t.tags.filter(c=>!c.context||c.context.includes("all"));const s=[];let n=[];if(e.forEach(c=>{t.tags.filter(d=>d.id===c).forEach(d=>{if(d.context){if(!d.context.includes("all")&&!d.context.includes(i))return;s.push(d.id)}d&&!d.deprecated&&n.push({...d})})}),s.length){const c=[];n.forEach((h,d)=>{s.includes(h.id)&&!h.context&&c.push(d)});for(let h=c.length-1;0<=h;h--)n.splice(c[h],1)}const r=$o(),o=r.aioseo.postData.postTypes.find(c=>c.name+"Title"===i||c.name+"Description"===i||"breadcrumbs-post-type-"+c.name===i);if(o&&(n=n.map(c=>(c.name=c.name.replace("Post",o.singular),c.description=c.description.replace("page/post",o.singular.toLowerCase()),c)),o.name==="product")){const c=n.findIndex(h=>h.id==="post_excerpt");c!==-1&&(n[c].name=Ae("Product Short Description",Te),n[c].description=Ae("A short description for your product.",Te),n[c].value=Ae("Sample short description for your product.",Te))}const a=r.aioseo.postData.taxonomies.find(c=>c.name+"Title"===i||c.name+"Description"===i||"breadcrumbs-taxonomy-"+c.name===i);return a&&(n=n.map(c=>(c.name=c.name.replace("Category",a.singular),c))),(i==="dateTitle"||i==="dateDescription")&&(n=n.map(c=>(c.name=c.name.replace("Category",Ae("Archive",Te)),c.name=c.name.replace("Post",Ae("Archive",Te)),c.description=c.description.replace("page/post",Ae("archive",Te)),c))),n.sort((c,h)=>c.nameh.name?1:0)},Xo=(i,t,e)=>{switch(e){case"title":switch(i){case"taxonomies":return["taxonomy_title","separator_sa","site_title"];case"archives":switch(t){case"author":return["author_name","separator_sa","site_title"];case"search":return["search_term","separator_sa","site_title"];case"date":default:return["archive_title","separator_sa","site_title"]}default:return["post_title","separator_sa","site_title"]}case"description":switch(i){case"taxonomies":return["taxonomy_title","separator_sa","taxonomy_description"];case"attachment":return["attachment_caption","separator_sa","site_title"];case"archives":switch(t){case"author":return["author_name","separator_sa","site_title"];case"search":return["search_term","separator_sa","site_title"];case"date":default:return["archive_title","separator_sa","site_title"]}default:return t==="attachment"?["attachment_caption","separator_sa","site_title"]:t==="product"?["post_excerpt","post_content"]:["post_excerpt","post_content","separator_sa"]}}},fr={context:Zo,getDefaultTags:Xo},Yo=i=>{const{invalidClosingTags:t,invalidOpeningTags:e,tagNamePattern:s}=Wr(i);let n=i;return t.forEach(r=>{n=`<${r.match(s)[1]}>`+n}),e.forEach(r=>{const o=r.match(s)[1];n=n+``}),n},Qo=(i,t)=>{const{invalidClosingTags:e,invalidOpeningTags:s,tagNamePattern:n}=Wr(i);return e.forEach(r=>{const o=r.match(n)[1],a=new RegExp(`^<${o}>`);t=t.replace(a,"")}),s.forEach(r=>{const o=r.match(n)[1],a=new RegExp(`<\\/${o}>$`);t=t.replace(a,"")}),t},Wr=i=>{const t=new RegExp(/(<[^<>]*>)/),e=new RegExp(/<\s?\/[^<>]*>/),s=new RegExp(/<\s?\/?([^<\s>]*).*?>/,"s"),n=i.split(t),r=[];n.forEach(h=>{h.match(t)&&r.push(h)});const o=[];r.forEach((h,d)=>{if(!h)return;if(h.match(e)){o.push(h),r[d]="";return}const g=h.match(s)[1];let p=!1;r.forEach((m,b)=>{if(d===b||!m||p||!m.match(e))return;const E=m.match(s)[1];if(g===E){r[d]="",r[b]="",p=!0;return}o.push(h),r[d]=""})});const a=[],c=[];return o.forEach(h=>{if(h.match(t)){if(h.match(e)){c.push(h);return}a.push(h)}}),{invalidClosingTags:c,invalidOpeningTags:a,tagNamePattern:s}};var q=(i=>(i[i.TYPE=3]="TYPE",i[i.LEVEL=12]="LEVEL",i[i.ATTRIBUTE=13]="ATTRIBUTE",i[i.BLOT=14]="BLOT",i[i.INLINE=7]="INLINE",i[i.BLOCK=11]="BLOCK",i[i.BLOCK_BLOT=10]="BLOCK_BLOT",i[i.INLINE_BLOT=6]="INLINE_BLOT",i[i.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",i[i.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",i[i.ANY=15]="ANY",i))(q||{});class _t{constructor(t,e,s={}){this.attrName=t,this.keyName=e;const n=q.TYPE&q.ATTRIBUTE;this.scope=s.scope!=null?s.scope&q.LEVEL|n:q.ATTRIBUTE,s.whitelist!=null&&(this.whitelist=s.whitelist)}static keys(t){return Array.from(t.attributes).map(e=>e.name)}add(t,e){return this.canAdd(t,e)?(t.setAttribute(this.keyName,e),!0):!1}canAdd(t,e){return this.whitelist==null?!0:typeof e=="string"?this.whitelist.indexOf(e.replace(/["']/g,""))>-1:this.whitelist.indexOf(e)>-1}remove(t){t.removeAttribute(this.keyName)}value(t){const e=t.getAttribute(this.keyName);return this.canAdd(t,e)&&e?e:""}}class Oe extends Error{constructor(t){t="[Parchment] "+t,super(t),this.message=t,this.name=this.constructor.name}}const Zr=class Li{constructor(){this.attributes={},this.classes={},this.tags={},this.types={}}static find(t,e=!1){if(t==null)return null;if(this.blots.has(t))return this.blots.get(t)||null;if(e){let s=null;try{s=t.parentNode}catch{return null}return this.find(s,e)}return null}create(t,e,s){const n=this.query(e);if(n==null)throw new Oe(`Unable to create ${e} blot`);const r=n,o=e instanceof Node||e.nodeType===Node.TEXT_NODE?e:r.create(s),a=new r(t,o,s);return Li.blots.set(a.domNode,a),a}find(t,e=!1){return Li.find(t,e)}query(t,e=q.ANY){let s;return typeof t=="string"?s=this.types[t]||this.attributes[t]:t instanceof Text||t.nodeType===Node.TEXT_NODE?s=this.types.text:typeof t=="number"?t&q.LEVEL&q.BLOCK?s=this.types.block:t&q.LEVEL&q.INLINE&&(s=this.types.inline):t instanceof Element&&((t.getAttribute("class")||"").split(/\s+/).some(n=>(s=this.classes[n],!!s)),s=s||this.tags[t.tagName]),s==null?null:"scope"in s&&e&q.LEVEL&s.scope&&e&q.TYPE&s.scope?s:null}register(...t){return t.map(e=>{const s="blotName"in e,n="attrName"in e;if(!s&&!n)throw new Oe("Invalid definition");if(s&&e.blotName==="abstract")throw new Oe("Cannot register abstract class");const r=s?e.blotName:n?e.attrName:void 0;return this.types[r]=e,n?typeof e.keyName=="string"&&(this.attributes[e.keyName]=e):s&&(e.className&&(this.classes[e.className]=e),e.tagName&&(Array.isArray(e.tagName)?e.tagName=e.tagName.map(o=>o.toUpperCase()):e.tagName=e.tagName.toUpperCase(),(Array.isArray(e.tagName)?e.tagName:[e.tagName]).forEach(o=>{(this.tags[o]==null||e.className==null)&&(this.tags[o]=e)}))),e})}};Zr.blots=new WeakMap;let Me=Zr;function pr(i,t){return(i.getAttribute("class")||"").split(/\s+/).filter(e=>e.indexOf(`${t}-`)===0)}class Jo extends _t{static keys(t){return(t.getAttribute("class")||"").split(/\s+/).map(e=>e.split("-").slice(0,-1).join("-"))}add(t,e){return this.canAdd(t,e)?(this.remove(t),t.classList.add(`${this.keyName}-${e}`),!0):!1}remove(t){pr(t,this.keyName).forEach(e=>{t.classList.remove(e)}),t.classList.length===0&&t.removeAttribute("class")}value(t){const e=(pr(t,this.keyName)[0]||"").slice(this.keyName.length+1);return this.canAdd(t,e)?e:""}}const At=Jo;function pi(i){const t=i.split("-"),e=t.slice(1).map(s=>s[0].toUpperCase()+s.slice(1)).join("");return t[0]+e}class tl extends _t{static keys(t){return(t.getAttribute("style")||"").split(";").map(e=>e.split(":")[0].trim())}add(t,e){return this.canAdd(t,e)?(t.style[pi(this.keyName)]=e,!0):!1}remove(t){t.style[pi(this.keyName)]="",t.getAttribute("style")||t.removeAttribute("style")}value(t){const e=t.style[pi(this.keyName)];return this.canAdd(t,e)?e:""}}const Yt=tl;class el{constructor(t){this.attributes={},this.domNode=t,this.build()}attribute(t,e){e?t.add(this.domNode,e)&&(t.value(this.domNode)!=null?this.attributes[t.attrName]=t:delete this.attributes[t.attrName]):(t.remove(this.domNode),delete this.attributes[t.attrName])}build(){this.attributes={};const t=Me.find(this.domNode);if(t==null)return;const e=_t.keys(this.domNode),s=At.keys(this.domNode),n=Yt.keys(this.domNode);e.concat(s).concat(n).forEach(r=>{const o=t.scroll.query(r,q.ATTRIBUTE);o instanceof _t&&(this.attributes[o.attrName]=o)})}copy(t){Object.keys(this.attributes).forEach(e=>{const s=this.attributes[e].value(this.domNode);t.format(e,s)})}move(t){this.copy(t),Object.keys(this.attributes).forEach(e=>{this.attributes[e].remove(this.domNode)}),this.attributes={}}values(){return Object.keys(this.attributes).reduce((t,e)=>(t[e]=this.attributes[e].value(this.domNode),t),{})}}const dn=el,Xr=class{constructor(t,e){this.scroll=t,this.domNode=e,Me.blots.set(e,this),this.prev=null,this.next=null}static create(t){if(this.tagName==null)throw new Oe("Blot definition missing tagName");let e,s;return Array.isArray(this.tagName)?(typeof t=="string"?(s=t.toUpperCase(),parseInt(s,10).toString()===s&&(s=parseInt(s,10))):typeof t=="number"&&(s=t),typeof s=="number"?e=document.createElement(this.tagName[s-1]):s&&this.tagName.indexOf(s)>-1?e=document.createElement(s):e=document.createElement(this.tagName[0])):e=document.createElement(this.tagName),this.className&&e.classList.add(this.className),e}get statics(){return this.constructor}attach(){}clone(){const t=this.domNode.cloneNode(!1);return this.scroll.create(t)}detach(){this.parent!=null&&this.parent.removeChild(this),Me.blots.delete(this.domNode)}deleteAt(t,e){this.isolate(t,e).remove()}formatAt(t,e,s,n){const r=this.isolate(t,e);if(this.scroll.query(s,q.BLOT)!=null&&n)r.wrap(s,n);else if(this.scroll.query(s,q.ATTRIBUTE)!=null){const o=this.scroll.create(this.statics.scope);r.wrap(o),o.format(s,n)}}insertAt(t,e,s){const n=s==null?this.scroll.create("text",e):this.scroll.create(e,s),r=this.split(t);this.parent.insertBefore(n,r||void 0)}isolate(t,e){const s=this.split(t);if(s==null)throw new Error("Attempt to isolate at end");return s.split(e),s}length(){return 1}offset(t=this.parent){return this.parent==null||this===t?0:this.parent.children.offset(this)+this.parent.offset(t)}optimize(t){this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName)}remove(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()}replaceWith(t,e){const s=typeof t=="string"?this.scroll.create(t,e):t;return this.parent!=null&&(this.parent.insertBefore(s,this.next||void 0),this.remove()),s}split(t,e){return t===0?this:this.next}update(t,e){}wrap(t,e){const s=typeof t=="string"?this.scroll.create(t,e):t;if(this.parent!=null&&this.parent.insertBefore(s,this.next||void 0),typeof s.appendChild!="function")throw new Oe(`Cannot wrap ${t}`);return s.appendChild(this),s}};Xr.blotName="abstract";let Yr=Xr;const Qr=class extends Yr{static value(t){return!0}index(t,e){return this.domNode===t||this.domNode.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(e,1):-1}position(t,e){let s=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return t>0&&(s+=1),[this.parent.domNode,s]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}};Qr.scope=q.INLINE_BLOT;let sl=Qr;const Q=sl;class nl{constructor(){this.head=null,this.tail=null,this.length=0}append(...t){if(this.insertBefore(t[0],null),t.length>1){const e=t.slice(1);this.append(...e)}}at(t){const e=this.iterator();let s=e();for(;s&&t>0;)t-=1,s=e();return s}contains(t){const e=this.iterator();let s=e();for(;s;){if(s===t)return!0;s=e()}return!1}indexOf(t){const e=this.iterator();let s=e(),n=0;for(;s;){if(s===t)return n;n+=1,s=e()}return-1}insertBefore(t,e){t!=null&&(this.remove(t),t.next=e,e!=null?(t.prev=e.prev,e.prev!=null&&(e.prev.next=t),e.prev=t,e===this.head&&(this.head=t)):this.tail!=null?(this.tail.next=t,t.prev=this.tail,this.tail=t):(t.prev=null,this.head=this.tail=t),this.length+=1)}offset(t){let e=0,s=this.head;for(;s!=null;){if(s===t)return e;e+=s.length(),s=s.next}return-1}remove(t){this.contains(t)&&(t.prev!=null&&(t.prev.next=t.next),t.next!=null&&(t.next.prev=t.prev),t===this.head&&(this.head=t.next),t===this.tail&&(this.tail=t.prev),this.length-=1)}iterator(t=this.head){return()=>{const e=t;return t!=null&&(t=t.next),e}}find(t,e=!1){const s=this.iterator();let n=s();for(;n;){const r=n.length();if(to?s(c,t-o,Math.min(e,o+h-t)):s(c,0,Math.min(h,t+e-o)),o+=h,c=a()}}map(t){return this.reduce((e,s)=>(e.push(t(s)),e),[])}reduce(t,e){const s=this.iterator();let n=s();for(;n;)e=t(e,n),n=s();return e}}function mr(i,t){const e=t.find(i);if(e)return e;try{return t.create(i)}catch{const s=t.create(q.INLINE);return Array.from(i.childNodes).forEach(n=>{s.domNode.appendChild(n)}),i.parentNode&&i.parentNode.replaceChild(s.domNode,i),s.attach(),s}}const Jr=class Kt extends Yr{constructor(t,e){super(t,e),this.uiNode=null,this.build()}appendChild(t){this.insertBefore(t)}attach(){super.attach(),this.children.forEach(t=>{t.attach()})}attachUI(t){this.uiNode!=null&&this.uiNode.remove(),this.uiNode=t,Kt.uiClass&&this.uiNode.classList.add(Kt.uiClass),this.uiNode.setAttribute("contenteditable","false"),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new nl,Array.from(this.domNode.childNodes).filter(t=>t!==this.uiNode).reverse().forEach(t=>{try{const e=mr(t,this.scroll);this.insertBefore(e,this.children.head||void 0)}catch(e){if(e instanceof Oe)return;throw e}})}deleteAt(t,e){if(t===0&&e===this.length())return this.remove();this.children.forEachAt(t,e,(s,n,r)=>{s.deleteAt(n,r)})}descendant(t,e=0){const[s,n]=this.children.find(e);return t.blotName==null&&t(s)||t.blotName!=null&&s instanceof t?[s,n]:s instanceof Kt?s.descendant(t,n):[null,-1]}descendants(t,e=0,s=Number.MAX_VALUE){let n=[],r=s;return this.children.forEachAt(e,s,(o,a,c)=>{(t.blotName==null&&t(o)||t.blotName!=null&&o instanceof t)&&n.push(o),o instanceof Kt&&(n=n.concat(o.descendants(t,a,r))),r-=c}),n}detach(){this.children.forEach(t=>{t.detach()}),super.detach()}enforceAllowedChildren(){let t=!1;this.children.forEach(e=>{t||this.statics.allowedChildren.some(s=>e instanceof s)||(e.statics.scope===q.BLOCK_BLOT?(e.next!=null&&this.splitAfter(e),e.prev!=null&&this.splitAfter(e.prev),e.parent.unwrap(),t=!0):e instanceof Kt?e.unwrap():e.remove())})}formatAt(t,e,s,n){this.children.forEachAt(t,e,(r,o,a)=>{r.formatAt(o,a,s,n)})}insertAt(t,e,s){const[n,r]=this.children.find(t);if(n)n.insertAt(r,e,s);else{const o=s==null?this.scroll.create("text",e):this.scroll.create(e,s);this.appendChild(o)}}insertBefore(t,e){t.parent!=null&&t.parent.children.remove(t);let s=null;this.children.insertBefore(t,e||null),t.parent=this,e!=null&&(s=e.domNode),(this.domNode.parentNode!==t.domNode||this.domNode.nextSibling!==s)&&this.domNode.insertBefore(t.domNode,s),t.attach()}length(){return this.children.reduce((t,e)=>t+e.length(),0)}moveChildren(t,e){this.children.forEach(s=>{t.insertBefore(s,e)})}optimize(t){if(super.optimize(t),this.enforceAllowedChildren(),this.uiNode!=null&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length===0)if(this.statics.defaultChild!=null){const e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove()}path(t,e=!1){const[s,n]=this.children.find(t,e),r=[[this,t]];return s instanceof Kt?r.concat(s.path(n,e)):(s!=null&&r.push([s,n]),r)}removeChild(t){this.children.remove(t)}replaceWith(t,e){const s=typeof t=="string"?this.scroll.create(t,e):t;return s instanceof Kt&&this.moveChildren(s),super.replaceWith(s)}split(t,e=!1){if(!e){if(t===0)return this;if(t===this.length())return this.next}const s=this.clone();return this.parent&&this.parent.insertBefore(s,this.next||void 0),this.children.forEachAt(t,this.length(),(n,r,o)=>{const a=n.split(r,e);a!=null&&s.appendChild(a)}),s}splitAfter(t){const e=this.clone();for(;t.next!=null;)e.appendChild(t.next);return this.parent&&this.parent.insertBefore(e,this.next||void 0),e}unwrap(){this.parent&&this.moveChildren(this.parent,this.next||void 0),this.remove()}update(t,e){const s=[],n=[];t.forEach(r=>{r.target===this.domNode&&r.type==="childList"&&(s.push(...r.addedNodes),n.push(...r.removedNodes))}),n.forEach(r=>{if(r.parentNode!=null&&r.tagName!=="IFRAME"&&document.body.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;const o=this.scroll.find(r);o!=null&&(o.domNode.parentNode==null||o.domNode.parentNode===this.domNode)&&o.detach()}),s.filter(r=>r.parentNode===this.domNode&&r!==this.uiNode).sort((r,o)=>r===o?0:r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1).forEach(r=>{let o=null;r.nextSibling!=null&&(o=this.scroll.find(r.nextSibling));const a=mr(r,this.scroll);(a.next!==o||a.next==null)&&(a.parent!=null&&a.parent.removeChild(this),this.insertBefore(a,o||void 0))}),this.enforceAllowedChildren()}};Jr.uiClass="";let il=Jr;const Nt=il;function rl(i,t){if(Object.keys(i).length!==Object.keys(t).length)return!1;for(const e in i)if(i[e]!==t[e])return!1;return!0}const Le=class Ce extends Nt{static create(t){return super.create(t)}static formats(t,e){const s=e.query(Ce.blotName);if(!(s!=null&&t.tagName===s.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(t,e){super(t,e),this.attributes=new dn(this.domNode)}format(t,e){if(t===this.statics.blotName&&!e)this.children.forEach(s=>{s instanceof Ce||(s=s.wrap(Ce.blotName,!0)),this.attributes.copy(s)}),this.unwrap();else{const s=this.scroll.query(t,q.INLINE);if(s==null)return;s instanceof _t?this.attributes.attribute(s,e):e&&(t!==this.statics.blotName||this.formats()[t]!==e)&&this.replaceWith(t,e)}}formats(){const t=this.attributes.values(),e=this.statics.formats(this.domNode,this.scroll);return e!=null&&(t[this.statics.blotName]=e),t}formatAt(t,e,s,n){this.formats()[s]!=null||this.scroll.query(s,q.ATTRIBUTE)?this.isolate(t,e).format(s,n):super.formatAt(t,e,s,n)}optimize(t){super.optimize(t);const e=this.formats();if(Object.keys(e).length===0)return this.unwrap();const s=this.next;s instanceof Ce&&s.prev===this&&rl(e,s.formats())&&(s.moveChildren(this),s.remove())}replaceWith(t,e){const s=super.replaceWith(t,e);return this.attributes.copy(s),s}update(t,e){super.update(t,e),t.some(s=>s.target===this.domNode&&s.type==="attributes")&&this.attributes.build()}wrap(t,e){const s=super.wrap(t,e);return s instanceof Ce&&this.attributes.move(s),s}};Le.allowedChildren=[Le,Q],Le.blotName="inline",Le.scope=q.INLINE_BLOT,Le.tagName="SPAN";let ol=Le;const zi=ol,Se=class Ci extends Nt{static create(t){return super.create(t)}static formats(t,e){const s=e.query(Ci.blotName);if(!(s!=null&&t.tagName===s.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(t,e){super(t,e),this.attributes=new dn(this.domNode)}format(t,e){const s=this.scroll.query(t,q.BLOCK);s!=null&&(s instanceof _t?this.attributes.attribute(s,e):t===this.statics.blotName&&!e?this.replaceWith(Ci.blotName):e&&(t!==this.statics.blotName||this.formats()[t]!==e)&&this.replaceWith(t,e))}formats(){const t=this.attributes.values(),e=this.statics.formats(this.domNode,this.scroll);return e!=null&&(t[this.statics.blotName]=e),t}formatAt(t,e,s,n){this.scroll.query(s,q.BLOCK)!=null?this.format(s,n):super.formatAt(t,e,s,n)}insertAt(t,e,s){if(s==null||this.scroll.query(e,q.INLINE)!=null)super.insertAt(t,e,s);else{const n=this.split(t);if(n!=null){const r=this.scroll.create(e,s);n.parent.insertBefore(r,n)}else throw new Error("Attempt to insertAt after block boundaries")}}replaceWith(t,e){const s=super.replaceWith(t,e);return this.attributes.copy(s),s}update(t,e){super.update(t,e),t.some(s=>s.target===this.domNode&&s.type==="attributes")&&this.attributes.build()}};Se.blotName="block",Se.scope=q.BLOCK_BLOT,Se.tagName="P",Se.allowedChildren=[zi,Se,Q];let ll=Se;const ds=ll,Si=class extends Nt{checkMerge(){return this.next!==null&&this.next.statics.blotName===this.statics.blotName}deleteAt(t,e){super.deleteAt(t,e),this.enforceAllowedChildren()}formatAt(t,e,s,n){super.formatAt(t,e,s,n),this.enforceAllowedChildren()}insertAt(t,e,s){super.insertAt(t,e,s),this.enforceAllowedChildren()}optimize(t){super.optimize(t),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}};Si.blotName="container",Si.scope=q.BLOCK_BLOT;let al=Si;const fn=al;class cl extends Q{static formats(t,e){}format(t,e){super.formatAt(0,this.length(),t,e)}formatAt(t,e,s,n){t===0&&e===this.length()?this.format(s,n):super.formatAt(t,e,s,n)}formats(){return this.statics.formats(this.domNode,this.scroll)}}const lt=cl,ul={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},hl=100,qe=class extends Nt{constructor(t,e){super(null,e),this.registry=t,this.scroll=this,this.build(),this.observer=new MutationObserver(s=>{this.update(s)}),this.observer.observe(this.domNode,ul),this.attach()}create(t,e){return this.registry.create(this,t,e)}find(t,e=!1){const s=this.registry.find(t,e);return s?s.scroll===this?s:e?this.find(s.scroll.domNode.parentNode,!0):null:null}query(t,e=q.ANY){return this.registry.query(t,e)}register(...t){return this.registry.register(...t)}build(){this.scroll!=null&&super.build()}detach(){super.detach(),this.observer.disconnect()}deleteAt(t,e){this.update(),t===0&&e===this.length()?this.children.forEach(s=>{s.remove()}):super.deleteAt(t,e)}formatAt(t,e,s,n){this.update(),super.formatAt(t,e,s,n)}insertAt(t,e,s){this.update(),super.insertAt(t,e,s)}optimize(t=[],e={}){super.optimize(e);const s=e.mutationsMap||new WeakMap;let n=Array.from(this.observer.takeRecords());for(;n.length>0;)t.push(n.pop());const r=(c,h=!0)=>{c==null||c===this||c.domNode.parentNode!=null&&(s.has(c.domNode)||s.set(c.domNode,[]),h&&r(c.parent))},o=c=>{s.has(c.domNode)&&(c instanceof Nt&&c.children.forEach(o),s.delete(c.domNode),c.optimize(e))};let a=t;for(let c=0;a.length>0;c+=1){if(c>=hl)throw new Error("[Parchment] Maximum optimize iterations reached");for(a.forEach(h=>{const d=this.find(h.target,!0);d!=null&&(d.domNode===h.target&&(h.type==="childList"?(r(this.find(h.previousSibling,!1)),Array.from(h.addedNodes).forEach(g=>{const p=this.find(g,!1);r(p,!1),p instanceof Nt&&p.children.forEach(m=>{r(m,!1)})})):h.type==="attributes"&&r(d.prev)),r(d))}),this.children.forEach(o),a=Array.from(this.observer.takeRecords()),n=a.slice();n.length>0;)t.push(n.pop())}}update(t,e={}){t=t||this.observer.takeRecords();const s=new WeakMap;t.map(n=>{const r=this.find(n.target,!0);return r==null?null:s.has(r.domNode)?(s.get(r.domNode).push(n),null):(s.set(r.domNode,[n]),r)}).forEach(n=>{n!=null&&n!==this&&s.has(n.domNode)&&n.update(s.get(n.domNode)||[],e)}),e.mutationsMap=s,s.has(this.domNode)&&super.update(s.get(this.domNode),e),this.optimize(t,e)}};qe.blotName="scroll",qe.defaultChild=ds,qe.allowedChildren=[ds,fn],qe.scope=q.BLOCK_BLOT,qe.tagName="DIV";let dl=qe;const Vi=dl,qi=class to extends Q{static create(t){return document.createTextNode(t)}static value(t){return t.data}constructor(t,e){super(t,e),this.text=this.statics.value(this.domNode)}deleteAt(t,e){this.domNode.data=this.text=this.text.slice(0,t)+this.text.slice(t+e)}index(t,e){return this.domNode===t?e:-1}insertAt(t,e,s){s==null?(this.text=this.text.slice(0,t)+e+this.text.slice(t),this.domNode.data=this.text):super.insertAt(t,e,s)}length(){return this.text.length}optimize(t){super.optimize(t),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof to&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())}position(t,e=!1){return[this.domNode,t]}split(t,e=!1){if(!e){if(t===0)return this;if(t===this.length())return this.next}const s=this.scroll.create(this.domNode.splitText(t));return this.parent.insertBefore(s,this.next||void 0),this.text=this.statics.value(this.domNode),s}update(t,e){t.some(s=>s.type==="characterData"&&s.target===this.domNode)&&(this.text=this.statics.value(this.domNode))}value(){return this.text}};qi.blotName="text",qi.scope=q.INLINE_BLOT;let fl=qi;const ln=fl,pl=Object.freeze(Object.defineProperty({__proto__:null,Attributor:_t,AttributorStore:dn,BlockBlot:ds,ClassAttributor:At,ContainerBlot:fn,EmbedBlot:lt,InlineBlot:zi,LeafBlot:Q,ParentBlot:Nt,Registry:Me,Scope:q,ScrollBlot:Vi,StyleAttributor:Yt,TextBlot:ln},Symbol.toStringTag,{value:"Module"}));var ki={exports:{}},ot=-1,st=1,z=0;function fs(i,t,e,s,n){if(i===t)return i?[[z,i]]:[];if(e!=null){var r=Al(i,t,e);if(r)return r}var o=Ki(i,t),a=i.substring(0,o);i=i.substring(o),t=t.substring(o),o=pn(i,t);var c=i.substring(i.length-o);i=i.substring(0,i.length-o),t=t.substring(0,t.length-o);var h=ml(i,t);return a&&h.unshift([z,a]),c&&h.push([z,c]),Gi(h,n),s&&yl(h),h}function ml(i,t){var e;if(!i)return[[st,t]];if(!t)return[[ot,i]];var s=i.length>t.length?i:t,n=i.length>t.length?t:i,r=s.indexOf(n);if(r!==-1)return e=[[st,s.substring(0,r)],[z,n],[st,s.substring(r+n.length)]],i.length>t.length&&(e[0][0]=e[2][0]=ot),e;if(n.length===1)return[[ot,i],[st,t]];var o=bl(i,t);if(o){var a=o[0],c=o[1],h=o[2],d=o[3],g=o[4],p=fs(a,h),m=fs(c,d);return p.concat([[z,g]],m)}return gl(i,t)}function gl(i,t){for(var e=i.length,s=t.length,n=Math.ceil((e+s)/2),r=n,o=2*n,a=new Array(o),c=new Array(o),h=0;he)m+=2;else if(k>s)p+=2;else if(g){var C=r+d-x;if(C>=0&&C=I)return gr(i,t,T,k)}}}for(var M=-N+b;M<=N-E;M+=2){var C=r+M,I;M===-N||M!==N&&c[C-1]e)E+=2;else if(H>s)b+=2;else if(!g){var A=r+d-M;if(A>=0&&A=I)return gr(i,t,T,k)}}}}return[[ot,i],[st,t]]}function gr(i,t,e,s){var n=i.substring(0,e),r=t.substring(0,s),o=i.substring(e),a=t.substring(s),c=fs(n,r),h=fs(o,a);return c.concat(h)}function Ki(i,t){if(!i||!t||i.charAt(0)!==t.charAt(0))return 0;for(var e=0,s=Math.min(i.length,t.length),n=s,r=0;es?i=i.substring(e-s):et.length?i:t,s=i.length>t.length?t:i;if(e.length<4||s.length*2=m.length?[T,k,C,I,A]:null}var r=n(e,s,Math.ceil(e.length/4)),o=n(e,s,Math.ceil(e.length/2)),a;if(!r&&!o)return null;o?r?a=r[4].length>o[4].length?r:o:a=o:a=r;var c,h,d,g;i.length>t.length?(c=a[0],h=a[1],d=a[2],g=a[3]):(d=a[0],g=a[1],c=a[2],h=a[3]);var p=a[4];return[c,h,d,g,p]}function yl(i){for(var t=!1,e=[],s=0,n=null,r=0,o=0,a=0,c=0,h=0;r0?e[s-1]:-1,o=0,a=0,c=0,h=0,n=null,t=!0)),r++;for(t&&Gi(i),Nl(i),r=1;r=m?(p>=d.length/2||p>=g.length/2)&&(i.splice(r,0,[z,g.substring(0,p)]),i[r-1][1]=d.substring(0,d.length-p),i[r+1][1]=g.substring(p),r++):(m>=d.length/2||m>=g.length/2)&&(i.splice(r,0,[z,d.substring(0,m)]),i[r-1][0]=st,i[r-1][1]=g.substring(0,g.length-m),i[r+1][0]=ot,i[r+1][1]=d.substring(m),r++),r++}r++}}var yr=/[^a-zA-Z0-9]/,vr=/\s/,Er=/[\r\n]/,vl=/\n\r?\n$/,El=/^\r?\n\r?\n/;function Nl(i){function t(m,b){if(!m||!b)return 6;var E=m.charAt(m.length-1),N=b.charAt(0),x=E.match(yr),A=N.match(yr),T=x&&E.match(vr),k=A&&N.match(vr),C=T&&E.match(Er),I=k&&N.match(Er),M=C&&m.match(vl),H=I&&b.match(El);return M||H?5:C||I?4:x&&!T&&k?3:T||k?2:x||A?1:0}for(var e=1;e=g&&(g=p,c=s,h=n,d=r)}i[e-1][1]!=c&&(c?i[e-1][1]=c:(i.splice(e-1,1),e--),i[e][1]=h,d?i[e+1][1]=d:(i.splice(e+1,1),e--))}e++}}function Gi(i,t){i.push([z,""]);for(var e=0,s=0,n=0,r="",o="",a;e=0&&io(i[c][1])){var h=i[c][1].slice(-1);if(i[c][1]=i[c][1].slice(0,-1),r=h+r,o=h+o,!i[c][1]){i.splice(c,1),e--;var d=c-1;i[d]&&i[d][0]===st&&(n++,o=i[d][1]+o,d--),i[d]&&i[d][0]===ot&&(s++,r=i[d][1]+r,d--),c=d}}if(no(i[e][1])){var h=i[e][1].charAt(0);i[e][1]=i[e][1].slice(1),r+=h,o+=h}}if(e0||o.length>0){r.length>0&&o.length>0&&(a=Ki(o,r),a!==0&&(c>=0?i[c][1]+=o.substring(0,a):(i.splice(0,0,[z,o.substring(0,a)]),e++),o=o.substring(a),r=r.substring(a)),a=pn(o,r),a!==0&&(i[e][1]=o.substring(o.length-a)+i[e][1],o=o.substring(0,o.length-a),r=r.substring(0,r.length-a)));var g=n+s;r.length===0&&o.length===0?(i.splice(e-g,g),e=e-g):r.length===0?(i.splice(e-g,g,[st,o]),e=e-g+1):o.length===0?(i.splice(e-g,g,[ot,r]),e=e-g+1):(i.splice(e-g,g,[ot,r],[st,o]),e=e-g+2)}e!==0&&i[e-1][0]===z?(i[e-1][1]+=i[e][1],i.splice(e,1)):e++,n=0,s=0,r="",o="";break}}i[i.length-1][1]===""&&i.pop();var p=!1;for(e=1;e=55296&&i<=56319}function so(i){return i>=56320&&i<=57343}function no(i){return so(i.charCodeAt(0))}function io(i){return eo(i.charCodeAt(i.length-1))}function xl(i){for(var t=[],e=0;e0&&t.push(i[e]);return t}function mi(i,t,e,s){return io(i)||no(s)?null:xl([[z,i],[ot,t],[st,e],[z,s]])}function Al(i,t,e){var s=typeof e=="number"?{index:e,length:0}:e.oldRange,n=typeof e=="number"?null:e.newRange,r=i.length,o=t.length;if(s.length===0&&(n===null||n.length===0)){var a=s.index,c=i.slice(0,a),h=i.slice(a),d=n?n.index:null;t:{var g=a+o-r;if(d!==null&&d!==g||g<0||g>o)break t;var p=t.slice(0,g),m=t.slice(g);if(m!==h)break t;var b=Math.min(a,g),E=c.slice(0,b),N=p.slice(0,b);if(E!==N)break t;var x=c.slice(b),A=p.slice(b);return mi(E,x,A,h)}t:{if(d!==null&&d!==a)break t;var T=a,p=t.slice(0,T),m=t.slice(T);if(p!==c)break t;var k=Math.min(r-T,o-T),C=h.slice(h.length-k),I=m.slice(m.length-k);if(C!==I)break t;var x=h.slice(0,h.length-k),A=m.slice(0,m.length-k);return mi(c,x,A,C)}}if(s.length>0&&n&&n.length===0)t:{var E=i.slice(0,s.index),C=i.slice(s.index+s.length),b=E.length,k=C.length;if(o-1}function Pn(l,u){var f=this.__data__,v=ve(f,l);return v<0?f.push([l,u]):f[v][1]=u,this}V.prototype.clear=Rn,V.prototype.delete=Mn,V.prototype.get=Bn,V.prototype.has=Dn,V.prototype.set=Pn;function W(l){var u=-1,f=l?l.length:0;for(this.clear();++u-1&&l%1==0&&l-1&&l%1==0&&l<=n}function qt(l){var u=typeof l;return!!l&&(u=="object"||u=="function")}function Ks(l){return!!l&&typeof l=="object"}function ns(l){return xe(l)?ye(l):Jn(l)}function di(){return[]}function fi(){return!1}i.exports=js})(an,an.exports);var ro=an.exports,cn={exports:{}};cn.exports;(function(i,t){var e=200,s="__lodash_hash_undefined__",n=1,r=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",h="[object AsyncFunction]",d="[object Boolean]",g="[object Date]",p="[object Error]",m="[object Function]",b="[object GeneratorFunction]",E="[object Map]",N="[object Number]",x="[object Null]",A="[object Object]",T="[object Promise]",k="[object Proxy]",C="[object RegExp]",I="[object Set]",M="[object String]",H="[object Symbol]",It="[object Undefined]",Ht="[object WeakMap]",Jt="[object ArrayBuffer]",te="[object DataView]",Ns="[object Float32Array]",xs="[object Float64Array]",As="[object Int8Array]",En="[object Int16Array]",Nn="[object Int32Array]",xn="[object Uint8Array]",An="[object Uint8ClampedArray]",$="[object Uint16Array]",Tn="[object Uint32Array]",wn=/[\\^$.*+?()[\]{}|]/g,pt=/^\[object .+?Constructor\]$/,Ts=/^(?:0|[1-9]\d*)$/,U={};U[Ns]=U[xs]=U[As]=U[En]=U[Nn]=U[xn]=U[An]=U[$]=U[Tn]=!0,U[a]=U[c]=U[Jt]=U[d]=U[te]=U[g]=U[p]=U[m]=U[E]=U[N]=U[A]=U[C]=U[I]=U[M]=U[Ht]=!1;var ws=typeof Gt=="object"&&Gt&&Gt.Object===Object&&Gt,Ln=typeof self=="object"&&self&&self.Object===Object&&self,mt=ws||Ln||Function("return this")(),Ls=t&&!t.nodeType&&t,Cs=Ls&&!0&&i&&!i.nodeType&&i,$e=Cs&&Cs.exports===Ls,Ue=$e&&ws.process,Ss=function(){try{return Ue&&Ue.binding&&Ue.binding("util")}catch{}}(),He=Ss&&Ss.isTypedArray;function qs(l,u){for(var f=-1,v=l==null?0:l.length,O=0,_=[];++f-1}function Fn(l,u){var f=this.__data__,v=Ee(f,l);return v<0?(++this.size,f.push([l,u])):f[v][1]=u,this}W.prototype.clear=$n,W.prototype.delete=Un,W.prototype.get=Hn,W.prototype.has=jn,W.prototype.set=Fn;function nt(l){var u=-1,f=l==null?0:l.length;for(this.clear();++uB))return!1;var P=_.get(l);if(P&&_.get(u))return P==u;var Z=-1,it=!0,F=f&r?new ye:void 0;for(_.set(l,u),_.set(u,l);++Z-1&&l%1==0&&l-1&&l%1==0&&l<=o}function Vs(l){var u=typeof l;return l!=null&&(u=="object"||u=="function")}function qt(l){return l!=null&&typeof l=="object"}var Ks=He?Sn(He):si;function ns(l){return es(l)?Jn(l):ni(l)}function di(){return[]}function fi(){return!1}i.exports=hi})(cn,cn.exports);var oo=cn.exports,Wi={};Object.defineProperty(Wi,"__esModule",{value:!0});const wl=ro,Ll=oo;var _i;(function(i){function t(r={},o={},a=!1){typeof r!="object"&&(r={}),typeof o!="object"&&(o={});let c=wl(o);a||(c=Object.keys(c).reduce((h,d)=>(c[d]!=null&&(h[d]=c[d]),h),{}));for(const h in r)r[h]!==void 0&&o[h]===void 0&&(c[h]=r[h]);return Object.keys(c).length>0?c:void 0}i.compose=t;function e(r={},o={}){typeof r!="object"&&(r={}),typeof o!="object"&&(o={});const a=Object.keys(r).concat(Object.keys(o)).reduce((c,h)=>(Ll(r[h],o[h])||(c[h]=o[h]===void 0?null:o[h]),c),{});return Object.keys(a).length>0?a:void 0}i.diff=e;function s(r={},o={}){r=r||{};const a=Object.keys(o).reduce((c,h)=>(o[h]!==r[h]&&r[h]!==void 0&&(c[h]=o[h]),c),{});return Object.keys(r).reduce((c,h)=>(r[h]!==o[h]&&o[h]===void 0&&(c[h]=null),c),a)}i.invert=s;function n(r,o,a=!1){if(typeof r!="object")return o;if(typeof o!="object")return;if(!a)return o;const c=Object.keys(o).reduce((h,d)=>(r[d]===void 0&&(h[d]=o[d]),h),{});return Object.keys(c).length>0?c:void 0}i.transform=n})(_i||(_i={}));Wi.default=_i;var gn={};Object.defineProperty(gn,"__esModule",{value:!0});var Ii;(function(i){function t(e){return typeof e.delete=="number"?e.delete:typeof e.retain=="number"?e.retain:typeof e.retain=="object"&&e.retain!==null?1:typeof e.insert=="string"?e.insert.length:1}i.length=t})(Ii||(Ii={}));gn.default=Ii;var Zi={};Object.defineProperty(Zi,"__esModule",{value:!0});const Nr=gn;class Cl{constructor(t){this.ops=t,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(t){t||(t=1/0);const e=this.ops[this.index];if(e){const s=this.offset,n=Nr.default.length(e);if(t>=n-s?(t=n-s,this.index+=1,this.offset=0):this.offset+=t,typeof e.delete=="number")return{delete:t};{const r={};return e.attributes&&(r.attributes=e.attributes),typeof e.retain=="number"?r.retain=t:typeof e.retain=="object"&&e.retain!==null?r.retain=e.retain:typeof e.insert=="string"?r.insert=e.insert.substr(s,t):r.insert=e.insert,r}}else return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?Nr.default.length(this.ops[this.index])-this.offset:1/0}peekType(){const t=this.ops[this.index];return t?typeof t.delete=="number"?"delete":typeof t.retain=="number"||typeof t.retain=="object"&&t.retain!==null?"retain":"insert":"retain"}rest(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);{const t=this.offset,e=this.index,s=this.next(),n=this.ops.slice(this.index);return this.offset=t,this.index=e,[s].concat(n)}}else return[]}}Zi.default=Cl;(function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.AttributeMap=t.OpIterator=t.Op=void 0;const e=Tl,s=ro,n=oo,r=Wi;t.AttributeMap=r.default;const o=gn;t.Op=o.default;const a=Zi;t.OpIterator=a.default;const c="\0",h=(g,p)=>{if(typeof g!="object"||g===null)throw new Error(`cannot retain a ${typeof g}`);if(typeof p!="object"||p===null)throw new Error(`cannot retain a ${typeof p}`);const m=Object.keys(g)[0];if(!m||m!==Object.keys(p)[0])throw new Error(`embed types not matched: ${m} != ${Object.keys(p)[0]}`);return[m,g[m],p[m]]};class d{constructor(p){Array.isArray(p)?this.ops=p:p!=null&&Array.isArray(p.ops)?this.ops=p.ops:this.ops=[]}static registerEmbed(p,m){this.handlers[p]=m}static unregisterEmbed(p){delete this.handlers[p]}static getHandler(p){const m=this.handlers[p];if(!m)throw new Error(`no handlers for embed type "${p}"`);return m}insert(p,m){const b={};return typeof p=="string"&&p.length===0?this:(b.insert=p,m!=null&&typeof m=="object"&&Object.keys(m).length>0&&(b.attributes=m),this.push(b))}delete(p){return p<=0?this:this.push({delete:p})}retain(p,m){if(typeof p=="number"&&p<=0)return this;const b={retain:p};return m!=null&&typeof m=="object"&&Object.keys(m).length>0&&(b.attributes=m),this.push(b)}push(p){let m=this.ops.length,b=this.ops[m-1];if(p=s(p),typeof b=="object"){if(typeof p.delete=="number"&&typeof b.delete=="number")return this.ops[m-1]={delete:b.delete+p.delete},this;if(typeof b.delete=="number"&&p.insert!=null&&(m-=1,b=this.ops[m-1],typeof b!="object"))return this.ops.unshift(p),this;if(n(p.attributes,b.attributes)){if(typeof p.insert=="string"&&typeof b.insert=="string")return this.ops[m-1]={insert:b.insert+p.insert},typeof p.attributes=="object"&&(this.ops[m-1].attributes=p.attributes),this;if(typeof p.retain=="number"&&typeof b.retain=="number")return this.ops[m-1]={retain:b.retain+p.retain},typeof p.attributes=="object"&&(this.ops[m-1].attributes=p.attributes),this}}return m===this.ops.length?this.ops.push(p):this.ops.splice(m,0,p),this}chop(){const p=this.ops[this.ops.length-1];return p&&typeof p.retain=="number"&&!p.attributes&&this.ops.pop(),this}filter(p){return this.ops.filter(p)}forEach(p){this.ops.forEach(p)}map(p){return this.ops.map(p)}partition(p){const m=[],b=[];return this.forEach(E=>{(p(E)?m:b).push(E)}),[m,b]}reduce(p,m){return this.ops.reduce(p,m)}changeLength(){return this.reduce((p,m)=>m.insert?p+o.default.length(m):m.delete?p-m.delete:p,0)}length(){return this.reduce((p,m)=>p+o.default.length(m),0)}slice(p=0,m=1/0){const b=[],E=new a.default(this.ops);let N=0;for(;N0&&b.next(N.retain-A)}const x=new d(E);for(;m.hasNext()||b.hasNext();)if(b.peekType()==="insert")x.push(b.next());else if(m.peekType()==="delete")x.push(m.next());else{const A=Math.min(m.peekLength(),b.peekLength()),T=m.next(A),k=b.next(A);if(k.retain){const C={};if(typeof T.retain=="number")C.retain=typeof k.retain=="number"?A:k.retain;else if(typeof k.retain=="number")T.retain==null?C.insert=T.insert:C.retain=T.retain;else{const M=T.retain==null?"insert":"retain",[H,It,Ht]=h(T[M],k.retain),Jt=d.getHandler(H);C[M]={[H]:Jt.compose(It,Ht,M==="retain")}}const I=r.default.compose(T.attributes,k.attributes,typeof T.retain=="number");if(I&&(C.attributes=I),x.push(C),!b.hasNext()&&n(x.ops[x.ops.length-1],C)){const M=new d(m.rest());return x.concat(M).chop()}}else typeof k.delete=="number"&&(typeof T.retain=="number"||typeof T.retain=="object"&&T.retain!==null)&&x.push(k)}return x.chop()}concat(p){const m=new d(this.ops.slice());return p.ops.length>0&&(m.push(p.ops[0]),m.ops=m.ops.concat(p.ops.slice(1))),m}diff(p,m){if(this.ops===p.ops)return new d;const b=[this,p].map(T=>T.map(k=>{if(k.insert!=null)return typeof k.insert=="string"?k.insert:c;const C=T===p?"on":"with";throw new Error("diff() called "+C+" non-document")}).join("")),E=new d,N=e(b[0],b[1],m,!0),x=new a.default(this.ops),A=new a.default(p.ops);return N.forEach(T=>{let k=T[1].length;for(;k>0;){let C=0;switch(T[0]){case e.INSERT:C=Math.min(A.peekLength(),k),E.push(A.next(C));break;case e.DELETE:C=Math.min(k,x.peekLength()),x.next(C),E.delete(C);break;case e.EQUAL:C=Math.min(x.peekLength(),A.peekLength(),k);const I=x.next(C),M=A.next(C);n(I.insert,M.insert)?E.retain(C,r.default.diff(I.attributes,M.attributes)):E.push(M).delete(C);break}k-=C}}),E.chop()}eachLine(p,m=` `){const b=new a.default(this.ops);let E=new d,N=0;for(;b.hasNext();){if(b.peekType()!=="insert")return;const x=b.peek(),A=o.default.length(x)-b.peekLength(),T=typeof x.insert=="string"?x.insert.indexOf(m,A)-A:-1;if(T<0)E.push(b.next());else if(T>0)E.push(b.next(T));else{if(p(E,b.next(1).attributes||{},N)===!1)return;N+=1,E=new d}}E.length()>0&&p(E,{},N)}invert(p){const m=new d;return this.reduce((b,E)=>{if(E.insert)m.delete(o.default.length(E));else{if(typeof E.retain=="number"&&E.attributes==null)return m.retain(E.retain),b+E.retain;if(E.delete||typeof E.retain=="number"){const N=E.delete||E.retain;return p.slice(b,b+N).forEach(A=>{E.delete?m.push(A):E.retain&&E.attributes&&m.retain(o.default.length(A),r.default.invert(E.attributes,A.attributes))}),b+N}else if(typeof E.retain=="object"&&E.retain!==null){const N=p.slice(b,b+1),x=new a.default(N.ops).next(),[A,T,k]=h(E.retain,x.insert),C=d.getHandler(A);return m.retain({[A]:C.invert(T,k)},r.default.invert(E.attributes,x.attributes)),b+1}}return b},0),m.chop()}transform(p,m=!1){if(m=!!m,typeof p=="number")return this.transformPosition(p,m);const b=p,E=new a.default(this.ops),N=new a.default(b.ops),x=new d;for(;E.hasNext()||N.hasNext();)if(E.peekType()==="insert"&&(m||N.peekType()!=="insert"))x.retain(o.default.length(E.next()));else if(N.peekType()==="insert")x.push(N.next());else{const A=Math.min(E.peekLength(),N.peekLength()),T=E.next(A),k=N.next(A);if(T.delete)continue;if(k.delete)x.push(k);else{const C=T.retain,I=k.retain;let M=typeof I=="object"&&I!==null?I:A;if(typeof C=="object"&&C!==null&&typeof I=="object"&&I!==null){const H=Object.keys(C)[0];if(H===Object.keys(I)[0]){const It=d.getHandler(H);It&&(M={[H]:It.transform(C[H],I[H],m)})}}x.retain(M,r.default.transform(T.attributes,k.attributes,m))}}return x.chop()}transformPosition(p,m=!1){m=!!m;const b=new a.default(this.ops);let E=0;for(;b.hasNext()&&E<=p;){const N=b.peekLength(),x=b.peekType();if(b.next(),x==="delete"){p-=Math.min(N,p-E);continue}else x==="insert"&&(E"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}var rt;let Qt=(rt=class extends zi{static compare(t,e){const s=rt.order.indexOf(t),n=rt.order.indexOf(e);return s>=0||n>=0?s-n:t===e?0:t0){const e=this.parent.isolate(this.offset(),this.length());this.moveChildren(e),e.wrap(this)}}},w(rt,"allowedChildren",[rt,Tt,lt,xt]),w(rt,"order",["cursor","inline","link","underline","strike","italic","bold","script","code"]),rt);const xr=1;class G extends ds{constructor(){super(...arguments);w(this,"cache",{})}delta(){return this.cache.delta==null&&(this.cache.delta=lo(this)),this.cache.delta}deleteAt(e,s){super.deleteAt(e,s),this.cache={}}formatAt(e,s,n,r){s<=0||(this.scroll.query(n,q.BLOCK)?e+s===this.length()&&this.format(n,r):super.formatAt(e,Math.min(s,this.length()-e-1),n,r),this.cache={})}insertAt(e,s,n){if(n!=null){super.insertAt(e,s,n),this.cache={};return}if(s.length===0)return;const r=s.split(` `),o=r.shift();o.length>0&&(e(a=a.split(c,!0),a.insertAt(0,h),h.length),e+o.length)}insertBefore(e,s){const{head:n}=this.children;super.insertBefore(e,s),n instanceof Tt&&n.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+xr),this.cache.length}moveChildren(e,s){super.moveChildren(e,s),this.cache={}}optimize(e){super.optimize(e),this.cache={}}path(e){return super.path(e,!0)}removeChild(e){super.removeChild(e),this.cache={}}split(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(s&&(e===0||e>=this.length()-xr)){const r=this.clone();return e===0?(this.parent.insertBefore(r,this),this):(this.parent.insertBefore(r,this.next),r)}const n=super.split(e,s);return this.cache={},n}}G.blotName="block";G.tagName="P";G.defaultChild=Tt;G.allowedChildren=[Tt,Qt,lt,xt];class dt extends lt{attach(){super.attach(),this.attributes=new dn(this.domNode)}delta(){return new S().insert(this.value(),{...this.formats(),...this.attributes.values()})}format(t,e){const s=this.scroll.query(t,q.BLOCK_ATTRIBUTE);s!=null&&this.attributes.attribute(s,e)}formatAt(t,e,s,n){this.format(s,n)}insertAt(t,e,s){if(s!=null){super.insertAt(t,e,s);return}const n=e.split(` `),r=n.pop(),o=n.map(c=>{const h=this.scroll.create(G.blotName);return h.insertAt(0,c),h}),a=this.split(t);o.forEach(c=>{this.parent.insertBefore(c,a)}),r&&this.parent.insertBefore(this.scroll.create("text",r),a)}}dt.scope=q.BLOCK_BLOT;function lo(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return i.descendants(Q).reduce((e,s)=>s.length()===0?e:e.insert(s.value(),ut(s,{},t)),new S).insert(` `,ut(i))}function ut(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return i==null||("formats"in i&&typeof i.formats=="function"&&(t={...t,...i.formats()},e&&delete t["code-token"]),i.parent==null||i.parent.statics.blotName==="scroll"||i.parent.statics.scope!==i.statics.scope)?t:ut(i.parent,t,e)}const ct=class ct extends lt{static value(){}constructor(t,e,s){super(t,e),this.selection=s,this.textNode=document.createTextNode(ct.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){this.parent!=null&&this.parent.removeChild(this)}format(t,e){if(this.savedLength!==0){super.format(t,e);return}let s=this,n=0;for(;s!=null&&s.statics.scope!==q.BLOCK_BLOT;)n+=s.offset(s.parent),s=s.parent;s!=null&&(this.savedLength=ct.CONTENTS.length,s.optimize(),s.formatAt(n,ct.CONTENTS.length,t,e),this.savedLength=0)}index(t,e){return t===this.textNode?0:super.index(t,e)}length(){return this.savedLength}position(){return[this.textNode,this.textNode.data.length]}remove(){super.remove(),this.parent=null}restore(){if(this.selection.composing||this.parent==null)return null;const t=this.selection.getNativeRange();for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);const e=this.prev instanceof xt?this.prev:null,s=e?e.length():0,n=this.next instanceof xt?this.next:null,r=n?n.text:"",{textNode:o}=this,a=o.data.split(ct.CONTENTS).join("");o.data=ct.CONTENTS;let c;if(e)c=e,(a||n)&&(e.insertAt(e.length(),a+r),n&&n.remove());else if(n)c=n,n.insertAt(0,a);else{const h=document.createTextNode(a);c=this.scroll.create(h),this.parent.insertBefore(c,this)}if(this.remove(),t){const h=(p,m)=>e&&p===e.domNode?m:p===o?s+m-1:n&&p===n.domNode?s+a.length+m:null,d=h(t.start.node,t.start.offset),g=h(t.end.node,t.end.offset);if(d!==null&&g!==null)return{startNode:c.domNode,startOffset:d,endNode:c.domNode,endOffset:g}}return null}update(t,e){if(t.some(s=>s.type==="characterData"&&s.target===this.textNode)){const s=this.restore();s&&(e.range=s)}}optimize(t){super.optimize(t);let{parent:e}=this;for(;e;){if(e.domNode.tagName==="A"){this.savedLength=ct.CONTENTS.length,e.isolate(this.offset(e),this.length()).unwrap(),this.savedLength=0;break}e=e.parent}}value(){return""}};w(ct,"blotName","cursor"),w(ct,"className","ql-cursor"),w(ct,"tagName","span"),w(ct,"CONTENTS","\uFEFF");let Be=ct;var ao={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function n(c,h,d){this.fn=c,this.context=h,this.once=d||!1}function r(c,h,d,g,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new n(d,g||c,p),b=e?e+h:h;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],m]:c._events[b].push(m):(c._events[b]=m,c._eventsCount++),c}function o(c,h){--c._eventsCount===0?c._events=new s:delete c._events[h]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],d,g;if(this._eventsCount===0)return h;for(g in d=this._events)t.call(d,g)&&h.push(e?g.slice(1):g);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(d)):h},a.prototype.listeners=function(h){var d=e?e+h:h,g=this._events[d];if(!g)return[];if(g.fn)return[g.fn];for(var p=0,m=g.length,b=new Array(m);p1?t-1:0),s=1;s(t[e]=co.bind(console,e,i),t),{})}Ut.level=i=>{Mi=i};co.level=Ut.level;const gi=Ut("quill:events"),kl=["selectionchange","mousedown","mouseup","click"];kl.forEach(i=>{document.addEventListener(i,function(){for(var t=arguments.length,e=new Array(t),s=0;s{const r=Oi.get(n);r&&r.emitter&&r.emitter.handleDOM(...e)})})});class L extends ql{constructor(){super(),this.domListeners={},this.on("error",gi.error)}emit(){for(var t=arguments.length,e=new Array(t),s=0;s1?e-1:0),n=1;n{let{node:o,handler:a}=r;(t.target===o||o.contains(t.target))&&a(t,...s)})}listenDOM(t,e,s){this.domListeners[t]||(this.domListeners[t]=[]),this.domListeners[t].push({node:e,handler:s})}}w(L,"events",{EDITOR_CHANGE:"editor-change",SCROLL_BEFORE_UPDATE:"scroll-before-update",SCROLL_BLOT_MOUNT:"scroll-blot-mount",SCROLL_BLOT_UNMOUNT:"scroll-blot-unmount",SCROLL_OPTIMIZE:"scroll-optimize",SCROLL_UPDATE:"scroll-update",SCROLL_EMBED_UPDATE:"scroll-embed-update",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change",COMPOSITION_BEFORE_START:"composition-before-start",COMPOSITION_START:"composition-start",COMPOSITION_BEFORE_END:"composition-before-end",COMPOSITION_END:"composition-end"}),w(L,"sources",{API:"api",SILENT:"silent",USER:"user"});const bi=Ut("quill:selection");class ae{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=t,this.length=e}}class _l{constructor(t,e){this.emitter=e,this.scroll=t,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=this.scroll.create("cursor",this),this.savedRange=new ae(0,0),this.lastRange=this.savedRange,this.lastNative=null,this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",document,()=>{!this.mouseDown&&!this.composing&&setTimeout(this.update.bind(this,L.sources.USER),1)}),this.emitter.on(L.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;const s=this.getNativeRange();s!=null&&s.start.node!==this.cursor.textNode&&this.emitter.once(L.events.SCROLL_UPDATE,(n,r)=>{try{this.root.contains(s.start.node)&&this.root.contains(s.end.node)&&this.setNativeRange(s.start.node,s.start.offset,s.end.node,s.end.offset);const o=r.some(a=>a.type==="characterData"||a.type==="childList"||a.type==="attributes"&&a.target===this.root);this.update(o?L.sources.SILENT:n)}catch{}})}),this.emitter.on(L.events.SCROLL_OPTIMIZE,(s,n)=>{if(n.range){const{startNode:r,startOffset:o,endNode:a,endOffset:c}=n.range;this.setNativeRange(r,o,a,c),this.update(L.sources.SILENT)}}),this.update(L.sources.SILENT)}handleComposition(){this.emitter.on(L.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(L.events.COMPOSITION_END,()=>{if(this.composing=!1,this.cursor.parent){const t=this.cursor.restore();if(!t)return;setTimeout(()=>{this.setNativeRange(t.startNode,t.startOffset,t.endNode,t.endOffset)},1)}})}handleDragging(){this.emitter.listenDOM("mousedown",document.body,()=>{this.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,()=>{this.mouseDown=!1,this.update(L.sources.USER)})}focus(){this.hasFocus()||(this.root.focus({preventScroll:!0}),this.setRange(this.savedRange))}format(t,e){this.scroll.update();const s=this.getNativeRange();if(!(s==null||!s.native.collapsed||this.scroll.query(t,q.BLOCK))){if(s.start.node!==this.cursor.textNode){const n=this.scroll.find(s.start.node,!1);if(n==null)return;if(n instanceof Q){const r=n.split(s.start.offset);n.parent.insertBefore(this.cursor,r)}else n.insertBefore(this.cursor,s.start.node);this.cursor.attach()}this.cursor.format(t,e),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}getBounds(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const s=this.scroll.length();t=Math.min(t,s-1),e=Math.min(t+e,s-1)-t;let n,[r,o]=this.scroll.leaf(t);if(r==null)return null;if(e>0&&o===r.length()){const[d]=this.scroll.leaf(t+1);if(d){const[g]=this.scroll.line(t),[p]=this.scroll.line(t+1);g===p&&(r=d,o=0)}}[n,o]=r.position(o,!0);const a=document.createRange();if(e>0)return a.setStart(n,o),[r,o]=this.scroll.leaf(t+e),r==null?null:([n,o]=r.position(o,!0),a.setEnd(n,o),a.getBoundingClientRect());let c="left",h;if(n instanceof Text){if(!n.data.length)return null;o0&&(c="right")}return{bottom:h.top+h.height,height:h.height,left:h[c],right:h[c],top:h.top,width:0}}getNativeRange(){const t=document.getSelection();if(t==null||t.rangeCount<=0)return null;const e=t.getRangeAt(0);if(e==null)return null;const s=this.normalizeNative(e);return bi.info("getNativeRange",s),s}getRange(){const t=this.scroll.domNode;if("isConnected"in t&&!t.isConnected)return[null,null];const e=this.getNativeRange();return e==null?[null,null]:[this.normalizedToRange(e),e]}hasFocus(){return document.activeElement===this.root||document.activeElement!=null&&yi(this.root,document.activeElement)}normalizedToRange(t){const e=[[t.start.node,t.start.offset]];t.native.collapsed||e.push([t.end.node,t.end.offset]);const s=e.map(o=>{const[a,c]=o,h=this.scroll.find(a,!0),d=h.offset(this.scroll);return c===0?d:h instanceof Q?d+h.index(a,c):d+h.length()}),n=Math.min(Math.max(...s),this.scroll.length()-1),r=Math.min(n,...s);return new ae(r,n-r)}normalizeNative(t){if(!yi(this.root,t.startContainer)||!t.collapsed&&!yi(this.root,t.endContainer))return null;const e={start:{node:t.startContainer,offset:t.startOffset},end:{node:t.endContainer,offset:t.endOffset},native:t};return[e.start,e.end].forEach(s=>{let{node:n,offset:r}=s;for(;!(n instanceof Text)&&n.childNodes.length>0;)if(n.childNodes.length>r)n=n.childNodes[r],r=0;else if(n.childNodes.length===r)n=n.lastChild,n instanceof Text?r=n.data.length:n.childNodes.length>0?r=n.childNodes.length:r=n.childNodes.length+1;else break;s.node=n,s.offset=r}),e}rangeToNative(t){const e=this.scroll.length(),s=(n,r)=>{n=Math.min(e-1,n);const[o,a]=this.scroll.leaf(n);return o?o.position(a,r):[null,-1]};return[...s(t.index,!1),...s(t.index+t.length,!0)]}setNativeRange(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:e,r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(bi.info("setNativeRange",t,e,s,n),t!=null&&(this.root.parentNode==null||t.parentNode==null||s.parentNode==null))return;const o=document.getSelection();if(o!=null)if(t!=null){this.hasFocus()||this.root.focus({preventScroll:!0});const{native:a}=this.getNativeRange()||{};if(a==null||r||t!==a.startContainer||e!==a.startOffset||s!==a.endContainer||n!==a.endOffset){t instanceof Element&&t.tagName==="BR"&&(e=Array.from(t.parentNode.childNodes).indexOf(t),t=t.parentNode),s instanceof Element&&s.tagName==="BR"&&(n=Array.from(s.parentNode.childNodes).indexOf(s),s=s.parentNode);const c=document.createRange();c.setStart(t,e),c.setEnd(s,n),o.removeAllRanges(),o.addRange(c)}}else o.removeAllRanges(),this.root.blur()}setRange(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:L.sources.API;if(typeof e=="string"&&(s=e,e=!1),bi.info("setRange",t),t!=null){const n=this.rangeToNative(t);this.setNativeRange(...n,e)}else this.setNativeRange(null);this.update(s)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:L.sources.USER;const e=this.lastRange,[s,n]=this.getRange();if(this.lastRange=s,this.lastNative=n,this.lastRange!=null&&(this.savedRange=this.lastRange),!Fi(e,this.lastRange)){if(!this.composing&&n!=null&&n.native.collapsed&&n.start.node!==this.cursor.textNode){const o=this.cursor.restore();o&&this.setNativeRange(o.startNode,o.startOffset,o.endNode,o.endOffset)}const r=[L.events.SELECTION_CHANGE,Ie(this.lastRange),Ie(e),t];this.emitter.emit(L.events.EDITOR_CHANGE,...r),t!==L.sources.SILENT&&this.emitter.emit(...r)}}}function yi(i,t){try{t.parentNode}catch{return!1}return i.contains(t)}const Il=/^[ -~]*$/;class Ol{constructor(t){this.scroll=t,this.delta=this.getDelta()}applyDelta(t){this.scroll.update();let e=this.scroll.length();this.scroll.batchStart();const s=Ar(t),n=new S;return Ml(s.ops.slice()).reduce((o,a)=>{const c=ft.Op.length(a);let h=a.attributes||{},d=!1,g=!1;if(a.insert!=null){if(n.retain(c),typeof a.insert=="string"){const b=a.insert;g=!b.endsWith(` `)&&(e<=o||!!this.scroll.descendant(dt,o)[0]),this.scroll.insertAt(o,b);const[E,N]=this.scroll.line(o);let x=Zt({},ut(E));if(E instanceof G){const[A]=E.descendant(Q,N);A&&(x=Zt(x,ut(A)))}h=ft.AttributeMap.diff(x,h)||{}}else if(typeof a.insert=="object"){const b=Object.keys(a.insert)[0];if(b==null)return o;const E=this.scroll.query(b,q.INLINE)!=null;if(E)(e<=o||this.scroll.descendant(dt,o)[0])&&(g=!0);else if(o>0){const[N,x]=this.scroll.descendant(Q,o-1);N instanceof xt?N.value()[x]!==` `&&(d=!0):N instanceof lt&&N.statics.scope===q.INLINE_BLOT&&(d=!0)}if(this.scroll.insertAt(o,b,a.insert[b]),E){const[N]=this.scroll.descendant(Q,o);if(N){const x=Zt({},ut(N));h=ft.AttributeMap.diff(x,h)||{}}}}e+=c}else if(n.push(a),a.retain!==null&&typeof a.retain=="object"){const b=Object.keys(a.retain)[0];if(b==null)return o;this.scroll.updateEmbedAt(o,b,a.retain[b])}Object.keys(h).forEach(b=>{this.scroll.formatAt(o,c,b,h[b])});const p=d?1:0,m=g?1:0;return e+=p+m,n.retain(p),n.delete(m),o+c+p+m},0),n.reduce((o,a)=>typeof a.delete=="number"?(this.scroll.deleteAt(o,a.delete),o):o+ft.Op.length(a),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(s)}deleteText(t,e){return this.scroll.deleteAt(t,e),this.update(new S().retain(t).delete(e))}formatLine(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.scroll.update(),Object.keys(s).forEach(r=>{this.scroll.lines(t,Math.max(e,1)).forEach(o=>{o.format(r,s[r])})}),this.scroll.optimize();const n=new S().retain(t).retain(e,Ie(s));return this.update(n)}formatText(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.keys(s).forEach(r=>{this.scroll.formatAt(t,e,r,s[r])});const n=new S().retain(t).retain(e,Ie(s));return this.update(n)}getContents(t,e){return this.delta.slice(t,t+e)}getDelta(){return this.scroll.lines().reduce((t,e)=>t.concat(e.delta()),new S)}getFormat(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=[],n=[];e===0?this.scroll.path(t).forEach(a=>{const[c]=a;c instanceof G?s.push(c):c instanceof Q&&n.push(c)}):(s=this.scroll.lines(t,e),n=this.scroll.descendants(Q,t,e));const[r,o]=[s,n].map(a=>{const c=a.shift();if(c==null)return{};let h=ut(c);for(;Object.keys(h).length>0;){const d=a.shift();if(d==null)return h;h=Rl(ut(d),h)}return h});return{...r,...o}}getHTML(t,e){const[s,n]=this.scroll.line(t);if(s){const r=s.length();return s.length()>=n+e&&!(n===0&&e===r)?ps(s,n,e,!0):ps(this.scroll,t,e,!0)}return""}getText(t,e){return this.getContents(t,e).filter(s=>typeof s.insert=="string").map(s=>s.insert).join("")}insertContents(t,e){const s=Ar(e),n=new S().retain(t).concat(s);return this.scroll.insertContents(t,s),this.update(n)}insertEmbed(t,e,s){return this.scroll.insertAt(t,e,s),this.update(new S().retain(t).insert({[e]:s}))}insertText(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return e=e.replace(/\r\n/g,` `).replace(/\r/g,` `),this.scroll.insertAt(t,e),Object.keys(s).forEach(n=>{this.scroll.formatAt(t,e.length,n,s[n])}),this.update(new S().retain(t).insert(e,Ie(s)))}isBlank(){if(this.scroll.children.length===0)return!0;if(this.scroll.children.length>1)return!1;const t=this.scroll.children.head;if((t==null?void 0:t.statics.blotName)!==G.blotName)return!1;const e=t;return e.children.length>1?!1:e.children.head instanceof Tt}removeFormat(t,e){const s=this.getText(t,e),[n,r]=this.scroll.line(t+e);let o=0,a=new S;n!=null&&(o=n.length()-r,a=n.delta().slice(r,r+o-1).insert(` `));const h=this.getContents(t,e+o).diff(new S().insert(s).concat(a)),d=new S().retain(t).concat(h);return this.applyDelta(d)}update(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;const n=this.delta;if(e.length===1&&e[0].type==="characterData"&&e[0].target.data.match(Il)&&this.scroll.find(e[0].target)){const r=this.scroll.find(e[0].target),o=ut(r),a=r.offset(this.scroll),c=e[0].oldValue.replace(Be.CONTENTS,""),h=new S().insert(c),d=new S().insert(r.value()),g=s&&{oldRange:Tr(s.oldRange,-a),newRange:Tr(s.newRange,-a)};t=new S().retain(a).concat(h.diff(d,g)).reduce((m,b)=>b.insert?m.insert(b.insert,o):m.push(b),new S),this.delta=n.compose(t)}else this.delta=this.getDelta(),(!t||!Fi(n.compose(t),this.delta))&&(t=n.diff(this.delta,s));return t}}function ke(i,t,e){if(i.length===0){const[m]=vi(e.pop());return t<=0?``:`${ke([],t-1,e)}`}const[{child:s,offset:n,length:r,indent:o,type:a},...c]=i,[h,d]=vi(a);if(o>t)return e.push(a),o===t+1?`<${h}>${ps(s,n,r)}${ke(c,o,e)}`:`<${h}>
  • ${ke(i,t+1,e)}`;const g=e[e.length-1];if(o===t&&a===g)return`
  • ${ps(s,n,r)}${ke(c,o,e)}`;const[p]=vi(e.pop());return`${ke(i,t-1,e)}`}function ps(i,t,e){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if("html"in i&&typeof i.html=="function")return i.html(t,e);if(i instanceof xt)return bn(i.value().slice(t,t+e));if(i instanceof Nt){if(i.statics.blotName==="list-container"){const h=[];return i.children.forEachAt(t,e,(d,g,p)=>{const m="formats"in d&&typeof d.formats=="function"?d.formats():{};h.push({child:d,offset:g,length:p,indent:m.indent||0,type:m.list})}),ke(h,-1,[])}const n=[];if(i.children.forEachAt(t,e,(h,d,g)=>{n.push(ps(h,d,g))}),s||i.statics.blotName==="list")return n.join("");const{outerHTML:r,innerHTML:o}=i.domNode,[a,c]=r.split(`>${o}<`);return a==="${n.join("")}<${c}`:`${a}>${n.join("")}<${c}`}return i.domNode instanceof Element?i.domNode.outerHTML:""}function Rl(i,t){return Object.keys(t).reduce((e,s)=>{if(i[s]==null)return e;const n=t[s];return n===i[s]?e[s]=n:Array.isArray(n)?n.indexOf(i[s])<0?e[s]=n.concat([i[s]]):e[s]=n:e[s]=[n,i[s]],e},{})}function vi(i){const t=i==="ordered"?"ol":"ul";switch(i){case"checked":return[t,' data-list="checked"'];case"unchecked":return[t,' data-list="unchecked"'];default:return[t,""]}}function Ar(i){return i.reduce((t,e)=>{if(typeof e.insert=="string"){const s=e.insert.replace(/\r\n/g,` `).replace(/\r/g,` `);return t.insert(s,e.attributes)}return t.push(e)},new S)}function Tr(i,t){let{index:e,length:s}=i;return new ae(e+t,s)}function Ml(i){const t=[];return i.forEach(e=>{typeof e.insert=="string"?e.insert.split(` `).forEach((n,r)=>{r&&t.push({insert:` `,attributes:e.attributes}),n&&t.push({insert:n,attributes:e.attributes})}):t.push(e)}),t}class wt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=t,this.options=e}}w(wt,"DEFAULTS",{});const Qs="\uFEFF";let Xi=class extends lt{constructor(t,e){super(t,e),this.contentNode=document.createElement("span"),this.contentNode.setAttribute("contenteditable","false"),Array.from(this.domNode.childNodes).forEach(s=>{this.contentNode.appendChild(s)}),this.leftGuard=document.createTextNode(Qs),this.rightGuard=document.createTextNode(Qs),this.domNode.appendChild(this.leftGuard),this.domNode.appendChild(this.contentNode),this.domNode.appendChild(this.rightGuard)}index(t,e){return t===this.leftGuard?0:t===this.rightGuard?1:super.index(t,e)}restore(t){let e=null,s;const n=t.data.split(Qs).join("");if(t===this.leftGuard)if(this.prev instanceof xt){const r=this.prev.length();this.prev.insertAt(r,n),e={startNode:this.prev.domNode,startOffset:r+n.length}}else s=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(s),this),e={startNode:s,startOffset:n.length};else t===this.rightGuard&&(this.next instanceof xt?(this.next.insertAt(0,n),e={startNode:this.next.domNode,startOffset:n.length}):(s=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(s),this.next),e={startNode:s,startOffset:n.length}));return t.data=Qs,e}update(t,e){t.forEach(s=>{if(s.type==="characterData"&&(s.target===this.leftGuard||s.target===this.rightGuard)){const n=this.restore(s.target);n&&(e.range=n)}})}};class Bl{constructor(t,e){w(this,"isComposing",!1);this.scroll=t,this.emitter=e,this.setupListeners()}setupListeners(){this.scroll.domNode.addEventListener("compositionstart",t=>{this.isComposing||this.handleCompositionStart(t)}),this.scroll.domNode.addEventListener("compositionend",t=>{this.isComposing&&queueMicrotask(()=>{this.handleCompositionEnd(t)})})}handleCompositionStart(t){const e=t.target instanceof Node?this.scroll.find(t.target,!0):null;e&&!(e instanceof Xi)&&(this.emitter.emit(L.events.COMPOSITION_BEFORE_START,t),this.scroll.batchStart(),this.emitter.emit(L.events.COMPOSITION_START,t),this.isComposing=!0)}handleCompositionEnd(t){this.emitter.emit(L.events.COMPOSITION_BEFORE_END,t),this.scroll.batchEnd(),this.emitter.emit(L.events.COMPOSITION_END,t),this.isComposing=!1}}const us=class us{constructor(t,e){w(this,"modules",{});this.quill=t,this.options=e}init(){Object.keys(this.options.modules).forEach(t=>{this.modules[t]==null&&this.addModule(t)})}addModule(t){const e=this.quill.constructor.import(`modules/${t}`);return this.modules[t]=new e(this.quill,this.options.modules[t]||{}),this.modules[t]}};w(us,"DEFAULTS",{modules:{}}),w(us,"themes",{default:us});let De=us;const Dl=i=>i.parentElement||i.getRootNode().host||null,Pl=i=>{const t=i.getBoundingClientRect(),e="offsetWidth"in i&&Math.abs(t.width)/i.offsetWidth||1,s="offsetHeight"in i&&Math.abs(t.height)/i.offsetHeight||1;return{top:t.top,right:t.left+i.clientWidth*e,bottom:t.top+i.clientHeight*s,left:t.left}},Js=i=>{const t=parseInt(i,10);return Number.isNaN(t)?0:t},wr=(i,t,e,s,n,r)=>is?0:is?t-i>s-e?i+n-e:t-s+r:0,$l=(i,t)=>{var r,o,a;const e=i.ownerDocument;let s=t,n=i;for(;n;){const c=n===e.body,h=c?{top:0,right:((r=window.visualViewport)==null?void 0:r.width)??e.documentElement.clientWidth,bottom:((o=window.visualViewport)==null?void 0:o.height)??e.documentElement.clientHeight,left:0}:Pl(n),d=getComputedStyle(n),g=wr(s.left,s.right,h.left,h.right,Js(d.scrollPaddingLeft),Js(d.scrollPaddingRight)),p=wr(s.top,s.bottom,h.top,h.bottom,Js(d.scrollPaddingTop),Js(d.scrollPaddingBottom));if(g||p)if(c)(a=e.defaultView)==null||a.scrollBy(g,p);else{const{scrollLeft:m,scrollTop:b}=n;p&&(n.scrollTop+=p),g&&(n.scrollLeft+=g);const E=n.scrollLeft-m,N=n.scrollTop-b;s={left:s.left-E,top:s.top-N,right:s.right-E,bottom:s.bottom-N}}n=c||d.position==="fixed"?null:Dl(n)}},Ul=100,Hl=["block","break","cursor","inline","scroll","text"],jl=(i,t,e)=>{const s=new Me;return Hl.forEach(n=>{const r=t.query(n);r&&s.register(r)}),i.forEach(n=>{let r=t.query(n);r||e.error(`Cannot register "${n}" specified in "formats" config. Are you sure it was registered?`);let o=0;for(;r;)if(s.register(r),r="blotName"in r?r.requiredContainer??null:null,o+=1,o>Ul){e.error(`Cycle detected in registering blot requiredContainer: "${n}"`);break}}),s},Re=Ut("quill"),tn=new Me;Nt.uiClass="ql-ui";const vt=class vt{static debug(t){t===!0&&(t="log"),Ut.level(t)}static find(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Oi.get(t)||tn.find(t,e)}static import(t){return this.imports[t]==null&&Re.error(`Cannot import ${t}. Are you sure it was registered?`),this.imports[t]}static register(){if(typeof(arguments.length<=0?void 0:arguments[0])!="string"){const t=arguments.length<=0?void 0:arguments[0],e=!!(!(arguments.length<=1)&&arguments[1]),s="attrName"in t?t.attrName:t.blotName;typeof s=="string"?this.register(`formats/${s}`,t,e):Object.keys(t).forEach(n=>{this.register(n,t[n],e)})}else{const t=arguments.length<=0?void 0:arguments[0],e=arguments.length<=1?void 0:arguments[1],s=!!(!(arguments.length<=2)&&arguments[2]);this.imports[t]!=null&&!s&&Re.warn(`Overwriting ${t} with`,e),this.imports[t]=e,(t.startsWith("blots/")||t.startsWith("formats/"))&&e&&typeof e!="boolean"&&e.blotName!=="abstract"&&tn.register(e),typeof e.register=="function"&&e.register(tn)}}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=Fl(t,e),this.container=this.options.container,this.container==null){Re.error("Invalid Quill container",t);return}this.options.debug&&vt.debug(this.options.debug);const s=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",Oi.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new L;const n=Vi.blotName,r=this.options.registry.query(n);if(!r||!("blotName"in r))throw new Error(`Cannot initialize Quill without "${n}" blot`);if(this.scroll=new r(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new Ol(this.scroll),this.selection=new _l(this.scroll,this.emitter),this.composition=new Bl(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule("keyboard"),this.clipboard=this.theme.addModule("clipboard"),this.history=this.theme.addModule("history"),this.uploader=this.theme.addModule("uploader"),this.theme.addModule("input"),this.theme.addModule("uiNode"),this.theme.init(),this.emitter.on(L.events.EDITOR_CHANGE,o=>{o===L.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(L.events.SCROLL_UPDATE,(o,a)=>{const c=this.selection.lastRange,[h]=this.selection.getRange(),d=c&&h?{oldRange:c,newRange:h}:void 0;yt.call(this,()=>this.editor.update(null,a,d),o)}),this.emitter.on(L.events.SCROLL_EMBED_UPDATE,(o,a)=>{const c=this.selection.lastRange,[h]=this.selection.getRange(),d=c&&h?{oldRange:c,newRange:h}:void 0;yt.call(this,()=>{const g=new S().retain(o.offset(this)).retain({[o.statics.blotName]:a});return this.editor.update(g,[],d)},vt.sources.USER)}),s){const o=this.clipboard.convert({html:`${s}


    `,text:` `});this.setContents(o)}this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable(),this.allowReadOnlyEdits=!1}addContainer(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof t=="string"){const s=t;t=document.createElement("div"),t.classList.add(s)}return this.container.insertBefore(t,e),t}blur(){this.selection.setRange(null)}deleteText(t,e,s){return[t,e,,s]=Dt(t,e,s),yt.call(this,()=>this.editor.deleteText(t,e),s,t,-1*e)}disable(){this.enable(!1)}editReadOnly(t){this.allowReadOnlyEdits=!0;const e=t();return this.allowReadOnlyEdits=!1,e}enable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(t),this.container.classList.toggle("ql-disabled",!t)}focus(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.selection.focus(),t.preventScroll||this.scrollSelectionIntoView()}format(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:L.sources.API;return yt.call(this,()=>{const n=this.getSelection(!0);let r=new S;if(n==null)return r;if(this.scroll.query(t,q.BLOCK))r=this.editor.formatLine(n.index,n.length,{[t]:e});else{if(n.length===0)return this.selection.format(t,e),r;r=this.editor.formatText(n.index,n.length,{[t]:e})}return this.setSelection(n,L.sources.SILENT),r},s)}formatLine(t,e,s,n,r){let o;return[t,e,o,r]=Dt(t,e,s,n,r),yt.call(this,()=>this.editor.formatLine(t,e,o),r,t,0)}formatText(t,e,s,n,r){let o;return[t,e,o,r]=Dt(t,e,s,n,r),yt.call(this,()=>this.editor.formatText(t,e,o),r,t,0)}getBounds(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=null;if(typeof t=="number"?s=this.selection.getBounds(t,e):s=this.selection.getBounds(t.index,t.length),!s)return null;const n=this.container.getBoundingClientRect();return{bottom:s.bottom-n.top,height:s.height,left:s.left-n.left,right:s.right-n.left,top:s.top-n.top,width:s.width}}getContents(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-t;return[t,e]=Dt(t,e),this.editor.getContents(t,e)}getFormat(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof t=="number"?this.editor.getFormat(t,e):this.editor.getFormat(t.index,t.length)}getIndex(t){return t.offset(this.scroll)}getLength(){return this.scroll.length()}getLeaf(t){return this.scroll.leaf(t)}getLine(t){return this.scroll.line(t)}getLines(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof t!="number"?this.scroll.lines(t.index,t.length):this.scroll.lines(t,e)}getModule(t){return this.theme.modules[t]}getSelection(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1)&&this.focus(),this.update(),this.selection.getRange()[0]}getSemanticHTML(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return typeof t=="number"&&(e=e??this.getLength()-t),[t,e]=Dt(t,e),this.editor.getHTML(t,e)}getText(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return typeof t=="number"&&(e=e??this.getLength()-t),[t,e]=Dt(t,e),this.editor.getText(t,e)}hasFocus(){return this.selection.hasFocus()}insertEmbed(t,e,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:vt.sources.API;return yt.call(this,()=>this.editor.insertEmbed(t,e,s),n,t)}insertText(t,e,s,n,r){let o;return[t,,o,r]=Dt(t,0,s,n,r),yt.call(this,()=>this.editor.insertText(t,e,o),r,t,e.length)}isEnabled(){return this.scroll.isEnabled()}off(){return this.emitter.off(...arguments)}on(){return this.emitter.on(...arguments)}once(){return this.emitter.once(...arguments)}removeFormat(t,e,s){return[t,e,,s]=Dt(t,e,s),yt.call(this,()=>this.editor.removeFormat(t,e),s,t)}scrollRectIntoView(t){$l(this.root,t)}scrollIntoView(){console.warn("Quill#scrollIntoView() has been deprecated and will be removed in the near future. Please use Quill#scrollSelectionIntoView() instead."),this.scrollSelectionIntoView()}scrollSelectionIntoView(){const t=this.selection.lastRange,e=t&&this.selection.getBounds(t.index,t.length);e&&this.scrollRectIntoView(e)}setContents(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:L.sources.API;return yt.call(this,()=>{t=new S(t);const s=this.getLength(),n=this.editor.deleteText(0,s),r=this.editor.insertContents(0,t),o=this.editor.deleteText(this.getLength()-1,1);return n.compose(r).compose(o)},e)}setSelection(t,e,s){t==null?this.selection.setRange(null,e||vt.sources.API):([t,e,,s]=Dt(t,e,s),this.selection.setRange(new ae(Math.max(0,t),e),s),s!==L.sources.SILENT&&this.scrollSelectionIntoView())}setText(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:L.sources.API;const s=new S().insert(t);return this.setContents(s,e)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:L.sources.USER;const e=this.scroll.update(t);return this.selection.update(t),e}updateContents(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:L.sources.API;return yt.call(this,()=>(t=new S(t),this.editor.applyDelta(t)),e,!0)}};w(vt,"DEFAULTS",{bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:tn,theme:"default"}),w(vt,"events",L.events),w(vt,"sources",L.sources),w(vt,"version","2.0.2"),w(vt,"imports",{delta:S,parchment:pl,"core/module":wt,"core/theme":De});let y=vt;function Lr(i){return typeof i=="string"?document.querySelector(i):i}function Ei(i){return Object.entries(i??{}).reduce((t,e)=>{let[s,n]=e;return{...t,[s]:n===!0?{}:n}},{})}function Cr(i){return Object.fromEntries(Object.entries(i).filter(t=>t[1]!==void 0))}function Fl(i,t){const e=Lr(i);if(!e)throw new Error("Invalid Quill container");const n=!t.theme||t.theme===y.DEFAULTS.theme?De:y.import(`themes/${t.theme}`);if(!n)throw new Error(`Invalid theme ${t.theme}. Did you register it?`);const{modules:r,...o}=y.DEFAULTS,{modules:a,...c}=n.DEFAULTS;let h=Ei(t.modules);h!=null&&h.toolbar&&h.toolbar.constructor!==Object&&(h={...h,toolbar:{container:h.toolbar}});const d=Zt({},Ei(r),Ei(a),h),g={...o,...Cr(c),...Cr(t)};let p=t.registry;return p?t.formats&&Re.warn('Ignoring "formats" option because "registry" is specified'):p=t.formats?jl(t.formats,g.registry,Re):g.registry,{...g,registry:p,container:e,theme:n,modules:Object.entries(d).reduce((m,b)=>{let[E,N]=b;if(!N)return m;const x=y.import(`modules/${E}`);return x==null?(Re.error(`Cannot load ${E} module. Are you sure you registered it?`),m):{...m,[E]:Zt({},x.DEFAULTS||{},N)}},{}),bounds:Lr(g.bounds)}}function yt(i,t,e,s){if(!this.isEnabled()&&t===L.sources.USER&&!this.allowReadOnlyEdits)return new S;let n=e==null?null:this.getSelection();const r=this.editor.delta,o=i();if(n!=null&&(e===!0&&(e=n.index),s==null?n=Sr(n,o,t):s!==0&&(n=Sr(n,e,s,t)),this.setSelection(n,L.sources.SILENT)),o.length()>0){const a=[L.events.TEXT_CHANGE,o,r,t];this.emitter.emit(L.events.EDITOR_CHANGE,...a),t!==L.sources.SILENT&&this.emitter.emit(...a)}return o}function Dt(i,t,e,s,n){let r={};return typeof i.index=="number"&&typeof i.length=="number"?typeof t!="number"?(n=s,s=e,e=t,t=i.length,i=i.index):(t=i.length,i=i.index):typeof t!="number"&&(n=s,s=e,e=t,t=0),typeof e=="object"?(r=e,n=s):typeof e=="string"&&(s!=null?r[e]=s:n=e),n=n||L.sources.API,[i,t,r,n]}function Sr(i,t,e,s){const n=typeof e=="number"?e:0;if(i==null)return null;let r,o;return t&&typeof t.transformPosition=="function"?[r,o]=[i.index,i.index+i.length].map(a=>t.transformPosition(a,s!==L.sources.USER)):[r,o]=[i.index,i.index+i.length].map(a=>a=0?a+n:Math.max(t,a+n)),new ae(r,o-r)}class ce extends fn{}function qr(i){return i instanceof G||i instanceof dt}function kr(i){return typeof i.updateContent=="function"}class _e extends Vi{constructor(t,e,s){let{emitter:n}=s;super(t,e),this.emitter=n,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener("dragstart",r=>this.handleDragStart(r))}batchStart(){Array.isArray(this.batch)||(this.batch=[])}batchEnd(){if(!this.batch)return;const t=this.batch;this.batch=!1,this.update(t)}emitMount(t){this.emitter.emit(L.events.SCROLL_BLOT_MOUNT,t)}emitUnmount(t){this.emitter.emit(L.events.SCROLL_BLOT_UNMOUNT,t)}emitEmbedUpdate(t,e){this.emitter.emit(L.events.SCROLL_EMBED_UPDATE,t,e)}deleteAt(t,e){const[s,n]=this.line(t),[r]=this.line(t+e);if(super.deleteAt(t,e),r!=null&&s!==r&&n>0){if(s instanceof dt||r instanceof dt){this.optimize();return}const o=r.children.head instanceof Tt?null:r.children.head;s.moveChildren(r,o),s.remove()}this.optimize()}enable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",t?"true":"false")}formatAt(t,e,s,n){super.formatAt(t,e,s,n),this.optimize()}insertAt(t,e,s){if(t>=this.length())if(s==null||this.scroll.query(e,q.BLOCK)==null){const n=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(n),s==null&&e.endsWith(` `)?n.insertAt(0,e.slice(0,-1),s):n.insertAt(0,e,s)}else{const n=this.scroll.create(e,s);this.appendChild(n)}else super.insertAt(t,e,s);this.optimize()}insertBefore(t,e){if(t.statics.scope===q.INLINE_BLOT){const s=this.scroll.create(this.statics.defaultChild.blotName);s.appendChild(t),super.insertBefore(s,e)}else super.insertBefore(t,e)}insertContents(t,e){const s=this.deltaToRenderBlocks(e.concat(new S().insert(` `))),n=s.pop();if(n==null)return;this.batchStart();const r=s.shift();if(r){const c=r.type==="block"&&(r.delta.length()===0||!this.descendant(dt,t)[0]&&t{this.formatAt(g-1,1,b,m[b])}),t=g}let[o,a]=this.children.find(t);if(s.length&&(o&&(o=o.split(a),a=0),s.forEach(c=>{if(c.type==="block"){const h=this.createBlock(c.attributes,o||void 0);Ni(h,0,c.delta)}else{const h=this.create(c.key,c.value);this.insertBefore(h,o||void 0),Object.keys(c.attributes).forEach(d=>{h.format(d,c.attributes[d])})}})),n.type==="block"&&n.delta.length()){const c=o?o.offset(o.scroll)+a:this.length();Ni(this,c,n.delta)}this.batchEnd(),this.optimize()}isEnabled(){return this.domNode.getAttribute("contenteditable")==="true"}leaf(t){const e=this.path(t).pop();if(!e)return[null,-1];const[s,n]=e;return s instanceof Q?[s,n]:[null,-1]}line(t){return t===this.length()?this.line(t-1):this.descendant(qr,t)}lines(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;const s=(n,r,o)=>{let a=[],c=o;return n.children.forEachAt(r,o,(h,d,g)=>{qr(h)?a.push(h):h instanceof fn&&(a=a.concat(s(h,d,c))),c-=g}),a};return s(this,t,e)}optimize(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch||(super.optimize(t,e),t.length>0&&this.emitter.emit(L.events.SCROLL_OPTIMIZE,t,e))}path(t){return super.path(t).slice(1)}remove(){}update(t){if(this.batch){Array.isArray(t)&&(this.batch=this.batch.concat(t));return}let e=L.sources.USER;typeof t=="string"&&(e=t),Array.isArray(t)||(t=this.observer.takeRecords()),t=t.filter(s=>{let{target:n}=s;const r=this.find(n,!0);return r&&!kr(r)}),t.length>0&&this.emitter.emit(L.events.SCROLL_BEFORE_UPDATE,e,t),super.update(t.concat([])),t.length>0&&this.emitter.emit(L.events.SCROLL_UPDATE,e,t)}updateEmbedAt(t,e,s){const[n]=this.descendant(r=>r instanceof dt,t);n&&n.statics.blotName===e&&kr(n)&&n.updateContent(s)}handleDragStart(t){t.preventDefault()}deltaToRenderBlocks(t){const e=[];let s=new S;return t.forEach(n=>{const r=n==null?void 0:n.insert;if(r)if(typeof r=="string"){const o=r.split(` `);o.slice(0,-1).forEach(c=>{s.insert(c,n.attributes),e.push({type:"block",delta:s,attributes:n.attributes??{}}),s=new S});const a=o[o.length-1];a&&s.insert(a,n.attributes)}else{const o=Object.keys(r)[0];if(!o)return;this.query(o,q.INLINE)?s.push(n):(s.length()&&e.push({type:"block",delta:s,attributes:{}}),s=new S,e.push({type:"blockEmbed",key:o,value:r[o],attributes:n.attributes??{}}))}}),s.length()&&e.push({type:"block",delta:s,attributes:{}}),e}createBlock(t,e){let s;const n={};Object.entries(t).forEach(a=>{let[c,h]=a;this.query(c,q.BLOCK&q.BLOT)!=null?s=c:n[c]=h});const r=this.create(s||this.statics.defaultChild.blotName,s?t[s]:void 0);this.insertBefore(r,e||void 0);const o=r.length();return Object.entries(n).forEach(a=>{let[c,h]=a;r.formatAt(0,o,c,h)}),r}}w(_e,"blotName","scroll"),w(_e,"className","ql-editor"),w(_e,"tagName","DIV"),w(_e,"defaultChild",G),w(_e,"allowedChildren",[G,dt,ce]);function Ni(i,t,e){e.reduce((s,n)=>{const r=ft.Op.length(n);let o=n.attributes||{};if(n.insert!=null){if(typeof n.insert=="string"){const a=n.insert;i.insertAt(s,a);const[c]=i.descendant(Q,s),h=ut(c);o=ft.AttributeMap.diff(h,o)||{}}else if(typeof n.insert=="object"){const a=Object.keys(n.insert)[0];if(a==null)return s;if(i.insertAt(s,a,n.insert[a]),i.scroll.query(a,q.INLINE)!=null){const[h]=i.descendant(Q,s),d=ut(h);o=ft.AttributeMap.diff(d,o)||{}}}}return Object.keys(o).forEach(a=>{i.formatAt(s,r,a,o[a])}),s+r},t)}const Yi={scope:q.BLOCK,whitelist:["right","center","justify"]},zl=new _t("align","align",Yi),uo=new At("align","ql-align",Yi),ho=new Yt("align","text-align",Yi);class fo extends Yt{value(t){let e=super.value(t);return e.startsWith("rgb(")?(e=e.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),`#${e.split(",").map(n=>`00${parseInt(n,10).toString(16)}`.slice(-2)).join("")}`):e}}const Vl=new At("color","ql-color",{scope:q.INLINE}),Qi=new fo("color","color",{scope:q.INLINE}),Kl=new At("background","ql-bg",{scope:q.INLINE}),Ji=new fo("background","background-color",{scope:q.INLINE});class ue extends ce{static create(t){const e=super.create(t);return e.setAttribute("spellcheck","false"),e}code(t,e){return this.children.map(s=>s.length()<=1?"":s.domNode.innerText).join(` `).slice(t,t+e)}html(t,e){return`
    ${bn(this.code(t,e))}
    
    `}}class J extends G{static register(){y.register(ue)}}w(J,"TAB"," ");class tr extends Qt{}tr.blotName="code";tr.tagName="CODE";J.blotName="code-block";J.className="ql-code-block";J.tagName="DIV";ue.blotName="code-block-container";ue.className="ql-code-block-container";ue.tagName="DIV";ue.allowedChildren=[J];J.allowedChildren=[xt,Tt,Be];J.requiredContainer=ue;const er={scope:q.BLOCK,whitelist:["rtl"]},po=new _t("direction","dir",er),mo=new At("direction","ql-direction",er),go=new Yt("direction","direction",er),bo={scope:q.INLINE,whitelist:["serif","monospace"]},yo=new At("font","ql-font",bo);class Gl extends Yt{value(t){return super.value(t).replace(/["']/g,"")}}const vo=new Gl("font","font-family",bo),Eo=new At("size","ql-size",{scope:q.INLINE,whitelist:["small","large","huge"]}),No=new Yt("size","font-size",{scope:q.INLINE,whitelist:["10px","18px","32px"]}),Wl=Ut("quill:keyboard"),Zl=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey";class yn extends wt{static match(t,e){return["altKey","ctrlKey","metaKey","shiftKey"].some(s=>!!e[s]!==t[s]&&e[s]!==null)?!1:e.key===t.key||e.key===t.which}constructor(t,e){super(t,e),this.bindings={},Object.keys(this.options.bindings).forEach(s=>{this.options.bindings[s]&&this.addBinding(this.options.bindings[s])}),this.addBinding({key:"Enter",shiftKey:null},this.handleEnter),this.addBinding({key:"Enter",metaKey:null,ctrlKey:null,altKey:null},()=>{}),/Firefox/i.test(navigator.userAgent)?(this.addBinding({key:"Backspace"},{collapsed:!0},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0},this.handleDelete)):(this.addBinding({key:"Backspace"},{collapsed:!0,prefix:/^.?$/},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0,suffix:/^.?$/},this.handleDelete)),this.addBinding({key:"Backspace"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Delete"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Backspace",altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},this.handleBackspace),this.listen()}addBinding(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const n=Yl(t);if(n==null){Wl.warn("Attempted to add invalid keyboard binding",n);return}typeof e=="function"&&(e={handler:e}),typeof s=="function"&&(s={handler:s}),(Array.isArray(n.key)?n.key:[n.key]).forEach(o=>{const a={...n,key:o,...e,...s};this.bindings[a.key]=this.bindings[a.key]||[],this.bindings[a.key].push(a)})}listen(){this.quill.root.addEventListener("keydown",t=>{if(t.defaultPrevented||t.isComposing||t.keyCode===229&&(t.key==="Enter"||t.key==="Backspace"))return;const n=(this.bindings[t.key]||[]).concat(this.bindings[t.which]||[]).filter(x=>yn.match(t,x));if(n.length===0)return;const r=y.find(t.target,!0);if(r&&r.scroll!==this.quill.scroll)return;const o=this.quill.getSelection();if(o==null||!this.quill.hasFocus())return;const[a,c]=this.quill.getLine(o.index),[h,d]=this.quill.getLeaf(o.index),[g,p]=o.length===0?[h,d]:this.quill.getLeaf(o.index+o.length),m=h instanceof ln?h.value().slice(0,d):"",b=g instanceof ln?g.value().slice(p):"",E={collapsed:o.length===0,empty:o.length===0&&a.length()<=1,format:this.quill.getFormat(o),line:a,offset:c,prefix:m,suffix:b,event:t};n.some(x=>{if(x.collapsed!=null&&x.collapsed!==E.collapsed||x.empty!=null&&x.empty!==E.empty||x.offset!=null&&x.offset!==E.offset)return!1;if(Array.isArray(x.format)){if(x.format.every(A=>E.format[A]==null))return!1}else if(typeof x.format=="object"&&!Object.keys(x.format).every(A=>x.format[A]===!0?E.format[A]!=null:x.format[A]===!1?E.format[A]==null:Fi(x.format[A],E.format[A])))return!1;return x.prefix!=null&&!x.prefix.test(E.prefix)||x.suffix!=null&&!x.suffix.test(E.suffix)?!1:x.handler.call(this,o,E,x)!==!0})&&t.preventDefault()})}handleBackspace(t,e){const s=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(e.prefix)?2:1;if(t.index===0||this.quill.getLength()<=1)return;let n={};const[r]=this.quill.getLine(t.index);let o=new S().retain(t.index-s).delete(s);if(e.offset===0){const[a]=this.quill.getLine(t.index-1);if(a&&!(a.statics.blotName==="block"&&a.length()<=1)){const h=r.formats(),d=this.quill.getFormat(t.index-1,1);if(n=ft.AttributeMap.diff(h,d)||{},Object.keys(n).length>0){const g=new S().retain(t.index+r.length()-2).retain(1,n);o=o.compose(g)}}}this.quill.updateContents(o,y.sources.USER),this.quill.focus()}handleDelete(t,e){const s=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(e.suffix)?2:1;if(t.index>=this.quill.getLength()-s)return;let n={};const[r]=this.quill.getLine(t.index);let o=new S().retain(t.index).delete(s);if(e.offset>=r.length()-1){const[a]=this.quill.getLine(t.index+1);if(a){const c=r.formats(),h=this.quill.getFormat(t.index,1);n=ft.AttributeMap.diff(c,h)||{},Object.keys(n).length>0&&(o=o.retain(a.length()-1).retain(1,n))}}this.quill.updateContents(o,y.sources.USER),this.quill.focus()}handleDeleteRange(t){sr({range:t,quill:this.quill}),this.quill.focus()}handleEnter(t,e){const s=Object.keys(e.format).reduce((r,o)=>(this.quill.scroll.query(o,q.BLOCK)&&!Array.isArray(e.format[o])&&(r[o]=e.format[o]),r),{}),n=new S().retain(t.index).delete(t.length).insert(` `,s);this.quill.updateContents(n,y.sources.USER),this.quill.setSelection(t.index+1,y.sources.SILENT),this.quill.focus()}}const Xl={bindings:{bold:xi("bold"),italic:xi("italic"),underline:xi("underline"),indent:{key:"Tab",format:["blockquote","indent","list"],handler(i,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","+1",y.sources.USER),!1)}},outdent:{key:"Tab",shiftKey:!0,format:["blockquote","indent","list"],handler(i,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","-1",y.sources.USER),!1)}},"outdent backspace":{key:"Backspace",collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler(i,t){t.format.indent!=null?this.quill.format("indent","-1",y.sources.USER):t.format.list!=null&&this.quill.format("list",!1,y.sources.USER)}},"indent code-block":_r(!0),"outdent code-block":_r(!1),"remove tab":{key:"Tab",shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(i){this.quill.deleteText(i.index-1,1,y.sources.USER)}},tab:{key:"Tab",handler(i,t){if(t.format.table)return!0;this.quill.history.cutoff();const e=new S().retain(i.index).delete(i.length).insert(" ");return this.quill.updateContents(e,y.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(i.index+1,y.sources.SILENT),!1}},"blockquote empty enter":{key:"Enter",collapsed:!0,format:["blockquote"],empty:!0,handler(){this.quill.format("blockquote",!1,y.sources.USER)}},"list empty enter":{key:"Enter",collapsed:!0,format:["list"],empty:!0,handler(i,t){const e={list:!1};t.format.indent&&(e.indent=!1),this.quill.formatLine(i.index,i.length,e,y.sources.USER)}},"checklist enter":{key:"Enter",collapsed:!0,format:{list:"checked"},handler(i){const[t,e]=this.quill.getLine(i.index),s={...t.formats(),list:"checked"},n=new S().retain(i.index).insert(` `,s).retain(t.length()-e-1).retain(1,{list:"unchecked"});this.quill.updateContents(n,y.sources.USER),this.quill.setSelection(i.index+1,y.sources.SILENT),this.quill.scrollSelectionIntoView()}},"header enter":{key:"Enter",collapsed:!0,format:["header"],suffix:/^$/,handler(i,t){const[e,s]=this.quill.getLine(i.index),n=new S().retain(i.index).insert(` `,t.format).retain(e.length()-s-1).retain(1,{header:null});this.quill.updateContents(n,y.sources.USER),this.quill.setSelection(i.index+1,y.sources.SILENT),this.quill.scrollSelectionIntoView()}},"table backspace":{key:"Backspace",format:["table"],collapsed:!0,offset:0,handler(){}},"table delete":{key:"Delete",format:["table"],collapsed:!0,suffix:/^$/,handler(){}},"table enter":{key:"Enter",shiftKey:null,format:["table"],handler(i){const t=this.quill.getModule("table");if(t){const[e,s,n,r]=t.getTable(i),o=Ql(e,s,n,r);if(o==null)return;let a=e.offset();if(o<0){const c=new S().retain(a).insert(` `);this.quill.updateContents(c,y.sources.USER),this.quill.setSelection(i.index+1,i.length,y.sources.SILENT)}else if(o>0){a+=e.length();const c=new S().retain(a).insert(` `);this.quill.updateContents(c,y.sources.USER),this.quill.setSelection(a,y.sources.USER)}}}},"table tab":{key:"Tab",shiftKey:null,format:["table"],handler(i,t){const{event:e,line:s}=t,n=s.offset(this.quill.scroll);e.shiftKey?this.quill.setSelection(n-1,y.sources.USER):this.quill.setSelection(n+s.length(),y.sources.USER)}},"list autofill":{key:" ",shiftKey:null,collapsed:!0,format:{"code-block":!1,blockquote:!1,table:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler(i,t){if(this.quill.scroll.query("list")==null)return!0;const{length:e}=t.prefix,[s,n]=this.quill.getLine(i.index);if(n>e)return!0;let r;switch(t.prefix.trim()){case"[]":case"[ ]":r="unchecked";break;case"[x]":r="checked";break;case"-":case"*":r="bullet";break;default:r="ordered"}this.quill.insertText(i.index," ",y.sources.USER),this.quill.history.cutoff();const o=new S().retain(i.index-n).delete(e+1).retain(s.length()-2-n).retain(1,{list:r});return this.quill.updateContents(o,y.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(i.index-e,y.sources.SILENT),!1}},"code exit":{key:"Enter",collapsed:!0,format:["code-block"],prefix:/^$/,suffix:/^\s*$/,handler(i){const[t,e]=this.quill.getLine(i.index);let s=2,n=t;for(;n!=null&&n.length()<=1&&n.formats()["code-block"];)if(n=n.prev,s-=1,s<=0){const r=new S().retain(i.index+t.length()-e-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(r,y.sources.USER),this.quill.setSelection(i.index-1,y.sources.SILENT),!1}return!0}},"embed left":en("ArrowLeft",!1),"embed left shift":en("ArrowLeft",!0),"embed right":en("ArrowRight",!1),"embed right shift":en("ArrowRight",!0),"table down":Ir(!1),"table up":Ir(!0)}};yn.DEFAULTS=Xl;function _r(i){return{key:"Tab",shiftKey:!i,format:{"code-block":!0},handler(t,e){let{event:s}=e;const n=this.quill.scroll.query("code-block"),{TAB:r}=n;if(t.length===0&&!s.shiftKey){this.quill.insertText(t.index,r,y.sources.USER),this.quill.setSelection(t.index+r.length,y.sources.SILENT);return}const o=t.length===0?this.quill.getLines(t.index,1):this.quill.getLines(t);let{index:a,length:c}=t;o.forEach((h,d)=>{i?(h.insertAt(0,r),d===0?a+=r.length:c+=r.length):h.domNode.textContent.startsWith(r)&&(h.deleteAt(0,r.length),d===0?a-=r.length:c-=r.length)}),this.quill.update(y.sources.USER),this.quill.setSelection(a,c,y.sources.SILENT)}}}function en(i,t){return{key:i,shiftKey:t,altKey:null,[i==="ArrowLeft"?"prefix":"suffix"]:/^$/,handler(s){let{index:n}=s;i==="ArrowRight"&&(n+=s.length+1);const[r]=this.quill.getLeaf(n);return r instanceof lt?(i==="ArrowLeft"?t?this.quill.setSelection(s.index-1,s.length+1,y.sources.USER):this.quill.setSelection(s.index-1,y.sources.USER):t?this.quill.setSelection(s.index,s.length+1,y.sources.USER):this.quill.setSelection(s.index+s.length+1,y.sources.USER),!1):!0}}}function xi(i){return{key:i[0],shortKey:!0,handler(t,e){this.quill.format(i,!e.format[i],y.sources.USER)}}}function Ir(i){return{key:i?"ArrowUp":"ArrowDown",collapsed:!0,format:["table"],handler(t,e){const s=i?"prev":"next",n=e.line,r=n.parent[s];if(r!=null){if(r.statics.blotName==="table-row"){let o=r.children.head,a=n;for(;a.prev!=null;)a=a.prev,o=o.next;const c=o.offset(this.quill.scroll)+Math.min(e.offset,o.length()-1);this.quill.setSelection(c,0,y.sources.USER)}}else{const o=n.table()[s];o!=null&&(i?this.quill.setSelection(o.offset(this.quill.scroll)+o.length()-1,0,y.sources.USER):this.quill.setSelection(o.offset(this.quill.scroll),0,y.sources.USER))}return!1}}}function Yl(i){if(typeof i=="string"||typeof i=="number")i={key:i};else if(typeof i=="object")i=Ie(i);else return null;return i.shortKey&&(i[Zl]=i.shortKey,delete i.shortKey),i}function sr(i){let{quill:t,range:e}=i;const s=t.getLines(e);let n={};if(s.length>1){const r=s[0].formats(),o=s[s.length-1].formats();n=ft.AttributeMap.diff(o,r)||{}}t.deleteText(e,y.sources.USER),Object.keys(n).length>0&&t.formatLine(e.index,1,n,y.sources.USER),t.setSelection(e.index,y.sources.SILENT)}function Ql(i,t,e,s){return t.prev==null&&t.next==null?e.prev==null&&e.next==null?s===0?-1:1:e.prev==null?-1:1:t.prev==null?-1:t.next==null?1:null}const Jl=/font-weight:\s*normal/,ta=["P","OL","UL"],Or=i=>i&&ta.includes(i.tagName),ea=i=>{Array.from(i.querySelectorAll("br")).filter(t=>Or(t.previousElementSibling)&&Or(t.nextElementSibling)).forEach(t=>{var e;(e=t.parentNode)==null||e.removeChild(t)})},sa=i=>{Array.from(i.querySelectorAll('b[style*="font-weight"]')).filter(t=>{var e;return(e=t.getAttribute("style"))==null?void 0:e.match(Jl)}).forEach(t=>{var s;const e=i.createDocumentFragment();e.append(...t.childNodes),(s=t.parentNode)==null||s.replaceChild(e,t)})};function na(i){i.querySelector('[id^="docs-internal-guid-"]')&&(sa(i),ea(i))}const ia=/\bmso-list:[^;]*ignore/i,ra=/\bmso-list:[^;]*\bl(\d+)/i,oa=/\bmso-list:[^;]*\blevel(\d+)/i,la=(i,t)=>{const e=i.getAttribute("style"),s=e==null?void 0:e.match(ra);if(!s)return null;const n=Number(s[1]),r=e==null?void 0:e.match(oa),o=r?Number(r[1]):1,a=new RegExp(`@list l${n}:level${o}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,"i"),c=t.match(a),h=c&&c[1]==="bullet"?"bullet":"ordered";return{id:n,indent:o,type:h,element:i}},aa=i=>{var o,a;const t=Array.from(i.querySelectorAll("[style*=mso-list]")),e=[],s=[];t.forEach(c=>{(c.getAttribute("style")||"").match(ia)?e.push(c):s.push(c)}),e.forEach(c=>{var h;return(h=c.parentNode)==null?void 0:h.removeChild(c)});const n=i.documentElement.innerHTML,r=s.map(c=>la(c,n)).filter(c=>c);for(;r.length;){const c=[];let h=r.shift();for(;h;)c.push(h),h=r.length&&((o=r[0])==null?void 0:o.element)===h.element.nextElementSibling&&r[0].id===h.id?r.shift():null;const d=document.createElement("ul");c.forEach(m=>{const b=document.createElement("li");b.setAttribute("data-list",m.type),m.indent>1&&b.setAttribute("class",`ql-indent-${m.indent-1}`),b.innerHTML=m.element.innerHTML,d.appendChild(b)});const g=(a=c[0])==null?void 0:a.element,{parentNode:p}=g??{};g&&(p==null||p.replaceChild(d,g)),c.slice(1).forEach(m=>{let{element:b}=m;p==null||p.removeChild(b)})}};function ca(i){i.documentElement.getAttribute("xmlns:w")==="urn:schemas-microsoft-com:office:word"&&aa(i)}const ua=[ca,na],ha=i=>{i.documentElement&&ua.forEach(t=>{t(i)})},da=Ut("quill:clipboard"),fa=[[Node.TEXT_NODE,La],[Node.TEXT_NODE,Mr],["br",va],[Node.ELEMENT_NODE,Mr],[Node.ELEMENT_NODE,ya],[Node.ELEMENT_NODE,ba],[Node.ELEMENT_NODE,Ta],["li",xa],["ol, ul",Aa],["pre",Ea],["tr",wa],["b",Ai("bold")],["i",Ai("italic")],["strike",Ai("strike")],["style",Na]],pa=[zl,po].reduce((i,t)=>(i[t.keyName]=t,i),{}),Rr=[ho,Ji,Qi,go,vo,No].reduce((i,t)=>(i[t.keyName]=t,i),{});var wi;let ma=(wi=class extends wt{constructor(t,e){super(t,e),this.quill.root.addEventListener("copy",s=>this.onCaptureCopy(s,!1)),this.quill.root.addEventListener("cut",s=>this.onCaptureCopy(s,!0)),this.quill.root.addEventListener("paste",this.onCapturePaste.bind(this)),this.matchers=[],fa.concat(this.options.matchers??[]).forEach(s=>{let[n,r]=s;this.addMatcher(n,r)})}addMatcher(t,e){this.matchers.push([t,e])}convert(t){let{html:e,text:s}=t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(n[J.blotName])return new S().insert(s||"",{[J.blotName]:n[J.blotName]});if(!e)return new S().insert(s||"",n);const r=this.convertHTML(e);return bs(r,` `)&&(r.ops[r.ops.length-1].attributes==null||n.table)?r.compose(new S().retain(r.length()-1).delete(1)):r}normalizeHTML(t){ha(t)}convertHTML(t){const e=new DOMParser().parseFromString(t,"text/html");this.normalizeHTML(e);const s=e.body,n=new WeakMap,[r,o]=this.prepareMatching(s,n);return nr(this.quill.scroll,s,r,o,n)}dangerouslyPasteHTML(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:y.sources.API;if(typeof t=="string"){const n=this.convert({html:t,text:""});this.quill.setContents(n,e),this.quill.setSelection(0,y.sources.SILENT)}else{const n=this.convert({html:e,text:""});this.quill.updateContents(new S().retain(t).concat(n),s),this.quill.setSelection(t+n.length(),y.sources.SILENT)}}onCaptureCopy(t){var o,a;let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(t.defaultPrevented)return;t.preventDefault();const[s]=this.quill.selection.getRange();if(s==null)return;const{html:n,text:r}=this.onCopy(s,e);(o=t.clipboardData)==null||o.setData("text/plain",r),(a=t.clipboardData)==null||a.setData("text/html",n),e&&sr({range:s,quill:this.quill})}normalizeURIList(t){return t.split(/\r?\n/).filter(e=>e[0]!=="#").join(` `)}onCapturePaste(t){var o,a,c,h,d;if(t.defaultPrevented||!this.quill.isEnabled())return;t.preventDefault();const e=this.quill.getSelection(!0);if(e==null)return;const s=(o=t.clipboardData)==null?void 0:o.getData("text/html");let n=(a=t.clipboardData)==null?void 0:a.getData("text/plain");if(!s&&!n){const g=(c=t.clipboardData)==null?void 0:c.getData("text/uri-list");g&&(n=this.normalizeURIList(g))}const r=Array.from(((h=t.clipboardData)==null?void 0:h.files)||[]);if(!s&&r.length>0){this.quill.uploader.upload(e,r);return}if(s&&r.length>0){const g=new DOMParser().parseFromString(s,"text/html");if(g.body.childElementCount===1&&((d=g.body.firstElementChild)==null?void 0:d.tagName)==="IMG"){this.quill.uploader.upload(e,r);return}}this.onPaste(e,{html:s,text:n})}onCopy(t){const e=this.quill.getText(t);return{html:this.quill.getSemanticHTML(t),text:e}}onPaste(t,e){let{text:s,html:n}=e;const r=this.quill.getFormat(t.index),o=this.convert({text:s,html:n},r);da.log("onPaste",o,{text:s,html:n});const a=new S().retain(t.index).delete(t.length).concat(o);this.quill.updateContents(a,y.sources.USER),this.quill.setSelection(a.length()-t.length,y.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(t,e){const s=[],n=[];return this.matchers.forEach(r=>{const[o,a]=r;switch(o){case Node.TEXT_NODE:n.push(a);break;case Node.ELEMENT_NODE:s.push(a);break;default:Array.from(t.querySelectorAll(o)).forEach(c=>{if(e.has(c)){const h=e.get(c);h==null||h.push(a)}else e.set(c,[a])});break}}),[s,n]}},w(wi,"DEFAULTS",{matchers:[]}),wi);function he(i,t,e,s){return s.query(t)?i.reduce((n,r)=>{if(!r.insert)return n;if(r.attributes&&r.attributes[t])return n.push(r);const o=e?{[t]:e}:{};return n.insert(r.insert,{...o,...r.attributes})},new S):i}function bs(i,t){let e="";for(let s=i.ops.length-1;s>=0&&e.lengtho(t,r,i),new S):t.nodeType===t.ELEMENT_NODE?Array.from(t.childNodes||[]).reduce((r,o)=>{let a=nr(i,o,e,s,n);return o.nodeType===t.ELEMENT_NODE&&(a=e.reduce((c,h)=>h(o,c,i),a),a=(n.get(o)||[]).reduce((c,h)=>h(o,c,i),a)),r.concat(a)},new S):new S}function Ai(i){return(t,e,s)=>he(e,i,!0,s)}function ba(i,t,e){const s=_t.keys(i),n=At.keys(i),r=Yt.keys(i),o={};return s.concat(n).concat(r).forEach(a=>{let c=e.query(a,q.ATTRIBUTE);c!=null&&(o[c.attrName]=c.value(i),o[c.attrName])||(c=pa[a],c!=null&&(c.attrName===a||c.keyName===a)&&(o[c.attrName]=c.value(i)||void 0),c=Rr[a],c!=null&&(c.attrName===a||c.keyName===a)&&(c=Rr[a],o[c.attrName]=c.value(i)||void 0))}),Object.entries(o).reduce((a,c)=>{let[h,d]=c;return he(a,h,d,e)},t)}function ya(i,t,e){const s=e.query(i);if(s==null)return t;if(s.prototype instanceof lt){const n={},r=s.value(i);if(r!=null)return n[s.blotName]=r,new S().insert(n,s.formats(i,e))}else if(s.prototype instanceof ds&&!bs(t,` `)&&t.insert(` `),"blotName"in s&&"formats"in s&&typeof s.formats=="function")return he(t,s.blotName,s.formats(i,e),e);return t}function va(i,t){return bs(t,` `)||t.insert(` `),t}function Ea(i,t,e){const s=e.query("code-block"),n=s&&"formats"in s&&typeof s.formats=="function"?s.formats(i,e):!0;return he(t,"code-block",n,e)}function Na(){return new S}function xa(i,t,e){const s=e.query(i);if(s==null||s.blotName!=="list"||!bs(t,` `))return t;let n=-1,r=i.parentNode;for(;r!=null;)["OL","UL"].includes(r.tagName)&&(n+=1),r=r.parentNode;return n<=0?t:t.reduce((o,a)=>a.insert?a.attributes&&typeof a.attributes.indent=="number"?o.push(a):o.insert(a.insert,{indent:n,...a.attributes||{}}):o,new S)}function Aa(i,t,e){const s=i;let n=s.tagName==="OL"?"ordered":"bullet";const r=s.getAttribute("data-checked");return r&&(n=r==="true"?"checked":"unchecked"),he(t,"list",n,e)}function Mr(i,t,e){if(!bs(t,` `)){if(Wt(i,e)&&(i.childNodes.length>0||i instanceof HTMLParagraphElement))return t.insert(` `);if(t.length()>0&&i.nextSibling){let s=i.nextSibling;for(;s!=null;){if(Wt(s,e))return t.insert(` `);const n=e.query(s);if(n&&n.prototype instanceof dt)return t.insert(` `);s=s.firstChild}}}return t}function Ta(i,t,e){var r;const s={},n=i.style||{};return n.fontStyle==="italic"&&(s.italic=!0),n.textDecoration==="underline"&&(s.underline=!0),n.textDecoration==="line-through"&&(s.strike=!0),((r=n.fontWeight)!=null&&r.startsWith("bold")||parseInt(n.fontWeight,10)>=700)&&(s.bold=!0),t=Object.entries(s).reduce((o,a)=>{let[c,h]=a;return he(o,c,h,e)},t),parseFloat(n.textIndent||0)>0?new S().insert(" ").concat(t):t}function wa(i,t,e){var n,r;const s=((n=i.parentElement)==null?void 0:n.tagName)==="TABLE"?i.parentElement:(r=i.parentElement)==null?void 0:r.parentElement;if(s!=null){const a=Array.from(s.querySelectorAll("tr")).indexOf(i)+1;return he(t,"table",a,e)}return t}function La(i,t,e){var n;let s=i.data;if(((n=i.parentElement)==null?void 0:n.tagName)==="O:P")return t.insert(s.trim());if(!xo(i)){if(s.trim().length===0&&s.includes(` `)&&!ga(i,e))return t;const r=(o,a)=>{const c=a.replace(/[^\u00a0]/g,"");return c.length<1&&o?" ":c};s=s.replace(/\r\n/g," ").replace(/\n/g," "),s=s.replace(/\s\s+/g,r.bind(r,!0)),(i.previousSibling==null&&i.parentElement!=null&&Wt(i.parentElement,e)||i.previousSibling instanceof Element&&Wt(i.previousSibling,e))&&(s=s.replace(/^\s+/,r.bind(r,!1))),(i.nextSibling==null&&i.parentElement!=null&&Wt(i.parentElement,e)||i.nextSibling instanceof Element&&Wt(i.nextSibling,e))&&(s=s.replace(/\s+$/,r.bind(r,!1)))}return t.insert(s)}class Ao extends wt{constructor(e,s){super(e,s);w(this,"lastRecorded",0);w(this,"ignoreChange",!1);w(this,"stack",{undo:[],redo:[]});w(this,"currentRange",null);this.quill.on(y.events.EDITOR_CHANGE,(n,r,o,a)=>{n===y.events.SELECTION_CHANGE?r&&a!==y.sources.SILENT&&(this.currentRange=r):n===y.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||a===y.sources.USER?this.record(r,o):this.transform(r)),this.currentRange=Bi(this.currentRange,r))}),this.quill.keyboard.addBinding({key:"z",shortKey:!0},this.undo.bind(this)),this.quill.keyboard.addBinding({key:["z","Z"],shortKey:!0,shiftKey:!0},this.redo.bind(this)),/Win/i.test(navigator.platform)&&this.quill.keyboard.addBinding({key:"y",shortKey:!0},this.redo.bind(this)),this.quill.root.addEventListener("beforeinput",n=>{n.inputType==="historyUndo"?(this.undo(),n.preventDefault()):n.inputType==="historyRedo"&&(this.redo(),n.preventDefault())})}change(e,s){if(this.stack[e].length===0)return;const n=this.stack[e].pop();if(!n)return;const r=this.quill.getContents(),o=n.delta.invert(r);this.stack[s].push({delta:o,range:Bi(n.range,o)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(n.delta,y.sources.USER),this.ignoreChange=!1,this.restoreSelection(n)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(e,s){if(e.ops.length===0)return;this.stack.redo=[];let n=e.invert(s),r=this.currentRange;const o=Date.now();if(this.lastRecorded+this.options.delay>o&&this.stack.undo.length>0){const a=this.stack.undo.pop();a&&(n=n.compose(a.delta),r=a.range)}else this.lastRecorded=o;n.length()!==0&&(this.stack.undo.push({delta:n,range:r}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change("redo","undo")}transform(e){Br(this.stack.undo,e),Br(this.stack.redo,e)}undo(){this.change("undo","redo")}restoreSelection(e){if(e.range)this.quill.setSelection(e.range,y.sources.USER);else{const s=Sa(this.quill.scroll,e.delta);this.quill.setSelection(s,y.sources.USER)}}}w(Ao,"DEFAULTS",{delay:1e3,maxStack:100,userOnly:!1});function Br(i,t){let e=t;for(let s=i.length-1;s>=0;s-=1){const n=i[s];i[s]={delta:e.transform(n.delta,!0),range:n.range&&Bi(n.range,e)},e=n.delta.transform(e),i[s].delta.length()===0&&i.splice(s,1)}}function Ca(i,t){const e=t.ops[t.ops.length-1];return e==null?!1:e.insert!=null?typeof e.insert=="string"&&e.insert.endsWith(` `):e.attributes!=null?Object.keys(e.attributes).some(s=>i.query(s,q.BLOCK)!=null):!1}function Sa(i,t){const e=t.reduce((n,r)=>n+(r.delete||0),0);let s=t.length()-e;return Ca(i,t)&&(s-=1),s}function Bi(i,t){if(!i)return i;const e=t.transformPosition(i.index),s=t.transformPosition(i.index+i.length);return{index:e,length:s-e}}class To extends wt{constructor(t,e){super(t,e),t.root.addEventListener("drop",s=>{var o;s.preventDefault();let n=null;if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(s.clientX,s.clientY);else if(document.caretPositionFromPoint){const a=document.caretPositionFromPoint(s.clientX,s.clientY);n=document.createRange(),n.setStart(a.offsetNode,a.offset),n.setEnd(a.offsetNode,a.offset)}const r=n&&t.selection.normalizeNative(n);if(r){const a=t.selection.normalizedToRange(r);(o=s.dataTransfer)!=null&&o.files&&this.upload(a,s.dataTransfer.files)}})}upload(t,e){const s=[];Array.from(e).forEach(n=>{var r;n&&((r=this.options.mimetypes)!=null&&r.includes(n.type))&&s.push(n)}),s.length>0&&this.options.handler.call(this,t,s)}}To.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(i,t){if(!this.quill.scroll.query("image"))return;const e=t.map(s=>new Promise(n=>{const r=new FileReader;r.onload=()=>{n(r.result)},r.readAsDataURL(s)}));Promise.all(e).then(s=>{const n=s.reduce((r,o)=>r.insert({image:o}),new S().retain(i.index).delete(i.length));this.quill.updateContents(n,L.sources.USER),this.quill.setSelection(i.index+s.length,L.sources.SILENT)})}};const qa=["insertText","insertReplacementText"];class ka extends wt{constructor(t,e){super(t,e),t.root.addEventListener("beforeinput",s=>{this.handleBeforeInput(s)}),/Android/i.test(navigator.userAgent)||t.on(y.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(t){sr({range:t,quill:this.quill})}replaceText(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(t.length===0)return!1;if(e){const s=this.quill.getFormat(t.index,1);this.deleteRange(t),this.quill.updateContents(new S().retain(t.index).insert(e,s),y.sources.USER)}else this.deleteRange(t);return this.quill.setSelection(t.index+e.length,0,y.sources.SILENT),!0}handleBeforeInput(t){if(this.quill.composition.isComposing||t.defaultPrevented||!qa.includes(t.inputType))return;const e=t.getTargetRanges?t.getTargetRanges()[0]:null;if(!e||e.collapsed===!0)return;const s=_a(t);if(s==null)return;const n=this.quill.selection.normalizeNative(e),r=n?this.quill.selection.normalizedToRange(n):null;r&&this.replaceText(r,s)&&t.preventDefault()}handleCompositionStart(){const t=this.quill.getSelection();t&&this.replaceText(t)}}function _a(i){var t;return typeof i.data=="string"?i.data:(t=i.dataTransfer)!=null&&t.types.includes("text/plain")?i.dataTransfer.getData("text/plain"):null}const Ia=/Mac/i.test(navigator.platform),Oa=100,Ra=i=>!!(i.key==="ArrowLeft"||i.key==="ArrowRight"||i.key==="ArrowUp"||i.key==="ArrowDown"||i.key==="Home"||Ia&&i.key==="a"&&i.ctrlKey===!0);class Ma extends wt{constructor(e,s){super(e,s);w(this,"isListening",!1);w(this,"selectionChangeDeadline",0);this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:["ArrowLeft","ArrowRight"],offset:0,shiftKey:null,handler(e,s){let{line:n,event:r}=s;if(!(n instanceof Nt)||!n.uiNode)return!0;const o=getComputedStyle(n.domNode).direction==="rtl";return o&&r.key!=="ArrowRight"||!o&&r.key!=="ArrowLeft"?!0:(this.quill.setSelection(e.index-1,e.length+(r.shiftKey?1:0),y.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",e=>{!e.defaultPrevented&&Ra(e)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){if(this.selectionChangeDeadline=Date.now()+Oa,this.isListening)return;this.isListening=!0;const e=()=>{this.isListening=!1,Date.now()<=this.selectionChangeDeadline&&this.handleSelectionChange()};document.addEventListener("selectionchange",e,{once:!0})}handleSelectionChange(){const e=document.getSelection();if(!e)return;const s=e.getRangeAt(0);if(s.collapsed!==!0||s.startOffset!==0)return;const n=this.quill.scroll.find(s.startContainer);if(!(n instanceof Nt)||!n.uiNode)return;const r=document.createRange();r.setStartAfter(n.uiNode),r.setEndAfter(n.uiNode),e.removeAllRanges(),e.addRange(r)}}y.register({"blots/block":G,"blots/block/embed":dt,"blots/break":Tt,"blots/container":ce,"blots/cursor":Be,"blots/embed":Xi,"blots/inline":Qt,"blots/scroll":_e,"blots/text":xt,"modules/clipboard":ma,"modules/history":Ao,"modules/keyboard":yn,"modules/uploader":To,"modules/input":ka,"modules/uiNode":Ma});class Ba extends At{add(t,e){let s=0;if(e==="+1"||e==="-1"){const n=this.value(t)||0;s=e==="+1"?n+1:n-1}else typeof e=="number"&&(s=e);return s===0?(this.remove(t),!0):super.add(t,s.toString())}canAdd(t,e){return super.canAdd(t,e)||super.canAdd(t,parseInt(e,10))}value(t){return parseInt(super.value(t),10)||void 0}}const Da=new Ba("indent","ql-indent",{scope:q.BLOCK,whitelist:[1,2,3,4,5,6,7,8]});class Di extends G{}w(Di,"blotName","blockquote"),w(Di,"tagName","blockquote");class Pi extends G{static formats(t){return this.tagName.indexOf(t.tagName)+1}}w(Pi,"blotName","header"),w(Pi,"tagName",["H1","H2","H3","H4","H5","H6"]);class ys extends ce{}ys.blotName="list-container";ys.tagName="OL";class vs extends G{static create(t){const e=super.create();return e.setAttribute("data-list",t),e}static formats(t){return t.getAttribute("data-list")||void 0}static register(){y.register(ys)}constructor(t,e){super(t,e);const s=e.ownerDocument.createElement("span"),n=r=>{if(!t.isEnabled())return;const o=this.statics.formats(e,t);o==="checked"?(this.format("list","unchecked"),r.preventDefault()):o==="unchecked"&&(this.format("list","checked"),r.preventDefault())};s.addEventListener("mousedown",n),s.addEventListener("touchstart",n),this.attachUI(s)}format(t,e){t===this.statics.blotName&&e?this.domNode.setAttribute("data-list",e):super.format(t,e)}}vs.blotName="list";vs.tagName="LI";ys.allowedChildren=[vs];vs.requiredContainer=ys;class ms extends Qt{static create(){return super.create()}static formats(){return!0}optimize(t){super.optimize(t),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}}w(ms,"blotName","bold"),w(ms,"tagName",["STRONG","B"]);var nn;let Pa=(nn=class extends ms{},w(nn,"blotName","italic"),w(nn,"tagName",["EM","I"]),nn);var we;let un=(we=class extends Qt{static create(t){const e=super.create(t);return e.setAttribute("href",this.sanitize(t)),e.setAttribute("rel","noopener noreferrer"),e.setAttribute("target","_blank"),e}static formats(t){return t.getAttribute("href")}static sanitize(t){return wo(t,this.PROTOCOL_WHITELIST)?t:this.SANITIZED_URL}format(t,e){t!==this.statics.blotName||!e?super.format(t,e):this.domNode.setAttribute("href",this.constructor.sanitize(e))}},w(we,"blotName","link"),w(we,"tagName","A"),w(we,"SANITIZED_URL","about:blank"),w(we,"PROTOCOL_WHITELIST",["http","https","mailto","tel","sms"]),we);function wo(i,t){const e=document.createElement("a");e.href=i;const s=e.href.slice(0,e.href.indexOf(":"));return t.indexOf(s)>-1}class $i extends Qt{static create(t){return t==="super"?document.createElement("sup"):t==="sub"?document.createElement("sub"):super.create(t)}static formats(t){if(t.tagName==="SUB")return"sub";if(t.tagName==="SUP")return"super"}}w($i,"blotName","script"),w($i,"tagName",["SUB","SUP"]);class Ui extends ms{}w(Ui,"blotName","strike"),w(Ui,"tagName",["S","STRIKE"]);class Hi extends Qt{}w(Hi,"blotName","underline"),w(Hi,"tagName","U");class rn extends Xi{static create(t){if(window.katex==null)throw new Error("Formula module requires KaTeX.");const e=super.create(t);return typeof t=="string"&&(window.katex.render(t,e,{throwOnError:!1,errorColor:"#f00"}),e.setAttribute("data-value",t)),e}static value(t){return t.getAttribute("data-value")}html(){const{formula:t}=this.value();return`${t}`}}w(rn,"blotName","formula"),w(rn,"className","ql-formula"),w(rn,"tagName","SPAN");const Dr=["alt","height","width"];class ji extends lt{static create(t){const e=super.create(t);return typeof t=="string"&&e.setAttribute("src",this.sanitize(t)),e}static formats(t){return Dr.reduce((e,s)=>(t.hasAttribute(s)&&(e[s]=t.getAttribute(s)),e),{})}static match(t){return/\.(jpe?g|gif|png)$/.test(t)||/^data:image\/.+;base64/.test(t)}static sanitize(t){return wo(t,["http","https","data"])?t:"//:0"}static value(t){return t.getAttribute("src")}format(t,e){Dr.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}}w(ji,"blotName","image"),w(ji,"tagName","IMG");const Pr=["height","width"];class on extends dt{static create(t){const e=super.create(t);return e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("src",this.sanitize(t)),e}static formats(t){return Pr.reduce((e,s)=>(t.hasAttribute(s)&&(e[s]=t.getAttribute(s)),e),{})}static sanitize(t){return un.sanitize(t)}static value(t){return t.getAttribute("src")}format(t,e){Pr.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}html(){const{video:t}=this.value();return`${t}`}}w(on,"blotName","video"),w(on,"className","ql-video"),w(on,"tagName","IFRAME");const as=new At("code-token","hljs",{scope:q.INLINE});class Pt extends Qt{static formats(t,e){for(;t!=null&&t!==e.domNode;){if(t.classList&&t.classList.contains(J.className))return super.formats(t,e);t=t.parentNode}}constructor(t,e,s){super(t,e,s),as.add(this.domNode,s)}format(t,e){t!==Pt.blotName?super.format(t,e):e?as.add(this.domNode,e):(as.remove(this.domNode),this.domNode.classList.remove(this.statics.className))}optimize(){super.optimize(...arguments),as.value(this.domNode)||this.unwrap()}}Pt.blotName="code-token";Pt.className="ql-token";class ht extends J{static create(t){const e=super.create(t);return typeof t=="string"&&e.setAttribute("data-language",t),e}static formats(t){return t.getAttribute("data-language")||"plain"}static register(){}format(t,e){t===this.statics.blotName&&e?this.domNode.setAttribute("data-language",e):super.format(t,e)}replaceWith(t,e){return this.formatAt(0,this.length(),Pt.blotName,!1),super.replaceWith(t,e)}}class cs extends ue{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(t,e){t===ht.blotName&&(this.forceNext=!0,this.children.forEach(s=>{s.format(t,e)}))}formatAt(t,e,s,n){s===ht.blotName&&(this.forceNext=!0),super.formatAt(t,e,s,n)}highlight(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.children.head==null)return;const n=`${Array.from(this.domNode.childNodes).filter(o=>o!==this.uiNode).map(o=>o.textContent).join(` `)} `,r=ht.formats(this.children.head.domNode);if(e||this.forceNext||this.cachedText!==n){if(n.trim().length>0||this.cachedText==null){const o=this.children.reduce((c,h)=>c.concat(lo(h,!1)),new S),a=t(n,r);o.diff(a).reduce((c,h)=>{let{retain:d,attributes:g}=h;return d?(g&&Object.keys(g).forEach(p=>{[ht.blotName,Pt.blotName].includes(p)&&this.formatAt(c,d,p,g[p])}),c+d):c},0)}this.cachedText=n,this.forceNext=!1}}html(t,e){const[s]=this.children.find(t);return`
    ${bn(this.code(t,e))}
    
    `}optimize(t){if(super.optimize(t),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){const e=ht.formats(this.children.head.domNode);e!==this.uiNode.value&&(this.uiNode.value=e)}}}cs.allowedChildren=[ht];ht.requiredContainer=cs;ht.allowedChildren=[Pt,Be,xt,Tt];const $a=(i,t,e)=>{if(typeof i.versionString=="string"){const s=i.versionString.split(".")[0];if(parseInt(s,10)>=11)return i.highlight(e,{language:t}).value}return i.highlight(t,e).value};class Lo extends wt{static register(){y.register(Pt,!0),y.register(ht,!0),y.register(cs,!0)}constructor(t,e){if(super(t,e),this.options.hljs==null)throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");this.languages=this.options.languages.reduce((s,n)=>{let{key:r}=n;return s[r]=!0,s},{}),this.highlightBlot=this.highlightBlot.bind(this),this.initListener(),this.initTimer()}initListener(){this.quill.on(y.events.SCROLL_BLOT_MOUNT,t=>{if(!(t instanceof cs))return;const e=this.quill.root.ownerDocument.createElement("select");this.options.languages.forEach(s=>{let{key:n,label:r}=s;const o=e.ownerDocument.createElement("option");o.textContent=r,o.setAttribute("value",n),e.appendChild(o)}),e.addEventListener("change",()=>{t.format(ht.blotName,e.value),this.quill.root.focus(),this.highlight(t,!0)}),t.uiNode==null&&(t.attachUI(e),t.children.head&&(e.value=ht.formats(t.children.head.domNode)))})}initTimer(){let t=null;this.quill.on(y.events.SCROLL_OPTIMIZE,()=>{t&&clearTimeout(t),t=setTimeout(()=>{this.highlight(),t=null},this.options.interval)})}highlight(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.quill.selection.composing)return;this.quill.update(y.sources.USER);const s=this.quill.getSelection();(t==null?this.quill.scroll.descendants(cs):[t]).forEach(r=>{r.highlight(this.highlightBlot,e)}),this.quill.update(y.sources.SILENT),s!=null&&this.quill.setSelection(s,y.sources.SILENT)}highlightBlot(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"plain";if(e=this.languages[e]?e:"plain",e==="plain")return bn(t).split(` `).reduce((n,r,o)=>(o!==0&&n.insert(` `,{[J.blotName]:e}),n.insert(r)),new S);const s=this.quill.root.ownerDocument.createElement("div");return s.classList.add(J.className),s.innerHTML=$a(this.options.hljs,e,t),nr(this.quill.scroll,s,[(n,r)=>{const o=as.value(n);return o?r.compose(new S().retain(r.length(),{[Pt.blotName]:o})):r}],[(n,r)=>n.data.split(` `).reduce((o,a,c)=>(c!==0&&o.insert(` `,{[J.blotName]:e}),o.insert(a)),r)],new WeakMap)}}Lo.DEFAULTS={hljs:window.hljs,interval:1e3,languages:[{key:"plain",label:"Plain"},{key:"bash",label:"Bash"},{key:"cpp",label:"C++"},{key:"cs",label:"C#"},{key:"css",label:"CSS"},{key:"diff",label:"Diff"},{key:"xml",label:"HTML/XML"},{key:"java",label:"Java"},{key:"javascript",label:"JavaScript"},{key:"markdown",label:"Markdown"},{key:"php",label:"PHP"},{key:"python",label:"Python"},{key:"ruby",label:"Ruby"},{key:"sql",label:"SQL"}]};const hs=class hs extends G{static create(t){const e=super.create();return t?e.setAttribute("data-row",t):e.setAttribute("data-row",ir()),e}static formats(t){if(t.hasAttribute("data-row"))return t.getAttribute("data-row")}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}format(t,e){t===hs.blotName&&e?this.domNode.setAttribute("data-row",e):super.format(t,e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}};w(hs,"blotName","table"),w(hs,"tagName","TD");let Et=hs;class $t extends ce{checkMerge(){if(super.checkMerge()&&this.next.children.head!=null){const t=this.children.head.formats(),e=this.children.tail.formats(),s=this.next.children.head.formats(),n=this.next.children.tail.formats();return t.table===e.table&&t.table===s.table&&t.table===n.table}return!1}optimize(t){super.optimize(t),this.children.forEach(e=>{if(e.next==null)return;const s=e.formats(),n=e.next.formats();if(s.table!==n.table){const r=this.splitAfter(e);r&&r.optimize(),this.prev&&this.prev.optimize()}})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}w($t,"blotName","table-row"),w($t,"tagName","TR");class kt extends ce{}w(kt,"blotName","table-body"),w(kt,"tagName","TBODY");class Pe extends ce{balanceCells(){const t=this.descendants($t),e=t.reduce((s,n)=>Math.max(n.children.length,s),0);t.forEach(s=>{new Array(e-s.children.length).fill(0).forEach(()=>{let n;s.children.head!=null&&(n=Et.formats(s.children.head.domNode));const r=this.scroll.create(Et.blotName,n);s.appendChild(r),r.optimize()})})}cells(t){return this.rows().map(e=>e.children.at(t))}deleteColumn(t){const[e]=this.descendant(kt);e==null||e.children.head==null||e.children.forEach(s=>{const n=s.children.at(t);n!=null&&n.remove()})}insertColumn(t){const[e]=this.descendant(kt);e==null||e.children.head==null||e.children.forEach(s=>{const n=s.children.at(t),r=Et.formats(s.children.head.domNode),o=this.scroll.create(Et.blotName,r);s.insertBefore(o,n)})}insertRow(t){const[e]=this.descendant(kt);if(e==null||e.children.head==null)return;const s=ir(),n=this.scroll.create($t.blotName);e.children.head.children.forEach(()=>{const o=this.scroll.create(Et.blotName,s);n.appendChild(o)});const r=e.children.at(t);e.insertBefore(n,r)}rows(){const t=this.children.head;return t==null?[]:t.children.map(e=>e)}}w(Pe,"blotName","table-container"),w(Pe,"tagName","TABLE");Pe.allowedChildren=[kt];kt.requiredContainer=Pe;kt.allowedChildren=[$t];$t.requiredContainer=kt;$t.allowedChildren=[Et];Et.requiredContainer=$t;function ir(){return`row-${Math.random().toString(36).slice(2,6)}`}class Ua extends wt{static register(){y.register(Et),y.register($t),y.register(kt),y.register(Pe)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants(Pe).forEach(t=>{t.balanceCells()})}deleteColumn(){const[t,,e]=this.getTable();e!=null&&(t.deleteColumn(e.cellOffset()),this.quill.update(y.sources.USER))}deleteRow(){const[,t]=this.getTable();t!=null&&(t.remove(),this.quill.update(y.sources.USER))}deleteTable(){const[t]=this.getTable();if(t==null)return;const e=t.offset();t.remove(),this.quill.update(y.sources.USER),this.quill.setSelection(e,y.sources.SILENT)}getTable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.quill.getSelection();if(t==null)return[null,null,null,-1];const[e,s]=this.quill.getLine(t.index);if(e==null||e.statics.blotName!==Et.blotName)return[null,null,null,-1];const n=e.parent;return[n.parent.parent,n,e,s]}insertColumn(t){const e=this.quill.getSelection();if(!e)return;const[s,n,r]=this.getTable(e);if(r==null)return;const o=r.cellOffset();s.insertColumn(o+t),this.quill.update(y.sources.USER);let a=n.rowOffset();t===0&&(a+=1),this.quill.setSelection(e.index+a,e.length,y.sources.SILENT)}insertColumnLeft(){this.insertColumn(0)}insertColumnRight(){this.insertColumn(1)}insertRow(t){const e=this.quill.getSelection();if(!e)return;const[s,n,r]=this.getTable(e);if(r==null)return;const o=n.rowOffset();s.insertRow(o+t),this.quill.update(y.sources.USER),t>0?this.quill.setSelection(e,y.sources.SILENT):this.quill.setSelection(e.index+n.children.length,e.length,y.sources.SILENT)}insertRowAbove(){this.insertRow(0)}insertRowBelow(){this.insertRow(1)}insertTable(t,e){const s=this.quill.getSelection();if(s==null)return;const n=new Array(t).fill(0).reduce(r=>{const o=new Array(e).fill(` `).join("");return r.insert(o,{table:ir()})},new S().retain(s.index));this.quill.updateContents(n,y.sources.USER),this.quill.setSelection(s.index,y.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(y.events.SCROLL_OPTIMIZE,t=>{t.some(e=>["TD","TR","TBODY","TABLE"].includes(e.target.tagName)?(this.quill.once(y.events.TEXT_CHANGE,(s,n,r)=>{r===y.sources.USER&&this.balanceTables()}),!0):!1)})}}const $r=Ut("quill:toolbar");let rr=class extends wt{constructor(t,e){var s,n;if(super(t,e),Array.isArray(this.options.container)){const r=document.createElement("div");r.setAttribute("role","toolbar"),Ha(r,this.options.container),(n=(s=t.container)==null?void 0:s.parentNode)==null||n.insertBefore(r,t.container),this.container=r}else typeof this.options.container=="string"?this.container=document.querySelector(this.options.container):this.container=this.options.container;if(!(this.container instanceof HTMLElement)){$r.error("Container required for toolbar",this.options);return}this.container.classList.add("ql-toolbar"),this.controls=[],this.handlers={},this.options.handlers&&Object.keys(this.options.handlers).forEach(r=>{var a;const o=(a=this.options.handlers)==null?void 0:a[r];o&&this.addHandler(r,o)}),Array.from(this.container.querySelectorAll("button, select")).forEach(r=>{this.attach(r)}),this.quill.on(y.events.EDITOR_CHANGE,()=>{const[r]=this.quill.selection.getRange();this.update(r)})}addHandler(t,e){this.handlers[t]=e}attach(t){let e=Array.from(t.classList).find(n=>n.indexOf("ql-")===0);if(!e)return;if(e=e.slice(3),t.tagName==="BUTTON"&&t.setAttribute("type","button"),this.handlers[e]==null&&this.quill.scroll.query(e)==null){$r.warn("ignoring attaching to nonexistent format",e,t);return}const s=t.tagName==="SELECT"?"change":"click";t.addEventListener(s,n=>{let r;if(t.tagName==="SELECT"){if(t.selectedIndex<0)return;const a=t.options[t.selectedIndex];a.hasAttribute("selected")?r=!1:r=a.value||!1}else t.classList.contains("ql-active")?r=!1:r=t.value||!t.hasAttribute("value"),n.preventDefault();this.quill.focus();const[o]=this.quill.selection.getRange();if(this.handlers[e]!=null)this.handlers[e].call(this,r);else if(this.quill.scroll.query(e).prototype instanceof lt){if(r=prompt(`Enter ${e}`),!r)return;this.quill.updateContents(new S().retain(o.index).delete(o.length).insert({[e]:r}),y.sources.USER)}else this.quill.format(e,r,y.sources.USER);this.update(o)}),this.controls.push([e,t])}update(t){const e=t==null?{}:this.quill.getFormat(t);this.controls.forEach(s=>{const[n,r]=s;if(r.tagName==="SELECT"){let o=null;if(t==null)o=null;else if(e[n]==null)o=r.querySelector("option[selected]");else if(!Array.isArray(e[n])){let a=e[n];typeof a=="string"&&(a=a.replace(/"/g,'\\"')),o=r.querySelector(`option[value="${a}"]`)}o==null?(r.value="",r.selectedIndex=-1):o.selected=!0}else if(t==null)r.classList.remove("ql-active"),r.setAttribute("aria-pressed","false");else if(r.hasAttribute("value")){const o=e[n],a=o===r.getAttribute("value")||o!=null&&o.toString()===r.getAttribute("value")||o==null&&!r.getAttribute("value");r.classList.toggle("ql-active",a),r.setAttribute("aria-pressed",a.toString())}else{const o=e[n]!=null;r.classList.toggle("ql-active",o),r.setAttribute("aria-pressed",o.toString())}})}};rr.DEFAULTS={};function Ur(i,t,e){const s=document.createElement("button");s.setAttribute("type","button"),s.classList.add(`ql-${t}`),s.setAttribute("aria-pressed","false"),e!=null?(s.value=e,s.setAttribute("aria-label",`${t}: ${e}`)):s.setAttribute("aria-label",t),i.appendChild(s)}function Ha(i,t){Array.isArray(t[0])||(t=[t]),t.forEach(e=>{const s=document.createElement("span");s.classList.add("ql-formats"),e.forEach(n=>{if(typeof n=="string")Ur(s,n);else{const r=Object.keys(n)[0],o=n[r];Array.isArray(o)?ja(s,r,o):Ur(s,r,o)}}),i.appendChild(s)})}function ja(i,t,e){const s=document.createElement("select");s.classList.add(`ql-${t}`),e.forEach(n=>{const r=document.createElement("option");n!==!1?r.setAttribute("value",String(n)):r.setAttribute("selected","selected"),s.appendChild(r)}),i.appendChild(s)}rr.DEFAULTS={container:null,handlers:{clean(){const i=this.quill.getSelection();if(i!=null)if(i.length===0){const t=this.quill.getFormat();Object.keys(t).forEach(e=>{this.quill.scroll.query(e,q.INLINE)!=null&&this.quill.format(e,!1,y.sources.USER)})}else this.quill.removeFormat(i.index,i.length,y.sources.USER)},direction(i){const{align:t}=this.quill.getFormat();i==="rtl"&&t==null?this.quill.format("align","right",y.sources.USER):!i&&t==="right"&&this.quill.format("align",!1,y.sources.USER),this.quill.format("direction",i,y.sources.USER)},indent(i){const t=this.quill.getSelection(),e=this.quill.getFormat(t),s=parseInt(e.indent||0,10);if(i==="+1"||i==="-1"){let n=i==="+1"?1:-1;e.direction==="rtl"&&(n*=-1),this.quill.format("indent",s+n,y.sources.USER)}},link(i){i===!0&&(i=prompt("Enter link URL:")),this.quill.format("link",i,y.sources.USER)},list(i){const t=this.quill.getSelection(),e=this.quill.getFormat(t);i==="check"?e.list==="checked"||e.list==="unchecked"?this.quill.format("list",!1,y.sources.USER):this.quill.format("list","unchecked",y.sources.USER):this.quill.format("list",i,y.sources.USER)}}};const Fa='',za='',Va='',Ka='',Ga='',Wa='',Za='',Xa='',Hr='',Ya='',Qa='',Ja='',tc='',ec='',sc='',nc='',ic='',rc='',oc='',lc='',ac='',cc='',uc='',hc='',dc='',fc='',pc='',mc='',gc='',bc='',yc='',vc='',Ec='',gs={align:{"":Fa,center:za,right:Va,justify:Ka},background:Ga,blockquote:Wa,bold:Za,clean:Xa,code:Hr,"code-block":Hr,color:Ya,direction:{"":Qa,rtl:Ja},formula:tc,header:{1:ec,2:sc,3:nc,4:ic,5:rc,6:oc},italic:lc,image:ac,indent:{"+1":cc,"-1":uc},link:hc,list:{bullet:dc,check:fc,ordered:pc},script:{sub:mc,super:gc},strike:bc,table:yc,underline:vc,video:Ec},Nc='';let jr=0;function Fr(i,t){i.setAttribute(t,`${i.getAttribute(t)!=="true"}`)}class vn{constructor(t){this.select=t,this.container=document.createElement("span"),this.buildPicker(),this.select.style.display="none",this.select.parentNode.insertBefore(this.container,this.select),this.label.addEventListener("mousedown",()=>{this.togglePicker()}),this.label.addEventListener("keydown",e=>{switch(e.key){case"Enter":this.togglePicker();break;case"Escape":this.escape(),e.preventDefault();break}}),this.select.addEventListener("change",this.update.bind(this))}togglePicker(){this.container.classList.toggle("ql-expanded"),Fr(this.label,"aria-expanded"),Fr(this.options,"aria-hidden")}buildItem(t){const e=document.createElement("span");e.tabIndex="0",e.setAttribute("role","button"),e.classList.add("ql-picker-item");const s=t.getAttribute("value");return s&&e.setAttribute("data-value",s),t.textContent&&e.setAttribute("data-label",t.textContent),e.addEventListener("click",()=>{this.selectItem(e,!0)}),e.addEventListener("keydown",n=>{switch(n.key){case"Enter":this.selectItem(e,!0),n.preventDefault();break;case"Escape":this.escape(),n.preventDefault();break}}),e}buildLabel(){const t=document.createElement("span");return t.classList.add("ql-picker-label"),t.innerHTML=Nc,t.tabIndex="0",t.setAttribute("role","button"),t.setAttribute("aria-expanded","false"),this.container.appendChild(t),t}buildOptions(){const t=document.createElement("span");t.classList.add("ql-picker-options"),t.setAttribute("aria-hidden","true"),t.tabIndex="-1",t.id=`ql-picker-options-${jr}`,jr+=1,this.label.setAttribute("aria-controls",t.id),this.options=t,Array.from(this.select.options).forEach(e=>{const s=this.buildItem(e);t.appendChild(s),e.selected===!0&&this.selectItem(s)}),this.container.appendChild(t)}buildPicker(){Array.from(this.select.attributes).forEach(t=>{this.container.setAttribute(t.name,t.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}escape(){this.close(),setTimeout(()=>this.label.focus(),1)}close(){this.container.classList.remove("ql-expanded"),this.label.setAttribute("aria-expanded","false"),this.options.setAttribute("aria-hidden","true")}selectItem(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const s=this.container.querySelector(".ql-selected");t!==s&&(s!=null&&s.classList.remove("ql-selected"),t!=null&&(t.classList.add("ql-selected"),this.select.selectedIndex=Array.from(t.parentNode.children).indexOf(t),t.hasAttribute("data-value")?this.label.setAttribute("data-value",t.getAttribute("data-value")):this.label.removeAttribute("data-value"),t.hasAttribute("data-label")?this.label.setAttribute("data-label",t.getAttribute("data-label")):this.label.removeAttribute("data-label"),e&&(this.select.dispatchEvent(new Event("change")),this.close())))}update(){let t;if(this.select.selectedIndex>-1){const s=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];t=this.select.options[this.select.selectedIndex],this.selectItem(s)}else this.selectItem(null);const e=t!=null&&t!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",e)}}class Co extends vn{constructor(t,e){super(t),this.label.innerHTML=e,this.container.classList.add("ql-color-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).slice(0,7).forEach(s=>{s.classList.add("ql-primary")})}buildItem(t){const e=super.buildItem(t);return e.style.backgroundColor=t.getAttribute("value")||"",e}selectItem(t,e){super.selectItem(t,e);const s=this.label.querySelector(".ql-color-label"),n=t&&t.getAttribute("data-value")||"";s&&(s.tagName==="line"?s.style.stroke=n:s.style.fill=n)}}class So extends vn{constructor(t,e){super(t),this.container.classList.add("ql-icon-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).forEach(s=>{s.innerHTML=e[s.getAttribute("data-value")||""]}),this.defaultItem=this.container.querySelector(".ql-selected"),this.selectItem(this.defaultItem)}selectItem(t,e){super.selectItem(t,e);const s=t||this.defaultItem;if(s!=null){if(this.label.innerHTML===s.innerHTML)return;this.label.innerHTML=s.innerHTML}}}const xc=i=>{const{overflowY:t}=getComputedStyle(i,null);return t!=="visible"&&t!=="clip"};class qo{constructor(t,e){this.quill=t,this.boundsContainer=e||document.body,this.root=t.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,xc(this.quill.root)&&this.quill.root.addEventListener("scroll",()=>{this.root.style.marginTop=`${-1*this.quill.root.scrollTop}px`}),this.hide()}hide(){this.root.classList.add("ql-hidden")}position(t){const e=t.left+t.width/2-this.root.offsetWidth/2,s=t.bottom+this.quill.root.scrollTop;this.root.style.left=`${e}px`,this.root.style.top=`${s}px`,this.root.classList.remove("ql-flip");const n=this.boundsContainer.getBoundingClientRect(),r=this.root.getBoundingClientRect();let o=0;if(r.right>n.right&&(o=n.right-r.right,this.root.style.left=`${e+o}px`),r.leftn.bottom){const a=r.bottom-r.top,c=t.bottom-t.top+a;this.root.style.top=`${s-c}px`,this.root.classList.add("ql-flip")}return o}show(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}const Ac=[!1,"center","right","justify"],Tc=["#000000","#e60000","#ff9900","#ffff00","#008a00","#0066cc","#9933ff","#ffffff","#facccc","#ffebcc","#ffffcc","#cce8cc","#cce0f5","#ebd6ff","#bbbbbb","#f06666","#ffc266","#ffff66","#66b966","#66a3e0","#c285ff","#888888","#a10000","#b26b00","#b2b200","#006100","#0047b2","#6b24b2","#444444","#5c0000","#663d00","#666600","#003700","#002966","#3d1466"],wc=[!1,"serif","monospace"],Lc=["1","2","3",!1],Cc=["small",!1,"large","huge"];class Es extends De{constructor(t,e){super(t,e);const s=n=>{if(!document.body.contains(t.root)){document.body.removeEventListener("click",s);return}this.tooltip!=null&&!this.tooltip.root.contains(n.target)&&document.activeElement!==this.tooltip.textbox&&!this.quill.hasFocus()&&this.tooltip.hide(),this.pickers!=null&&this.pickers.forEach(r=>{r.container.contains(n.target)||r.close()})};t.emitter.listenDOM("click",document.body,s)}addModule(t){const e=super.addModule(t);return t==="toolbar"&&this.extendToolbar(e),e}buildButtons(t,e){Array.from(t).forEach(s=>{(s.getAttribute("class")||"").split(/\s+/).forEach(r=>{if(r.startsWith("ql-")&&(r=r.slice(3),e[r]!=null))if(r==="direction")s.innerHTML=e[r][""]+e[r].rtl;else if(typeof e[r]=="string")s.innerHTML=e[r];else{const o=s.value||"";o!=null&&e[r][o]&&(s.innerHTML=e[r][o])}})})}buildPickers(t,e){this.pickers=Array.from(t).map(n=>{if(n.classList.contains("ql-align")&&(n.querySelector("option")==null&&ls(n,Ac),typeof e.align=="object"))return new So(n,e.align);if(n.classList.contains("ql-background")||n.classList.contains("ql-color")){const r=n.classList.contains("ql-background")?"background":"color";return n.querySelector("option")==null&&ls(n,Tc,r==="background"?"#ffffff":"#000000"),new Co(n,e[r])}return n.querySelector("option")==null&&(n.classList.contains("ql-font")?ls(n,wc):n.classList.contains("ql-header")?ls(n,Lc):n.classList.contains("ql-size")&&ls(n,Cc)),new vn(n)});const s=()=>{this.pickers.forEach(n=>{n.update()})};this.quill.on(L.events.EDITOR_CHANGE,s)}}Es.DEFAULTS=Zt({},De.DEFAULTS,{modules:{toolbar:{handlers:{formula(){this.quill.theme.tooltip.edit("formula")},image(){let i=this.container.querySelector("input.ql-image[type=file]");i==null&&(i=document.createElement("input"),i.setAttribute("type","file"),i.setAttribute("accept",this.quill.uploader.options.mimetypes.join(", ")),i.classList.add("ql-image"),i.addEventListener("change",()=>{const t=this.quill.getSelection(!0);this.quill.uploader.upload(t,i.files),i.value=""}),this.container.appendChild(i)),i.click()},video(){this.quill.theme.tooltip.edit("video")}}}}});class ko extends qo{constructor(t,e){super(t,e),this.textbox=this.root.querySelector('input[type="text"]'),this.listen()}listen(){this.textbox.addEventListener("keydown",t=>{t.key==="Enter"?(this.save(),t.preventDefault()):t.key==="Escape"&&(this.cancel(),t.preventDefault())})}cancel(){this.hide(),this.restoreFocus()}edit(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),this.textbox==null)return;e!=null?this.textbox.value=e:t!==this.root.getAttribute("data-mode")&&(this.textbox.value="");const s=this.quill.getBounds(this.quill.selection.savedRange);s!=null&&this.position(s),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute(`data-${t}`)||""),this.root.setAttribute("data-mode",t)}restoreFocus(){this.quill.focus({preventScroll:!0})}save(){let{value:t}=this.textbox;switch(this.root.getAttribute("data-mode")){case"link":{const{scrollTop:e}=this.quill.root;this.linkRange?(this.quill.formatText(this.linkRange,"link",t,L.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",t,L.sources.USER)),this.quill.root.scrollTop=e;break}case"video":t=Sc(t);case"formula":{if(!t)break;const e=this.quill.getSelection(!0);if(e!=null){const s=e.index+e.length;this.quill.insertEmbed(s,this.root.getAttribute("data-mode"),t,L.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(s+1," ",L.sources.USER),this.quill.setSelection(s+2,L.sources.USER)}break}}this.textbox.value="",this.hide()}}function Sc(i){let t=i.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||i.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return t?`${t[1]||"https"}://www.youtube.com/embed/${t[2]}?showinfo=0`:(t=i.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?`${t[1]||"https"}://player.vimeo.com/video/${t[2]}/`:i}function ls(i,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;t.forEach(s=>{const n=document.createElement("option");s===e?n.setAttribute("selected","selected"):n.setAttribute("value",String(s)),i.appendChild(n)})}const qc=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]];class _o extends ko{constructor(t,e){super(t,e),this.quill.on(L.events.EDITOR_CHANGE,(s,n,r,o)=>{if(s===L.events.SELECTION_CHANGE)if(n!=null&&n.length>0&&o===L.sources.USER){this.show(),this.root.style.left="0px",this.root.style.width="",this.root.style.width=`${this.root.offsetWidth}px`;const a=this.quill.getLines(n.index,n.length);if(a.length===1){const c=this.quill.getBounds(n);c!=null&&this.position(c)}else{const c=a[a.length-1],h=this.quill.getIndex(c),d=Math.min(c.length()-1,n.index+n.length-h),g=this.quill.getBounds(new ae(h,d));g!=null&&this.position(g)}}else document.activeElement!==this.textbox&&this.quill.hasFocus()&&this.hide()})}listen(){super.listen(),this.root.querySelector(".ql-close").addEventListener("click",()=>{this.root.classList.remove("ql-editing")}),this.quill.on(L.events.SCROLL_OPTIMIZE,()=>{setTimeout(()=>{if(this.root.classList.contains("ql-hidden"))return;const t=this.quill.getSelection();if(t!=null){const e=this.quill.getBounds(t);e!=null&&this.position(e)}},1)})}cancel(){this.show()}position(t){const e=super.position(t),s=this.root.querySelector(".ql-tooltip-arrow");return s.style.marginLeft="",e!==0&&(s.style.marginLeft=`${-1*e-s.offsetWidth/2}px`),e}}w(_o,"TEMPLATE",['','
    ','','',"
    "].join(""));class Io extends Es{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=qc),super(t,e),this.quill.container.classList.add("ql-bubble")}extendToolbar(t){this.tooltip=new _o(this.quill,this.options.bounds),t.container!=null&&(this.tooltip.root.appendChild(t.container),this.buildButtons(t.container.querySelectorAll("button"),gs),this.buildPickers(t.container.querySelectorAll("select"),gs))}}Io.DEFAULTS=Zt({},Es.DEFAULTS,{modules:{toolbar:{handlers:{link(i){i?this.quill.theme.tooltip.edit():this.quill.format("link",!1,y.sources.USER)}}}}});const kc=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]];class Oo extends ko{constructor(){super(...arguments);w(this,"preview",this.root.querySelector("a.ql-preview"))}listen(){super.listen(),this.root.querySelector("a.ql-action").addEventListener("click",e=>{this.root.classList.contains("ql-editing")?this.save():this.edit("link",this.preview.textContent),e.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",e=>{if(this.linkRange!=null){const s=this.linkRange;this.restoreFocus(),this.quill.formatText(s,"link",!1,L.sources.USER),delete this.linkRange}e.preventDefault(),this.hide()}),this.quill.on(L.events.SELECTION_CHANGE,(e,s,n)=>{if(e!=null){if(e.length===0&&n===L.sources.USER){const[r,o]=this.quill.scroll.descendant(un,e.index);if(r!=null){this.linkRange=new ae(e.index-o,r.length());const a=un.formats(r.domNode);this.preview.textContent=a,this.preview.setAttribute("href",a),this.show();const c=this.quill.getBounds(this.linkRange);c!=null&&this.position(c);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute("data-mode")}}w(Oo,"TEMPLATE",['','','',''].join(""));class Ro extends Es{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=kc),super(t,e),this.quill.container.classList.add("ql-snow")}extendToolbar(t){t.container!=null&&(t.container.classList.add("ql-snow"),this.buildButtons(t.container.querySelectorAll("button"),gs),this.buildPickers(t.container.querySelectorAll("select"),gs),this.tooltip=new Oo(this.quill,this.options.bounds),t.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"k",shortKey:!0},(e,s)=>{t.handlers.link.call(t,!s.format.link)}))}}Ro.DEFAULTS=Zt({},Es.DEFAULTS,{modules:{toolbar:{handlers:{link(i){if(i){const t=this.quill.getSelection();if(t==null||t.length===0)return;let e=this.quill.getText(t);/^\S+@\S+\.\S+$/.test(e)&&e.indexOf("mailto:")!==0&&(e=`mailto:${e}`);const{tooltip:s}=this.quill.theme;s.edit("link",e)}else this.quill.format("link",!1,y.sources.USER)}}}}});y.register({"attributors/attribute/direction":po,"attributors/class/align":uo,"attributors/class/background":Kl,"attributors/class/color":Vl,"attributors/class/direction":mo,"attributors/class/font":yo,"attributors/class/size":Eo,"attributors/style/align":ho,"attributors/style/background":Ji,"attributors/style/color":Qi,"attributors/style/direction":go,"attributors/style/font":vo,"attributors/style/size":No},!0);y.register({"formats/align":uo,"formats/direction":mo,"formats/indent":Da,"formats/background":Ji,"formats/color":Qi,"formats/font":yo,"formats/size":Eo,"formats/blockquote":Di,"formats/code-block":J,"formats/header":Pi,"formats/list":vs,"formats/bold":ms,"formats/code":tr,"formats/italic":Pa,"formats/link":un,"formats/script":$i,"formats/strike":Ui,"formats/underline":Hi,"formats/formula":rn,"formats/image":ji,"formats/video":on,"modules/syntax":Lo,"modules/table":Ua,"modules/toolbar":rr,"themes/bubble":Io,"themes/snow":Ro,"ui/icons":gs,"ui/picker":vn,"ui/icon-picker":So,"ui/color-picker":Co,"ui/tooltip":qo},!0);const _c=(i,t,e)=>{const s=i;return Object.keys(t).forEach(n=>{-1t.reduce((e,s)=>{const n=i.lastIndexOf(s);return n>e.mentionCharIndex?{mentionChar:s,mentionCharIndex:n}:{mentionChar:e.mentionChar,mentionCharIndex:e.mentionCharIndex}},{mentionChar:null,mentionCharIndex:-1}),Ic=(i,t)=>t.test(i),Oc=(i,t,e)=>-1{const n=Xt.getQuillInstance(e);if(n){const r=n.getModule("mention");r.currentNode=e}},0),Xt.setDataValues(e,t)}static setDataValues(t,e){const s=t;return Object.keys(e).forEach(n=>{s.dataset[n]=e[n]}),s}static value(t){return t.dataset}format(t,e){t==="customValue"&&e?this.domNode.dataset.customValue=e:super.format(t,e)}}Xt.blotName="mention";Xt.tagName="span";Xt.className="mention";y.register(Xt);const Y={TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",UP:"ArrowUp",DOWN:"ArrowDown",SPACE:" "};class Mc{constructor(t,e){this.isOpen=!1,this.itemIndex=0,this.mentionCharPos=null,this.cursorPos=null,this.values=[],this.suspendMouseEnter=!1,this.activeElement=null,this.currentBlot=null,this.currentNode=null,this.quill=t,this.silentInsert=!1,this.insertingCustomItem=!1,this.options={source:null,renderItem(a){return`${a.value}`},onSelect(a,c){c(a)},mentionDenotationChars:["@"],showDenotationChar:!0,allowedChars:/^[a-zA-Z0-9_]*$/,minChars:0,maxChars:1e3,offsetTop:2,offsetLeft:0,isolateCharacter:!1,fixMentionsToQuill:!1,defaultMenuOrientation:"bottom",dataAttributes:["id","value","denotationChar","link","target"],linkTarget:"_blank",onOpen(){return!0},onClose(){return!0},listItemClass:"ql-mention-list-item",mentionContainerClass:"ql-mention-list-container",mentionListClass:"ql-mention-list",spaceAfterInsert:!0,selectKeys:[Y.ENTER]},Object.assign(this.options,e,{dataAttributes:Array.isArray(e.dataAttributes)?this.options.dataAttributes.concat(e.dataAttributes):this.options.dataAttributes}),this.mentionContainer=document.createElement("div"),this.mentionContainer.className=this.options.mentionContainerClass?this.options.mentionContainerClass:"",this.mentionContainer.style.cssText="display: none; position: absolute;",this.mentionContainer.onmousemove=this.onContainerMouseMove.bind(this),this.options.fixMentionsToQuill&&(this.mentionContainer.style.width="auto"),this.customFieldInput=document.createElement("div"),this.customFieldInput.className=this.options.mentionPrependClassCustom?this.options.mentionPrependClassCustom:"",this.customFieldInput.innerHTML=this.options.customFieldInput||"",this.mentionContainer.appendChild(this.customFieldInput),this.mentionSearch=document.createElement("div"),this.mentionSearch.className=this.options.mentionPrependClass?this.options.mentionPrependClass:"",this.mentionSearch.innerHTML=this.options.prependMentionList||"",this.mentionContainer.appendChild(this.mentionSearch);const s=this.mentionSearch.querySelector(".aioseo-trash");s&&s.addEventListener("click",()=>{this.currentBlot.remove(),this.hideMentionList(),this.removeOrphanedMentionChar()}),this.customFieldInput.addEventListener("click",a=>{this.activeElement=a.target;const c=a.target.querySelector("input");c&&setTimeout(()=>{c.focus()},0)});const n=this.customFieldInput.querySelector("input");n&&n.addEventListener("input",a=>{if(this.currentNode){let c=this.currentNode.querySelector(".tag-custom");if(!c){c=document.createElement("span"),c.classList.add("tag-custom");const h=this.currentNode.querySelector(".tag-name");h.parentNode.insertBefore(c,h.nextSibling)}c.innerHTML=a.target.value?" - "+a.target.value:"",this.currentBlot=y.find(this.currentNode),this.currentBlot.format("customValue",a.target.value)}}),this.customFieldInput.addEventListener("keydown",a=>{Y.ENTER===a.key&&(this.hideMentionList(),this.removeOrphanedMentionChar(),a.preventDefault()),Y.ESCAPE===a.key&&(this.hideMentionList(),this.removeOrphanedMentionChar()),Y.SPACE===a.key&&a.preventDefault()}),this.mentionSearch.addEventListener("click",a=>{this.activeElement=a.target}),this.mentionSearch.addEventListener("keydown",a=>{Y.DOWN===a.key&&this.nextItem(),Y.UP===a.key&&this.prevItem(),Y.ENTER===a.key&&(this.selectItem(),a.preventDefault()),Y.ESCAPE===a.key&&this.hideMentionList()});const r=this.mentionSearch.querySelector("input");r&&r.addEventListener("input",a=>{const c=this.getTextBeforeCursor(),{mentionChar:h}=zr(c,this.options.mentionDenotationChars);if(!h&&!this.currentBlot)return;const d=h||this.currentBlot.domNode.dataset.denotationChar;this.options.source(a.target.value,this.renderList.bind(this,d),d)}),this.mentionList=document.createElement("ul"),this.mentionList.id="quill-mention-list",t.root.setAttribute("aria-owns","quill-mention-list"),this.mentionList.className=this.options.mentionListClass?this.options.mentionListClass:"",this.mentionContainer.appendChild(this.mentionList);const o=document.createElement("div");o.className="aioseo-documentation-link",o.innerHTML=this.options.documentationDiv||"",o.addEventListener("click",a=>{this.activeElement=a.target}),this.mentionContainer.appendChild(o),this.quill.container.appendChild(this.mentionContainer),t.on("text-change",this.onTextChange.bind(this)),t.on("selection-change",this.onSelectionChange.bind(this)),t.container.addEventListener("paste",()=>{setTimeout(()=>{const a=t.getSelection();this.onSelectionChange(a)})}),t.keyboard.addBinding({key:Y.TAB},this.selectHandler.bind(this)),t.keyboard.bindings[Y.TAB].unshift(t.keyboard.bindings[Y.TAB].pop());for(const a of this.options.selectKeys??[])t.keyboard.addBinding({key:a},this.selectHandler.bind(this));t.keyboard.bindings[Y.ENTER].unshift(t.keyboard.bindings[Y.ENTER].pop()),t.keyboard.addBinding({key:Y.ESCAPE},this.escapeHandler.bind(this)),t.keyboard.addBinding({key:Y.UP},this.upHandler.bind(this)),t.keyboard.addBinding({key:Y.DOWN},this.downHandler.bind(this)),t.clipboard.addMatcher(Node.TEXT_NODE,this.clipboardHandler.bind(this))}selectHandler(){return this.isOpen?(this.selectItem(),!1):!0}escapeHandler(){return this.isOpen?(this.hideMentionList(),this.removeOrphanedMentionChar(),!1):!0}removeOrphanedMentionChar(t=!1){let e=!1;!t&&!this.quill.hasFocus()&&(this.quill.focus(),e=!0);const s=this.getTextBeforeCursor();s.charAt(s.length-1)==="#"&&this.quill.deleteText(this.quill.getSelection().index-1,1,y.sources.USER),e&&this.quill.blur()}upHandler(){return this.isOpen?(this.prevItem(),!1):!0}downHandler(){return this.isOpen?(this.nextItem(),!1):!0}clipboardHandler(t,e){if(typeof t.data!="string")return;const s=new RegExp(`${this.options.mentionDenotationChars.join("|")}[A-Za-z_-]+`,"g"),n=t.data.match(s);if(n&&0{const c=a.charAt(0),h=a.substr(1).split("-"),d=h[0];delete h[0];const g=h.filter(N=>N).join("-"),p=this.options.source(d,this.renderList.bind(this,c),c,!0,g||null);if(!p)return;const m={denotationChar:this.options.showDenotationChar?c:"",...p};g!==void 0&&(m.customValue=g);const b=o.split(a),E=b.shift();r.push({insert:E}),r.push({insert:{mention:m}}),o=b.join(a)}),r.push({insert:o}),e.ops=r}return e}showMentionList(){if(this.mentionContainer.style.visibility="hidden",this.mentionContainer.style.display="",this.setMentionContainerPosition(),this.customFieldInput.style.display="none",this.currentNode&&this.currentNode.dataset.custom){this.customFieldInput.style.display="block";const e=this.customFieldInput&&this.customFieldInput.querySelector("input"),s=this.currentNode.querySelector(".tag-custom");e&&s&&(e.value=s.innerHTML.replace(" - ","").trim())}const t=this.mentionSearch.querySelector(".aioseo-trash");t&&(t.style.display="block",this.currentBlot||(t.style.display="none")),this.setIsOpen(!0)}hideMentionList(){document.querySelectorAll(".aioseo-tag .tag-toggle svg").forEach(n=>{n.classList.remove("rotated")});const e=this.mentionSearch&&this.mentionSearch.querySelector("input");e&&(e.value="");const s=this.customFieldInput&&this.customFieldInput.querySelector("input");s&&(s.value=""),this.currentBlot=null,this.currentNode=null,this.mentionContainer.style.display="none",this.setIsOpen(!1)}highlightItem(t=!0){if(!this.mentionList.childNodes[this.itemIndex])return;for(let s=0;so-s&&(this.mentionList.scrollTop+=n-o+s)}}getItemData(){const{link:t}=this.mentionList.childNodes[this.itemIndex].dataset,e=typeof t<"u",s=this.mentionList.childNodes[this.itemIndex].dataset.target;return e&&(this.mentionList.childNodes[this.itemIndex].dataset.value=`${this.mentionList.childNodes[this.itemIndex].dataset.value}`),this.mentionList.childNodes[this.itemIndex].dataset}onContainerMouseMove(){this.suspendMouseEnter=!1}selectItem(){const t=this.getItemData();if(!t.id)return this.hideMentionList();this.options.onSelect(t,e=>{this.insertItem(e)}),t.custom||this.hideMentionList()}insertItem(t){const e=t;if(e===null)return;this.options.showDenotationChar||(e.denotationChar=""),t.custom&&(this.insertingCustomItem=!0,setTimeout(()=>{this.insertingCustomItem=!1},50),this.customFieldInput.style.display="block",this.customFieldInput.click());const s=this.mentionCharPos;this.quill.deleteText(this.mentionCharPos,this.cursorPos-this.mentionCharPos,y.sources.USER),this.quill.insertEmbed(s,"mention",e,y.sources.USER),this.options.spaceAfterInsert?(this.quill.insertText(s+1," ",y.sources.USER),this.quill.setSelection(s+2,y.sources.USER)):this.quill.setSelection(s+1,y.sources.USER),t.custom||this.hideMentionList()}onItemMouseEnter(t){if(this.suspendMouseEnter)return;const e=Number(t.target.dataset.index);!Number.isNaN(e)&&e!==this.itemIndex&&(this.itemIndex=e,this.highlightItem(!1))}onItemClick(t){t.preventDefault(),t.stopImmediatePropagation(),this.itemIndex=t.currentTarget.dataset.index,this.highlightItem(),this.selectItem()}renderList(t,e,s,n=!1,r=!1){if(this.mentionList.innerHTML="",e&&0a.name===s||a.id===s);if(o)return o}else if(r){const o=this.values.find(a=>a.name===s||a.id===s);o&&this.insertItem(o)}for(let o=0;owindow.innerHeight}containerRightIsNotVisible(t,e){return this.options.fixMentionsToQuill?!1:e.width=n+t.top){let o=this.options.offsetTop;this.options.fixMentionsToQuill?o+=t.height:o+=e.bottom,n=o}}else if(this.options.fixMentionsToQuill?n+=t.height:n+=e.bottom,this.containerBottomIsNotVisible(n,t)){let o=this.options.offsetTop*-1;this.options.fixMentionsToQuill||(o+=e.top),n=o-s}0<=n?this.options.mentionContainerClass.split(" ").forEach(o=>{this.mentionContainer.classList.add(`${o}-bottom`),this.mentionContainer.classList.remove(`${o}-top`)}):this.options.mentionContainerClass.split(" ").forEach(o=>{this.mentionContainer.classList.add(`${o}-top`),this.mentionContainer.classList.remove(`${o}-bottom`)}),this.mentionContainer.style.top=`${n}px`,this.mentionContainer.style.left=`${r}px`,this.mentionContainer.style.visibility="visible"}getTextBeforeCursor(){const t=Math.max(0,(this.cursorPos??0)-this.options.maxChars);return this.quill.getText(t,(this.cursorPos??0)-t)}onSomethingChange(){const t=this.quill.getSelection();if(t===null||this.insertingCustomItem)return;this.cursorPos=t.index;const e=this.getTextBeforeCursor(),{mentionChar:s,mentionCharIndex:n}=zr(e,this.options.mentionDenotationChars);if(Oc(n,e,this.options.isolateCharacter)){const r=this.cursorPos-(e.length-n);this.mentionCharPos=r;const o=e.substring(n+s.length);o.length>=this.options.minChars&&Ic(o,this.options.allowedChars)?this.options.source(o,this.renderList.bind(this,s),s):this.hideMentionList()}else this.hideMentionList()}onTextChange(t,e,s){s==="user"&&setTimeout(this.onSomethingChange.bind(this),0)}onSelectionChange(t){t&&t.length===0?this.onSomethingChange():setTimeout(()=>{this.activeElement?this.activeElement.classList.contains("aioseo-tag-custom")||(this.activeElement=null):this.hideMentionList.bind(this)},0)}}y.register("modules/mention",Mc);const Bc=y.import("modules/toolbar");class Mo extends Bc{}Mo.DEFAULTS.handlers.autoLink=function(){const i=this.quill.getSelection(),t=this.quill.getModule("autoLink"),e=this.quill.getContents();e.ops.forEach(s=>{var n;(n=s==null?void 0:s.attributes)!=null&&n.link&&delete s.attributes.link}),this.quill.setContents(e,y.sources.SILENT),this.quill.setSelection(i,y.sources.SILENT),this.quill.format("link",t.options.url,y.sources.USER)};y.register("modules/toolbar",Mo,!0);class Dc{constructor(t,e){this.quill=t,this.options=e,this.container=document.querySelector(e.container)}}y.register("modules/autoLink",Dc,!0);class Pc{constructor(t,e){this.quill=t,this.options=e,this.container=document.querySelector(e.container),t.on("text-change",this.update.bind(this)),this.update()}calculate(){let t=this.quill.getText()?this.quill.root.innerHTML:"";const e=document.createRange().createContextualFragment(t),s=document.createRange().createContextualFragment("");e.childNodes.forEach(r=>{if(r.tagName!=="P")return;r.childNodes.forEach(a=>{if(a.nodeType===3){s.appendChild(a.cloneNode(!0));return}if(a.tagName==="SPAN"){const c=a.querySelector(".aioseo-tag .tag-name");if(c){const h=this.options.tags.find(p=>p.name===c.textContent),d=typeof h.valueText=="string"?ur.decode(h.valueText):h.valueText,g=document.createTextNode(d);s.appendChild(g)}}});const o=document.createElement("br");s.appendChild(o)}),s.normalize();const n=document.createElement("div");return n.appendChild(s.cloneNode(!0)),t=n.innerHTML.replace(/ /gi," ").replace(//gi,this.single?"":` `).trim(),{length:ur.decode(t).length,text:t}}update(){const{length:t}=this.calculate();let e=this.options.unit;t!==1&&(e+="s"),this.container&&(this.container.innerText=t+" "+e)}}y.register("modules/counter",Pc);const $c=y.import("modules/clipboard"),Uc=y.import("delta");class Hc extends $c{onPaste(t,{html:e,text:s}){const n=this.options,r=this.quill.getFormat(t.index),o=this.convert({text:s,html:e},r),a=new Uc().retain(t.index).delete(t.length).concat(o);n.newLines===!1&&a.ops.map(function(c){return typeof c.insert=="string"&&(c.insert=c.insert.replace(/(\r\n|\n|\r)/gm," ")),c}),this.quill.updateContents(a,y.sources.USER),this.quill.setSelection(a.length()-t.length,y.sources.SILENT),this.quill.scrollSelectionIntoView()}convert({html:t,text:e}){return typeof t=="string"&&(t=t.replace(/>\r?\n +<")),super.convert({html:t,text:e})}}y.register("modules/clipboard",Hc,!0);class jc{constructor(t,e){this.quill=t,this.options={defaultLength:1,...e},this.container=e.container,t.on("text-change",this.update.bind(this)),this.update()}update(){for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild);const t=this.quill.getLines();if(this.options.defaultLength>t.length)for(let n=t.length;this.options.defaultLength>n;n++)t.push({});let e=0;for(let n=0;n(i.forEach(s=>{e[s]&&t.setAttribute(s,e[s]),s==="data-*"&&Object.keys(e).forEach(n=>{n.indexOf("data-")===0&&t.setAttribute(n,e[n])})}),t),lr=(i,t)=>i.reduce((e,s)=>(t.hasAttribute(s)&&(e[s]=t.getAttribute(s)),s==="data-*"&&Object.keys(t.dataset).forEach(n=>{n="data-"+n.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`),e[n]=t.getAttribute(n)}),e),{}),Fc=y.import("formats/link"),Ti=["href","rel","target","class","data-*","style"];class Bo extends Fc{static create(t){typeof t=="string"&&(t=this.linkAttributesCache);const e=or(Ti,super.create(t),t);return Ti.forEach(s=>{s==="href"&&(t[s]=this.sanitize(t[s]),e.setAttribute(s,t[s]))}),this.linkAttributesCache=t,e}static formats(t){return lr(Ti,t)}}w(Bo,"linkAttributesCache",{});y.register("formats/link",Bo,!0);const hn=["style","class","data-*"],zc=y.import("blots/inline");class ar extends zc{static create(t){return or(hn,super.create(t),t)}static formats(t){return lr(hn,t)}}ar.blotName="aioseoInline";ar.tagName="aioseo-inline";y.register("formats/aioseoInline",ar,!0);const Vc=y.import("formats/italic");class Kc extends Vc{static create(t){return or(hn,super.create(t),t)}static formats(t){return lr(hn,t)}}y.register("formats/italic",Kc,!0);class Gc{constructor(t,e){this.quill=t,this.options=e,this.preserveWhitespace=e.preserveWhitespace||!1,t.clipboard.addMatcher(Node.TEXT_NODE,this.clipboardHandler.bind(this)),t.container.style.whiteSpace="pre-line"}clipboardHandler(t,e){if(t.data.match(/^\t/)&&this.preserveWhitespace){const s=y.import("delta");return new s().insert(t.data)}return e}}y.register("modules/preserveWhiteSpace",Gc);const Wc={},Zc={viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:"aioseo-plus"},Xc=et("path",{d:"M6 0.00115967H4V4.00116H0V6.00116H4V10.0012H6V6.00116H10V4.00116H6V0.00115967Z",fill:"currentColor"},null,-1),Yc=[Xc];function Qc(i,t){return zt(),Vt("svg",Zc,Yc)}const Jc=Gr(Wc,[["render",Qc]]),R=[],tu={setup(){return{postEditorStore:Uo(),tagsStore:Vr()}},emits:["counter","selection-change","updateEditor","focus","blur","update:modelValue","paste"],components:{BaseInput:jo,SvgCaret:zo,SvgPlus:Jc,SvgTrash:Fo},props:{modelValue:{type:String,default:""},minimumLineNumbers:{type:Number,default(){return 5}},single:Boolean,lineNumbers:Boolean,allowTags:Boolean,disabled:Boolean,tagsContext:String,forceUpdates:Boolean,monospace:Boolean,defaultMenuOrientation:String,description:Boolean,showToolbar:Boolean,preserveWhitespace:Boolean,autoLink:{type:[Object,Boolean],default(){return!1}}},data(){return{tags:fr,localTags:[],quill:null,html:"",insertExact:!1,cachedPhrase:"",strings:{searchPlaceholder:this.$t.__("Search for an item...",this.$td),enterCustomFieldName:this.$t.__("Enter a custom field/taxonomy name...",this.$td),learnMoreSmartTags:this.$t.__("Learn more about Smart Tags",this.$td),removeSmartTag:this.$t.__("Remove Smart Tag",this.$td)}}},watch:{disabled(){this.disabled?R[this.$.uid].disable():R[this.$.uid].enable()},modelValue(){this.forceUpdates&&this.startup(!0)},"tagsStore.liveTags":{deep:!0,handler(){this.localTags=this.getTags();const i=R[this.$.uid].getModule("counter");i&&(i.options.tags=this.localTags,this.$emit("counter",i.calculate()))}},tags:{deep:!0,handler(){const i=this.getTags();JSON.stringify(this.localTags)!==JSON.stringify(i)&&(this.localTags=i,this.startup(!0))}}},methods:{emitPasteEvent(i){this.$emit("paste",i)},getTags(){return(this.tagsContext?[...fr.context(this.tagsContext)]:[...this.tagsStore.tags].filter(t=>!t.deprecated)).map((t,e)=>{const s=this.postEditorStore.currentPost&&this.tagsStore.liveTags[t.id]||t.value;return{...t,valueText:s,value:this.$refs["select-template"][e]?this.$refs["select-template"][e].innerHTML:"",menuHtml:this.$refs["menu-template"][e]?this.$refs["menu-template"][e].innerHTML:""}})},update(){if(this.allowTags){const n=R[this.$.uid].getModule("counter");this.$emit("counter",n.calculate())}let i=R[this.$.uid].getText()?R[this.$.uid].root.innerHTML:"";const t=document.createRange().createContextualFragment(i),e=document.createRange().createContextualFragment("");t.childNodes.forEach(n=>{if(n.tagName!=="P")return;n.childNodes.forEach(o=>{if(o.nodeType===3){e.appendChild(o.cloneNode(!0));return}if(o.tagName==="SPAN"&&this.allowTags){const a=o.querySelector(".aioseo-tag");if(a){const c=a.querySelector(".tag-name");if(c){const h=this.localTags.find(g=>g.name===c.textContent);if(h.custom){const g=a.querySelector(".tag-custom");if(g){const p=document.createTextNode(`#${h.id}-${g.innerHTML.replace(" - ","")}`);e.appendChild(p);return}}const d=document.createTextNode(`#${h.id}`);e.appendChild(d)}}}});const r=document.createElement("br");e.appendChild(r)}),e.normalize();const s=document.createElement("div");s.appendChild(e.cloneNode(!0)),i=s.innerHTML.replace(//gi,this.single?"":` `).trim(),i=i.replace(/ /gi," ").trim(),this.$emit("update:modelValue",i)},insertToCursor(i){R[this.$.uid].focus(),R[this.$.uid].insertText(R[this.$.uid].getSelection().index,i,y.sources.USER),R[this.$.uid].setSelection(R[this.$.uid].getSelection().index+i.length,y.sources.USER)},insertTag(i){const t=R[this.$.uid].getModule("mention");t.removeOrphanedMentionChar();const e=t.getTextBeforeCursor();this.insertExact=!0;const s=i?this.localTags.find(o=>o.id===i):null;let n=s?`#${s.id}`:e.charAt(e.length-1)==="#"?"":"#";const r=R[this.$.uid].getContents(0,t.cursorPos);r.ops.length&&(typeof r.ops.pop().insert!="string"||!e.match(/\s$/))&&(n=" "+n),R[this.$.uid].focus(),i&&t.removeOrphanedMentionChar(),R[this.$.uid].insertText(R[this.$.uid].getSelection().index,n,y.sources.USER),R[this.$.uid].setSelection(R[this.$.uid].getSelection().index+n.length,y.sources.USER),this.insertExact=!1,i?t.hideMentionList():setTimeout(()=>{t.mentionCharPos=R[this.$.uid].getSelection().index-1,t.silentInsert=!0,t.showMentionList()},0)},maybeCloseMenu(i){const t=i.target;if(t.classList.contains("aioseo-tag")||t.closest(".aioseo-tag")||t.closest(".add-tags"))return;if(t.classList.contains("ql-mention-list-container")||t.closest(".ql-mention-list-container")){const s=t.classList.contains("prepend-icon")?t:t.closest(".prepend-icon");s&&s.nextSibling.focus();return}const e=R[this.$.uid].getModule("mention");e.isOpen&&(e.hideMentionList(),e.removeOrphanedMentionChar())},async startup(i=!1){if(this.allowTags&&!this.$refs["tag-search"])return;R[this.$.uid]=this.startQuill(),i&&R[this.$.uid].setText("");let t=this.modelValue;t&&t.length&&t.match(/#[^\s]*$/)&&(t=t.trim()+" "),t=t&&(this.single?t.replace(` `," "):"

    "+t.split(` `).map(n=>n===""?"
    ":n).join("

    ")+"

    ");const e=R[this.$.uid].clipboard.convert({html:t,text:""});R[this.$.uid].setContents(e);const s=R[this.$.uid].getModule("mention");if(s&&s.removeOrphanedMentionChar(!0),this.allowTags){const n=R[this.$.uid].getModule("counter");this.$emit("counter",n.calculate())}this.removeTrailingNewLine(),await this.$nextTick(),R[this.$.uid].on("text-change",()=>this.update()),R[this.$.uid].on("selection-change",(n,r,o)=>{o==="api"&&this.update(),n?this.$emit("focus",R[this.$.uid]):this.$emit("blur",R[this.$.uid]),this.$emit("selection-change",{range:n,oldRange:r,source:o})}),document.addEventListener("click",this.maybeCloseMenu),this.disabled&&R[this.$.uid].disable(),i||R[this.$.uid].history.clear()},startQuill(){return new y(this.$refs.quill,{modules:{toolbar:this.showToolbar?["bold","italic","underline","autoLink"]:[],lineNumbers:this.lineNumbers?{container:this.$refs["line-numbers"],defaultLength:this.minimumLineNumbers}:null,mention:this.allowTags?{defaultMenuOrientation:this.defaultMenuOrientation||"bottom",dataAttributes:["id","value","denotationChar","link","target","custom","customValue"],allowedChars:/^[A-Za-z\s_]*$/,mentionDenotationChars:["#"],spaceAfterInsert:!0,mentionPrependClass:"aioseo-tag-search",mentionPrependClassCustom:"aioseo-tag-custom",prependMentionList:this.$refs["tag-search"].innerHTML,customFieldInput:this.$refs["tag-custom"].innerHTML,documentationDiv:this.$refs["documentation-div"].innerHTML,listItemClassNoMatch:"aioseo-tag-no-match",renderItemNoMatch(){return"No matches found"},renderItem(i){return`${i.menuHtml}`},source:(i,t,e,s=!1,n="")=>{const r=[...this.localTags];if(r[0].custom&&(r[0].customValue=n),i.length===0)return t(r,i,s,this.insertExact);const o=[];for(let a=0;a!this.single}}},preserveWhiteSpace:this.preserveWhitespace},theme:"snow",formats:this.showToolbar?["bold","underline","italic","link","list","aioseoInline"]:["mention"]})},setPhrase(i){this.cachedPhrase=i,i=Yo(i),i=i.replace(/]*)>/g,"").replace(/<\/span>/g,"");const t=R[this.$.uid].clipboard.convert({html:i,text:""});R[this.$.uid].setContents(t)},getPhrase(){return R[this.$.uid].getText()},getPhraseWithFormats(){return R[this.$.uid].getContents()},getPhraseHtml(){let i=R[this.$.uid].root.childNodes[0].innerHTML;return i=i.replace(/]*)>/g,"").replace(/<\/aioseo-inline>/g,""),i=Qo(this.cachedPhrase,i),i},removeTrailingNewLine(){const i=document.querySelector(".aioseo-editor-description .ql-editor");this.description&&i&&(i.innerHTML=i.innerHTML.replace(/


    <\/p>$/i,""))}},mounted(){this.localTags=this.getTags(),this.startup(!0),this.tagsContext&&window.aioseoBus.$on("updateEditor"+this.tagsContext,i=>{i!==this.$.uid&&this.startup(!0)})},beforeUnmount(){document.removeEventListener("click",this.maybeCloseMenu)},unmounted(){this.tagsContext&&window.aioseoBus.$emit("updateEditor"+this.tagsContext,this.$.uid)}},eu={class:"aioseo-editor"},su={key:0,ref:"line-numbers",class:"aioseo-line-numbers"},nu={key:1,class:"aioseo-append-icon"},iu={key:2,class:"aioseo-append-button"},ru={class:"aioseo-tag"},ou={class:"tag-name"},lu={key:0,class:"tag-custom"},au={class:"tag-toggle"},cu={class:"aioseo-tag-item"},uu={class:"aioseo-tag-title"},hu={class:"aioseo-tag-description"},du={ref:"tag-search"},fu={ref:"tag-custom"},pu=["innerHTML"];function mu(i,t,e,s,n,r){const o=Zs("svg-caret"),a=Zs("svg-plus"),c=Zs("base-input"),h=Zs("svg-trash");return zt(),Vt("div",eu,[et("div",{class:Vo([{"aioseo-editor-line-numbers":e.lineNumbers},{"aioseo-editor-single":e.single},{"aioseo-editor-monospace":e.monospace},{"aioseo-editor-description":e.description}]),ref:"quill",onPaste:t[0]||(t[0]=(...d)=>r.emitPasteEvent&&r.emitPasteEvent(...d))},null,34),e.lineNumbers?(zt(),Vt("div",su,null,512)):Xs("",!0),i.$slots["append-icon"]?(zt(),Vt("div",nu,[hr(i.$slots,"append-icon")])):Xs("",!0),i.$slots["append-button"]?(zt(),Vt("div",iu,[hr(i.$slots,"append-button")])):Xs("",!0),(zt(!0),Vt(dr,null,Ko(n.tags.context(e.tagsContext),(d,g)=>(zt(),Vt(dr,{key:g},[is(et("div",{ref_for:!0,ref:"select-template"},[et("span",ru,[et("span",ou,Ys(d.name),1),d.custom&&d.customValue?(zt(),Vt("span",lu," - "+Ys(d.customValue),1)):Xs("",!0),et("span",au,[rs(o)])])],512),[[os,!1]]),is(et("div",{ref_for:!0,ref:"menu-template"},[et("div",cu,[et("div",null,[rs(a)]),et("div",null,[et("div",uu,Ys(d.name),1),et("div",hu,Ys(d.description),1)])])],512),[[os,!1]])],64))),128)),is(et("div",du,[rs(c,{size:"medium",placeholder:n.strings.searchPlaceholder,prependIcon:"search"},null,8,["placeholder"]),rs(h)],512),[[os,!1]]),is(et("div",fu,[rs(c,{size:"small",placeholder:n.strings.enterCustomFieldName},null,8,["placeholder"])],512),[[os,!1]]),is(et("div",{ref:"documentation-div",innerHTML:i.$links.getDocLink(n.strings.learnMoreSmartTags,"smartTags",!0)},null,8,pu),[[os,!1]])])}const Mu=Gr(tu,[["render",mu]]);export{Mu as B,Jc as S,fr as t};