dootask/public/js/build/quill-mention-hi.ad82e911.js
2024-05-01 14:18:57 +08:00

50 lines
143 KiB
JavaScript
Vendored

var As=Object.defineProperty;var Ss=(i,t,e)=>t in i?As(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var g=(i,t,e)=>(Ss(i,typeof t!="symbol"?t+"":t,e),e);import{E as O,T as Vt,I as Is,S as x,B as We,A as Os,L as M,P as St,R as Ge,a as Rs,b as Ze,C as Xe,c as oe,d as V,e as ht}from"./parchment.d5c5924e.js";import{D as v,a as B}from"./quill-delta.72524c38.js";import{i as le,c as lt,m as Y}from"./lodash-es.df04b444.js";class P extends O{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return""}}P.blotName="break";P.tagName="BR";class D extends Vt{}function Rt(i){return i.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}const W=class extends Is{static compare(t,e){const s=W.order.indexOf(t),n=W.order.indexOf(e);return s>=0||n>=0?s-n:t===e?0:t<e?-1:1}formatAt(t,e,s,n){if(W.compare(this.statics.blotName,s)<0&&this.scroll.query(s,x.BLOT)){const r=this.isolate(t,e);n&&r.wrap(s,n)}else super.formatAt(t,e,s,n)}optimize(t){if(super.optimize(t),this.parent instanceof W&&W.compare(this.statics.blotName,this.parent.statics.blotName)>0){const e=this.parent.isolate(this.offset(),this.length());this.moveChildren(e),e.wrap(this)}}};let I=W;g(I,"allowedChildren",[W,P,O,D]),g(I,"order",["cursor","inline","link","underline","strike","italic","bold","script","code"]);const xe=1;class N extends We{constructor(){super(...arguments);g(this,"cache",{})}delta(){return this.cache.delta==null&&(this.cache.delta=Qe(this)),this.cache.delta}deleteAt(e,s){super.deleteAt(e,s),this.cache={}}formatAt(e,s,n,r){s<=0||(this.scroll.query(n,x.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<this.length()-1||this.children.tail==null?super.insertAt(Math.min(e,this.length()-1),o):this.children.tail.insertAt(this.children.tail.length(),o),this.cache={});let l=this;r.reduce((a,c)=>(l=l.split(a,!0),l.insertAt(0,c),c.length),e+o.length)}insertBefore(e,s){const{head:n}=this.children;super.insertBefore(e,s),n instanceof P&&n.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+xe),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()-xe)){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}}N.blotName="block";N.tagName="P";N.defaultChild=P;N.allowedChildren=[P,I,O,D];class S extends O{attach(){super.attach(),this.attributes=new Os(this.domNode)}delta(){return new v().insert(this.value(),{...this.formats(),...this.attributes.values()})}format(t,e){const s=this.scroll.query(t,x.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(a=>{const c=this.scroll.create(N.blotName);return c.insertAt(0,a),c}),l=this.split(t);o.forEach(a=>{this.parent.insertBefore(a,l)}),r&&this.parent.insertBefore(this.scroll.create("text",r),l)}}S.scope=x.BLOCK_BLOT;function Qe(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return i.descendants(M).reduce((e,s)=>s.length()===0?e:e.insert(s.value(),T(s,{},t)),new v).insert(`
`,T(i))}function T(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:T(i.parent,t,e)}const G=class extends O{static value(){}constructor(t,e,s){super(t,e),this.selection=s,this.textNode=document.createTextNode(G.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!==x.BLOCK_BLOT;)n+=s.offset(s.parent),s=s.parent;s!=null&&(this.savedLength=G.CONTENTS.length,s.optimize(),s.formatAt(n,G.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 D?this.prev:null,s=e?e.length():0,n=this.next instanceof D?this.next:null,r=n?n.text:"",{textNode:o}=this,l=o.data.split(G.CONTENTS).join("");o.data=G.CONTENTS;let a;if(e)a=e,(l||n)&&(e.insertAt(e.length(),l+r),n&&n.remove());else if(n)a=n,n.insertAt(0,l);else{const c=document.createTextNode(l);a=this.scroll.create(c),this.parent.insertBefore(a,this)}if(this.remove(),t){const c=(b,y)=>e&&b===e.domNode?y:b===o?s+y-1:n&&b===n.domNode?s+l.length+y:null,u=c(t.start.node,t.start.offset),d=c(t.end.node,t.end.offset);if(u!==null&&d!==null)return{startNode:a.domNode,startOffset:u,endNode:a.domNode,endOffset:d}}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=G.CONTENTS.length,e.isolate(this.offset(e),this.length()).unwrap(),this.savedLength=0;break}e=e.parent}}value(){return""}};let _=G;g(_,"blotName","cursor"),g(_,"className","ql-cursor"),g(_,"tagName","span"),g(_,"CONTENTS","\uFEFF");var Ye={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(a,c,u){this.fn=a,this.context=c,this.once=u||!1}function r(a,c,u,d,b){if(typeof u!="function")throw new TypeError("The listener must be a function");var y=new n(u,d||a,b),f=e?e+c:c;return a._events[f]?a._events[f].fn?a._events[f]=[a._events[f],y]:a._events[f].push(y):(a._events[f]=y,a._eventsCount++),a}function o(a,c){--a._eventsCount===0?a._events=new s:delete a._events[c]}function l(){this._events=new s,this._eventsCount=0}l.prototype.eventNames=function(){var c=[],u,d;if(this._eventsCount===0)return c;for(d in u=this._events)t.call(u,d)&&c.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},l.prototype.listeners=function(c){var u=e?e+c:c,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var b=0,y=d.length,f=new Array(y);b<y;b++)f[b]=d[b].fn;return f},l.prototype.listenerCount=function(c){var u=e?e+c:c,d=this._events[u];return d?d.fn?1:d.length:0},l.prototype.emit=function(c,u,d,b,y,f){var E=e?e+c:c;if(!this._events[E])return!1;var m=this._events[E],q=arguments.length,L,w;if(m.fn){switch(m.once&&this.removeListener(c,m.fn,void 0,!0),q){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,u),!0;case 3:return m.fn.call(m.context,u,d),!0;case 4:return m.fn.call(m.context,u,d,b),!0;case 5:return m.fn.call(m.context,u,d,b,y),!0;case 6:return m.fn.call(m.context,u,d,b,y,f),!0}for(w=1,L=new Array(q-1);w<q;w++)L[w-1]=arguments[w];m.fn.apply(m.context,L)}else{var Ts=m.length,dt;for(w=0;w<Ts;w++)switch(m[w].once&&this.removeListener(c,m[w].fn,void 0,!0),q){case 1:m[w].fn.call(m[w].context);break;case 2:m[w].fn.call(m[w].context,u);break;case 3:m[w].fn.call(m[w].context,u,d);break;case 4:m[w].fn.call(m[w].context,u,d,b);break;default:if(!L)for(dt=1,L=new Array(q-1);dt<q;dt++)L[dt-1]=arguments[dt];m[w].fn.apply(m[w].context,L)}}return!0},l.prototype.on=function(c,u,d){return r(this,c,u,d,!1)},l.prototype.once=function(c,u,d){return r(this,c,u,d,!0)},l.prototype.removeListener=function(c,u,d,b){var y=e?e+c:c;if(!this._events[y])return this;if(!u)return o(this,y),this;var f=this._events[y];if(f.fn)f.fn===u&&(!b||f.once)&&(!d||f.context===d)&&o(this,y);else{for(var E=0,m=[],q=f.length;E<q;E++)(f[E].fn!==u||b&&!f[E].once||d&&f[E].context!==d)&&m.push(f[E]);m.length?this._events[y]=m.length===1?m[0]:m:o(this,y)}return this},l.prototype.removeAllListeners=function(c){var u;return c?(u=e?e+c:c,this._events[u]&&o(this,u)):(this._events=new s,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=e,l.EventEmitter=l,i.exports=l})(Ye);var Ms=Ye.exports,Kt=new WeakMap;const Wt=["error","warn","log","info"];let Gt="warn";function Je(i){if(Gt&&Wt.indexOf(i)<=Wt.indexOf(Gt)){for(var t=arguments.length,e=new Array(t>1?t-1:0),s=1;s<t;s++)e[s-1]=arguments[s];console[i](...e)}}function K(i){return Wt.reduce((t,e)=>(t[e]=Je.bind(console,e,i),t),{})}K.level=i=>{Gt=i};Je.level=K.level;const Pt=K("quill:events"),Bs=["selectionchange","mousedown","mouseup","click"];Bs.forEach(i=>{document.addEventListener(i,function(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];Array.from(document.querySelectorAll(".ql-container")).forEach(n=>{const r=Kt.get(n);r&&r.emitter&&r.emitter.handleDOM(...e)})})});class p extends Ms{constructor(){super(),this.domListeners={},this.on("error",Pt.error)}emit(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return Pt.log.call(Pt,...e),super.emit(...e)}handleDOM(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),n=1;n<e;n++)s[n-1]=arguments[n];(this.domListeners[t.type]||[]).forEach(r=>{let{node:o,handler:l}=r;(t.target===o||o.contains(t.target))&&l(t,...s)})}listenDOM(t,e,s){this.domListeners[t]||(this.domListeners[t]=[]),this.domListeners[t].push({node:e,handler:s})}}g(p,"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"}),g(p,"sources",{API:"api",SILENT:"silent",USER:"user"});const Ut=K("quill:selection");class tt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=t,this.length=e}}class Ds{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 tt(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,p.sources.USER),1)}),this.emitter.on(p.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;const s=this.getNativeRange();s!=null&&s.start.node!==this.cursor.textNode&&this.emitter.once(p.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(l=>l.type==="characterData"||l.type==="childList"||l.type==="attributes"&&l.target===this.root);this.update(o?p.sources.SILENT:n)}catch{}})}),this.emitter.on(p.events.SCROLL_OPTIMIZE,(s,n)=>{if(n.range){const{startNode:r,startOffset:o,endNode:l,endOffset:a}=n.range;this.setNativeRange(r,o,l,a),this.update(p.sources.SILENT)}}),this.update(p.sources.SILENT)}handleComposition(){this.emitter.on(p.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(p.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(p.sources.USER)})}focus(){this.hasFocus()||(this.root.focus(),this.setRange(this.savedRange))}format(t,e){this.scroll.update();const s=this.getNativeRange();if(!(s==null||!s.native.collapsed||this.scroll.query(t,x.BLOCK))){if(s.start.node!==this.cursor.textNode){const n=this.scroll.find(s.start.node,!1);if(n==null)return;if(n instanceof M){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[u]=this.scroll.leaf(t+1);if(u){const[d]=this.scroll.line(t),[b]=this.scroll.line(t+1);d===b&&(r=u,o=0)}}[n,o]=r.position(o,!0);const l=document.createRange();if(e>0)return l.setStart(n,o),[r,o]=this.scroll.leaf(t+e),r==null?null:([n,o]=r.position(o,!0),l.setEnd(n,o),l.getBoundingClientRect());let a="left",c;if(n instanceof Text){if(!n.data.length)return null;o<n.data.length?(l.setStart(n,o),l.setEnd(n,o+1)):(l.setStart(n,o-1),l.setEnd(n,o),a="right"),c=l.getBoundingClientRect()}else{if(!(r.domNode instanceof Element))return null;c=r.domNode.getBoundingClientRect(),o>0&&(a="right")}return{bottom:c.top+c.height,height:c.height,left:c[a],right:c[a],top:c.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 Ut.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&&Ht(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[l,a]=o,c=this.scroll.find(l,!0),u=c.offset(this.scroll);return a===0?u:c instanceof M?u+c.index(l,a):u+c.length()}),n=Math.min(Math.max(...s),this.scroll.length()-1),r=Math.min(n,...s);return new tt(r,n-r)}normalizeNative(t){if(!Ht(this.root,t.startContainer)||!t.collapsed&&!Ht(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,l]=this.scroll.leaf(n);return o?o.position(l,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(Ut.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();const{native:l}=this.getNativeRange()||{};if(l==null||r||t!==l.startContainer||e!==l.startOffset||s!==l.endContainer||n!==l.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 a=document.createRange();a.setStart(t,e),a.setEnd(s,n),o.removeAllRanges(),o.addRange(a)}}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]:p.sources.API;if(typeof e=="string"&&(s=e,e=!1),Ut.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]:p.sources.USER;const e=this.lastRange,[s,n]=this.getRange();if(this.lastRange=s,this.lastNative=n,this.lastRange!=null&&(this.savedRange=this.lastRange),!le(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=[p.events.SELECTION_CHANGE,lt(this.lastRange),lt(e),t];this.emitter.emit(p.events.EDITOR_CHANGE,...r),t!==p.sources.SILENT&&this.emitter.emit(...r)}}}function Ht(i,t){try{t.parentNode}catch{return!1}return i.contains(t)}const Ps=/^[ -~]*$/;class Us{constructor(t){this.scroll=t,this.delta=this.getDelta()}applyDelta(t){this.scroll.update();let e=this.scroll.length();this.scroll.batchStart();const s=Ee(t),n=new v;return _s(s.ops.slice()).reduce((o,l)=>{const a=B.exports.Op.length(l);let c=l.attributes||{},u=!1,d=!1;if(l.insert!=null){if(n.retain(a),typeof l.insert=="string"){const f=l.insert;d=!f.endsWith(`
`)&&(e<=o||!!this.scroll.descendant(S,o)[0]),this.scroll.insertAt(o,f);const[E,m]=this.scroll.line(o);let q=Y({},T(E));if(E instanceof N){const[L]=E.descendant(M,m);L&&(q=Y(q,T(L)))}c=B.exports.AttributeMap.diff(q,c)||{}}else if(typeof l.insert=="object"){const f=Object.keys(l.insert)[0];if(f==null)return o;const E=this.scroll.query(f,x.INLINE)!=null;if(E)(e<=o||!!this.scroll.descendant(S,o)[0])&&(d=!0);else if(o>0){const[m,q]=this.scroll.descendant(M,o-1);m instanceof D?m.value()[q]!==`
`&&(u=!0):m instanceof O&&m.statics.scope===x.INLINE_BLOT&&(u=!0)}if(this.scroll.insertAt(o,f,l.insert[f]),E){const[m]=this.scroll.descendant(M,o);if(m){const q=Y({},T(m));c=B.exports.AttributeMap.diff(q,c)||{}}}}e+=a}else if(n.push(l),l.retain!==null&&typeof l.retain=="object"){const f=Object.keys(l.retain)[0];if(f==null)return o;this.scroll.updateEmbedAt(o,f,l.retain[f])}Object.keys(c).forEach(f=>{this.scroll.formatAt(o,a,f,c[f])});const b=u?1:0,y=d?1:0;return e+=b+y,n.retain(b),n.delete(y),o+a+b+y},0),n.reduce((o,l)=>typeof l.delete=="number"?(this.scroll.deleteAt(o,l.delete),o):o+B.exports.Op.length(l),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(s)}deleteText(t,e){return this.scroll.deleteAt(t,e),this.update(new v().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 v().retain(t).retain(e,lt(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 v().retain(t).retain(e,lt(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 v)}getFormat(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=[],n=[];e===0?this.scroll.path(t).forEach(l=>{const[a]=l;a instanceof N?s.push(a):a instanceof M&&n.push(a)}):(s=this.scroll.lines(t,e),n=this.scroll.descendants(M,t,e));const[r,o]=[s,n].map(l=>{const a=l.shift();if(a==null)return{};let c=T(a);for(;Object.keys(c).length>0;){const u=l.shift();if(u==null)return c;c=Hs(T(u),c)}return c});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)?pt(s,n,e,!0):pt(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=Ee(e),n=new v().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 v().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 v().retain(t).insert(e,lt(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)!==N.blotName)return!1;const e=t;return e.children.length>1?!1:e.children.head instanceof P}removeFormat(t,e){const s=this.getText(t,e),[n,r]=this.scroll.line(t+e);let o=0,l=new v;n!=null&&(o=n.length()-r,l=n.delta().slice(r,r+o-1).insert(`
`));const c=this.getContents(t,e+o).diff(new v().insert(s).concat(l)),u=new v().retain(t).concat(c);return this.applyDelta(u)}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(Ps)&&this.scroll.find(e[0].target)){const r=this.scroll.find(e[0].target),o=T(r),l=r.offset(this.scroll),a=e[0].oldValue.replace(_.CONTENTS,""),c=new v().insert(a),u=new v().insert(r.value()),d=s&&{oldRange:qe(s.oldRange,-l),newRange:qe(s.newRange,-l)};t=new v().retain(l).concat(c.diff(u,d)).reduce((y,f)=>f.insert?y.insert(f.insert,o):y.push(f),new v),this.delta=n.compose(t)}else this.delta=this.getDelta(),(!t||!le(n.compose(t),this.delta))&&(t=n.diff(this.delta,s));return t}}function it(i,t,e){if(i.length===0){const[y]=_t(e.pop());return t<=0?`</li></${y}>`:`</li></${y}>${it([],t-1,e)}`}const[{child:s,offset:n,length:r,indent:o,type:l},...a]=i,[c,u]=_t(l);if(o>t)return e.push(l),o===t+1?`<${c}><li${u}>${pt(s,n,r)}${it(a,o,e)}`:`<${c}><li>${it(i,t+1,e)}`;const d=e[e.length-1];if(o===t&&l===d)return`</li><li${u}>${pt(s,n,r)}${it(a,o,e)}`;const[b]=_t(e.pop());return`</li></${b}>${it(i,t-1,e)}`}function pt(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 D)return Rt(i.value().slice(t,t+e));if(i instanceof St){if(i.statics.blotName==="list-container"){const c=[];return i.children.forEachAt(t,e,(u,d,b)=>{const y="formats"in u&&typeof u.formats=="function"?u.formats():{};c.push({child:u,offset:d,length:b,indent:y.indent||0,type:y.list})}),it(c,-1,[])}const n=[];if(i.children.forEachAt(t,e,(c,u,d)=>{n.push(pt(c,u,d))}),s||i.statics.blotName==="list")return n.join("");const{outerHTML:r,innerHTML:o}=i.domNode,[l,a]=r.split(`>${o}<`);return l==="<table"?`<table style="border: 1px solid #000;">${n.join("")}<${a}`:`${l}>${n.join("")}<${a}`}return i.domNode instanceof Element?i.domNode.outerHTML:""}function Hs(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 _t(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 Ee(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 v)}function qe(i,t){let{index:e,length:s}=i;return new tt(e+t,s)}function _s(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 U{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=t,this.options=e}}g(U,"DEFAULTS",{});const wt="\uFEFF";class ae extends O{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(wt),this.rightGuard=document.createTextNode(wt),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(wt).join("");if(t===this.leftGuard)if(this.prev instanceof D){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 D?(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=wt,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 Fs{constructor(t,e){g(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 ae)&&(this.emitter.emit(p.events.COMPOSITION_BEFORE_START,t),this.scroll.batchStart(),this.emitter.emit(p.events.COMPOSITION_START,t),this.isComposing=!0)}handleCompositionEnd(t){this.emitter.emit(p.events.COMPOSITION_BEFORE_END,t),this.scroll.batchEnd(),this.emitter.emit(p.events.COMPOSITION_END,t),this.isComposing=!1}}const ye=class{constructor(t,e){g(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]}};let Z=ye;g(Z,"DEFAULTS",{modules:{}}),g(Z,"themes",{default:ye});const $s=i=>i.parentElement||i.getRootNode().host||null,js=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}},Nt=i=>{const t=parseInt(i,10);return Number.isNaN(t)?0:t},we=(i,t,e,s,n,r)=>i<e&&t>s?0:i<e?-(e-i+n):t>s?t-i>s-e?i+n-e:t-s+r:0,zs=(i,t)=>{var r,o,l,a,c;const e=i.ownerDocument;let s=t,n=i;for(;n;){const u=n===e.body,d=u?{top:0,right:(o=(r=window.visualViewport)==null?void 0:r.width)!=null?o:e.documentElement.clientWidth,bottom:(a=(l=window.visualViewport)==null?void 0:l.height)!=null?a:e.documentElement.clientHeight,left:0}:js(n),b=getComputedStyle(n),y=we(s.left,s.right,d.left,d.right,Nt(b.scrollPaddingLeft),Nt(b.scrollPaddingRight)),f=we(s.top,s.bottom,d.top,d.bottom,Nt(b.scrollPaddingTop),Nt(b.scrollPaddingBottom));if(y||f)if(u)(c=e.defaultView)==null||c.scrollBy(y,f);else{const{scrollLeft:E,scrollTop:m}=n;f&&(n.scrollTop+=f),y&&(n.scrollLeft+=y);const q=n.scrollLeft-E,L=n.scrollTop-m;s={left:s.left-q,top:s.top-L,right:s.right-q,bottom:s.bottom-L}}n=u||b.position==="fixed"?null:$s(n)}},Vs=100,Ks=["block","break","cursor","inline","scroll","text"],Ws=(i,t,e)=>{const s=new Ge;return Ks.forEach(n=>{const r=t.query(n);r&&s.register(r)}),i.forEach(n=>{var l;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&&(l=r.requiredContainer)!=null?l:null,o+=1,o>Vs){e.error(`Cycle detected in registering blot requiredContainer: "${n}"`);break}}),s},at=K("quill"),kt=new Ge;St.uiClass="ql-ui";const ot=class{static debug(t){t===!0&&(t="log"),K.level(t)}static find(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Kt.get(t)||kt.find(t,e)}static import(t){return this.imports[t]==null&&at.error(`Cannot import ${t}. Are you sure it was registered?`),this.imports[t]}static register(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(typeof t!="string"){const n="attrName"in t?t.attrName:t.blotName;typeof n=="string"?this.register(`formats/${n}`,t,e):Object.keys(t).forEach(r=>{this.register(r,t[r],e)})}else this.imports[t]!=null&&!s&&at.warn(`Overwriting ${t} with`,e),this.imports[t]=e,(t.startsWith("blots/")||t.startsWith("formats/"))&&e&&typeof e!="boolean"&&e.blotName!=="abstract"&&kt.register(e),typeof e.register=="function"&&e.register(kt)}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=Gs(t,e),this.container=this.options.container,this.container==null){at.error("Invalid Quill container",t);return}this.options.debug&&ot.debug(this.options.debug);const s=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",Kt.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new p;const n=Ze.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 Us(this.scroll),this.selection=new Ds(this.scroll,this.emitter),this.composition=new Fs(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(p.events.COMPOSITION_START,()=>{this.root.classList.toggle("ql-blank",!1)}),this.emitter.on(p.events.COMPOSITION_END,()=>{this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(p.events.EDITOR_CHANGE,o=>{o===p.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(p.events.SCROLL_UPDATE,(o,l)=>{const a=this.selection.lastRange,[c]=this.selection.getRange(),u=a&&c?{oldRange:a,newRange:c}:void 0;R.call(this,()=>this.editor.update(null,l,u),o)}),this.emitter.on(p.events.SCROLL_EMBED_UPDATE,(o,l)=>{const a=this.selection.lastRange,[c]=this.selection.getRange(),u=a&&c?{oldRange:a,newRange:c}:void 0;R.call(this,()=>{const d=new v().retain(o.offset(this)).retain({[o.statics.blotName]:l});return this.editor.update(d,[],u)},ot.sources.USER)}),s){const o=this.clipboard.convert({html:`${s}<p><br></p>`,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]=$(t,e,s),R.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(){this.selection.focus(),this.scrollSelectionIntoView()}format(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:p.sources.API;return R.call(this,()=>{const n=this.getSelection(!0);let r=new v;if(n==null)return r;if(this.scroll.query(t,x.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,p.sources.SILENT),r},s)}formatLine(t,e,s,n,r){let o;return[t,e,o,r]=$(t,e,s,n,r),R.call(this,()=>this.editor.formatLine(t,e,o),r,t,0)}formatText(t,e,s,n,r){let o;return[t,e,o,r]=$(t,e,s,n,r),R.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]=$(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!=null?e:this.getLength()-t),[t,e]=$(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!=null?e:this.getLength()-t),[t,e]=$(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]:ot.sources.API;return R.call(this,()=>this.editor.insertEmbed(t,e,s),n,t)}insertText(t,e,s,n,r){let o;return[t,,o,r]=$(t,0,s,n,r),R.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]=$(t,e,s),R.call(this,()=>this.editor.removeFormat(t,e),s,t)}scrollRectIntoView(t){zs(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]:p.sources.API;return R.call(this,()=>{t=new v(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||ot.sources.API):([t,e,,s]=$(t,e,s),this.selection.setRange(new tt(Math.max(0,t),e),s),s!==p.sources.SILENT&&this.scrollSelectionIntoView())}setText(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p.sources.API;const s=new v().insert(t);return this.setContents(s,e)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p.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]:p.sources.API;return R.call(this,()=>(t=new v(t),this.editor.applyDelta(t)),e,!0)}};let h=ot;g(h,"DEFAULTS",{bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:kt,theme:"default"}),g(h,"events",p.events),g(h,"sources",p.sources),g(h,"version","2.0.0"),g(h,"imports",{delta:v,parchment:Rs,"core/module":U,"core/theme":Z});function Ne(i){return typeof i=="string"?document.querySelector(i):i}function Ft(i){return Object.entries(i!=null?i:{}).reduce((t,e)=>{let[s,n]=e;return{...t,[s]:n===!0?{}:n}},{})}function ke(i){return Object.fromEntries(Object.entries(i).filter(t=>t[1]!==void 0))}function Gs(i,t){const e=Ne(i);if(!e)throw new Error("Invalid Quill container");const n=!t.theme||t.theme===h.DEFAULTS.theme?Z:h.import(`themes/${t.theme}`);if(!n)throw new Error(`Invalid theme ${t.theme}. Did you register it?`);const{modules:r,...o}=h.DEFAULTS,{modules:l,...a}=n.DEFAULTS,c=Y({},Ft(r),Ft(l),Ft(t.modules));c!=null&&c.toolbar&&c.toolbar.constructor!==Object&&(c.toolbar={container:c.toolbar});const u={...o,...ke(a),...ke(t)};let d=t.registry;return d?t.formats&&at.warn('Ignoring "formats" option because "registry" is specified'):d=t.formats?Ws(t.formats,u.registry,at):u.registry,{...u,registry:d,container:e,theme:n,modules:Object.entries(c).reduce((b,y)=>{let[f,E]=y;if(!E)return b;const m=h.import(`modules/${f}`);return m==null?(at.error(`Cannot load ${f} module. Are you sure you registered it?`),b):{...b,[f]:Y({},m.DEFAULTS||{},E)}},{}),bounds:Ne(u.bounds)}}function R(i,t,e,s){if(!this.isEnabled()&&t===p.sources.USER&&!this.allowReadOnlyEdits)return new v;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=Le(n,o,t):s!==0&&(n=Le(n,e,s,t)),this.setSelection(n,p.sources.SILENT)),o.length()>0){const l=[p.events.TEXT_CHANGE,o,r,t];this.emitter.emit(p.events.EDITOR_CHANGE,...l),t!==p.sources.SILENT&&this.emitter.emit(...l)}return o}function $(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||p.sources.API,[i,t,r,n]}function Le(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(l=>t.transformPosition(l,s!==p.sources.USER)):[r,o]=[i.index,i.index+i.length].map(l=>l<t||l===t&&s===p.sources.USER?l:n>=0?l+n:Math.max(t,l+n)),new tt(r,o-r)}class et extends Xe{}function Ce(i){return i instanceof N||i instanceof S}function Te(i){return typeof i.updateContent=="function"}class rt extends Ze{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(p.events.SCROLL_BLOT_MOUNT,t)}emitUnmount(t){this.emitter.emit(p.events.SCROLL_BLOT_UNMOUNT,t)}emitEmbedUpdate(t,e){this.emitter.emit(p.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 S||r instanceof S){this.optimize();return}const o=r.children.head instanceof P?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,x.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===x.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 v().insert(`
`))),n=s.pop();if(n==null)return;this.batchStart();const r=s.shift();if(r){const a=r.type==="block"&&(r.delta.length()===0||!this.descendant(S,t)[0]&&t<this.length()),c=r.type==="block"?r.delta:new v().insert({[r.key]:r.value});$t(this,t,c);const u=r.type==="block"?1:0,d=t+c.length()+u;a&&this.insertAt(d-1,`
`);const b=T(this.line(t)[0]),y=B.exports.AttributeMap.diff(b,r.attributes)||{};Object.keys(y).forEach(f=>{this.formatAt(d-1,1,f,y[f])}),t=d}let[o,l]=this.children.find(t);if(s.length&&(o&&(o=o.split(l),l=0),s.forEach(a=>{if(a.type==="block"){const c=this.createBlock(a.attributes,o||void 0);$t(c,0,a.delta)}else{const c=this.create(a.key,a.value);this.insertBefore(c,o||void 0),Object.keys(a.attributes).forEach(u=>{c.format(u,a.attributes[u])})}})),n.type==="block"&&n.delta.length()){const a=o?o.offset(o.scroll)+l:this.length();$t(this,a,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 M?[s,n]:[null,-1]}line(t){return t===this.length()?this.line(t-1):this.descendant(Ce,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 l=[],a=o;return n.children.forEachAt(r,o,(c,u,d)=>{Ce(c)?l.push(c):c instanceof Xe&&(l=l.concat(s(c,u,a))),a-=d}),l};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(p.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=p.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&&!Te(r)}),t.length>0&&this.emitter.emit(p.events.SCROLL_BEFORE_UPDATE,e,t),super.update(t.concat([])),t.length>0&&this.emitter.emit(p.events.SCROLL_UPDATE,e,t)}updateEmbedAt(t,e,s){const[n]=this.descendant(r=>r instanceof S,t);n&&n.statics.blotName===e&&Te(n)&&n.updateContent(s)}handleDragStart(t){t.preventDefault()}deltaToRenderBlocks(t){const e=[];let s=new v;return t.forEach(n=>{var o;const r=n==null?void 0:n.insert;if(!!r)if(typeof r=="string"){const l=r.split(`
`);l.slice(0,-1).forEach(c=>{var u;s.insert(c,n.attributes),e.push({type:"block",delta:s,attributes:(u=n.attributes)!=null?u:{}}),s=new v});const a=l[l.length-1];a&&s.insert(a,n.attributes)}else{const l=Object.keys(r)[0];if(!l)return;this.query(l,x.INLINE)?s.push(n):(s.length()&&e.push({type:"block",delta:s,attributes:{}}),s=new v,e.push({type:"blockEmbed",key:l,value:r[l],attributes:(o=n.attributes)!=null?o:{}}))}}),s.length()&&e.push({type:"block",delta:s,attributes:{}}),e}createBlock(t,e){let s;const n={};Object.entries(t).forEach(l=>{let[a,c]=l;this.query(a,x.BLOCK&x.BLOT)!=null?s=a:n[a]=c});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(l=>{let[a,c]=l;r.formatAt(0,o,a,c)}),r}}g(rt,"blotName","scroll"),g(rt,"className","ql-editor"),g(rt,"tagName","DIV"),g(rt,"defaultChild",N),g(rt,"allowedChildren",[N,S,et]);function $t(i,t,e){e.reduce((s,n)=>{const r=B.exports.Op.length(n);let o=n.attributes||{};if(n.insert!=null){if(typeof n.insert=="string"){const l=n.insert;i.insertAt(s,l);const[a]=i.descendant(M,s),c=T(a);o=B.exports.AttributeMap.diff(c,o)||{}}else if(typeof n.insert=="object"){const l=Object.keys(n.insert)[0];if(l==null)return s;if(i.insertAt(s,l,n.insert[l]),i.scroll.query(l,x.INLINE)!=null){const[c]=i.descendant(M,s),u=T(c);o=B.exports.AttributeMap.diff(u,o)||{}}}}return Object.keys(o).forEach(l=>{i.formatAt(s,r,l,o[l])}),s+r},t)}const ce={scope:x.BLOCK,whitelist:["right","center","justify"]},Zs=new oe("align","align",ce),ts=new V("align","ql-align",ce),es=new ht("align","text-align",ce);class ss extends ht{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 Xs=new V("color","ql-color",{scope:x.INLINE}),ue=new ss("color","color",{scope:x.INLINE}),Qs=new V("background","ql-bg",{scope:x.INLINE}),he=new ss("background","background-color",{scope:x.INLINE});class st extends et{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`<pre>
${Rt(this.code(t,e))}
</pre>`}}class k extends N{static register(){h.register(st)}}g(k,"TAB"," ");class de extends I{}de.blotName="code";de.tagName="CODE";k.blotName="code-block";k.className="ql-code-block";k.tagName="DIV";st.blotName="code-block-container";st.className="ql-code-block-container";st.tagName="DIV";st.allowedChildren=[k];k.allowedChildren=[D,P,_];k.requiredContainer=st;const fe={scope:x.BLOCK,whitelist:["rtl"]},ns=new oe("direction","dir",fe),is=new V("direction","ql-direction",fe),rs=new ht("direction","direction",fe),os={scope:x.INLINE,whitelist:["serif","monospace"]},ls=new V("font","ql-font",os);class Ys extends ht{value(t){return super.value(t).replace(/["']/g,"")}}const as=new Ys("font","font-family",os),cs=new V("size","ql-size",{scope:x.INLINE,whitelist:["small","large","huge"]}),us=new ht("size","font-size",{scope:x.INLINE,whitelist:["10px","18px","32px"]}),Js=K("quill:keyboard"),tn=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey";class Mt extends U{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=sn(t);if(n==null){Js.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 l={...n,key:o,...e,...s};this.bindings[l.key]=this.bindings[l.key]||[],this.bindings[l.key].push(l)})}listen(){this.quill.root.addEventListener("keydown",t=>{if(t.defaultPrevented||t.isComposing)return;const s=(this.bindings[t.key]||[]).concat(this.bindings[t.which]||[]).filter(m=>Mt.match(t,m));if(s.length===0)return;const n=h.find(t.target,!0);if(n&&n.scroll!==this.quill.scroll)return;const r=this.quill.getSelection();if(r==null||!this.quill.hasFocus())return;const[o,l]=this.quill.getLine(r.index),[a,c]=this.quill.getLeaf(r.index),[u,d]=r.length===0?[a,c]:this.quill.getLeaf(r.index+r.length),b=a instanceof Vt?a.value().slice(0,c):"",y=u instanceof Vt?u.value().slice(d):"",f={collapsed:r.length===0,empty:r.length===0&&o.length()<=1,format:this.quill.getFormat(r),line:o,offset:l,prefix:b,suffix:y,event:t};s.some(m=>{if(m.collapsed!=null&&m.collapsed!==f.collapsed||m.empty!=null&&m.empty!==f.empty||m.offset!=null&&m.offset!==f.offset)return!1;if(Array.isArray(m.format)){if(m.format.every(q=>f.format[q]==null))return!1}else if(typeof m.format=="object"&&!Object.keys(m.format).every(q=>m.format[q]===!0?f.format[q]!=null:m.format[q]===!1?f.format[q]==null:le(m.format[q],f.format[q])))return!1;return m.prefix!=null&&!m.prefix.test(f.prefix)||m.suffix!=null&&!m.suffix.test(f.suffix)?!1:m.handler.call(this,r,f,m)!==!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 v().retain(t.index-s).delete(s);if(e.offset===0){const[l]=this.quill.getLine(t.index-1);if(l&&!(l.statics.blotName==="block"&&l.length()<=1)){const c=r.formats(),u=this.quill.getFormat(t.index-1,1);if(n=B.exports.AttributeMap.diff(c,u)||{},Object.keys(n).length>0){const d=new v().retain(t.index+r.length()-2).retain(1,n);o=o.compose(d)}}}this.quill.updateContents(o,h.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 v().retain(t.index).delete(s);if(e.offset>=r.length()-1){const[l]=this.quill.getLine(t.index+1);if(l){const a=r.formats(),c=this.quill.getFormat(t.index,1);n=B.exports.AttributeMap.diff(a,c)||{},Object.keys(n).length>0&&(o=o.retain(l.length()-1).retain(1,n))}}this.quill.updateContents(o,h.sources.USER),this.quill.focus()}handleDeleteRange(t){me({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,x.BLOCK)&&!Array.isArray(e.format[o])&&(r[o]=e.format[o]),r),{}),n=new v().retain(t.index).delete(t.length).insert(`
`,s);this.quill.updateContents(n,h.sources.USER),this.quill.setSelection(t.index+1,h.sources.SILENT),this.quill.focus()}}const en={bindings:{bold:jt("bold"),italic:jt("italic"),underline:jt("underline"),indent:{key:"Tab",format:["blockquote","indent","list"],handler(i,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","+1",h.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",h.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",h.sources.USER):t.format.list!=null&&this.quill.format("list",!1,h.sources.USER)}},"indent code-block":Ae(!0),"outdent code-block":Ae(!1),"remove tab":{key:"Tab",shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(i){this.quill.deleteText(i.index-1,1,h.sources.USER)}},tab:{key:"Tab",handler(i,t){if(t.format.table)return!0;this.quill.history.cutoff();const e=new v().retain(i.index).delete(i.length).insert(" ");return this.quill.updateContents(e,h.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(i.index+1,h.sources.SILENT),!1}},"blockquote empty enter":{key:"Enter",collapsed:!0,format:["blockquote"],empty:!0,handler(){this.quill.format("blockquote",!1,h.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,h.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 v().retain(i.index).insert(`
`,s).retain(t.length()-e-1).retain(1,{list:"unchecked"});this.quill.updateContents(n,h.sources.USER),this.quill.setSelection(i.index+1,h.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 v().retain(i.index).insert(`
`,t.format).retain(e.length()-s-1).retain(1,{header:null});this.quill.updateContents(n,h.sources.USER),this.quill.setSelection(i.index+1,h.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=nn(e,s,n,r);if(o==null)return;let l=e.offset();if(o<0){const a=new v().retain(l).insert(`
`);this.quill.updateContents(a,h.sources.USER),this.quill.setSelection(i.index+1,i.length,h.sources.SILENT)}else if(o>0){l+=e.length();const a=new v().retain(l).insert(`
`);this.quill.updateContents(a,h.sources.USER),this.quill.setSelection(l,h.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,h.sources.USER):this.quill.setSelection(n+s.length(),h.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," ",h.sources.USER),this.quill.history.cutoff();const o=new v().retain(i.index-n).delete(e+1).retain(s.length()-2-n).retain(1,{list:r});return this.quill.updateContents(o,h.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(i.index-e,h.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 v().retain(i.index+t.length()-e-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(r,h.sources.USER),this.quill.setSelection(i.index-1,h.sources.SILENT),!1}return!0}},"embed left":Lt("ArrowLeft",!1),"embed left shift":Lt("ArrowLeft",!0),"embed right":Lt("ArrowRight",!1),"embed right shift":Lt("ArrowRight",!0),"table down":Se(!1),"table up":Se(!0)}};Mt.DEFAULTS=en;function Ae(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,h.sources.USER),this.quill.setSelection(t.index+r.length,h.sources.SILENT);return}const o=t.length===0?this.quill.getLines(t.index,1):this.quill.getLines(t);let{index:l,length:a}=t;o.forEach((c,u)=>{i?(c.insertAt(0,r),u===0?l+=r.length:a+=r.length):c.domNode.textContent.startsWith(r)&&(c.deleteAt(0,r.length),u===0?l-=r.length:a-=r.length)}),this.quill.update(h.sources.USER),this.quill.setSelection(l,a,h.sources.SILENT)}}}function Lt(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 O?(i==="ArrowLeft"?t?this.quill.setSelection(s.index-1,s.length+1,h.sources.USER):this.quill.setSelection(s.index-1,h.sources.USER):t?this.quill.setSelection(s.index,s.length+1,h.sources.USER):this.quill.setSelection(s.index+s.length+1,h.sources.USER),!1):!0}}}function jt(i){return{key:i[0],shortKey:!0,handler(t,e){this.quill.format(i,!e.format[i],h.sources.USER)}}}function Se(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,l=n;for(;l.prev!=null;)l=l.prev,o=o.next;const a=o.offset(this.quill.scroll)+Math.min(e.offset,o.length()-1);this.quill.setSelection(a,0,h.sources.USER)}}else{const o=n.table()[s];o!=null&&(i?this.quill.setSelection(o.offset(this.quill.scroll)+o.length()-1,0,h.sources.USER):this.quill.setSelection(o.offset(this.quill.scroll),0,h.sources.USER))}return!1}}}function sn(i){if(typeof i=="string"||typeof i=="number")i={key:i};else if(typeof i=="object")i=lt(i);else return null;return i.shortKey&&(i[tn]=i.shortKey,delete i.shortKey),i}function me(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=B.exports.AttributeMap.diff(o,r)||{}}t.deleteText(e,h.sources.USER),Object.keys(n).length>0&&t.formatLine(e.index,1,n,h.sources.USER),t.setSelection(e.index,h.sources.SILENT)}function nn(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 rn=/font-weight:\s*normal/,on=["P","OL","UL"],Ie=i=>i&&on.includes(i.tagName),ln=i=>{Array.from(i.querySelectorAll("br")).filter(t=>Ie(t.previousElementSibling)&&Ie(t.nextElementSibling)).forEach(t=>{var e;(e=t.parentNode)==null||e.removeChild(t)})},an=i=>{Array.from(i.querySelectorAll('b[style*="font-weight"]')).filter(t=>{var e;return(e=t.getAttribute("style"))==null?void 0:e.match(rn)}).forEach(t=>{var s;const e=i.createDocumentFragment();e.append(...t.childNodes),(s=t.parentNode)==null||s.replaceChild(e,t)})};function cn(i){i.querySelector('[id^="docs-internal-guid-"]')&&(an(i),ln(i))}const un=/\bmso-list:[^;]*ignore/i,hn=/\bmso-list:[^;]*\bl(\d+)/i,dn=/\bmso-list:[^;]*\blevel(\d+)/i,fn=(i,t)=>{const e=i.getAttribute("style"),s=e==null?void 0:e.match(hn);if(!s)return null;const n=Number(s[1]),r=e==null?void 0:e.match(dn),o=r?Number(r[1]):1,l=new RegExp(`@list l${n}:level${o}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,"i"),a=t.match(l),c=a&&a[1]==="bullet"?"bullet":"ordered";return{id:n,indent:o,type:c,element:i}},mn=i=>{var o,l;const t=Array.from(i.querySelectorAll("[style*=mso-list]")),e=[],s=[];t.forEach(a=>{(a.getAttribute("style")||"").match(un)?e.push(a):s.push(a)}),e.forEach(a=>{var c;return(c=a.parentNode)==null?void 0:c.removeChild(a)});const n=i.documentElement.innerHTML,r=s.map(a=>fn(a,n)).filter(a=>a);for(;r.length;){const a=[];let c=r.shift();for(;c;)a.push(c),c=r.length&&((o=r[0])==null?void 0:o.element)===c.element.nextElementSibling&&r[0].id===c.id?r.shift():null;const u=document.createElement("ul");a.forEach(y=>{const f=document.createElement("li");f.setAttribute("data-list",y.type),y.indent>1&&f.setAttribute("class",`ql-indent-${y.indent-1}`),f.innerHTML=y.element.innerHTML,u.appendChild(f)});const d=(l=a[0])==null?void 0:l.element,{parentNode:b}=d!=null?d:{};d&&(b==null||b.replaceChild(u,d)),a.slice(1).forEach(y=>{let{element:f}=y;b==null||b.removeChild(f)})}};function gn(i){i.documentElement.getAttribute("xmlns:w")==="urn:schemas-microsoft-com:office:word"&&mn(i)}const pn=[gn,cn],bn=i=>{i.documentElement&&pn.forEach(t=>{t(i)})},yn=K("quill:clipboard"),vn=[[Node.TEXT_NODE,In],[Node.TEXT_NODE,Re],["br",Nn],[Node.ELEMENT_NODE,Re],[Node.ELEMENT_NODE,wn],[Node.ELEMENT_NODE,qn],[Node.ELEMENT_NODE,An],["li",Cn],["ol, ul",Tn],["pre",kn],["tr",Sn],["b",zt("bold")],["i",zt("italic")],["strike",zt("strike")],["style",Ln]],xn=[Zs,ns].reduce((i,t)=>(i[t.keyName]=t,i),{}),Oe=[es,he,ue,rs,as,us].reduce((i,t)=>(i[t.keyName]=t,i),{});class hs extends U{constructor(t,e){var s;super(t,e),this.quill.root.addEventListener("copy",n=>this.onCaptureCopy(n,!1)),this.quill.root.addEventListener("cut",n=>this.onCaptureCopy(n,!0)),this.quill.root.addEventListener("paste",this.onCapturePaste.bind(this)),this.matchers=[],vn.concat((s=this.options.matchers)!=null?s:[]).forEach(n=>{let[r,o]=n;this.addMatcher(r,o)})}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[k.blotName])return new v().insert(s||"",{[k.blotName]:n[k.blotName]});if(!e)return new v().insert(s||"",n);const r=this.convertHTML(e);return vt(r,`
`)&&(r.ops[r.ops.length-1].attributes==null||n.table)?r.compose(new v().retain(r.length()-1).delete(1)):r}normalizeHTML(t){bn(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 ge(this.quill.scroll,s,r,o,n)}dangerouslyPasteHTML(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:h.sources.API;if(typeof t=="string"){const n=this.convert({html:t,text:""});this.quill.setContents(n,e),this.quill.setSelection(0,h.sources.SILENT)}else{const n=this.convert({html:e,text:""});this.quill.updateContents(new v().retain(t).concat(n),s),this.quill.setSelection(t+n.length(),h.sources.SILENT)}}onCaptureCopy(t){var o,l;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),(l=t.clipboardData)==null||l.setData("text/html",n),e&&me({range:s,quill:this.quill})}normalizeURIList(t){return t.split(/\r?\n/).filter(e=>e[0]!=="#").join(`
`)}onCapturePaste(t){var o,l,a,c,u;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=(l=t.clipboardData)==null?void 0:l.getData("text/plain");if(!s&&!n){const d=(a=t.clipboardData)==null?void 0:a.getData("text/uri-list");d&&(n=this.normalizeURIList(d))}const r=Array.from(((c=t.clipboardData)==null?void 0:c.files)||[]);if(!s&&r.length>0){this.quill.uploader.upload(e,r);return}if(s&&r.length>0){const d=new DOMParser().parseFromString(s,"text/html");if(d.body.childElementCount===1&&((u=d.body.firstElementChild)==null?void 0:u.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);yn.log("onPaste",o,{text:s,html:n});const l=new v().retain(t.index).delete(t.length).concat(o);this.quill.updateContents(l,h.sources.USER),this.quill.setSelection(l.length()-t.length,h.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(t,e){const s=[],n=[];return this.matchers.forEach(r=>{const[o,l]=r;switch(o){case Node.TEXT_NODE:n.push(l);break;case Node.ELEMENT_NODE:s.push(l);break;default:Array.from(t.querySelectorAll(o)).forEach(a=>{if(e.has(a)){const c=e.get(a);c==null||c.push(l)}else e.set(a,[l])});break}}),[s,n]}}g(hs,"DEFAULTS",{matchers:[]});function nt(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 v):i}function vt(i,t){let e="";for(let s=i.ops.length-1;s>=0&&e.length<t.length;--s){const n=i.ops[s];if(typeof n.insert!="string")break;e=n.insert+e}return e.slice(-1*t.length)===t}function X(i,t){if(!(i instanceof Element))return!1;const e=t.query(i);return e&&e.prototype instanceof O?!1:["address","article","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","iframe","li","main","nav","ol","output","p","pre","section","table","td","tr","ul","video"].includes(i.tagName.toLowerCase())}function En(i,t){return i.previousElementSibling&&i.nextElementSibling&&!X(i.previousElementSibling,t)&&!X(i.nextElementSibling,t)}const Ct=new WeakMap;function ds(i){return i==null?!1:(Ct.has(i)||(i.tagName==="PRE"?Ct.set(i,!0):Ct.set(i,ds(i.parentNode))),Ct.get(i))}function ge(i,t,e,s,n){return t.nodeType===t.TEXT_NODE?s.reduce((r,o)=>o(t,r,i),new v):t.nodeType===t.ELEMENT_NODE?Array.from(t.childNodes||[]).reduce((r,o)=>{let l=ge(i,o,e,s,n);return o.nodeType===t.ELEMENT_NODE&&(l=e.reduce((a,c)=>c(o,a,i),l),l=(n.get(o)||[]).reduce((a,c)=>c(o,a,i),l)),r.concat(l)},new v):new v}function zt(i){return(t,e,s)=>nt(e,i,!0,s)}function qn(i,t,e){const s=oe.keys(i),n=V.keys(i),r=ht.keys(i),o={};return s.concat(n).concat(r).forEach(l=>{let a=e.query(l,x.ATTRIBUTE);a!=null&&(o[a.attrName]=a.value(i),o[a.attrName])||(a=xn[l],a!=null&&(a.attrName===l||a.keyName===l)&&(o[a.attrName]=a.value(i)||void 0),a=Oe[l],a!=null&&(a.attrName===l||a.keyName===l)&&(a=Oe[l],o[a.attrName]=a.value(i)||void 0))}),Object.entries(o).reduce((l,a)=>{let[c,u]=a;return nt(l,c,u,e)},t)}function wn(i,t,e){const s=e.query(i);if(s==null)return t;if(s.prototype instanceof O){const n={},r=s.value(i);if(r!=null)return n[s.blotName]=r,new v().insert(n,s.formats(i,e))}else if(s.prototype instanceof We&&!vt(t,`
`)&&t.insert(`
`),"blotName"in s&&"formats"in s&&typeof s.formats=="function")return nt(t,s.blotName,s.formats(i,e),e);return t}function Nn(i,t){return vt(t,`
`)||t.insert(`
`),t}function kn(i,t,e){const s=e.query("code-block"),n=s&&"formats"in s&&typeof s.formats=="function"?s.formats(i,e):!0;return nt(t,"code-block",n,e)}function Ln(){return new v}function Cn(i,t,e){const s=e.query(i);if(s==null||s.blotName!=="list"||!vt(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,l)=>l.insert?l.attributes&&typeof l.attributes.indent=="number"?o.push(l):o.insert(l.insert,{indent:n,...l.attributes||{}}):o,new v)}function Tn(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"),nt(t,"list",n,e)}function Re(i,t,e){if(!vt(t,`
`)){if(X(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(X(s,e))return t.insert(`
`);const n=e.query(s);if(n&&n.prototype instanceof S)return t.insert(`
`);s=s.firstChild}}}return t}function An(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?void 0:r.startsWith("bold"))||parseInt(n.fontWeight,10)>=700)&&(s.bold=!0),t=Object.entries(s).reduce((o,l)=>{let[a,c]=l;return nt(o,a,c,e)},t),parseFloat(n.textIndent||0)>0?new v().insert(" ").concat(t):t}function Sn(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 l=Array.from(s.querySelectorAll("tr")).indexOf(i)+1;return nt(t,"table",l,e)}return t}function In(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(!ds(i)){if(s.trim().length===0&&s.includes(`
`)&&!En(i,e))return t;const r=(o,l)=>{const a=l.replace(/[^\u00a0]/g,"");return a.length<1&&o?" ":a};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&&X(i.parentElement,e)||i.previousSibling instanceof Element&&X(i.previousSibling,e))&&(s=s.replace(/^\s+/,r.bind(r,!1))),(i.nextSibling==null&&i.parentElement!=null&&X(i.parentElement,e)||i.nextSibling instanceof Element&&X(i.nextSibling,e))&&(s=s.replace(/\s+$/,r.bind(r,!1)))}return t.insert(s)}class fs extends U{constructor(e,s){super(e,s);g(this,"lastRecorded",0);g(this,"ignoreChange",!1);g(this,"stack",{undo:[],redo:[]});g(this,"currentRange",null);this.quill.on(h.events.EDITOR_CHANGE,(n,r,o,l)=>{n===h.events.SELECTION_CHANGE?r&&l!==h.sources.SILENT&&(this.currentRange=r):n===h.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||l===h.sources.USER?this.record(r,o):this.transform(r)),this.currentRange=Zt(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:Zt(n.range,o)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(n.delta,h.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 l=this.stack.undo.pop();l&&(n=n.compose(l.delta),r=l.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){Me(this.stack.undo,e),Me(this.stack.redo,e)}undo(){this.change("undo","redo")}restoreSelection(e){if(e.range)this.quill.setSelection(e.range,h.sources.USER);else{const s=Rn(this.quill.scroll,e.delta);this.quill.setSelection(s,h.sources.USER)}}}g(fs,"DEFAULTS",{delay:1e3,maxStack:100,userOnly:!1});function Me(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&&Zt(n.range,e)},e=n.delta.transform(e),i[s].delta.length()===0&&i.splice(s,1)}}function On(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,x.BLOCK)!=null):!1}function Rn(i,t){const e=t.reduce((n,r)=>n+(r.delete||0),0);let s=t.length()-e;return On(i,t)&&(s-=1),s}function Zt(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 ms extends U{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 l=document.caretPositionFromPoint(s.clientX,s.clientY);n=document.createRange(),n.setStart(l.offsetNode,l.offset),n.setEnd(l.offsetNode,l.offset)}const r=n&&t.selection.normalizeNative(n);if(r){const l=t.selection.normalizedToRange(r);(o=s.dataTransfer)!=null&&o.files&&this.upload(l,s.dataTransfer.files)}})}upload(t,e){const s=[];Array.from(e).forEach(n=>{var r;n&&((r=this.options.mimetypes)==null?void 0:r.includes(n.type))&&s.push(n)}),s.length>0&&this.options.handler.call(this,t,s)}}ms.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(i,t){const e=t.map(s=>new Promise(n=>{const r=new FileReader;r.onload=o=>{n(o.target.result)},r.readAsDataURL(s)}));Promise.all(e).then(s=>{const n=s.reduce((r,o)=>r.insert({image:o}),new v().retain(i.index).delete(i.length));this.quill.updateContents(n,p.sources.USER),this.quill.setSelection(i.index+s.length,p.sources.SILENT)})}};const Mn=["insertText","insertReplacementText"];class Bn extends U{constructor(t,e){super(t,e),t.root.addEventListener("beforeinput",s=>{this.handleBeforeInput(s)}),/Android/i.test(navigator.userAgent)||t.on(h.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(t){me({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 v().retain(t.index).insert(e,s),h.sources.USER)}else this.deleteRange(t);return this.quill.setSelection(t.index+e.length,0,h.sources.SILENT),!0}handleBeforeInput(t){if(this.quill.composition.isComposing||t.defaultPrevented||!Mn.includes(t.inputType))return;const e=t.getTargetRanges?t.getTargetRanges()[0]:null;if(!e||e.collapsed===!0)return;const s=Dn(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 Dn(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 Pn=/Mac/i.test(navigator.platform),Un=100,Hn=i=>!!(i.key==="ArrowLeft"||i.key==="ArrowRight"||i.key==="ArrowUp"||i.key==="ArrowDown"||i.key==="Home"||Pn&&i.key==="a"&&i.ctrlKey===!0);class _n extends U{constructor(e,s){super(e,s);g(this,"isListening",!1);g(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 St)||!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),h.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",e=>{!e.defaultPrevented&&Hn(e)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){if(this.selectionChangeDeadline=Date.now()+Un,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 St)||!n.uiNode)return;const r=document.createRange();r.setStartAfter(n.uiNode),r.setEndAfter(n.uiNode),e.removeAllRanges(),e.addRange(r)}}h.register({"blots/block":N,"blots/block/embed":S,"blots/break":P,"blots/container":et,"blots/cursor":_,"blots/embed":ae,"blots/inline":I,"blots/scroll":rt,"blots/text":D,"modules/clipboard":hs,"modules/history":fs,"modules/keyboard":Mt,"modules/uploader":ms,"modules/input":Bn,"modules/uiNode":_n});class Fn extends V{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 $n=new Fn("indent","ql-indent",{scope:x.BLOCK,whitelist:[1,2,3,4,5,6,7,8]});class Xt extends N{}g(Xt,"blotName","blockquote"),g(Xt,"tagName","blockquote");class Qt extends N{static formats(t){return this.tagName.indexOf(t.tagName)+1}}g(Qt,"blotName","header"),g(Qt,"tagName",["H1","H2","H3","H4","H5","H6"]);class xt extends et{}xt.blotName="list-container";xt.tagName="OL";class Et extends N{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(){h.register(xt)}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)}}Et.blotName="list";Et.tagName="LI";xt.allowedChildren=[Et];Et.requiredContainer=xt;class bt extends I{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)}}g(bt,"blotName","bold"),g(bt,"tagName",["STRONG","B"]);class Yt extends bt{}g(Yt,"blotName","italic"),g(Yt,"tagName",["EM","I"]);class Q extends I{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 gs(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))}}g(Q,"blotName","link"),g(Q,"tagName","A"),g(Q,"SANITIZED_URL","about:blank"),g(Q,"PROTOCOL_WHITELIST",["http","https","mailto","tel","sms"]);function gs(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 Jt extends I{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"}}g(Jt,"blotName","script"),g(Jt,"tagName",["SUB","SUP"]);class te extends bt{}g(te,"blotName","strike"),g(te,"tagName",["S","STRIKE"]);class ee extends I{}g(ee,"blotName","underline"),g(ee,"tagName","U");class Tt extends ae{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`<span>${t}</span>`}}g(Tt,"blotName","formula"),g(Tt,"className","ql-formula"),g(Tt,"tagName","SPAN");const Be=["alt","height","width"];class se extends O{static create(t){const e=super.create(t);return typeof t=="string"&&e.setAttribute("src",this.sanitize(t)),e}static formats(t){return Be.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 gs(t,["http","https","data"])?t:"//:0"}static value(t){return t.getAttribute("src")}format(t,e){Be.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}}g(se,"blotName","image"),g(se,"tagName","IMG");const De=["height","width"];class At extends S{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 De.reduce((e,s)=>(t.hasAttribute(s)&&(e[s]=t.getAttribute(s)),e),{})}static sanitize(t){return Q.sanitize(t)}static value(t){return t.getAttribute("src")}format(t,e){De.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}html(){const{video:t}=this.value();return`<a href="${t}">${t}</a>`}}g(At,"blotName","video"),g(At,"className","ql-video"),g(At,"tagName","IFRAME");const mt=new V("code-token","hljs",{scope:x.INLINE});class j extends I{static formats(t,e){for(;t!=null&&t!==e.domNode;){if(t.classList&&t.classList.contains(k.className))return super.formats(t,e);t=t.parentNode}}constructor(t,e,s){super(t,e,s),mt.add(this.domNode,s)}format(t,e){t!==j.blotName?super.format(t,e):e?mt.add(this.domNode,e):(mt.remove(this.domNode),this.domNode.classList.remove(this.statics.className))}optimize(){super.optimize(...arguments),mt.value(this.domNode)||this.unwrap()}}j.blotName="code-token";j.className="ql-token";class A extends k{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(),j.blotName,!1),super.replaceWith(t,e)}}class gt extends st{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(t,e){t===A.blotName&&(this.forceNext=!0,this.children.forEach(s=>{s.format(t,e)}))}formatAt(t,e,s,n){s===A.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=A.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((a,c)=>a.concat(Qe(c,!1)),new v),l=t(n,r);o.diff(l).reduce((a,c)=>{let{retain:u,attributes:d}=c;return u?(d&&Object.keys(d).forEach(b=>{[A.blotName,j.blotName].includes(b)&&this.formatAt(a,u,b,d[b])}),a+u):a},0)}this.cachedText=n,this.forceNext=!1}}html(t,e){const[s]=this.children.find(t);return`<pre data-language="${s?A.formats(s.domNode):"plain"}">
${Rt(this.code(t,e))}
</pre>`}optimize(t){if(super.optimize(t),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){const e=A.formats(this.children.head.domNode);e!==this.uiNode.value&&(this.uiNode.value=e)}}}gt.allowedChildren=[A];A.requiredContainer=gt;A.allowedChildren=[j,_,D,P];const jn=(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 ps extends U{static register(){h.register(j,!0),h.register(A,!0),h.register(gt,!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(h.events.SCROLL_BLOT_MOUNT,t=>{if(!(t instanceof gt))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(A.blotName,e.value),this.quill.root.focus(),this.highlight(t,!0)}),t.uiNode==null&&(t.attachUI(e),t.children.head&&(e.value=A.formats(t.children.head.domNode)))})}initTimer(){let t=null;this.quill.on(h.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(h.sources.USER);const s=this.quill.getSelection();(t==null?this.quill.scroll.descendants(gt):[t]).forEach(r=>{r.highlight(this.highlightBlot,e)}),this.quill.update(h.sources.SILENT),s!=null&&this.quill.setSelection(s,h.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 Rt(t).split(`
`).reduce((n,r,o)=>(o!==0&&n.insert(`
`,{[k.blotName]:e}),n.insert(r)),new v);const s=this.quill.root.ownerDocument.createElement("div");return s.classList.add(k.className),s.innerHTML=jn(this.options.hljs,e,t),ge(this.quill.scroll,s,[(n,r)=>{const o=mt.value(n);return o?r.compose(new v().retain(r.length(),{[j.blotName]:o})):r}],[(n,r)=>n.data.split(`
`).reduce((o,l,a)=>(a!==0&&o.insert(`
`,{[k.blotName]:e}),o.insert(l)),r)],new WeakMap)}}ps.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 ve=class extends N{static create(t){const e=super.create();return t?e.setAttribute("data-row",t):e.setAttribute("data-row",pe()),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===ve.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()}};let C=ve;g(C,"blotName","table"),g(C,"tagName","TD");class z extends et{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}}g(z,"blotName","table-row"),g(z,"tagName","TR");class F extends et{}g(F,"blotName","table-body"),g(F,"tagName","TBODY");class ut extends et{balanceCells(){const t=this.descendants(z),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=C.formats(s.children.head.domNode));const r=this.scroll.create(C.blotName,n);s.appendChild(r),r.optimize()})})}cells(t){return this.rows().map(e=>e.children.at(t))}deleteColumn(t){const[e]=this.descendant(F);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(F);e==null||e.children.head==null||e.children.forEach(s=>{const n=s.children.at(t),r=C.formats(s.children.head.domNode),o=this.scroll.create(C.blotName,r);s.insertBefore(o,n)})}insertRow(t){const[e]=this.descendant(F);if(e==null||e.children.head==null)return;const s=pe(),n=this.scroll.create(z.blotName);e.children.head.children.forEach(()=>{const o=this.scroll.create(C.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)}}g(ut,"blotName","table-container"),g(ut,"tagName","TABLE");ut.allowedChildren=[F];F.requiredContainer=ut;F.allowedChildren=[z];z.requiredContainer=F;z.allowedChildren=[C];C.requiredContainer=z;function pe(){return`row-${Math.random().toString(36).slice(2,6)}`}class zn extends U{static register(){h.register(C),h.register(z),h.register(F),h.register(ut)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants(ut).forEach(t=>{t.balanceCells()})}deleteColumn(){const[t,,e]=this.getTable();e!=null&&(t.deleteColumn(e.cellOffset()),this.quill.update(h.sources.USER))}deleteRow(){const[,t]=this.getTable();t!=null&&(t.remove(),this.quill.update(h.sources.USER))}deleteTable(){const[t]=this.getTable();if(t==null)return;const e=t.offset();t.remove(),this.quill.update(h.sources.USER),this.quill.setSelection(e,h.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!==C.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(h.sources.USER);let l=n.rowOffset();t===0&&(l+=1),this.quill.setSelection(e.index+l,e.length,h.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(h.sources.USER),t>0?this.quill.setSelection(e,h.sources.SILENT):this.quill.setSelection(e.index+n.children.length,e.length,h.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:pe()})},new v().retain(s.index));this.quill.updateContents(n,h.sources.USER),this.quill.setSelection(s.index,h.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(h.events.SCROLL_OPTIMIZE,t=>{t.some(e=>["TD","TR","TBODY","TABLE"].includes(e.target.tagName)?(this.quill.once(h.events.TEXT_CHANGE,(s,n,r)=>{r===h.sources.USER&&this.balanceTables()}),!0):!1)})}}const Pe=K("quill:toolbar");class be extends U{constructor(t,e){var s,n;if(super(t,e),Array.isArray(this.options.container)){const r=document.createElement("div");r.setAttribute("role","toolbar"),Vn(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)){Pe.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 l;const o=(l=this.options.handlers)==null?void 0:l[r];o&&this.addHandler(r,o)}),Array.from(this.container.querySelectorAll("button, select")).forEach(r=>{this.attach(r)}),this.quill.on(h.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){Pe.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 l=t.options[t.selectedIndex];l.hasAttribute("selected")?r=!1:r=l.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 O){if(r=prompt(`Enter ${e}`),!r)return;this.quill.updateContents(new v().retain(o.index).delete(o.length).insert({[e]:r}),h.sources.USER)}else this.quill.format(e,r,h.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 l=e[n];typeof l=="string"&&(l=l.replace(/"/g,'\\"')),o=r.querySelector(`option[value="${l}"]`)}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],l=o===r.getAttribute("value")||o!=null&&o.toString()===r.getAttribute("value")||o==null&&!r.getAttribute("value");r.classList.toggle("ql-active",l),r.setAttribute("aria-pressed",l.toString())}else{const o=e[n]!=null;r.classList.toggle("ql-active",o),r.setAttribute("aria-pressed",o.toString())}})}}be.DEFAULTS={};function Ue(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 Vn(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")Ue(s,n);else{const r=Object.keys(n)[0],o=n[r];Array.isArray(o)?Kn(s,r,o):Ue(s,r,o)}}),i.appendChild(s)})}function Kn(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)}be.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,x.INLINE)!=null&&this.quill.format(e,!1,h.sources.USER)})}else this.quill.removeFormat(i,h.sources.USER)},direction(i){const{align:t}=this.quill.getFormat();i==="rtl"&&t==null?this.quill.format("align","right",h.sources.USER):!i&&t==="right"&&this.quill.format("align",!1,h.sources.USER),this.quill.format("direction",i,h.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,h.sources.USER)}},link(i){i===!0&&(i=prompt("Enter link URL:")),this.quill.format("link",i,h.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,h.sources.USER):this.quill.format("list","unchecked",h.sources.USER):this.quill.format("list",i,h.sources.USER)}}};const Wn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="3" x2="15" y1="9" y2="9"/><line class="ql-stroke" x1="3" x2="13" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="9" y1="4" y2="4"/></svg>',Gn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="14" x2="4" y1="14" y2="14"/><line class="ql-stroke" x1="12" x2="6" y1="4" y2="4"/></svg>',Zn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="15" x2="5" y1="14" y2="14"/><line class="ql-stroke" x1="15" x2="9" y1="4" y2="4"/></svg>',Xn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="15" x2="3" y1="14" y2="14"/><line class="ql-stroke" x1="15" x2="3" y1="4" y2="4"/></svg>',Qn='<svg viewbox="0 0 18 18"><g class="ql-fill ql-color-label"><polygon points="6 6.868 6 6 5 6 5 7 5.942 7 6 6.868"/><rect height="1" width="1" x="4" y="4"/><polygon points="6.817 5 6 5 6 6 6.38 6 6.817 5"/><rect height="1" width="1" x="2" y="6"/><rect height="1" width="1" x="3" y="5"/><rect height="1" width="1" x="4" y="7"/><polygon points="4 11.439 4 11 3 11 3 12 3.755 12 4 11.439"/><rect height="1" width="1" x="2" y="12"/><rect height="1" width="1" x="2" y="9"/><rect height="1" width="1" x="2" y="15"/><polygon points="4.63 10 4 10 4 11 4.192 11 4.63 10"/><rect height="1" width="1" x="3" y="8"/><path d="M10.832,4.2L11,4.582V4H10.708A1.948,1.948,0,0,1,10.832,4.2Z"/><path d="M7,4.582L7.168,4.2A1.929,1.929,0,0,1,7.292,4H7V4.582Z"/><path d="M8,13H7.683l-0.351.8a1.933,1.933,0,0,1-.124.2H8V13Z"/><rect height="1" width="1" x="12" y="2"/><rect height="1" width="1" x="11" y="3"/><path d="M9,3H8V3.282A1.985,1.985,0,0,1,9,3Z"/><rect height="1" width="1" x="2" y="3"/><rect height="1" width="1" x="6" y="2"/><rect height="1" width="1" x="3" y="2"/><rect height="1" width="1" x="5" y="3"/><rect height="1" width="1" x="9" y="2"/><rect height="1" width="1" x="15" y="14"/><polygon points="13.447 10.174 13.469 10.225 13.472 10.232 13.808 11 14 11 14 10 13.37 10 13.447 10.174"/><rect height="1" width="1" x="13" y="7"/><rect height="1" width="1" x="15" y="5"/><rect height="1" width="1" x="14" y="6"/><rect height="1" width="1" x="15" y="8"/><rect height="1" width="1" x="14" y="9"/><path d="M3.775,14H3v1H4V14.314A1.97,1.97,0,0,1,3.775,14Z"/><rect height="1" width="1" x="14" y="3"/><polygon points="12 6.868 12 6 11.62 6 12 6.868"/><rect height="1" width="1" x="15" y="2"/><rect height="1" width="1" x="12" y="5"/><rect height="1" width="1" x="13" y="4"/><polygon points="12.933 9 13 9 13 8 12.495 8 12.933 9"/><rect height="1" width="1" x="9" y="14"/><rect height="1" width="1" x="8" y="15"/><path d="M6,14.926V15H7V14.316A1.993,1.993,0,0,1,6,14.926Z"/><rect height="1" width="1" x="5" y="15"/><path d="M10.668,13.8L10.317,13H10v1h0.792A1.947,1.947,0,0,1,10.668,13.8Z"/><rect height="1" width="1" x="11" y="15"/><path d="M14.332,12.2a1.99,1.99,0,0,1,.166.8H15V12H14.245Z"/><rect height="1" width="1" x="14" y="15"/><rect height="1" width="1" x="15" y="11"/></g><polyline class="ql-stroke" points="5.5 13 9 5 12.5 13"/><line class="ql-stroke" x1="11.63" x2="6.38" y1="11" y2="11"/></svg>',Yn='<svg viewbox="0 0 18 18"><rect class="ql-fill ql-stroke" height="3" width="3" x="4" y="5"/><rect class="ql-fill ql-stroke" height="3" width="3" x="11" y="5"/><path class="ql-even ql-fill ql-stroke" d="M7,8c0,4.031-3,5-3,5"/><path class="ql-even ql-fill ql-stroke" d="M14,8c0,4.031-3,5-3,5"/></svg>',Jn='<svg viewbox="0 0 18 18"><path class="ql-stroke" d="M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z"/><path class="ql-stroke" d="M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z"/></svg>',ti='<svg class="" viewbox="0 0 18 18"><line class="ql-stroke" x1="5" x2="13" y1="3" y2="3"/><line class="ql-stroke" x1="6" x2="9.35" y1="12" y2="3"/><line class="ql-stroke" x1="11" x2="15" y1="11" y2="15"/><line class="ql-stroke" x1="15" x2="11" y1="11" y2="15"/><rect class="ql-fill" height="1" rx="0.5" ry="0.5" width="7" x="2" y="14"/></svg>',He='<svg viewbox="0 0 18 18"><polyline class="ql-even ql-stroke" points="5 7 3 9 5 11"/><polyline class="ql-even ql-stroke" points="13 7 15 9 13 11"/><line class="ql-stroke" x1="10" x2="8" y1="5" y2="13"/></svg>',ei='<svg viewbox="0 0 18 18"><line class="ql-color-label ql-stroke ql-transparent" x1="3" x2="15" y1="15" y2="15"/><polyline class="ql-stroke" points="5.5 11 9 3 12.5 11"/><line class="ql-stroke" x1="11.63" x2="6.38" y1="9" y2="9"/></svg>',si='<svg viewbox="0 0 18 18"><polygon class="ql-stroke ql-fill" points="3 11 5 9 3 7 3 11"/><line class="ql-stroke ql-fill" x1="15" x2="11" y1="4" y2="4"/><path class="ql-fill" d="M11,3a3,3,0,0,0,0,6h1V3H11Z"/><rect class="ql-fill" height="11" width="1" x="11" y="4"/><rect class="ql-fill" height="11" width="1" x="13" y="4"/></svg>',ni='<svg viewbox="0 0 18 18"><polygon class="ql-stroke ql-fill" points="15 12 13 10 15 8 15 12"/><line class="ql-stroke ql-fill" x1="9" x2="5" y1="4" y2="4"/><path class="ql-fill" d="M5,3A3,3,0,0,0,5,9H6V3H5Z"/><rect class="ql-fill" height="11" width="1" x="5" y="4"/><rect class="ql-fill" height="11" width="1" x="7" y="4"/></svg>',ii='<svg viewbox="0 0 18 18"><path class="ql-fill" d="M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z"/><rect class="ql-fill" height="1.6" rx="0.8" ry="0.8" width="5" x="5.15" y="6.2"/><path class="ql-fill" d="M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z"/></svg>',ri='<svg viewBox="0 0 18 18"><path class="ql-fill" d="M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z"/></svg>',oi='<svg viewBox="0 0 18 18"><path class="ql-fill" d="M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z"/></svg>',li='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="7" x2="13" y1="4" y2="4"/><line class="ql-stroke" x1="5" x2="11" y1="14" y2="14"/><line class="ql-stroke" x1="8" x2="10" y1="14" y2="4"/></svg>',ai='<svg viewbox="0 0 18 18"><rect class="ql-stroke" height="10" width="12" x="3" y="4"/><circle class="ql-fill" cx="6" cy="7" r="1"/><polyline class="ql-even ql-fill" points="5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12"/></svg>',ci='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="3" x2="15" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="9" x2="15" y1="9" y2="9"/><polyline class="ql-fill ql-stroke" points="3 7 3 11 5 9 3 7"/></svg>',ui='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="3" x2="15" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="9" x2="15" y1="9" y2="9"/><polyline class="ql-stroke" points="5 7 5 11 3 9 5 7"/></svg>',hi='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="7" x2="11" y1="7" y2="11"/><path class="ql-even ql-stroke" d="M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z"/><path class="ql-even ql-stroke" d="M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z"/></svg>',di='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="6" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="6" x2="15" y1="9" y2="9"/><line class="ql-stroke" x1="6" x2="15" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="3" y1="4" y2="4"/><line class="ql-stroke" x1="3" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="3" x2="3" y1="14" y2="14"/></svg>',fi='<svg class="" viewbox="0 0 18 18"><line class="ql-stroke" x1="9" x2="15" y1="4" y2="4"/><polyline class="ql-stroke" points="3 4 4 5 6 3"/><line class="ql-stroke" x1="9" x2="15" y1="14" y2="14"/><polyline class="ql-stroke" points="3 14 4 15 6 13"/><line class="ql-stroke" x1="9" x2="15" y1="9" y2="9"/><polyline class="ql-stroke" points="3 9 4 10 6 8"/></svg>',mi='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="7" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="7" x2="15" y1="9" y2="9"/><line class="ql-stroke" x1="7" x2="15" y1="14" y2="14"/><line class="ql-stroke ql-thin" x1="2.5" x2="4.5" y1="5.5" y2="5.5"/><path class="ql-fill" d="M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z"/><path class="ql-stroke ql-thin" d="M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156"/><path class="ql-stroke ql-thin" d="M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109"/></svg>',gi='<svg viewbox="0 0 18 18"><path class="ql-fill" d="M15.5,15H13.861a3.858,3.858,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.921,1.921,0,0,0,12.021,11.7a0.50013,0.50013,0,1,0,.957.291h0a0.914,0.914,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.076-1.16971,1.86982-1.93971,2.43082A1.45639,1.45639,0,0,0,12,15.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,15Z"/><path class="ql-fill" d="M9.65,5.241a1,1,0,0,0-1.409.108L6,7.964,3.759,5.349A1,1,0,0,0,2.192,6.59178Q2.21541,6.6213,2.241,6.649L4.684,9.5,2.241,12.35A1,1,0,0,0,3.71,13.70722q0.02557-.02768.049-0.05722L6,11.036,8.241,13.65a1,1,0,1,0,1.567-1.24277Q9.78459,12.3777,9.759,12.35L7.316,9.5,9.759,6.651A1,1,0,0,0,9.65,5.241Z"/></svg>',pi='<svg viewbox="0 0 18 18"><path class="ql-fill" d="M15.5,7H13.861a4.015,4.015,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.922,1.922,0,0,0,12.021,3.7a0.5,0.5,0,1,0,.957.291,0.917,0.917,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.077-1.164,1.925-1.934,2.486A1.423,1.423,0,0,0,12,7.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,7Z"/><path class="ql-fill" d="M9.651,5.241a1,1,0,0,0-1.41.108L6,7.964,3.759,5.349a1,1,0,1,0-1.519,1.3L4.683,9.5,2.241,12.35a1,1,0,1,0,1.519,1.3L6,11.036,8.241,13.65a1,1,0,0,0,1.519-1.3L7.317,9.5,9.759,6.651A1,1,0,0,0,9.651,5.241Z"/></svg>',bi='<svg viewbox="0 0 18 18"><line class="ql-stroke ql-thin" x1="15.5" x2="2.5" y1="8.5" y2="9.5"/><path class="ql-fill" d="M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z"/><path class="ql-fill" d="M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z"/></svg>',yi='<svg viewbox="0 0 18 18"><rect class="ql-stroke" height="12" width="12" x="3" y="3"/><rect class="ql-fill" height="2" width="3" x="5" y="5"/><rect class="ql-fill" height="2" width="4" x="9" y="5"/><g class="ql-fill ql-transparent"><rect height="2" width="3" x="5" y="8"/><rect height="2" width="4" x="9" y="8"/><rect height="2" width="3" x="5" y="11"/><rect height="2" width="4" x="9" y="11"/></g></svg>',vi='<svg viewbox="0 0 18 18"><path class="ql-stroke" d="M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3"/><rect class="ql-fill" height="1" rx="0.5" ry="0.5" width="12" x="3" y="15"/></svg>',xi='<svg viewbox="0 0 18 18"><rect class="ql-stroke" height="12" width="12" x="3" y="3"/><rect class="ql-fill" height="12" width="1" x="5" y="3"/><rect class="ql-fill" height="12" width="1" x="12" y="3"/><rect class="ql-fill" height="2" width="8" x="5" y="8"/><rect class="ql-fill" height="1" width="3" x="3" y="5"/><rect class="ql-fill" height="1" width="3" x="3" y="7"/><rect class="ql-fill" height="1" width="3" x="3" y="10"/><rect class="ql-fill" height="1" width="3" x="3" y="12"/><rect class="ql-fill" height="1" width="3" x="12" y="5"/><rect class="ql-fill" height="1" width="3" x="12" y="7"/><rect class="ql-fill" height="1" width="3" x="12" y="10"/><rect class="ql-fill" height="1" width="3" x="12" y="12"/></svg>';var yt={align:{"":Wn,center:Gn,right:Zn,justify:Xn},background:Qn,blockquote:Yn,bold:Jn,clean:ti,code:He,"code-block":He,color:ei,direction:{"":si,rtl:ni},formula:ii,header:{1:ri,2:oi},italic:li,image:ai,indent:{"+1":ci,"-1":ui},link:hi,list:{bullet:di,check:fi,ordered:mi},script:{sub:gi,super:pi},strike:bi,table:yi,underline:vi,video:xi};const Ei='<svg viewbox="0 0 18 18"><polygon class="ql-stroke" points="7 11 9 13 11 11 7 11"/><polygon class="ql-stroke" points="7 7 9 5 11 7 7 7"/></svg>';let _e=0;function Fe(i,t){i.setAttribute(t,`${i.getAttribute(t)!=="true"}`)}class Bt{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"),Fe(this.label,"aria-expanded"),Fe(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=Ei,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-${_e}`,_e+=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 bs extends Bt{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 ys extends Bt{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 qi=i=>{const{overflowY:t}=getComputedStyle(i,null);return t!=="visible"&&t!=="clip"};class vs{constructor(t,e){this.quill=t,this.boundsContainer=e||document.body,this.root=t.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,qi(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.left<n.left&&(o=n.left-r.left,this.root.style.left=`${e+o}px`),r.bottom>n.bottom){const l=r.bottom-r.top,a=t.bottom-t.top+l;this.root.style.top=`${s-a}px`,this.root.classList.add("ql-flip")}return o}show(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}const wi=[!1,"center","right","justify"],Ni=["#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"],ki=[!1,"serif","monospace"],Li=["1","2","3",!1],Ci=["small",!1,"large","huge"];class qt extends Z{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&&ft(n,wi),typeof e.align=="object"))return new ys(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&&ft(n,Ni,r==="background"?"#ffffff":"#000000"),new bs(n,e[r])}return n.querySelector("option")==null&&(n.classList.contains("ql-font")?ft(n,ki):n.classList.contains("ql-header")?ft(n,Li):n.classList.contains("ql-size")&&ft(n,Ci)),new Bt(n)});const s=()=>{this.pickers.forEach(n=>{n.update()})};this.quill.on(p.events.EDITOR_CHANGE,s)}}qt.DEFAULTS=Y({},Z.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 xs extends vs{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()}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,p.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",t,p.sources.USER)),this.quill.root.scrollTop=e;break}case"video":t=Ti(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,p.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(s+1," ",p.sources.USER),this.quill.setSelection(s+2,p.sources.USER)}break}}this.textbox.value="",this.hide()}}function Ti(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 ft(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 Ai=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]];class Es extends xs{constructor(t,e){super(t,e),this.quill.on(p.events.EDITOR_CHANGE,(s,n,r,o)=>{if(s===p.events.SELECTION_CHANGE)if(n!=null&&n.length>0&&o===p.sources.USER){this.show(),this.root.style.left="0px",this.root.style.width="",this.root.style.width=`${this.root.offsetWidth}px`;const l=this.quill.getLines(n.index,n.length);if(l.length===1){const a=this.quill.getBounds(n);a!=null&&this.position(a)}else{const a=l[l.length-1],c=this.quill.getIndex(a),u=Math.min(a.length()-1,n.index+n.length-c),d=this.quill.getBounds(new tt(c,u));d!=null&&this.position(d)}}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(p.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}}g(Es,"TEMPLATE",['<span class="ql-tooltip-arrow"></span>','<div class="ql-tooltip-editor">','<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">','<a class="ql-close"></a>',"</div>"].join(""));class qs extends qt{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=Ai),super(t,e),this.quill.container.classList.add("ql-bubble")}extendToolbar(t){this.tooltip=new Es(this.quill,this.options.bounds),t.container!=null&&(this.tooltip.root.appendChild(t.container),this.buildButtons(t.container.querySelectorAll("button"),yt),this.buildPickers(t.container.querySelectorAll("select"),yt))}}qs.DEFAULTS=Y({},qt.DEFAULTS,{modules:{toolbar:{handlers:{link(i){i?this.quill.theme.tooltip.edit():this.quill.format("link",!1)}}}}});const Si=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]];class ws extends xs{constructor(){super(...arguments);g(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,p.sources.USER),delete this.linkRange}e.preventDefault(),this.hide()}),this.quill.on(p.events.SELECTION_CHANGE,(e,s,n)=>{if(e!=null){if(e.length===0&&n===p.sources.USER){const[r,o]=this.quill.scroll.descendant(Q,e.index);if(r!=null){this.linkRange=new tt(e.index-o,r.length());const l=Q.formats(r.domNode);this.preview.textContent=l,this.preview.setAttribute("href",l),this.show();const a=this.quill.getBounds(this.linkRange);a!=null&&this.position(a);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute("data-mode")}}g(ws,"TEMPLATE",['<a class="ql-preview" rel="noopener noreferrer" target="_blank" href="about:blank"></a>','<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">','<a class="ql-action"></a>','<a class="ql-remove"></a>'].join(""));class Ns extends qt{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=Si),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"),yt),this.buildPickers(t.container.querySelectorAll("select"),yt),this.tooltip=new ws(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)}))}}Ns.DEFAULTS=Y({},qt.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)}}}}});h.register({"attributors/attribute/direction":ns,"attributors/class/align":ts,"attributors/class/background":Qs,"attributors/class/color":Xs,"attributors/class/direction":is,"attributors/class/font":ls,"attributors/class/size":cs,"attributors/style/align":es,"attributors/style/background":he,"attributors/style/color":ue,"attributors/style/direction":rs,"attributors/style/font":as,"attributors/style/size":us},!0);h.register({"formats/align":ts,"formats/direction":is,"formats/indent":$n,"formats/background":he,"formats/color":ue,"formats/font":ls,"formats/size":cs,"formats/blockquote":Xt,"formats/code-block":k,"formats/header":Qt,"formats/list":Et,"formats/bold":bt,"formats/code":de,"formats/italic":Yt,"formats/link":Q,"formats/script":Jt,"formats/strike":te,"formats/underline":ee,"formats/formula":Tt,"formats/image":se,"formats/video":At,"modules/syntax":ps,"modules/table":zn,"modules/toolbar":be,"themes/bubble":qs,"themes/snow":Ns,"ui/icons":yt,"ui/picker":Bt,"ui/icon-picker":ys,"ui/color-picker":bs,"ui/tooltip":vs},!0);function $e(i,t){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);t&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(i,n).enumerable})),e.push.apply(e,s)}return e}function je(i){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?$e(Object(e),!0).forEach(function(s){ne(i,s,e[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):$e(Object(e)).forEach(function(s){Object.defineProperty(i,s,Object.getOwnPropertyDescriptor(e,s))})}return i}function It(i){return It=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},It(i)}function ks(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}function ze(i,t){for(var e=0;e<t.length;e++){var s=t[e];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(i,Cs(s.key),s)}}function Ls(i,t,e){return t&&ze(i.prototype,t),e&&ze(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function ne(i,t,e){return t=Cs(t),t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function Ot(){return Ot=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s])}return i},Ot.apply(this,arguments)}function Ii(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),t&&ie(i,t)}function J(i){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},J(i)}function ie(i,t){return ie=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,n){return s.__proto__=n,s},ie(i,t)}function Oi(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function re(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Ri(i,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return re(i)}function Mi(i){var t=Oi();return function(){var s=J(i),n;if(t){var r=J(this).constructor;n=Reflect.construct(s,arguments,r)}else n=s.apply(this,arguments);return Ri(this,n)}}function Bi(i,t){for(;!Object.prototype.hasOwnProperty.call(i,t)&&(i=J(i),i!==null););return i}function ct(){return typeof Reflect!="undefined"&&Reflect.get?ct=Reflect.get.bind():ct=function(t,e,s){var n=Bi(t,e);if(!!n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:s):r.value}},ct.apply(this,arguments)}function Di(i,t){if(!!i){if(typeof i=="string")return Ve(i,t);var e=Object.prototype.toString.call(i).slice(8,-1);if(e==="Object"&&i.constructor&&(e=i.constructor.name),e==="Map"||e==="Set")return Array.from(i);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Ve(i,t)}}function Ve(i,t){(t==null||t>i.length)&&(t=i.length);for(var e=0,s=new Array(t);e<t;e++)s[e]=i[e];return s}function Pi(i,t){var e=typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(!e){if(Array.isArray(i)||(e=Di(i))||t&&i&&typeof i.length=="number"){e&&(i=e);var s=0,n=function(){};return{s:n,n:function(){return s>=i.length?{done:!0}:{done:!1,value:i[s++]}},e:function(a){throw a},f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var r=!0,o=!1,l;return{s:function(){e=e.call(i)},n:function(){var a=e.next();return r=a.done,a},e:function(a){o=!0,l=a},f:function(){try{!r&&e.return!=null&&e.return()}finally{if(o)throw l}}}}function Ui(i,t){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var s=e.call(i,t||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function Cs(i){var t=Ui(i,"string");return typeof t=="symbol"?t:String(t)}var H={TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",UP:"ArrowUp",DOWN:"ArrowDown"};function Hi(i,t,e){var s=i;return Object.keys(t).forEach(function(n){e.indexOf(n)>-1?s.dataset[n]=t[n]:delete s.dataset[n]}),s}function Ke(i,t){t!==null&&(It(t)==="object"?i.appendChild(t):i.innerHTML=t)}function _i(i,t,e,s){return t.reduce(function(n,r){var o;if(e&&s){var l=new RegExp("^".concat(r,"|\\s").concat(r),"g"),a=(i.match(l)||[]).pop();if(!a)return{mentionChar:n.mentionChar,mentionCharIndex:n.mentionCharIndex};o=a!==r?i.lastIndexOf(a)+a.length-r.length:0}else o=i.lastIndexOf(r);return o>n.mentionCharIndex?{mentionChar:r,mentionCharIndex:o}:{mentionChar:n.mentionChar,mentionCharIndex:n.mentionCharIndex}},{mentionChar:null,mentionCharIndex:-1})}function Fi(i,t){return t.test(i)}function $i(i,t,e,s){if(i===-1)return!1;if(!e)return!0;var n=i?t[i-1]:s;return!n||!!n.match(/\s/)}function ji(i){return It(i)!=="object"||i===null?i:JSON.parse(JSON.stringify(i))}var zi=h.import("blots/embed"),Dt=function(i){Ii(e,i);var t=Mi(e);function e(s,n){var r;return ks(this,e),r=t.call(this,s,n),ne(re(r),"hoverHandler",void 0),ne(re(r),"hoverHandler",void 0),r.clickHandler=null,r.hoverHandler=null,r.mounted=!1,r}return Ls(e,[{key:"update",value:function(n,r){var o=this;if(e.isAndroid()){var l=Pi(n),a;try{for(l.s();!(a=l.n()).done;){var c=a.value;if(!(c.type==="attributes"&&c.attributeName==="contenteditable")){setTimeout(function(){return o.remove()},0);return}}}catch(u){l.e(u)}finally{l.f()}}else n.forEach(function(u){if(u.type==="characterData"&&(u.target===o.leftGuard||u.target===o.rightGuard)){var d=o.restore(u.target);d&&(r.range=d)}})}},{key:"attach",value:function(){ct(J(e.prototype),"attach",this).call(this),this.mounted||(this.mounted=!0,this.clickHandler=this.getClickHandler(),this.hoverHandler=this.getHoverHandler(),this.domNode.addEventListener("click",this.clickHandler,!1),this.domNode.addEventListener("mouseenter",this.hoverHandler,!1))}},{key:"detach",value:function(){ct(J(e.prototype),"detach",this).call(this),this.mounted=!1,this.clickHandler&&(this.domNode.removeEventListener("click",this.clickHandler),this.clickHandler=null)}},{key:"getClickHandler",value:function(){var n=this;return function(r){var o=n.buildEvent("mention-clicked",r);window.dispatchEvent(o),r.preventDefault()}}},{key:"getHoverHandler",value:function(){var n=this;return function(r){var o=n.buildEvent("mention-hovered",r);window.dispatchEvent(o),r.preventDefault()}}},{key:"buildEvent",value:function(n,r){var o=new Event(n,{bubbles:!0,cancelable:!0});return o.value=Ot({},this.domNode.dataset),o.event=r,o}}],[{key:"create",value:function(n){var r=ct(J(e),"create",this).call(this),o=document.createElement("span");if(o.className="ql-mention-denotation-char",o.innerHTML=n.denotationChar,r.appendChild(o),r.innerHTML+=n.value,e.isAndroid()){var l=document.createElement("span");l.innerHTML="&nbsp;",l.setAttribute("style","display: inline-block; height: 1px; width: 1px; overflow: hidden; "),r.appendChild(l)}return e.setDataValues(r,n)}},{key:"setDataValues",value:function(n,r){setTimeout(function(){e.isAndroid()?n.getElementsByTagName("span")[0].setAttribute("contenteditable","inherit"):e.isChrome()&&n.getElementsByTagName("span")[0].parentNode.setAttribute("contenteditable","false")},0);var o=n;return Object.keys(r).forEach(function(l){o.dataset[l]=r[l]}),o}},{key:"value",value:function(n){return n.dataset}},{key:"isAndroid",value:function(){var n=typeof window!="undefined"&&window.navigator.userAgent.toLowerCase();return n&&n.indexOf("android")>0}},{key:"isChrome",value:function(){var n=typeof window!="undefined"&&window.navigator.userAgent.toLowerCase();return n.match(/Chrome/i)+""=="chrome"}}]),e}(zi);Dt.blotName="mention";Dt.tagName="span";Dt.className="mention";h.register("blots/mention",Dt);var Vi=function(){function i(t,e){var s=this;ks(this,i),this.isOpen=!1,this.itemIndex=0,this.mentionCharPos=null,this.cursorPos=null,this.values=[],this.suspendMouseEnter=!1,this.existingSourceExecutionToken=null,this.quill=t,this.options={source:null,renderItem:function(o){var l=o.value;return"".concat(l)},renderLoading:function(){return null},onSelect:function(o,l){l(o)},mentionDenotationChars:["@"],showDenotationChar:!0,allowedChars:/^[a-zA-Z0-9_]*$/,minChars:0,maxChars:31,offsetTop:2,offsetLeft:0,isolateCharacter:!1,allowInlineMentionChar:!1,fixMentionsToQuill:!1,positioningStrategy:"normal",defaultMenuOrientation:"bottom",blotName:"mention",dataAttributes:["id","value","denotationChar","link","target","disabled"],linkTarget:"_blank",onOpen:function(){return!0},onBeforeClose:function(){return!0},onClose:function(){return!0},listItemClass:"ql-mention-list-item",mentionContainerClass:"ql-mention-list-container",mentionListClass:"ql-mention-list",spaceAfterInsert:!0,selectKeys:[H.ENTER]},Ot(this.options,e,{dataAttributes:Array.isArray(e.dataAttributes)?this.options.dataAttributes.concat(e.dataAttributes):this.options.dataAttributes});for(var n in this.options)typeof this.options[n]=="function"&&(this.options[n]=this.options[n].bind(this));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.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),t.on("text-change",this.onTextChange.bind(this)),t.on("selection-change",this.onSelectionChange.bind(this)),t.container.addEventListener("paste",function(){setTimeout(function(){var r=t.getSelection();s.onSelectionChange(r)})}),t.keyboard.addBinding({key:H.TAB},this.selectHandler.bind(this)),t.keyboard.bindings[H.TAB].unshift(t.keyboard.bindings[H.TAB].pop()),t.keyboard.addBinding({key:H.ENTER},this.selectHandler.bind(this)),t.keyboard.bindings[H.ENTER].unshift(t.keyboard.bindings[H.ENTER].pop()),t.keyboard.addBinding({key:H.ESCAPE},this.escapeHandler.bind(this)),t.keyboard.addBinding({key:H.UP},this.upHandler.bind(this)),t.keyboard.addBinding({key:H.DOWN},this.downHandler.bind(this))}return Ls(i,[{key:"selectHandler",value:function(){return this.isOpen&&!this.existingSourceExecutionToken?(this.selectItem(),!1):!0}},{key:"escapeHandler",value:function(){return this.isOpen?(this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList(),!1):!0}},{key:"upHandler",value:function(){return this.isOpen&&!this.existingSourceExecutionToken?(this.prevItem(),!1):!0}},{key:"downHandler",value:function(){return this.isOpen&&!this.existingSourceExecutionToken?(this.nextItem(),!1):!0}},{key:"showMentionList",value:function(){this.options.positioningStrategy==="fixed"?document.body.appendChild(this.mentionContainer):this.quill.container.appendChild(this.mentionContainer),this.mentionContainer.style.visibility="hidden",this.mentionContainer.style.display="",this.mentionContainer.scrollTop=0,this.setMentionContainerPosition(),this.setIsOpen(!0)}},{key:"hideMentionList",value:function(){this.options.onBeforeClose(),this.mentionContainer.style.display="none",this.mentionContainer.remove(),this.setIsOpen(!1),this.quill.root.removeAttribute("aria-activedescendant")}},{key:"highlightItem",value:function(){for(var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,s=0;s<this.mentionList.childNodes.length;s+=1)this.mentionList.childNodes[s].classList.remove("selected");if(!(this.itemIndex===-1||this.mentionList.childNodes[this.itemIndex].dataset.disabled==="true")&&(this.mentionList.childNodes[this.itemIndex].classList.add("selected"),this.quill.root.setAttribute("aria-activedescendant",this.mentionList.childNodes[this.itemIndex].id),e)){var n=this.mentionList.childNodes[this.itemIndex].offsetHeight,r=this.mentionList.childNodes[this.itemIndex].offsetTop,o=this.mentionContainer.scrollTop,l=o+this.mentionContainer.offsetHeight;r<o?this.mentionContainer.scrollTop=r:r>l-n&&(this.mentionContainer.scrollTop+=r-l+n)}}},{key:"onContainerMouseMove",value:function(){this.suspendMouseEnter=!1}},{key:"selectItem",value:function(){var e=this;if(this.itemIndex!==-1){var s=this.mentionList.childNodes[this.itemIndex].dataset;s.disabled||(this.options.onSelect(s,function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return e.insertItem(n,r,o)}),this.hideMentionList())}}},{key:"insertItem",value:function(e,s){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=e;if(r!==null){var o=je(je({},this.options),n);o.showDenotationChar||(r.denotationChar="");var l;s?l=this.cursorPos:(l=this.mentionCharPos,this.quill.deleteText(this.mentionCharPos,this.cursorPos-this.mentionCharPos,h.sources.USER));var a=this.quill.insertEmbed(l,o.blotName,r,h.sources.USER);return o.spaceAfterInsert?(this.quill.insertText(l+1," ",h.sources.USER),this.quill.setSelection(l+2,h.sources.USER)):this.quill.setSelection(l+1,h.sources.USER),this.hideMentionList(),a}}},{key:"onItemMouseEnter",value:function(e){if(!this.suspendMouseEnter){var s=Number(e.target.dataset.index);!Number.isNaN(s)&&s!==this.itemIndex&&(this.itemIndex=s,this.highlightItem(!1))}}},{key:"onDisabledItemMouseEnter",value:function(e){this.suspendMouseEnter||(this.itemIndex=-1,this.highlightItem(!1))}},{key:"onItemClick",value:function(e){e.button===0&&(e.preventDefault(),e.stopImmediatePropagation(),this.itemIndex=e.currentTarget.dataset.index,this.highlightItem(),this.selectItem())}},{key:"onItemMouseDown",value:function(e){e.preventDefault(),e.stopImmediatePropagation()}},{key:"renderLoading",value:function(){var e=this.options.renderLoading();if(!!e){if(this.mentionContainer.getElementsByClassName("ql-mention-loading").length>0){this.showMentionList();return}this.mentionList.innerHTML="";var s=document.createElement("div");s.className="ql-mention-loading",Ke(s,this.options.renderLoading()),this.mentionContainer.append(s),this.showMentionList()}}},{key:"removeLoading",value:function(){var e=this.mentionContainer.getElementsByClassName("ql-mention-loading");e.length>0&&e[0].remove()}},{key:"renderList",value:function(e,s,n){if(s&&s.length>0){this.removeLoading(),this.values=s,this.mentionList.innerHTML="";for(var r=-1,o=0;o<s.length;o+=1){var l=document.createElement("li");l.id="quill-mention-item-"+o,l.className=this.options.listItemClass?this.options.listItemClass:"",s[o].disabled?(l.className+=" disabled",l.setAttribute("aria-hidden","true")):r===-1&&(r=o),l.dataset.index=o;var a=this.options.renderItem(s[o],n);Ke(l,a),s[o].disabled?l.onmouseenter=this.onDisabledItemMouseEnter.bind(this):(l.onmouseenter=this.onItemMouseEnter.bind(this),l.onmouseup=this.onItemClick.bind(this),l.onmousedown=this.onItemMouseDown.bind(this)),l.dataset.denotationChar=e,this.mentionList.appendChild(Hi(l,s[o],this.options.dataAttributes))}this.itemIndex=r,this.highlightItem(),this.showMentionList()}else this.hideMentionList()}},{key:"nextItem",value:function(){var e=0,s;do{e++,s=(this.itemIndex+e)%this.values.length;var n=this.mentionList.childNodes[s].dataset.disabled==="true";if(e===this.values.length+1){s=-1;break}}while(n);this.itemIndex=s,this.suspendMouseEnter=!0,this.highlightItem()}},{key:"prevItem",value:function(){var e=0,s;do{e++,s=(this.itemIndex+this.values.length-e)%this.values.length;var n=this.mentionList.childNodes[s].dataset.disabled==="true";if(e===this.values.length+1){s=-1;break}}while(n);this.itemIndex=s,this.suspendMouseEnter=!0,this.highlightItem()}},{key:"containerBottomIsNotVisible",value:function(e,s){var n=e+this.mentionContainer.offsetHeight+s.top;return n>window.pageYOffset+window.innerHeight}},{key:"containerRightIsNotVisible",value:function(e,s){if(this.options.fixMentionsToQuill)return!1;var n=e+this.mentionContainer.offsetWidth+s.left,r=window.pageXOffset+document.documentElement.clientWidth;return n>r}},{key:"setIsOpen",value:function(e){this.isOpen!==e&&(e?this.options.onOpen():this.options.onClose(),this.isOpen=e)}},{key:"setMentionContainerPosition",value:function(){this.options.positioningStrategy==="fixed"?this.setMentionContainerPosition_Fixed():this.setMentionContainerPosition_Normal()}},{key:"setMentionContainerPosition_Normal",value:function(){var e=this,s=this.quill.container.getBoundingClientRect(),n=this.quill.getBounds(this.mentionCharPos),r=this.mentionContainer.offsetHeight,o=this.options.offsetTop,l=this.options.offsetLeft;if(this.options.fixMentionsToQuill){var a=0;this.mentionContainer.style.right="".concat(a,"px")}else l+=n.left;if(this.containerRightIsNotVisible(l,s)){var c=this.mentionContainer.offsetWidth+this.options.offsetLeft,u=s.width;l=u-c}if(this.options.defaultMenuOrientation==="top"){if(this.options.fixMentionsToQuill?o=-1*(r+this.options.offsetTop):o=n.top-(r+this.options.offsetTop),o+s.top<=0){var d=this.options.offsetTop;this.options.fixMentionsToQuill?d+=s.height:d+=n.bottom,o=d}}else if(this.options.fixMentionsToQuill?o+=s.height:o+=n.bottom,this.containerBottomIsNotVisible(o,s)){var b=this.options.offsetTop*-1;this.options.fixMentionsToQuill||(b+=n.top),o=b-r}o>=0?this.options.mentionContainerClass.split(" ").forEach(function(y){e.mentionContainer.classList.add("".concat(y,"-bottom")),e.mentionContainer.classList.remove("".concat(y,"-top"))}):this.options.mentionContainerClass.split(" ").forEach(function(y){e.mentionContainer.classList.add("".concat(y,"-top")),e.mentionContainer.classList.remove("".concat(y,"-bottom"))}),this.mentionContainer.style.top="".concat(o,"px"),this.mentionContainer.style.left="".concat(l,"px"),this.mentionContainer.style.visibility="visible"}},{key:"setMentionContainerPosition_Fixed",value:function(){var e=this;this.mentionContainer.style.position="fixed",this.mentionContainer.style.height=null;var s=ji(this.quill.container.getBoundingClientRect());s.top+=window.scrollY;var n=this.quill.getBounds(this.mentionCharPos),r={left:s.left+n.left,top:s.top+n.top,width:0,height:n.height},o=this.options.fixMentionsToQuill?s:r,l=this.options.offsetTop,a=this.options.offsetLeft;if(this.options.fixMentionsToQuill){var c=o.right;this.mentionContainer.style.right="".concat(c,"px")}else a+=o.left,a+this.mentionContainer.offsetWidth>document.documentElement.clientWidth&&(a-=a+this.mentionContainer.offsetWidth-document.documentElement.clientWidth);var u=o.top,d=document.documentElement.clientHeight-(o.top+o.height),b=this.mentionContainer.offsetHeight<=d,y=this.mentionContainer.offsetHeight<=u,f;this.options.defaultMenuOrientation==="top"&&y?f="top":this.options.defaultMenuOrientation==="bottom"&&b?f="bottom":f=d>u?"bottom":"top",f==="bottom"?(l=o.top+o.height,b||(this.mentionContainer.style.height=d-3+"px"),this.options.mentionContainerClass.split(" ").forEach(function(E){e.mentionContainer.classList.add("".concat(E,"-bottom")),e.mentionContainer.classList.remove("".concat(E,"-top"))})):(l=o.top-this.mentionContainer.offsetHeight,y||(this.mentionContainer.style.height=u-3+"px",l=3),this.options.mentionContainerClass.split(" ").forEach(function(E){e.mentionContainer.classList.add("".concat(E,"-top")),e.mentionContainer.classList.remove("".concat(E,"-bottom"))})),this.mentionContainer.style.top="".concat(l,"px"),this.mentionContainer.style.left="".concat(a,"px"),this.mentionContainer.style.visibility="visible"}},{key:"getTextBeforeCursor",value:function(){var e=Math.max(0,this.cursorPos-this.options.maxChars),s=this.quill.getText(e,this.cursorPos-e);return s}},{key:"onSomethingChange",value:function(){var e=this,s=this.quill.getSelection();if(s!=null){this.cursorPos=s.index;var n=this.getTextBeforeCursor(),r=Math.max(0,this.cursorPos-this.options.maxChars),o=r?this.quill.getText(r-1,r):"",l=_i(n,this.options.mentionDenotationChars,this.options.isolateCharacter,this.options.allowInlineMentionChar),a=l.mentionChar,c=l.mentionCharIndex;if($i(c,n,this.options.isolateCharacter,o)){var u=this.cursorPos-(n.length-c);this.mentionCharPos=u;var d=n.substring(c+a.length);if(d.length>=this.options.minChars&&Fi(d,this.getAllowedCharsRegex(a))){this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.renderLoading();var b={abandoned:!1};this.existingSourceExecutionToken=b,this.options.source(d,function(y,f){b.abandoned||(e.existingSourceExecutionToken=null,e.renderList(a,y,f))},a)}else this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList()}else this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList()}}},{key:"getAllowedCharsRegex",value:function(e){return this.options.allowedChars instanceof RegExp?this.options.allowedChars:this.options.allowedChars(e)}},{key:"onTextChange",value:function(e,s,n){n==="user"&&setTimeout(this.onSomethingChange.bind(this),50)}},{key:"onSelectionChange",value:function(e){e&&e.length===0?this.onSomethingChange():this.hideMentionList()}},{key:"openMenu",value:function(e){var s=this.quill.getSelection(!0);this.quill.insertText(s.index,e),this.quill.blur(),this.quill.focus()}}]),i}();h.register("modules/mention",Vi);