import{b as dt,g as Xt,h as et}from"./chunk-MPPP2QUX.js";import{a as f}from"./chunk-ZE2KCNEA.js";import{a as L,b as wt,d as Br,f as Tt,g as mo,h as tt}from"./chunk-CEWFFWI2.js";var Mn=Tt((rd,Bn)=>{f();var rt=-1,V=1,D=0;function Ee(r,e,t,s,n){if(r===e)return r?[[D,r]]:[];if(t!=null){var i=Bo(r,e,t);if(i)return i}var l=Gr(r,e),o=r.substring(0,l);r=r.substring(l),e=e.substring(l),l=ze(r,e);var a=r.substring(r.length-l);r=r.substring(0,r.length-l),e=e.substring(0,e.length-l);var c=qo(r,e);return o&&c.unshift([D,o]),a&&c.push([D,a]),Wr(c,n),s&&Co(c),c}function qo(r,e){var t;if(!r)return[[V,e]];if(!e)return[[rt,r]];var s=r.length>e.length?r:e,n=r.length>e.length?e:r,i=s.indexOf(n);if(i!==-1)return t=[[V,s.substring(0,i)],[D,n],[V,s.substring(i+n.length)]],r.length>e.length&&(t[0][0]=t[2][0]=rt),t;if(n.length===1)return[[rt,r],[V,e]];var l=ko(r,e);if(l){var o=l[0],a=l[1],c=l[2],u=l[3],h=l[4],m=Ee(o,c),p=Ee(a,u);return m.concat([[D,h]],p)}return So(r,e)}function So(r,e){for(var t=r.length,s=e.length,n=Math.ceil((t+s)/2),i=n,l=2*n,o=new Array(l),a=new Array(l),c=0;ct)p+=2;else if(w>s)m+=2;else if(h){var S=i+u-v;if(S>=0&&S=k)return Ln(r,e,A,w)}}}for(var W=-N+b;W<=N-E;W+=2){var S=i+W,k;W===-N||W!==N&&a[S-1]t)E+=2;else if(at>s)b+=2;else if(!h){var x=i+u-W;if(x>=0&&x=k)return Ln(r,e,A,w)}}}}return[[rt,r],[V,e]]}function Ln(r,e,t,s){var n=r.substring(0,t),i=e.substring(0,s),l=r.substring(t),o=e.substring(s),a=Ee(n,i),c=Ee(l,o);return a.concat(c)}function Gr(r,e){if(!r||!e||r.charAt(0)!==e.charAt(0))return 0;for(var t=0,s=Math.min(r.length,e.length),n=s,i=0;ts?r=r.substring(t-s):te.length?r:e,s=r.length>e.length?e:r;if(t.length<4||s.length*2=p.length?[A,w,S,k,x]:null}var i=n(t,s,Math.ceil(t.length/4)),l=n(t,s,Math.ceil(t.length/2)),o;if(!i&&!l)return null;l?i?o=i[4].length>l[4].length?i:l:o=l:o=i;var a,c,u,h;r.length>e.length?(a=o[0],c=o[1],u=o[2],h=o[3]):(u=o[0],h=o[1],a=o[2],c=o[3]);var m=o[4];return[a,c,u,h,m]}function Co(r){for(var e=!1,t=[],s=0,n=null,i=0,l=0,o=0,a=0,c=0;i0?t[s-1]:-1,l=0,o=0,a=0,c=0,n=null,e=!0)),i++;for(e&&Wr(r),Io(r),i=1;i=p?(m>=u.length/2||m>=h.length/2)&&(r.splice(i,0,[D,h.substring(0,m)]),r[i-1][1]=u.substring(0,u.length-m),r[i+1][1]=h.substring(m),i++):(p>=u.length/2||p>=h.length/2)&&(r.splice(i,0,[D,u.substring(0,p)]),r[i-1][0]=V,r[i-1][1]=h.substring(0,h.length-p),r[i+1][0]=rt,r[i+1][1]=u.substring(p),i++),i++}i++}}var Sn=/[^a-zA-Z0-9]/,kn=/\s/,Cn=/[\r\n]/,Oo=/\n\r?\n$/,_o=/^\r?\n\r?\n/;function Io(r){function e(p,b){if(!p||!b)return 6;var E=p.charAt(p.length-1),N=b.charAt(0),v=E.match(Sn),x=N.match(Sn),A=v&&E.match(kn),w=x&&N.match(kn),S=A&&E.match(Cn),k=w&&N.match(Cn),W=S&&p.match(Oo),at=k&&b.match(_o);return W||at?5:S||k?4:v&&!A&&w?3:A||w?2:v||x?1:0}for(var t=1;t=h&&(h=m,a=s,c=n,u=i)}r[t-1][1]!=a&&(a?r[t-1][1]=a:(r.splice(t-1,1),t--),r[t][1]=c,u?r[t+1][1]=u:(r.splice(t+1,1),t--))}t++}}function Wr(r,e){r.push([D,""]);for(var t=0,s=0,n=0,i="",l="",o;t=0&&Rn(r[a][1])){var c=r[a][1].slice(-1);if(r[a][1]=r[a][1].slice(0,-1),i=c+i,l=c+l,!r[a][1]){r.splice(a,1),t--;var u=a-1;r[u]&&r[u][0]===V&&(n++,l=r[u][1]+l,u--),r[u]&&r[u][0]===rt&&(s++,i=r[u][1]+i,u--),a=u}}if(In(r[t][1])){var c=r[t][1].charAt(0);r[t][1]=r[t][1].slice(1),i+=c,l+=c}}if(t0||l.length>0){i.length>0&&l.length>0&&(o=Gr(l,i),o!==0&&(a>=0?r[a][1]+=l.substring(0,o):(r.splice(0,0,[D,l.substring(0,o)]),t++),l=l.substring(o),i=i.substring(o)),o=ze(l,i),o!==0&&(r[t][1]=l.substring(l.length-o)+r[t][1],l=l.substring(0,l.length-o),i=i.substring(0,i.length-o)));var h=n+s;i.length===0&&l.length===0?(r.splice(t-h,h),t=t-h):i.length===0?(r.splice(t-h,h,[V,l]),t=t-h+1):l.length===0?(r.splice(t-h,h,[rt,i]),t=t-h+1):(r.splice(t-h,h,[rt,i],[V,l]),t=t-h+2)}t!==0&&r[t-1][0]===D?(r[t-1][1]+=r[t][1],r.splice(t,1)):t++,n=0,s=0,i="",l="";break}}r[r.length-1][1]===""&&r.pop();var m=!1;for(t=1;t=55296&&r<=56319}function _n(r){return r>=56320&&r<=57343}function In(r){return _n(r.charCodeAt(0))}function Rn(r){return On(r.charCodeAt(r.length-1))}function Ro(r){for(var e=[],t=0;t0&&e.push(r[t]);return e}function Kr(r,e,t,s){return Rn(r)||In(s)?null:Ro([[D,r],[rt,e],[V,t],[D,s]])}function Bo(r,e,t){var s=typeof t=="number"?{index:t,length:0}:t.oldRange,n=typeof t=="number"?null:t.newRange,i=r.length,l=e.length;if(s.length===0&&(n===null||n.length===0)){var o=s.index,a=r.slice(0,o),c=r.slice(o),u=n?n.index:null;t:{var h=o+l-i;if(u!==null&&u!==h||h<0||h>l)break t;var m=e.slice(0,h),p=e.slice(h);if(p!==c)break t;var b=Math.min(o,h),E=a.slice(0,b),N=m.slice(0,b);if(E!==N)break t;var v=a.slice(b),x=m.slice(b);return Kr(E,v,x,c)}t:{if(u!==null&&u!==o)break t;var A=o,m=e.slice(0,A),p=e.slice(A);if(m!==a)break t;var w=Math.min(i-A,l-A),S=c.slice(c.length-w),k=p.slice(p.length-w);if(S!==k)break t;var v=c.slice(0,c.length-w),x=p.slice(0,p.length-w);return Kr(a,v,x,S)}}if(s.length>0&&n&&n.length===0)t:{var E=r.slice(0,s.index),S=r.slice(s.index+s.length),b=E.length,w=S.length;if(l{f();var Mo=200,Wn="__lodash_hash_undefined__",Zn=9007199254740991,rs="[object Arguments]",Do="[object Array]",Qn="[object Boolean]",Xn="[object Date]",Uo="[object Error]",ss="[object Function]",Yn="[object GeneratorFunction]",Ke="[object Map]",Jn="[object Number]",ns="[object Object]",Dn="[object Promise]",ti="[object RegExp]",Ge="[object Set]",ei="[object String]",ri="[object Symbol]",Qr="[object WeakMap]",si="[object ArrayBuffer]",We="[object DataView]",ni="[object Float32Array]",ii="[object Float64Array]",li="[object Int8Array]",oi="[object Int16Array]",ai="[object Int32Array]",ci="[object Uint8Array]",ui="[object Uint8ClampedArray]",hi="[object Uint16Array]",fi="[object Uint32Array]",Po=/[\\^$.*+?()[\]{}|]/g,jo=/\w*$/,Ho=/^\[object .+?Constructor\]$/,Fo=/^(?:0|[1-9]\d*)$/,T={};T[rs]=T[Do]=T[si]=T[We]=T[Qn]=T[Xn]=T[ni]=T[ii]=T[li]=T[oi]=T[ai]=T[Ke]=T[Jn]=T[ns]=T[ti]=T[Ge]=T[ei]=T[ri]=T[ci]=T[ui]=T[hi]=T[fi]=!0;T[Uo]=T[ss]=T[Qr]=!1;var $o=typeof global=="object"&&global&&global.Object===Object&&global,zo=typeof self=="object"&&self&&self.Object===Object&&self,mt=$o||zo||Function("return this")(),di=typeof Ne=="object"&&Ne&&!Ne.nodeType&&Ne,Un=di&&typeof ne=="object"&&ne&&!ne.nodeType&&ne,Vo=Un&&Un.exports===di;function Ko(r,e){return r.set(e[0],e[1]),r}function Go(r,e){return r.add(e),r}function Wo(r,e){for(var t=-1,s=r?r.length:0;++t-1}function Na(r,e){var t=this.__data__,s=Xe(t,r);return s<0?t.push([r,e]):t[s][1]=e,this}pt.prototype.clear=ba;pt.prototype.delete=ya;pt.prototype.get=va;pt.prototype.has=Ea;pt.prototype.set=Na;function ie(r){var e=-1,t=r?r.length:0;for(this.clear();++e-1&&r%1==0&&r-1&&r%1==0&&r<=Zn}function Je(r){var e=typeof r;return!!r&&(e=="object"||e=="function")}function lc(r){return!!r&&typeof r=="object"}function as(r){return xi(r)?_a(r):Ua(r)}function oc(){return[]}function ac(){return!1}ne.exports=ec});var Ns=Tt((we,ce)=>{f();var cc=200,Es="__lodash_hash_undefined__",or=1,Bi=2,Mi=9007199254740991,tr="[object Arguments]",ds="[object Array]",uc="[object AsyncFunction]",Di="[object Boolean]",Ui="[object Date]",Pi="[object Error]",ji="[object Function]",hc="[object GeneratorFunction]",er="[object Map]",Hi="[object Number]",fc="[object Null]",ae="[object Object]",wi="[object Promise]",dc="[object Proxy]",Fi="[object RegExp]",rr="[object Set]",$i="[object String]",mc="[object Symbol]",pc="[object Undefined]",ms="[object WeakMap]",zi="[object ArrayBuffer]",sr="[object DataView]",gc="[object Float32Array]",bc="[object Float64Array]",yc="[object Int8Array]",vc="[object Int16Array]",Ec="[object Int32Array]",Nc="[object Uint8Array]",xc="[object Uint8ClampedArray]",Ac="[object Uint16Array]",wc="[object Uint32Array]",Tc=/[\\^$.*+?()[\]{}|]/g,Lc=/^\[object .+?Constructor\]$/,qc=/^(?:0|[1-9]\d*)$/,q={};q[gc]=q[bc]=q[yc]=q[vc]=q[Ec]=q[Nc]=q[xc]=q[Ac]=q[wc]=!0;q[tr]=q[ds]=q[zi]=q[Di]=q[sr]=q[Ui]=q[Pi]=q[ji]=q[er]=q[Hi]=q[ae]=q[Fi]=q[rr]=q[$i]=q[ms]=!1;var Vi=typeof global=="object"&&global&&global.Object===Object&&global,Sc=typeof self=="object"&&self&&self.Object===Object&&self,gt=Vi||Sc||Function("return this")(),Ki=typeof we=="object"&&we&&!we.nodeType&&we,Ti=Ki&&typeof ce=="object"&&ce&&!ce.nodeType&&ce,Gi=Ti&&Ti.exports===Ki,us=Gi&&Vi.process,Li=(function(){try{return us&&us.binding&&us.binding("util")}catch(r){}})(),qi=Li&&Li.isTypedArray;function kc(r,e){for(var t=-1,s=r==null?0:r.length,n=0,i=[];++t-1}function iu(r,e){var t=this.__data__,s=cr(t,r);return s<0?(++this.size,t.push([r,e])):t[s][1]=e,this}bt.prototype.clear=eu;bt.prototype.delete=ru;bt.prototype.get=su;bt.prototype.has=nu;bt.prototype.set=iu;function Vt(r){var e=-1,t=r==null?0:r.length;for(this.clear();++eo))return!1;var c=i.get(r);if(c&&i.get(e))return c==e;var u=-1,h=!0,m=t&Bi?new ir:void 0;for(i.set(r,e),i.set(e,r);++u-1&&r%1==0&&r-1&&r%1==0&&r<=Mi}function rl(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function qe(r){return r!=null&&typeof r=="object"}var sl=qi?Ic(qi):xu;function Mu(r){return Ru(r)?yu(r):Au(r)}function Du(){return[]}function Uu(){return!1}ce.exports=Bu});var nl=Tt(As=>{"use strict";f();Object.defineProperty(As,"__esModule",{value:!0});var Pu=cs(),ju=Ns(),xs;(function(r){function e(i={},l={},o=!1){typeof i!="object"&&(i={}),typeof l!="object"&&(l={});let a=Pu(l);o||(a=Object.keys(a).reduce((c,u)=>(a[u]!=null&&(c[u]=a[u]),c),{}));for(let c in i)i[c]!==void 0&&l[c]===void 0&&(a[c]=i[c]);return Object.keys(a).length>0?a:void 0}r.compose=e;function t(i={},l={}){typeof i!="object"&&(i={}),typeof l!="object"&&(l={});let o=Object.keys(i).concat(Object.keys(l)).reduce((a,c)=>(ju(i[c],l[c])||(a[c]=l[c]===void 0?null:l[c]),a),{});return Object.keys(o).length>0?o:void 0}r.diff=t;function s(i={},l={}){i=i||{};let o=Object.keys(l).reduce((a,c)=>(l[c]!==i[c]&&i[c]!==void 0&&(a[c]=l[c]),a),{});return Object.keys(i).reduce((a,c)=>(i[c]!==l[c]&&l[c]===void 0&&(a[c]=null),a),o)}r.invert=s;function n(i,l,o=!1){if(typeof i!="object")return l;if(typeof l!="object")return;if(!o)return l;let a=Object.keys(l).reduce((c,u)=>(i[u]===void 0&&(c[u]=l[u]),c),{});return Object.keys(a).length>0?a:void 0}r.transform=n})(xs||(xs={}));As.default=xs});var Ls=Tt(Ts=>{"use strict";f();Object.defineProperty(Ts,"__esModule",{value:!0});var ws;(function(r){function e(t){return typeof t.delete=="number"?t.delete:typeof t.retain=="number"?t.retain:typeof t.retain=="object"&&t.retain!==null?1:typeof t.insert=="string"?t.insert.length:1}r.length=e})(ws||(ws={}));Ts.default=ws});var ll=Tt(Ss=>{"use strict";f();Object.defineProperty(Ss,"__esModule",{value:!0});var il=Ls(),qs=class{constructor(e){this.ops=e,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(e){e||(e=1/0);let t=this.ops[this.index];if(t){let s=this.offset,n=il.default.length(t);if(e>=n-s?(e=n-s,this.index+=1,this.offset=0):this.offset+=e,typeof t.delete=="number")return{delete:e};{let i={};return t.attributes&&(i.attributes=t.attributes),typeof t.retain=="number"?i.retain=e:typeof t.retain=="object"&&t.retain!==null?i.retain=t.retain:typeof t.insert=="string"?i.insert=t.insert.substr(s,e):i.insert=t.insert,i}}else return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?il.default.length(this.ops[this.index])-this.offset:1/0}peekType(){let e=this.ops[this.index];return e?typeof e.delete=="number"?"delete":typeof e.retain=="number"||typeof e.retain=="object"&&e.retain!==null?"retain":"insert":"retain"}rest(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);{let e=this.offset,t=this.index,s=this.next(),n=this.ops.slice(this.index);return this.offset=e,this.index=t,[s].concat(n)}}else return[]}};Ss.default=qs});var st=Tt((vt,fr)=>{"use strict";f();Object.defineProperty(vt,"__esModule",{value:!0});vt.AttributeMap=vt.OpIterator=vt.Op=void 0;var hr=Mn(),Hu=cs(),ks=Ns(),Gt=nl();vt.AttributeMap=Gt.default;var yt=Ls();vt.Op=yt.default;var it=ll();vt.OpIterator=it.default;var Fu="\0",ol=(r,e)=>{if(typeof r!="object"||r===null)throw new Error(`cannot retain a ${typeof r}`);if(typeof e!="object"||e===null)throw new Error(`cannot retain a ${typeof e}`);let t=Object.keys(r)[0];if(!t||t!==Object.keys(e)[0])throw new Error(`embed types not matched: ${t} != ${Object.keys(e)[0]}`);return[t,r[t],e[t]]},Et=class r{constructor(e){Array.isArray(e)?this.ops=e:e!=null&&Array.isArray(e.ops)?this.ops=e.ops:this.ops=[]}static registerEmbed(e,t){this.handlers[e]=t}static unregisterEmbed(e){delete this.handlers[e]}static getHandler(e){let t=this.handlers[e];if(!t)throw new Error(`no handlers for embed type "${e}"`);return t}insert(e,t){let s={};return typeof e=="string"&&e.length===0?this:(s.insert=e,t!=null&&typeof t=="object"&&Object.keys(t).length>0&&(s.attributes=t),this.push(s))}delete(e){return e<=0?this:this.push({delete:e})}retain(e,t){if(typeof e=="number"&&e<=0)return this;let s={retain:e};return t!=null&&typeof t=="object"&&Object.keys(t).length>0&&(s.attributes=t),this.push(s)}push(e){let t=this.ops.length,s=this.ops[t-1];if(e=Hu(e),typeof s=="object"){if(typeof e.delete=="number"&&typeof s.delete=="number")return this.ops[t-1]={delete:s.delete+e.delete},this;if(typeof s.delete=="number"&&e.insert!=null&&(t-=1,s=this.ops[t-1],typeof s!="object"))return this.ops.unshift(e),this;if(ks(e.attributes,s.attributes)){if(typeof e.insert=="string"&&typeof s.insert=="string")return this.ops[t-1]={insert:s.insert+e.insert},typeof e.attributes=="object"&&(this.ops[t-1].attributes=e.attributes),this;if(typeof e.retain=="number"&&typeof s.retain=="number")return this.ops[t-1]={retain:s.retain+e.retain},typeof e.attributes=="object"&&(this.ops[t-1].attributes=e.attributes),this}}return t===this.ops.length?this.ops.push(e):this.ops.splice(t,0,e),this}chop(){let e=this.ops[this.ops.length-1];return e&&typeof e.retain=="number"&&!e.attributes&&this.ops.pop(),this}filter(e){return this.ops.filter(e)}forEach(e){this.ops.forEach(e)}map(e){return this.ops.map(e)}partition(e){let t=[],s=[];return this.forEach(n=>{(e(n)?t:s).push(n)}),[t,s]}reduce(e,t){return this.ops.reduce(e,t)}changeLength(){return this.reduce((e,t)=>t.insert?e+yt.default.length(t):t.delete?e-t.delete:e,0)}length(){return this.reduce((e,t)=>e+yt.default.length(t),0)}slice(e=0,t=1/0){let s=[],n=new it.default(this.ops),i=0;for(;i0&&s.next(i.retain-o)}let l=new r(n);for(;t.hasNext()||s.hasNext();)if(s.peekType()==="insert")l.push(s.next());else if(t.peekType()==="delete")l.push(t.next());else{let o=Math.min(t.peekLength(),s.peekLength()),a=t.next(o),c=s.next(o);if(c.retain){let u={};if(typeof a.retain=="number")u.retain=typeof c.retain=="number"?o:c.retain;else if(typeof c.retain=="number")a.retain==null?u.insert=a.insert:u.retain=a.retain;else{let m=a.retain==null?"insert":"retain",[p,b,E]=ol(a[m],c.retain),N=r.getHandler(p);u[m]={[p]:N.compose(b,E,m==="retain")}}let h=Gt.default.compose(a.attributes,c.attributes,typeof a.retain=="number");if(h&&(u.attributes=h),l.push(u),!s.hasNext()&&ks(l.ops[l.ops.length-1],u)){let m=new r(t.rest());return l.concat(m).chop()}}else typeof c.delete=="number"&&(typeof a.retain=="number"||typeof a.retain=="object"&&a.retain!==null)&&l.push(c)}return l.chop()}concat(e){let t=new r(this.ops.slice());return e.ops.length>0&&(t.push(e.ops[0]),t.ops=t.ops.concat(e.ops.slice(1))),t}diff(e,t){if(this.ops===e.ops)return new r;let s=[this,e].map(a=>a.map(c=>{if(c.insert!=null)return typeof c.insert=="string"?c.insert:Fu;let u=a===e?"on":"with";throw new Error("diff() called "+u+" non-document")}).join("")),n=new r,i=hr(s[0],s[1],t,!0),l=new it.default(this.ops),o=new it.default(e.ops);return i.forEach(a=>{let c=a[1].length;for(;c>0;){let u=0;switch(a[0]){case hr.INSERT:u=Math.min(o.peekLength(),c),n.push(o.next(u));break;case hr.DELETE:u=Math.min(c,l.peekLength()),l.next(u),n.delete(u);break;case hr.EQUAL:u=Math.min(l.peekLength(),o.peekLength(),c);let h=l.next(u),m=o.next(u);ks(h.insert,m.insert)?n.retain(u,Gt.default.diff(h.attributes,m.attributes)):n.push(m).delete(u);break}c-=u}}),n.chop()}eachLine(e,t=` `){let s=new it.default(this.ops),n=new r,i=0;for(;s.hasNext();){if(s.peekType()!=="insert")return;let l=s.peek(),o=yt.default.length(l)-s.peekLength(),a=typeof l.insert=="string"?l.insert.indexOf(t,o)-o:-1;if(a<0)n.push(s.next());else if(a>0)n.push(s.next(a));else{if(e(n,s.next(1).attributes||{},i)===!1)return;i+=1,n=new r}}n.length()>0&&e(n,{},i)}invert(e){let t=new r;return this.reduce((s,n)=>{if(n.insert)t.delete(yt.default.length(n));else{if(typeof n.retain=="number"&&n.attributes==null)return t.retain(n.retain),s+n.retain;if(n.delete||typeof n.retain=="number"){let i=n.delete||n.retain;return e.slice(s,s+i).forEach(o=>{n.delete?t.push(o):n.retain&&n.attributes&&t.retain(yt.default.length(o),Gt.default.invert(n.attributes,o.attributes))}),s+i}else if(typeof n.retain=="object"&&n.retain!==null){let i=e.slice(s,s+1),l=new it.default(i.ops).next(),[o,a,c]=ol(n.retain,l.insert),u=r.getHandler(o);return t.retain({[o]:u.invert(a,c)},Gt.default.invert(n.attributes,l.attributes)),s+1}}return s},0),t.chop()}transform(e,t=!1){if(t=!!t,typeof e=="number")return this.transformPosition(e,t);let s=e,n=new it.default(this.ops),i=new it.default(s.ops),l=new r;for(;n.hasNext()||i.hasNext();)if(n.peekType()==="insert"&&(t||i.peekType()!=="insert"))l.retain(yt.default.length(n.next()));else if(i.peekType()==="insert")l.push(i.next());else{let o=Math.min(n.peekLength(),i.peekLength()),a=n.next(o),c=i.next(o);if(a.delete)continue;if(c.delete)l.push(c);else{let u=a.retain,h=c.retain,m=typeof h=="object"&&h!==null?h:o;if(typeof u=="object"&&u!==null&&typeof h=="object"&&h!==null){let p=Object.keys(u)[0];if(p===Object.keys(h)[0]){let b=r.getHandler(p);b&&(m={[p]:b.transform(u[p],h[p],t)})}}l.retain(m,Gt.default.transform(a.attributes,c.attributes,t))}}return l.chop()}transformPosition(e,t=!1){t=!!t;let s=new it.default(this.ops),n=0;for(;s.hasNext()&&n<=e;){let i=s.peekLength(),l=s.peekType();if(s.next(),l==="delete"){e-=Math.min(i,e-n);continue}else l==="insert"&&(n{"use strict";f();var Gu=Object.prototype.hasOwnProperty,K="~";function ke(){}Object.create&&(ke.prototype=Object.create(null),new ke().__proto__||(K=!1));function Wu(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function cl(r,e,t,s,n){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new Wu(t,s||r,n),l=K?K+e:e;return r._events[l]?r._events[l].fn?r._events[l]=[r._events[l],i]:r._events[l].push(i):(r._events[l]=i,r._eventsCount++),r}function dr(r,e){--r._eventsCount===0?r._events=new ke:delete r._events[e]}function F(){this._events=new ke,this._eventsCount=0}F.prototype.eventNames=function(){var e=[],t,s;if(this._eventsCount===0)return e;for(s in t=this._events)Gu.call(t,s)&&e.push(K?s.slice(1):s);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};F.prototype.listeners=function(e){var t=K?K+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var n=0,i=s.length,l=new Array(i);nz,AttributorStore:()=>be,BlockBlot:()=>Pt,ClassAttributor:()=>B,ContainerBlot:()=>re,EmbedBlot:()=>C,InlineBlot:()=>$e,LeafBlot:()=>M,ParentBlot:()=>Z,Registry:()=>St,Scope:()=>g,ScrollBlot:()=>ye,StyleAttributor:()=>Q,TextBlot:()=>se});f();var g=(r=>(r[r.TYPE=3]="TYPE",r[r.LEVEL=12]="LEVEL",r[r.ATTRIBUTE=13]="ATTRIBUTE",r[r.BLOT=14]="BLOT",r[r.INLINE=7]="INLINE",r[r.BLOCK=11]="BLOCK",r[r.BLOCK_BLOT=10]="BLOCK_BLOT",r[r.INLINE_BLOT=6]="INLINE_BLOT",r[r.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",r[r.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",r[r.ANY=15]="ANY",r))(g||{}),z=class{constructor(e,t,s={}){this.attrName=e,this.keyName=t;let n=g.TYPE&g.ATTRIBUTE;this.scope=s.scope!=null?s.scope&g.LEVEL|n:g.ATTRIBUTE,s.whitelist!=null&&(this.whitelist=s.whitelist)}static keys(e){return Array.from(e.attributes).map(t=>t.name)}add(e,t){return this.canAdd(e,t)?(e.setAttribute(this.keyName,t),!0):!1}canAdd(e,t){return this.whitelist==null?!0:typeof t=="string"?this.whitelist.indexOf(t.replace(/["']/g,""))>-1:this.whitelist.indexOf(t)>-1}remove(e){e.removeAttribute(this.keyName)}value(e){let t=e.getAttribute(this.keyName);return this.canAdd(e,t)&&t?t:""}},qt=class extends Error{constructor(e){e="[Parchment] "+e,super(e),this.message=e,this.name=this.constructor.name}},po=(()=>{let r=class Dr{constructor(){this.attributes={},this.classes={},this.tags={},this.types={}}static find(t,s=!1){if(t==null)return null;if(this.blots.has(t))return this.blots.get(t)||null;if(s){let n=null;try{n=t.parentNode}catch(i){return null}return this.find(n,s)}return null}create(t,s,n){let i=this.query(s);if(i==null)throw new qt(`Unable to create ${s} blot`);let l=i,o=s instanceof Node||s.nodeType===Node.TEXT_NODE?s:l.create(n),a=new l(t,o,n);return Dr.blots.set(a.domNode,a),a}find(t,s=!1){return Dr.find(t,s)}query(t,s=g.ANY){let n;return typeof t=="string"?n=this.types[t]||this.attributes[t]:t instanceof Text||t.nodeType===Node.TEXT_NODE?n=this.types.text:typeof t=="number"?t&g.LEVEL&g.BLOCK?n=this.types.block:t&g.LEVEL&g.INLINE&&(n=this.types.inline):t instanceof Element&&((t.getAttribute("class")||"").split(/\s+/).some(i=>(n=this.classes[i],!!n)),n=n||this.tags[t.tagName]),n==null?null:"scope"in n&&s&g.LEVEL&n.scope&&s&g.TYPE&n.scope?n:null}register(...t){return t.map(s=>{let n="blotName"in s,i="attrName"in s;if(!n&&!i)throw new qt("Invalid definition");if(n&&s.blotName==="abstract")throw new qt("Cannot register abstract class");let l=n?s.blotName:i?s.attrName:void 0;return this.types[l]=s,i?typeof s.keyName=="string"&&(this.attributes[s.keyName]=s):n&&(s.className&&(this.classes[s.className]=s),s.tagName&&(Array.isArray(s.tagName)?s.tagName=s.tagName.map(o=>o.toUpperCase()):s.tagName=s.tagName.toUpperCase(),(Array.isArray(s.tagName)?s.tagName:[s.tagName]).forEach(o=>{(this.tags[o]==null||s.className==null)&&(this.tags[o]=s)}))),s})}};return r.blots=new WeakMap,r})(),St=po;function En(r,e){return(r.getAttribute("class")||"").split(/\s+/).filter(t=>t.indexOf(`${e}-`)===0)}var Ur=class extends z{static keys(e){return(e.getAttribute("class")||"").split(/\s+/).map(t=>t.split("-").slice(0,-1).join("-"))}add(e,t){return this.canAdd(e,t)?(this.remove(e),e.classList.add(`${this.keyName}-${t}`),!0):!1}remove(e){En(e,this.keyName).forEach(t=>{e.classList.remove(t)}),e.classList.length===0&&e.removeAttribute("class")}value(e){let t=(En(e,this.keyName)[0]||"").slice(this.keyName.length+1);return this.canAdd(e,t)?t:""}},B=Ur;function Mr(r){let e=r.split("-"),t=e.slice(1).map(s=>s[0].toUpperCase()+s.slice(1)).join("");return e[0]+t}var Pr=class extends z{static keys(e){return(e.getAttribute("style")||"").split(";").map(t=>t.split(":")[0].trim())}add(e,t){return this.canAdd(e,t)?(e.style[Mr(this.keyName)]=t,!0):!1}remove(e){e.style[Mr(this.keyName)]="",e.getAttribute("style")||e.removeAttribute("style")}value(e){let t=e.style[Mr(this.keyName)];return this.canAdd(e,t)?t:""}},Q=Pr,jr=class{constructor(e){this.attributes={},this.domNode=e,this.build()}attribute(e,t){t?e.add(this.domNode,t)&&(e.value(this.domNode)!=null?this.attributes[e.attrName]=e:delete this.attributes[e.attrName]):(e.remove(this.domNode),delete this.attributes[e.attrName])}build(){this.attributes={};let e=St.find(this.domNode);if(e==null)return;let t=z.keys(this.domNode),s=B.keys(this.domNode),n=Q.keys(this.domNode);t.concat(s).concat(n).forEach(i=>{let l=e.scroll.query(i,g.ATTRIBUTE);l instanceof z&&(this.attributes[l.attrName]=l)})}copy(e){Object.keys(this.attributes).forEach(t=>{let s=this.attributes[t].value(this.domNode);e.format(t,s)})}move(e){this.copy(e),Object.keys(this.attributes).forEach(t=>{this.attributes[t].remove(this.domNode)}),this.attributes={}}values(){return Object.keys(this.attributes).reduce((e,t)=>(e[t]=this.attributes[t].value(this.domNode),e),{})}},be=jr,xn=class{constructor(e,t){this.scroll=e,this.domNode=t,St.blots.set(t,this),this.prev=null,this.next=null}static create(e){if(this.tagName==null)throw new qt("Blot definition missing tagName");let t,s;return Array.isArray(this.tagName)?(typeof e=="string"?(s=e.toUpperCase(),parseInt(s,10).toString()===s&&(s=parseInt(s,10))):typeof e=="number"&&(s=e),typeof s=="number"?t=document.createElement(this.tagName[s-1]):s&&this.tagName.indexOf(s)>-1?t=document.createElement(s):t=document.createElement(this.tagName[0])):t=document.createElement(this.tagName),this.className&&t.classList.add(this.className),t}get statics(){return this.constructor}attach(){}clone(){let e=this.domNode.cloneNode(!1);return this.scroll.create(e)}detach(){this.parent!=null&&this.parent.removeChild(this),St.blots.delete(this.domNode)}deleteAt(e,t){this.isolate(e,t).remove()}formatAt(e,t,s,n){let i=this.isolate(e,t);if(this.scroll.query(s,g.BLOT)!=null&&n)i.wrap(s,n);else if(this.scroll.query(s,g.ATTRIBUTE)!=null){let l=this.scroll.create(this.statics.scope);i.wrap(l),l.format(s,n)}}insertAt(e,t,s){let n=s==null?this.scroll.create("text",t):this.scroll.create(t,s),i=this.split(e);this.parent.insertBefore(n,i||void 0)}isolate(e,t){let s=this.split(e);if(s==null)throw new Error("Attempt to isolate at end");return s.split(t),s}length(){return 1}offset(e=this.parent){return this.parent==null||this===e?0:this.parent.children.offset(this)+this.parent.offset(e)}optimize(e){this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName)}remove(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()}replaceWith(e,t){let s=typeof e=="string"?this.scroll.create(e,t):e;return this.parent!=null&&(this.parent.insertBefore(s,this.next||void 0),this.remove()),s}split(e,t){return e===0?this:this.next}update(e,t){}wrap(e,t){let s=typeof e=="string"?this.scroll.create(e,t):e;if(this.parent!=null&&this.parent.insertBefore(s,this.next||void 0),typeof s.appendChild!="function")throw new qt(`Cannot wrap ${e}`);return s.appendChild(this),s}};xn.blotName="abstract";var An=xn,wn=class extends An{static value(e){return!0}index(e,t){return this.domNode===e||this.domNode.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(t,1):-1}position(e,t){let s=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return e>0&&(s+=1),[this.parent.domNode,s]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}};wn.scope=g.INLINE_BLOT;var go=wn,M=go,Hr=class{constructor(){this.head=null,this.tail=null,this.length=0}append(...e){if(this.insertBefore(e[0],null),e.length>1){let t=e.slice(1);this.append(...t)}}at(e){let t=this.iterator(),s=t();for(;s&&e>0;)e-=1,s=t();return s}contains(e){let t=this.iterator(),s=t();for(;s;){if(s===e)return!0;s=t()}return!1}indexOf(e){let t=this.iterator(),s=t(),n=0;for(;s;){if(s===e)return n;n+=1,s=t()}return-1}insertBefore(e,t){e!=null&&(this.remove(e),e.next=t,t!=null?(e.prev=t.prev,t.prev!=null&&(t.prev.next=e),t.prev=e,t===this.head&&(this.head=e)):this.tail!=null?(this.tail.next=e,e.prev=this.tail,this.tail=e):(e.prev=null,this.head=this.tail=e),this.length+=1)}offset(e){let t=0,s=this.head;for(;s!=null;){if(s===e)return t;t+=s.length(),s=s.next}return-1}remove(e){this.contains(e)&&(e.prev!=null&&(e.prev.next=e.next),e.next!=null&&(e.next.prev=e.prev),e===this.head&&(this.head=e.next),e===this.tail&&(this.tail=e.prev),this.length-=1)}iterator(e=this.head){return()=>{let t=e;return e!=null&&(e=e.next),t}}find(e,t=!1){let s=this.iterator(),n=s();for(;n;){let i=n.length();if(el?s(a,e-l,Math.min(t,l+c-e)):s(a,0,Math.min(c,e+t-l)),l+=c,a=o()}}map(e){return this.reduce((t,s)=>(t.push(e(s)),t),[])}reduce(e,t){let s=this.iterator(),n=s();for(;n;)t=e(t,n),n=s();return t}};function Nn(r,e){let t=e.find(r);if(t)return t;try{return e.create(r)}catch(s){let n=e.create(g.INLINE);return Array.from(r.childNodes).forEach(i=>{n.domNode.appendChild(i)}),r.parentNode&&r.parentNode.replaceChild(n.domNode,r),n.attach(),n}}var bo=(()=>{let r=class Lt extends An{constructor(t,s){super(t,s),this.uiNode=null,this.build()}appendChild(t){this.insertBefore(t)}attach(){super.attach(),this.children.forEach(t=>{t.attach()})}attachUI(t){this.uiNode!=null&&this.uiNode.remove(),this.uiNode=t,Lt.uiClass&&this.uiNode.classList.add(Lt.uiClass),this.uiNode.setAttribute("contenteditable","false"),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new Hr,Array.from(this.domNode.childNodes).filter(t=>t!==this.uiNode).reverse().forEach(t=>{try{let s=Nn(t,this.scroll);this.insertBefore(s,this.children.head||void 0)}catch(s){if(s instanceof qt)return;throw s}})}deleteAt(t,s){if(t===0&&s===this.length())return this.remove();this.children.forEachAt(t,s,(n,i,l)=>{n.deleteAt(i,l)})}descendant(t,s=0){let[n,i]=this.children.find(s);return t.blotName==null&&t(n)||t.blotName!=null&&n instanceof t?[n,i]:n instanceof Lt?n.descendant(t,i):[null,-1]}descendants(t,s=0,n=Number.MAX_VALUE){let i=[],l=n;return this.children.forEachAt(s,n,(o,a,c)=>{(t.blotName==null&&t(o)||t.blotName!=null&&o instanceof t)&&i.push(o),o instanceof Lt&&(i=i.concat(o.descendants(t,a,l))),l-=c}),i}detach(){this.children.forEach(t=>{t.detach()}),super.detach()}enforceAllowedChildren(){let t=!1;this.children.forEach(s=>{t||this.statics.allowedChildren.some(n=>s instanceof n)||(s.statics.scope===g.BLOCK_BLOT?(s.next!=null&&this.splitAfter(s),s.prev!=null&&this.splitAfter(s.prev),s.parent.unwrap(),t=!0):s instanceof Lt?s.unwrap():s.remove())})}formatAt(t,s,n,i){this.children.forEachAt(t,s,(l,o,a)=>{l.formatAt(o,a,n,i)})}insertAt(t,s,n){let[i,l]=this.children.find(t);if(i)i.insertAt(l,s,n);else{let o=n==null?this.scroll.create("text",s):this.scroll.create(s,n);this.appendChild(o)}}insertBefore(t,s){t.parent!=null&&t.parent.children.remove(t);let n=null;this.children.insertBefore(t,s||null),t.parent=this,s!=null&&(n=s.domNode),(this.domNode.parentNode!==t.domNode||this.domNode.nextSibling!==n)&&this.domNode.insertBefore(t.domNode,n),t.attach()}length(){return this.children.reduce((t,s)=>t+s.length(),0)}moveChildren(t,s){this.children.forEach(n=>{t.insertBefore(n,s)})}optimize(t){if(super.optimize(t),this.enforceAllowedChildren(),this.uiNode!=null&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length===0)if(this.statics.defaultChild!=null){let s=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(s)}else this.remove()}path(t,s=!1){let[n,i]=this.children.find(t,s),l=[[this,t]];return n instanceof Lt?l.concat(n.path(i,s)):(n!=null&&l.push([n,i]),l)}removeChild(t){this.children.remove(t)}replaceWith(t,s){let n=typeof t=="string"?this.scroll.create(t,s):t;return n instanceof Lt&&this.moveChildren(n),super.replaceWith(n)}split(t,s=!1){if(!s){if(t===0)return this;if(t===this.length())return this.next}let n=this.clone();return this.parent&&this.parent.insertBefore(n,this.next||void 0),this.children.forEachAt(t,this.length(),(i,l,o)=>{let a=i.split(l,s);a!=null&&n.appendChild(a)}),n}splitAfter(t){let s=this.clone();for(;t.next!=null;)s.appendChild(t.next);return this.parent&&this.parent.insertBefore(s,this.next||void 0),s}unwrap(){this.parent&&this.moveChildren(this.parent,this.next||void 0),this.remove()}update(t,s){let n=[],i=[];t.forEach(l=>{l.target===this.domNode&&l.type==="childList"&&(n.push(...l.addedNodes),i.push(...l.removedNodes))}),i.forEach(l=>{if(l.parentNode!=null&&l.tagName!=="IFRAME"&&document.body.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;let o=this.scroll.find(l);o!=null&&(o.domNode.parentNode==null||o.domNode.parentNode===this.domNode)&&o.detach()}),n.filter(l=>l.parentNode===this.domNode&&l!==this.uiNode).sort((l,o)=>l===o?0:l.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1).forEach(l=>{let o=null;l.nextSibling!=null&&(o=this.scroll.find(l.nextSibling));let a=Nn(l,this.scroll);(a.next!==o||a.next==null)&&(a.parent!=null&&a.parent.removeChild(this),this.insertBefore(a,o||void 0))}),this.enforceAllowedChildren()}};return r.uiClass="",r})(),yo=bo,Z=yo;function vo(r,e){if(Object.keys(r).length!==Object.keys(e).length)return!1;for(let t in r)if(r[t]!==e[t])return!1;return!0}var Yt=class Jt extends Z{static create(e){return super.create(e)}static formats(e,t){let s=t.query(Jt.blotName);if(!(s!=null&&e.tagName===s.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return e.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new be(this.domNode)}format(e,t){if(e===this.statics.blotName&&!t)this.children.forEach(s=>{s instanceof Jt||(s=s.wrap(Jt.blotName,!0)),this.attributes.copy(s)}),this.unwrap();else{let s=this.scroll.query(e,g.INLINE);if(s==null)return;s instanceof z?this.attributes.attribute(s,t):t&&(e!==this.statics.blotName||this.formats()[e]!==t)&&this.replaceWith(e,t)}}formats(){let e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return t!=null&&(e[this.statics.blotName]=t),e}formatAt(e,t,s,n){this.formats()[s]!=null||this.scroll.query(s,g.ATTRIBUTE)?this.isolate(e,t).format(s,n):super.formatAt(e,t,s,n)}optimize(e){super.optimize(e);let t=this.formats();if(Object.keys(t).length===0)return this.unwrap();let s=this.next;s instanceof Jt&&s.prev===this&&vo(t,s.formats())&&(s.moveChildren(this),s.remove())}replaceWith(e,t){let s=super.replaceWith(e,t);return this.attributes.copy(s),s}update(e,t){super.update(e,t),e.some(s=>s.target===this.domNode&&s.type==="attributes")&&this.attributes.build()}wrap(e,t){let s=super.wrap(e,t);return s instanceof Jt&&this.attributes.move(s),s}};Yt.allowedChildren=[Yt,M],Yt.blotName="inline",Yt.scope=g.INLINE_BLOT,Yt.tagName="SPAN";var Eo=Yt,$e=Eo,te=class Fr extends Z{static create(e){return super.create(e)}static formats(e,t){let s=t.query(Fr.blotName);if(!(s!=null&&e.tagName===s.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return e.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new be(this.domNode)}format(e,t){let s=this.scroll.query(e,g.BLOCK);s!=null&&(s instanceof z?this.attributes.attribute(s,t):e===this.statics.blotName&&!t?this.replaceWith(Fr.blotName):t&&(e!==this.statics.blotName||this.formats()[e]!==t)&&this.replaceWith(e,t))}formats(){let e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return t!=null&&(e[this.statics.blotName]=t),e}formatAt(e,t,s,n){this.scroll.query(s,g.BLOCK)!=null?this.format(s,n):super.formatAt(e,t,s,n)}insertAt(e,t,s){if(s==null||this.scroll.query(t,g.INLINE)!=null)super.insertAt(e,t,s);else{let n=this.split(e);if(n!=null){let i=this.scroll.create(t,s);n.parent.insertBefore(i,n)}else throw new Error("Attempt to insertAt after block boundaries")}}replaceWith(e,t){let s=super.replaceWith(e,t);return this.attributes.copy(s),s}update(e,t){super.update(e,t),e.some(s=>s.target===this.domNode&&s.type==="attributes")&&this.attributes.build()}};te.blotName="block",te.scope=g.BLOCK_BLOT,te.tagName="P",te.allowedChildren=[$e,te,M];var No=te,Pt=No,$r=class extends Z{checkMerge(){return this.next!==null&&this.next.statics.blotName===this.statics.blotName}deleteAt(e,t){super.deleteAt(e,t),this.enforceAllowedChildren()}formatAt(e,t,s,n){super.formatAt(e,t,s,n),this.enforceAllowedChildren()}insertAt(e,t,s){super.insertAt(e,t,s),this.enforceAllowedChildren()}optimize(e){super.optimize(e),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}};$r.blotName="container",$r.scope=g.BLOCK_BLOT;var xo=$r,re=xo,zr=class extends M{static formats(e,t){}format(e,t){super.formatAt(0,this.length(),e,t)}formatAt(e,t,s,n){e===0&&t===this.length()?this.format(s,n):super.formatAt(e,t,s,n)}formats(){return this.statics.formats(this.domNode,this.scroll)}},C=zr,Ao={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},wo=100,ee=class extends Z{constructor(e,t){super(null,t),this.registry=e,this.scroll=this,this.build(),this.observer=new MutationObserver(s=>{this.update(s)}),this.observer.observe(this.domNode,Ao),this.attach()}create(e,t){return this.registry.create(this,e,t)}find(e,t=!1){let s=this.registry.find(e,t);return s?s.scroll===this?s:t?this.find(s.scroll.domNode.parentNode,!0):null:null}query(e,t=g.ANY){return this.registry.query(e,t)}register(...e){return this.registry.register(...e)}build(){this.scroll!=null&&super.build()}detach(){super.detach(),this.observer.disconnect()}deleteAt(e,t){this.update(),e===0&&t===this.length()?this.children.forEach(s=>{s.remove()}):super.deleteAt(e,t)}formatAt(e,t,s,n){this.update(),super.formatAt(e,t,s,n)}insertAt(e,t,s){this.update(),super.insertAt(e,t,s)}optimize(e=[],t={}){super.optimize(t);let s=t.mutationsMap||new WeakMap,n=Array.from(this.observer.takeRecords());for(;n.length>0;)e.push(n.pop());let i=(a,c=!0)=>{a==null||a===this||a.domNode.parentNode!=null&&(s.has(a.domNode)||s.set(a.domNode,[]),c&&i(a.parent))},l=a=>{s.has(a.domNode)&&(a instanceof Z&&a.children.forEach(l),s.delete(a.domNode),a.optimize(t))},o=e;for(let a=0;o.length>0;a+=1){if(a>=wo)throw new Error("[Parchment] Maximum optimize iterations reached");for(o.forEach(c=>{let u=this.find(c.target,!0);u!=null&&(u.domNode===c.target&&(c.type==="childList"?(i(this.find(c.previousSibling,!1)),Array.from(c.addedNodes).forEach(h=>{let m=this.find(h,!1);i(m,!1),m instanceof Z&&m.children.forEach(p=>{i(p,!1)})})):c.type==="attributes"&&i(u.prev)),i(u))}),this.children.forEach(l),o=Array.from(this.observer.takeRecords()),n=o.slice();n.length>0;)e.push(n.pop())}}update(e,t={}){e=e||this.observer.takeRecords();let s=new WeakMap;e.map(n=>{let i=this.find(n.target,!0);return i==null?null:s.has(i.domNode)?(s.get(i.domNode).push(n),null):(s.set(i.domNode,[n]),i)}).forEach(n=>{n!=null&&n!==this&&s.has(n.domNode)&&n.update(s.get(n.domNode)||[],t)}),t.mutationsMap=s,s.has(this.domNode)&&super.update(s.get(this.domNode),t),this.optimize(e,t)}};ee.blotName="scroll",ee.defaultChild=Pt,ee.allowedChildren=[Pt,re],ee.scope=g.BLOCK_BLOT,ee.tagName="DIV";var To=ee,ye=To,Vr=class Tn extends M{static create(e){return document.createTextNode(e)}static value(e){return e.data}constructor(e,t){super(e,t),this.text=this.statics.value(this.domNode)}deleteAt(e,t){this.domNode.data=this.text=this.text.slice(0,e)+this.text.slice(e+t)}index(e,t){return this.domNode===e?t:-1}insertAt(e,t,s){s==null?(this.text=this.text.slice(0,e)+t+this.text.slice(e),this.domNode.data=this.text):super.insertAt(e,t,s)}length(){return this.text.length}optimize(e){super.optimize(e),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof Tn&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())}position(e,t=!1){return[this.domNode,e]}split(e,t=!1){if(!t){if(e===0)return this;if(e===this.length())return this.next}let s=this.scroll.create(this.domNode.splitText(e));return this.parent.insertBefore(s,this.next||void 0),this.text=this.statics.value(this.domNode),s}update(e,t){e.some(s=>s.type==="characterData"&&s.target===this.domNode)&&(this.text=this.statics.value(this.domNode))}value(){return this.text}};Vr.blotName="text",Vr.scope=g.INLINE_BLOT;var Lo=Vr,se=Lo;var It=tt(st(),1);f();var O=tt(st(),1);f();var Cs=tt(st(),1);f();var $u=(()=>{class r extends C{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return""}}return r.blotName="break",r.tagName="BR",r})(),j=$u;f();f();var I=class extends se{},zu={"&":"&","<":"<",">":">",'"':""","'":"'"};function Wt(r){return r.replace(/[&<>"']/g,e=>zu[e])}var Vu=(()=>{class r extends $e{static allowedChildren=[r,j,C,I];static order=["cursor","inline","link","underline","strike","italic","bold","script","code"];static compare(t,s){let n=r.order.indexOf(t),i=r.order.indexOf(s);return n>=0||i>=0?n-i:t===s?0:t0){let s=this.parent.isolate(this.offset(),this.length());this.moveChildren(s),s.wrap(this)}}}return r})(),H=Vu;var al=1,R=(()=>{class r extends Pt{cache={};delta(){return this.cache.delta==null&&(this.cache.delta=Os(this)),this.cache.delta}deleteAt(t,s){super.deleteAt(t,s),this.cache={}}formatAt(t,s,n,i){s<=0||(this.scroll.query(n,g.BLOCK)?t+s===this.length()&&this.format(n,i):super.formatAt(t,Math.min(s,this.length()-t-1),n,i),this.cache={})}insertAt(t,s,n){if(n!=null){super.insertAt(t,s,n),this.cache={};return}if(s.length===0)return;let i=s.split(` `),l=i.shift();l.length>0&&(t(o=o.split(a,!0),o.insertAt(0,c),c.length),t+l.length)}insertBefore(t,s){let{head:n}=this.children;super.insertBefore(t,s),n instanceof j&&n.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+al),this.cache.length}moveChildren(t,s){super.moveChildren(t,s),this.cache={}}optimize(t){super.optimize(t),this.cache={}}path(t){return super.path(t,!0)}removeChild(t){super.removeChild(t),this.cache={}}split(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(s&&(t===0||t>=this.length()-al)){let i=this.clone();return t===0?(this.parent.insertBefore(i,this),this):(this.parent.insertBefore(i,this.next),i)}let n=super.split(t,s);return this.cache={},n}}return r.blotName="block",r.tagName="P",r.defaultChild=j,r.allowedChildren=[j,H,C,I],r})(),U=class extends C{attach(){super.attach(),this.attributes=new be(this.domNode)}delta(){return new Cs.default().insert(this.value(),L(L({},this.formats()),this.attributes.values()))}format(e,t){let s=this.scroll.query(e,g.BLOCK_ATTRIBUTE);s!=null&&this.attributes.attribute(s,t)}formatAt(e,t,s,n){this.format(s,n)}insertAt(e,t,s){if(s!=null){super.insertAt(e,t,s);return}let n=t.split(` `),i=n.pop(),l=n.map(a=>{let c=this.scroll.create(R.blotName);return c.insertAt(0,a),c}),o=this.split(e);l.forEach(a=>{this.parent.insertBefore(a,o)}),i&&this.parent.insertBefore(this.scroll.create("text",i),o)}};U.scope=g.BLOCK_BLOT;function Os(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return r.descendants(M).reduce((t,s)=>s.length()===0?t:t.insert(s.value(),X(s,{},e)),new Cs.default).insert(` `,X(r))}function X(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return r==null||("formats"in r&&typeof r.formats=="function"&&(e=L(L({},e),r.formats()),t&&delete e["code-token"]),r.parent==null||r.parent.statics.blotName==="scroll"||r.parent.statics.scope!==r.statics.scope)?e:X(r.parent,e,t)}f();var Ku=(()=>{class r extends C{static blotName="cursor";static className="ql-cursor";static tagName="span";static CONTENTS="\uFEFF";static value(){}constructor(t,s,n){super(t,s),this.selection=n,this.textNode=document.createTextNode(r.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){this.parent!=null&&this.parent.removeChild(this)}format(t,s){if(this.savedLength!==0){super.format(t,s);return}let n=this,i=0;for(;n!=null&&n.statics.scope!==g.BLOCK_BLOT;)i+=n.offset(n.parent),n=n.parent;n!=null&&(this.savedLength=r.CONTENTS.length,n.optimize(),n.formatAt(i,r.CONTENTS.length,t,s),this.savedLength=0)}index(t,s){return t===this.textNode?0:super.index(t,s)}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;let t=this.selection.getNativeRange();for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);let s=this.prev instanceof I?this.prev:null,n=s?s.length():0,i=this.next instanceof I?this.next:null,l=i?i.text:"",{textNode:o}=this,a=o.data.split(r.CONTENTS).join("");o.data=r.CONTENTS;let c;if(s)c=s,(a||i)&&(s.insertAt(s.length(),a+l),i&&i.remove());else if(i)c=i,i.insertAt(0,a);else{let u=document.createTextNode(a);c=this.scroll.create(u),this.parent.insertBefore(c,this)}if(this.remove(),t){let u=(p,b)=>s&&p===s.domNode?b:p===o?n+b-1:i&&p===i.domNode?n+a.length+b:null,h=u(t.start.node,t.start.offset),m=u(t.end.node,t.end.offset);if(h!==null&&m!==null)return{startNode:c.domNode,startOffset:h,endNode:c.domNode,endOffset:m}}return null}update(t,s){if(t.some(n=>n.type==="characterData"&&n.target===this.textNode)){let n=this.restore();n&&(s.range=n)}}optimize(t){super.optimize(t);let{parent:s}=this;for(;s;){if(s.domNode.tagName==="A"){this.savedLength=r.CONTENTS.length,s.isolate(this.offset(s),this.length()).unwrap(),this.savedLength=0;break}s=s.parent}}value(){return""}}return r})(),_t=Ku;f();f();f();var Is=tt(ul(),1);f();var Ce=new WeakMap;f();var Rs=["error","warn","log","info"],Bs="warn";function hl(r){if(Bs&&Rs.indexOf(r)<=Rs.indexOf(Bs)){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s(e[t]=hl.bind(console,t,r),e),{})}Ms.level=r=>{Bs=r};hl.level=Ms.level;var nt=Ms;var Ds=nt("quill:events"),Zu=["selectionchange","mousedown","mouseup","click"];Zu.forEach(r=>{document.addEventListener(r,function(){for(var e=arguments.length,t=new Array(e),s=0;s{let i=Ce.get(n);i&&i.emitter&&i.emitter.handleDOM(...t)})})});var Qu=(()=>{class r extends Is.default{static 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"};static sources={API:"api",SILENT:"silent",USER:"user"};constructor(){super(),this.domListeners={},this.on("error",Ds.error)}emit(){for(var t=arguments.length,s=new Array(t),n=0;n1?s-1:0),i=1;i{let{node:o,handler:a}=l;(t.target===o||o.contains(t.target))&&a(t,...n)})}listenDOM(t,s,n){this.domListeners[t]||(this.domListeners[t]=[]),this.domListeners[t].push({node:s,handler:n})}}return r})(),y=Qu;var Us=nt("quill:selection"),G=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=e,this.length=t}},js=class{constructor(e,t){this.emitter=t,this.scroll=e,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=this.scroll.create("cursor",this),this.savedRange=new G(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,y.sources.USER),1)}),this.emitter.on(y.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;let s=this.getNativeRange();s!=null&&s.start.node!==this.cursor.textNode&&this.emitter.once(y.events.SCROLL_UPDATE,(n,i)=>{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);let l=i.some(o=>o.type==="characterData"||o.type==="childList"||o.type==="attributes"&&o.target===this.root);this.update(l?y.sources.SILENT:n)}catch(l){}})}),this.emitter.on(y.events.SCROLL_OPTIMIZE,(s,n)=>{if(n.range){let{startNode:i,startOffset:l,endNode:o,endOffset:a}=n.range;this.setNativeRange(i,l,o,a),this.update(y.sources.SILENT)}}),this.update(y.sources.SILENT)}handleComposition(){this.emitter.on(y.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(y.events.COMPOSITION_END,()=>{if(this.composing=!1,this.cursor.parent){let e=this.cursor.restore();if(!e)return;setTimeout(()=>{this.setNativeRange(e.startNode,e.startOffset,e.endNode,e.endOffset)},1)}})}handleDragging(){this.emitter.listenDOM("mousedown",document.body,()=>{this.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,()=>{this.mouseDown=!1,this.update(y.sources.USER)})}focus(){this.hasFocus()||(this.root.focus({preventScroll:!0}),this.setRange(this.savedRange))}format(e,t){this.scroll.update();let s=this.getNativeRange();if(!(s==null||!s.native.collapsed||this.scroll.query(e,g.BLOCK))){if(s.start.node!==this.cursor.textNode){let n=this.scroll.find(s.start.node,!1);if(n==null)return;if(n instanceof M){let i=n.split(s.start.offset);n.parent.insertBefore(this.cursor,i)}else n.insertBefore(this.cursor,s.start.node);this.cursor.attach()}this.cursor.format(e,t),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}getBounds(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=this.scroll.length();e=Math.min(e,s-1),t=Math.min(e+t,s-1)-e;let n,[i,l]=this.scroll.leaf(e);if(i==null)return null;if(t>0&&l===i.length()){let[u]=this.scroll.leaf(e+1);if(u){let[h]=this.scroll.line(e),[m]=this.scroll.line(e+1);h===m&&(i=u,l=0)}}[n,l]=i.position(l,!0);let o=document.createRange();if(t>0)return o.setStart(n,l),[i,l]=this.scroll.leaf(e+t),i==null?null:([n,l]=i.position(l,!0),o.setEnd(n,l),o.getBoundingClientRect());let a="left",c;if(n instanceof Text){if(!n.data.length)return null;l0&&(a="right")}return{bottom:c.top+c.height,height:c.height,left:c[a],right:c[a],top:c.top,width:0}}getNativeRange(){let e=document.getSelection();if(e==null||e.rangeCount<=0)return null;let t=e.getRangeAt(0);if(t==null)return null;let s=this.normalizeNative(t);return Us.info("getNativeRange",s),s}getRange(){let e=this.scroll.domNode;if("isConnected"in e&&!e.isConnected)return[null,null];let t=this.getNativeRange();return t==null?[null,null]:[this.normalizedToRange(t),t]}hasFocus(){return document.activeElement===this.root||document.activeElement!=null&&Ps(this.root,document.activeElement)}normalizedToRange(e){let t=[[e.start.node,e.start.offset]];e.native.collapsed||t.push([e.end.node,e.end.offset]);let s=t.map(l=>{let[o,a]=l,c=this.scroll.find(o,!0),u=c.offset(this.scroll);return a===0?u:c instanceof M?u+c.index(o,a):u+c.length()}),n=Math.min(Math.max(...s),this.scroll.length()-1),i=Math.min(n,...s);return new G(i,n-i)}normalizeNative(e){if(!Ps(this.root,e.startContainer)||!e.collapsed&&!Ps(this.root,e.endContainer))return null;let t={start:{node:e.startContainer,offset:e.startOffset},end:{node:e.endContainer,offset:e.endOffset},native:e};return[t.start,t.end].forEach(s=>{let{node:n,offset:i}=s;for(;!(n instanceof Text)&&n.childNodes.length>0;)if(n.childNodes.length>i)n=n.childNodes[i],i=0;else if(n.childNodes.length===i)n=n.lastChild,n instanceof Text?i=n.data.length:n.childNodes.length>0?i=n.childNodes.length:i=n.childNodes.length+1;else break;s.node=n,s.offset=i}),t}rangeToNative(e){let t=this.scroll.length(),s=(n,i)=>{n=Math.min(t-1,n);let[l,o]=this.scroll.leaf(n);return l?l.position(o,i):[null,-1]};return[...s(e.index,!1),...s(e.index+e.length,!0)]}setNativeRange(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:t,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(Us.info("setNativeRange",e,t,s,n),e!=null&&(this.root.parentNode==null||e.parentNode==null||s.parentNode==null))return;let l=document.getSelection();if(l!=null)if(e!=null){this.hasFocus()||this.root.focus({preventScroll:!0});let{native:o}=this.getNativeRange()||{};if(o==null||i||e!==o.startContainer||t!==o.startOffset||s!==o.endContainer||n!==o.endOffset){e instanceof Element&&e.tagName==="BR"&&(t=Array.from(e.parentNode.childNodes).indexOf(e),e=e.parentNode),s instanceof Element&&s.tagName==="BR"&&(n=Array.from(s.parentNode.childNodes).indexOf(s),s=s.parentNode);let a=document.createRange();a.setStart(e,t),a.setEnd(s,n),l.removeAllRanges(),l.addRange(a)}}else l.removeAllRanges(),this.root.blur()}setRange(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:y.sources.API;if(typeof t=="string"&&(s=t,t=!1),Us.info("setRange",e),e!=null){let n=this.rangeToNative(e);this.setNativeRange(...n,t)}else this.setNativeRange(null);this.update(s)}update(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y.sources.USER,t=this.lastRange,[s,n]=this.getRange();if(this.lastRange=s,this.lastNative=n,this.lastRange!=null&&(this.savedRange=this.lastRange),!Xt(t,this.lastRange)){if(!this.composing&&n!=null&&n.native.collapsed&&n.start.node!==this.cursor.textNode){let l=this.cursor.restore();l&&this.setNativeRange(l.startNode,l.startOffset,l.endNode,l.endOffset)}let i=[y.events.SELECTION_CHANGE,dt(this.lastRange),dt(t),e];this.emitter.emit(y.events.EDITOR_CHANGE,...i),e!==y.sources.SILENT&&this.emitter.emit(...i)}}};function Ps(r,e){try{e.parentNode}catch(t){return!1}return r.contains(e)}var fl=js;var Xu=/^[ -~]*$/,Fs=class{constructor(e){this.scroll=e,this.delta=this.getDelta()}applyDelta(e){this.scroll.update();let t=this.scroll.length();this.scroll.batchStart();let s=dl(e),n=new O.default;return Ju(s.ops.slice()).reduce((l,o)=>{let a=O.Op.length(o),c=o.attributes||{},u=!1,h=!1;if(o.insert!=null){if(n.retain(a),typeof o.insert=="string"){let b=o.insert;h=!b.endsWith(` `)&&(t<=l||!!this.scroll.descendant(U,l)[0]),this.scroll.insertAt(l,b);let[E,N]=this.scroll.line(l),v=et({},X(E));if(E instanceof R){let[x]=E.descendant(M,N);x&&(v=et(v,X(x)))}c=O.AttributeMap.diff(v,c)||{}}else if(typeof o.insert=="object"){let b=Object.keys(o.insert)[0];if(b==null)return l;let E=this.scroll.query(b,g.INLINE)!=null;if(E)(t<=l||this.scroll.descendant(U,l)[0])&&(h=!0);else if(l>0){let[N,v]=this.scroll.descendant(M,l-1);N instanceof I?N.value()[v]!==` `&&(u=!0):N instanceof C&&N.statics.scope===g.INLINE_BLOT&&(u=!0)}if(this.scroll.insertAt(l,b,o.insert[b]),E){let[N]=this.scroll.descendant(M,l);if(N){let v=et({},X(N));c=O.AttributeMap.diff(v,c)||{}}}}t+=a}else if(n.push(o),o.retain!==null&&typeof o.retain=="object"){let b=Object.keys(o.retain)[0];if(b==null)return l;this.scroll.updateEmbedAt(l,b,o.retain[b])}Object.keys(c).forEach(b=>{this.scroll.formatAt(l,a,b,c[b])});let m=u?1:0,p=h?1:0;return t+=m+p,n.retain(m),n.delete(p),l+a+m+p},0),n.reduce((l,o)=>typeof o.delete=="number"?(this.scroll.deleteAt(l,o.delete),l):l+O.Op.length(o),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(s)}deleteText(e,t){return this.scroll.deleteAt(e,t),this.update(new O.default().retain(e).delete(t))}formatLine(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.scroll.update(),Object.keys(s).forEach(i=>{this.scroll.lines(e,Math.max(t,1)).forEach(l=>{l.format(i,s[i])})}),this.scroll.optimize();let n=new O.default().retain(e).retain(t,dt(s));return this.update(n)}formatText(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.keys(s).forEach(i=>{this.scroll.formatAt(e,t,i,s[i])});let n=new O.default().retain(e).retain(t,dt(s));return this.update(n)}getContents(e,t){return this.delta.slice(e,e+t)}getDelta(){return this.scroll.lines().reduce((e,t)=>e.concat(t.delta()),new O.default)}getFormat(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=[],n=[];t===0?this.scroll.path(e).forEach(o=>{let[a]=o;a instanceof R?s.push(a):a instanceof M&&n.push(a)}):(s=this.scroll.lines(e,t),n=this.scroll.descendants(M,e,t));let[i,l]=[s,n].map(o=>{let a=o.shift();if(a==null)return{};let c=X(a);for(;Object.keys(c).length>0;){let u=o.shift();if(u==null)return c;c=Yu(X(u),c)}return c});return L(L({},i),l)}getHTML(e,t){let[s,n]=this.scroll.line(e);if(s){let i=s.length();return s.length()>=n+t&&!(n===0&&t===i)?Oe(s,n,t,!0):Oe(this.scroll,e,t,!0)}return""}getText(e,t){return this.getContents(e,t).filter(s=>typeof s.insert=="string").map(s=>s.insert).join("")}insertContents(e,t){let s=dl(t),n=new O.default().retain(e).concat(s);return this.scroll.insertContents(e,s),this.update(n)}insertEmbed(e,t,s){return this.scroll.insertAt(e,t,s),this.update(new O.default().retain(e).insert({[t]:s}))}insertText(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return t=t.replace(/\r\n/g,` `).replace(/\r/g,` `),this.scroll.insertAt(e,t),Object.keys(s).forEach(n=>{this.scroll.formatAt(e,t.length,n,s[n])}),this.update(new O.default().retain(e).insert(t,dt(s)))}isBlank(){if(this.scroll.children.length===0)return!0;if(this.scroll.children.length>1)return!1;let e=this.scroll.children.head;if(e?.statics.blotName!==R.blotName)return!1;let t=e;return t.children.length>1?!1:t.children.head instanceof j}removeFormat(e,t){let s=this.getText(e,t),[n,i]=this.scroll.line(e+t),l=0,o=new O.default;n!=null&&(l=n.length()-i,o=n.delta().slice(i,i+l-1).insert(` `));let c=this.getContents(e,t+l).diff(new O.default().insert(s).concat(o)),u=new O.default().retain(e).concat(c);return this.applyDelta(u)}update(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,n=this.delta;if(t.length===1&&t[0].type==="characterData"&&t[0].target.data.match(Xu)&&this.scroll.find(t[0].target)){let i=this.scroll.find(t[0].target),l=X(i),o=i.offset(this.scroll),a=t[0].oldValue.replace(_t.CONTENTS,""),c=new O.default().insert(a),u=new O.default().insert(i.value()),h=s&&{oldRange:ml(s.oldRange,-o),newRange:ml(s.newRange,-o)};e=new O.default().retain(o).concat(c.diff(u,h)).reduce((p,b)=>b.insert?p.insert(b.insert,l):p.push(b),new O.default),this.delta=n.compose(e)}else this.delta=this.getDelta(),(!e||!Xt(n.compose(e),this.delta))&&(e=n.diff(this.delta,s));return e}};function he(r,e,t){if(r.length===0){let[p]=Hs(t.pop());return e<=0?``:`${he([],e-1,t)}`}let[{child:s,offset:n,length:i,indent:l,type:o},...a]=r,[c,u]=Hs(o);if(l>e)return t.push(o),l===e+1?`<${c}>${Oe(s,n,i)}${he(a,l,t)}`:`<${c}>
  • ${he(r,e+1,t)}`;let h=t[t.length-1];if(l===e&&o===h)return`
  • ${Oe(s,n,i)}${he(a,l,t)}`;let[m]=Hs(t.pop());return`${he(r,e-1,t)}`}function Oe(r,e,t){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if("html"in r&&typeof r.html=="function")return r.html(e,t);if(r instanceof I)return Wt(r.value().slice(e,e+t)).replaceAll(" "," ");if(r instanceof Z){if(r.statics.blotName==="list-container"){let c=[];return r.children.forEachAt(e,t,(u,h,m)=>{let p="formats"in u&&typeof u.formats=="function"?u.formats():{};c.push({child:u,offset:h,length:m,indent:p.indent||0,type:p.list})}),he(c,-1,[])}let n=[];if(r.children.forEachAt(e,t,(c,u,h)=>{n.push(Oe(c,u,h))}),s||r.statics.blotName==="list")return n.join("");let{outerHTML:i,innerHTML:l}=r.domNode,[o,a]=i.split(`>${l}<`);return o==="${n.join("")}<${a}`:`${o}>${n.join("")}<${a}`}return r.domNode instanceof Element?r.domNode.outerHTML:""}function Yu(r,e){return Object.keys(e).reduce((t,s)=>{if(r[s]==null)return t;let n=e[s];return n===r[s]?t[s]=n:Array.isArray(n)?n.indexOf(r[s])<0?t[s]=n.concat([r[s]]):t[s]=n:t[s]=[n,r[s]],t},{})}function Hs(r){let e=r==="ordered"?"ol":"ul";switch(r){case"checked":return[e,' data-list="checked"'];case"unchecked":return[e,' data-list="unchecked"'];default:return[e,""]}}function dl(r){return r.reduce((e,t)=>{if(typeof t.insert=="string"){let s=t.insert.replace(/\r\n/g,` `).replace(/\r/g,` `);return e.insert(s,t.attributes)}return e.push(t)},new O.default)}function ml(r,e){let{index:t,length:s}=r;return new G(t+e,s)}function Ju(r){let e=[];return r.forEach(t=>{typeof t.insert=="string"?t.insert.split(` `).forEach((n,i)=>{i&&e.push({insert:` `,attributes:t.attributes}),n&&e.push({insert:n,attributes:t.attributes})}):e.push(t)}),e}var pl=Fs;f();var th=(()=>{class r{static DEFAULTS={};constructor(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=t,this.options=s}}return r})(),_=th;f();f();var mr="\uFEFF",$s=class extends C{constructor(e,t){super(e,t),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(mr),this.rightGuard=document.createTextNode(mr),this.domNode.appendChild(this.leftGuard),this.domNode.appendChild(this.contentNode),this.domNode.appendChild(this.rightGuard)}index(e,t){return e===this.leftGuard?0:e===this.rightGuard?1:super.index(e,t)}restore(e){let t=null,s,n=e.data.split(mr).join("");if(e===this.leftGuard)if(this.prev instanceof I){let i=this.prev.length();this.prev.insertAt(i,n),t={startNode:this.prev.domNode,startOffset:i+n.length}}else s=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(s),this),t={startNode:s,startOffset:n.length};else e===this.rightGuard&&(this.next instanceof I?(this.next.insertAt(0,n),t={startNode:this.next.domNode,startOffset:n.length}):(s=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(s),this.next),t={startNode:s,startOffset:n.length}));return e.data=mr,t}update(e,t){e.forEach(s=>{if(s.type==="characterData"&&(s.target===this.leftGuard||s.target===this.rightGuard)){let n=this.restore(s.target);n&&(t.range=n)}})}},fe=$s;var zs=class{isComposing=!1;constructor(e,t){this.scroll=e,this.emitter=t,this.setupListeners()}setupListeners(){this.scroll.domNode.addEventListener("compositionstart",e=>{this.isComposing||this.handleCompositionStart(e)}),this.scroll.domNode.addEventListener("compositionend",e=>{this.isComposing&&queueMicrotask(()=>{this.handleCompositionEnd(e)})})}handleCompositionStart(e){let t=e.target instanceof Node?this.scroll.find(e.target,!0):null;t&&!(t instanceof fe)&&(this.emitter.emit(y.events.COMPOSITION_BEFORE_START,e),this.scroll.batchStart(),this.emitter.emit(y.events.COMPOSITION_START,e),this.isComposing=!0)}handleCompositionEnd(e){this.emitter.emit(y.events.COMPOSITION_BEFORE_END,e),this.scroll.batchEnd(),this.emitter.emit(y.events.COMPOSITION_END,e),this.isComposing=!1}},gl=zs;f();var eh=(()=>{class r{static DEFAULTS={modules:{}};static themes={default:r};modules={};constructor(t,s){this.quill=t,this.options=s}init(){Object.keys(this.options.modules).forEach(t=>{this.modules[t]==null&&this.addModule(t)})}addModule(t){let s=this.quill.constructor.import(`modules/${t}`);return this.modules[t]=new s(this.quill,this.options.modules[t]||{}),this.modules[t]}}return r})(),de=eh;f();var rh=r=>r.parentElement||r.getRootNode().host||null,sh=r=>{let e=r.getBoundingClientRect(),t="offsetWidth"in r&&Math.abs(e.width)/r.offsetWidth||1,s="offsetHeight"in r&&Math.abs(e.height)/r.offsetHeight||1;return{top:e.top,right:e.left+r.clientWidth*t,bottom:e.top+r.clientHeight*s,left:e.left}},pr=r=>{let e=parseInt(r,10);return Number.isNaN(e)?0:e},bl=(r,e,t,s,n,i)=>rs?0:rs?e-r>s-t?r+n-t:e-s+i:0,nh=(r,e)=>{let t=r.ownerDocument,s=e,n=r;for(;n;){let i=n===t.body,l=i?{top:0,right:window.visualViewport?.width??t.documentElement.clientWidth,bottom:window.visualViewport?.height??t.documentElement.clientHeight,left:0}:sh(n),o=getComputedStyle(n),a=bl(s.left,s.right,l.left,l.right,pr(o.scrollPaddingLeft),pr(o.scrollPaddingRight)),c=bl(s.top,s.bottom,l.top,l.bottom,pr(o.scrollPaddingTop),pr(o.scrollPaddingBottom));if(a||c)if(i)t.defaultView?.scrollBy(a,c);else{let{scrollLeft:u,scrollTop:h}=n;c&&(n.scrollTop+=c),a&&(n.scrollLeft+=a);let m=n.scrollLeft-u,p=n.scrollTop-h;s={left:s.left-m,top:s.top-p,right:s.right-m,bottom:s.bottom-p}}n=i||o.position==="fixed"?null:rh(n)}},yl=nh;f();var ih=100,lh=["block","break","cursor","inline","scroll","text"],oh=(r,e,t)=>{let s=new St;return lh.forEach(n=>{let i=e.query(n);i&&s.register(i)}),r.forEach(n=>{let i=e.query(n);i||t.error(`Cannot register "${n}" specified in "formats" config. Are you sure it was registered?`);let l=0;for(;i;)if(s.register(i),i="blotName"in i?i.requiredContainer??null:null,l+=1,l>ih){t.error(`Cycle detected in registering blot requiredContainer: "${n}"`);break}}),s},vl=oh;var me=nt("quill"),gr=new St;Z.uiClass="ql-ui";var d=class r{static DEFAULTS={bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:gr,theme:"default"};static events=y.events;static sources=y.sources;static version="2.0.3";static imports={delta:It.default,parchment:ve,"core/module":_,"core/theme":de};static debug(e){e===!0&&(e="log"),nt.level(e)}static find(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Ce.get(e)||gr.find(e,t)}static import(e){return this.imports[e]==null&&me.error(`Cannot import ${e}. Are you sure it was registered?`),this.imports[e]}static register(){if(typeof(arguments.length<=0?void 0:arguments[0])!="string"){let e=arguments.length<=0?void 0:arguments[0],t=!!(!(arguments.length<=1)&&arguments[1]),s="attrName"in e?e.attrName:e.blotName;typeof s=="string"?this.register(`formats/${s}`,e,t):Object.keys(e).forEach(n=>{this.register(n,e[n],t)})}else{let e=arguments.length<=0?void 0:arguments[0],t=arguments.length<=1?void 0:arguments[1],s=!!(!(arguments.length<=2)&&arguments[2]);this.imports[e]!=null&&!s&&me.warn(`Overwriting ${e} with`,t),this.imports[e]=t,(e.startsWith("blots/")||e.startsWith("formats/"))&&t&&typeof t!="boolean"&&t.blotName!=="abstract"&&gr.register(t),typeof t.register=="function"&&t.register(gr)}}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=ah(e,t),this.container=this.options.container,this.container==null){me.error("Invalid Quill container",e);return}this.options.debug&&r.debug(this.options.debug);let s=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",Ce.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new y;let n=ye.blotName,i=this.options.registry.query(n);if(!i||!("blotName"in i))throw new Error(`Cannot initialize Quill without "${n}" blot`);if(this.scroll=new i(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new pl(this.scroll),this.selection=new fl(this.scroll,this.emitter),this.composition=new gl(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(y.events.EDITOR_CHANGE,l=>{l===y.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(y.events.SCROLL_UPDATE,(l,o)=>{let a=this.selection.lastRange,[c]=this.selection.getRange(),u=a&&c?{oldRange:a,newRange:c}:void 0;ct.call(this,()=>this.editor.update(null,o,u),l)}),this.emitter.on(y.events.SCROLL_EMBED_UPDATE,(l,o)=>{let a=this.selection.lastRange,[c]=this.selection.getRange(),u=a&&c?{oldRange:a,newRange:c}:void 0;ct.call(this,()=>{let h=new It.default().retain(l.offset(this)).retain({[l.statics.blotName]:o});return this.editor.update(h,[],u)},r.sources.USER)}),s){let l=this.clipboard.convert({html:`${s}


    `,text:` `});this.setContents(l)}this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable(),this.allowReadOnlyEdits=!1}addContainer(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof e=="string"){let s=e;e=document.createElement("div"),e.classList.add(s)}return this.container.insertBefore(e,t),e}blur(){this.selection.setRange(null)}deleteText(e,t,s){return[e,t,,s]=Nt(e,t,s),ct.call(this,()=>this.editor.deleteText(e,t),s,e,-1*t)}disable(){this.enable(!1)}editReadOnly(e){this.allowReadOnlyEdits=!0;let t=e();return this.allowReadOnlyEdits=!1,t}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(e),this.container.classList.toggle("ql-disabled",!e)}focus(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.selection.focus(),e.preventScroll||this.scrollSelectionIntoView()}format(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:y.sources.API;return ct.call(this,()=>{let n=this.getSelection(!0),i=new It.default;if(n==null)return i;if(this.scroll.query(e,g.BLOCK))i=this.editor.formatLine(n.index,n.length,{[e]:t});else{if(n.length===0)return this.selection.format(e,t),i;i=this.editor.formatText(n.index,n.length,{[e]:t})}return this.setSelection(n,y.sources.SILENT),i},s)}formatLine(e,t,s,n,i){let l;return[e,t,l,i]=Nt(e,t,s,n,i),ct.call(this,()=>this.editor.formatLine(e,t,l),i,e,0)}formatText(e,t,s,n,i){let l;return[e,t,l,i]=Nt(e,t,s,n,i),ct.call(this,()=>this.editor.formatText(e,t,l),i,e,0)}getBounds(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=null;if(typeof e=="number"?s=this.selection.getBounds(e,t):s=this.selection.getBounds(e.index,e.length),!s)return null;let 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 e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-e;return[e,t]=Nt(e,t),this.editor.getContents(e,t)}getFormat(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof e=="number"?this.editor.getFormat(e,t):this.editor.getFormat(e.index,e.length)}getIndex(e){return e.offset(this.scroll)}getLength(){return this.scroll.length()}getLeaf(e){return this.scroll.leaf(e)}getLine(e){return this.scroll.line(e)}getLines(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof e!="number"?this.scroll.lines(e.index,e.length):this.scroll.lines(e,t)}getModule(e){return this.theme.modules[e]}getSelection(){return arguments.length>0&&arguments[0]!==void 0&&arguments[0]&&this.focus(),this.update(),this.selection.getRange()[0]}getSemanticHTML(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;return typeof e=="number"&&(t=t??this.getLength()-e),[e,t]=Nt(e,t),this.editor.getHTML(e,t)}getText(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;return typeof e=="number"&&(t=t??this.getLength()-e),[e,t]=Nt(e,t),this.editor.getText(e,t)}hasFocus(){return this.selection.hasFocus()}insertEmbed(e,t,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r.sources.API;return ct.call(this,()=>this.editor.insertEmbed(e,t,s),n,e)}insertText(e,t,s,n,i){let l;return[e,,l,i]=Nt(e,0,s,n,i),ct.call(this,()=>this.editor.insertText(e,t,l),i,e,t.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(e,t,s){return[e,t,,s]=Nt(e,t,s),ct.call(this,()=>this.editor.removeFormat(e,t),s,e)}scrollRectIntoView(e){yl(this.root,e)}scrollIntoView(){console.warn("Quill#scrollIntoView() has been deprecated and will be removed in the near future. Please use Quill#scrollSelectionIntoView() instead."),this.scrollSelectionIntoView()}scrollSelectionIntoView(){let e=this.selection.lastRange,t=e&&this.selection.getBounds(e.index,e.length);t&&this.scrollRectIntoView(t)}setContents(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:y.sources.API;return ct.call(this,()=>{e=new It.default(e);let s=this.getLength(),n=this.editor.deleteText(0,s),i=this.editor.insertContents(0,e),l=this.editor.deleteText(this.getLength()-1,1);return n.compose(i).compose(l)},t)}setSelection(e,t,s){e==null?this.selection.setRange(null,t||r.sources.API):([e,t,,s]=Nt(e,t,s),this.selection.setRange(new G(Math.max(0,e),t),s),s!==y.sources.SILENT&&this.scrollSelectionIntoView())}setText(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:y.sources.API,s=new It.default().insert(e);return this.setContents(s,t)}update(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y.sources.USER,t=this.scroll.update(e);return this.selection.update(e),t}updateContents(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:y.sources.API;return ct.call(this,()=>(e=new It.default(e),this.editor.applyDelta(e)),t,!0)}};function El(r){return typeof r=="string"?document.querySelector(r):r}function Vs(r){return Object.entries(r??{}).reduce((e,t)=>{let[s,n]=t;return wt(L({},e),{[s]:n===!0?{}:n})},{})}function Nl(r){return Object.fromEntries(Object.entries(r).filter(e=>e[1]!==void 0))}function ah(r,e){let t=El(r);if(!t)throw new Error("Invalid Quill container");let n=!e.theme||e.theme===d.DEFAULTS.theme?de:d.import(`themes/${e.theme}`);if(!n)throw new Error(`Invalid theme ${e.theme}. Did you register it?`);let p=d.DEFAULTS,{modules:i}=p,l=Br(p,["modules"]),b=n.DEFAULTS,{modules:o}=b,a=Br(b,["modules"]),c=Vs(e.modules);c!=null&&c.toolbar&&c.toolbar.constructor!==Object&&(c=wt(L({},c),{toolbar:{container:c.toolbar}}));let u=et({},Vs(i),Vs(o),c),h=L(L(L({},l),Nl(a)),Nl(e)),m=e.registry;return m?e.formats&&me.warn('Ignoring "formats" option because "registry" is specified'):m=e.formats?vl(e.formats,h.registry,me):h.registry,wt(L({},h),{registry:m,container:t,theme:n,modules:Object.entries(u).reduce((E,N)=>{let[v,x]=N;if(!x)return E;let A=d.import(`modules/${v}`);return A==null?(me.error(`Cannot load ${v} module. Are you sure you registered it?`),E):wt(L({},E),{[v]:et({},A.DEFAULTS||{},x)})},{}),bounds:El(h.bounds)})}function ct(r,e,t,s){if(!this.isEnabled()&&e===y.sources.USER&&!this.allowReadOnlyEdits)return new It.default;let n=t==null?null:this.getSelection(),i=this.editor.delta,l=r();if(n!=null&&(t===!0&&(t=n.index),s==null?n=xl(n,l,e):s!==0&&(n=xl(n,t,s,e)),this.setSelection(n,y.sources.SILENT)),l.length()>0){let o=[y.events.TEXT_CHANGE,l,i,e];this.emitter.emit(y.events.EDITOR_CHANGE,...o),e!==y.sources.SILENT&&this.emitter.emit(...o)}return l}function Nt(r,e,t,s,n){let i={};return typeof r.index=="number"&&typeof r.length=="number"?typeof e!="number"?(n=s,s=t,t=e,e=r.length,r=r.index):(e=r.length,r=r.index):typeof e!="number"&&(n=s,s=t,t=e,e=0),typeof t=="object"?(i=t,n=s):typeof t=="string"&&(s!=null?i[t]=s:n=t),n=n||y.sources.API,[r,e,i,n]}function xl(r,e,t,s){let n=typeof t=="number"?t:0;if(r==null)return null;let i,l;return e&&typeof e.transformPosition=="function"?[i,l]=[r.index,r.index+r.length].map(o=>e.transformPosition(o,s!==y.sources.USER)):[i,l]=[r.index,r.index+r.length].map(o=>o=0?o+n:Math.max(e,o+n)),new G(i,l-i)}f();var Ks=class extends re{},lt=Ks;f();var ot=tt(st(),1);function Al(r){return r instanceof R||r instanceof U}function wl(r){return typeof r.updateContent=="function"}var ch=(()=>{class r extends ye{static blotName="scroll";static className="ql-editor";static tagName="DIV";static defaultChild=R;static allowedChildren=[R,U,lt];constructor(t,s,n){let{emitter:i}=n;super(t,s),this.emitter=i,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener("dragstart",l=>this.handleDragStart(l))}batchStart(){Array.isArray(this.batch)||(this.batch=[])}batchEnd(){if(!this.batch)return;let t=this.batch;this.batch=!1,this.update(t)}emitMount(t){this.emitter.emit(y.events.SCROLL_BLOT_MOUNT,t)}emitUnmount(t){this.emitter.emit(y.events.SCROLL_BLOT_UNMOUNT,t)}emitEmbedUpdate(t,s){this.emitter.emit(y.events.SCROLL_EMBED_UPDATE,t,s)}deleteAt(t,s){let[n,i]=this.line(t),[l]=this.line(t+s);if(super.deleteAt(t,s),l!=null&&n!==l&&i>0){if(n instanceof U||l instanceof U){this.optimize();return}let o=l.children.head instanceof j?null:l.children.head;n.moveChildren(l,o),n.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,s,n,i){super.formatAt(t,s,n,i),this.optimize()}insertAt(t,s,n){if(t>=this.length())if(n==null||this.scroll.query(s,g.BLOCK)==null){let i=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(i),n==null&&s.endsWith(` `)?i.insertAt(0,s.slice(0,-1),n):i.insertAt(0,s,n)}else{let i=this.scroll.create(s,n);this.appendChild(i)}else super.insertAt(t,s,n);this.optimize()}insertBefore(t,s){if(t.statics.scope===g.INLINE_BLOT){let n=this.scroll.create(this.statics.defaultChild.blotName);n.appendChild(t),super.insertBefore(n,s)}else super.insertBefore(t,s)}insertContents(t,s){let n=this.deltaToRenderBlocks(s.concat(new ot.default().insert(` `))),i=n.pop();if(i==null)return;this.batchStart();let l=n.shift();if(l){let c=l.type==="block"&&(l.delta.length()===0||!this.descendant(U,t)[0]&&t{this.formatAt(m-1,1,E,b[E])}),t=m}let[o,a]=this.children.find(t);if(n.length&&(o&&(o=o.split(a),a=0),n.forEach(c=>{if(c.type==="block"){let u=this.createBlock(c.attributes,o||void 0);Gs(u,0,c.delta)}else{let u=this.create(c.key,c.value);this.insertBefore(u,o||void 0),Object.keys(c.attributes).forEach(h=>{u.format(h,c.attributes[h])})}})),i.type==="block"&&i.delta.length()){let c=o?o.offset(o.scroll)+a:this.length();Gs(this,c,i.delta)}this.batchEnd(),this.optimize()}isEnabled(){return this.domNode.getAttribute("contenteditable")==="true"}leaf(t){let s=this.path(t).pop();if(!s)return[null,-1];let[n,i]=s;return n instanceof M?[n,i]:[null,-1]}line(t){return t===this.length()?this.line(t-1):this.descendant(Al,t)}lines(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,n=(i,l,o)=>{let a=[],c=o;return i.children.forEachAt(l,o,(u,h,m)=>{Al(u)?a.push(u):u instanceof re&&(a=a.concat(n(u,h,c))),c-=m}),a};return n(this,t,s)}optimize(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch||(super.optimize(t,s),t.length>0&&this.emitter.emit(y.events.SCROLL_OPTIMIZE,t,s))}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 s=y.sources.USER;typeof t=="string"&&(s=t),Array.isArray(t)||(t=this.observer.takeRecords()),t=t.filter(n=>{let{target:i}=n,l=this.find(i,!0);return l&&!wl(l)}),t.length>0&&this.emitter.emit(y.events.SCROLL_BEFORE_UPDATE,s,t),super.update(t.concat([])),t.length>0&&this.emitter.emit(y.events.SCROLL_UPDATE,s,t)}updateEmbedAt(t,s,n){let[i]=this.descendant(l=>l instanceof U,t);i&&i.statics.blotName===s&&wl(i)&&i.updateContent(n)}handleDragStart(t){t.preventDefault()}deltaToRenderBlocks(t){let s=[],n=new ot.default;return t.forEach(i=>{let l=i?.insert;if(l)if(typeof l=="string"){let o=l.split(` `);o.slice(0,-1).forEach(c=>{n.insert(c,i.attributes),s.push({type:"block",delta:n,attributes:i.attributes??{}}),n=new ot.default});let a=o[o.length-1];a&&n.insert(a,i.attributes)}else{let o=Object.keys(l)[0];if(!o)return;this.query(o,g.INLINE)?n.push(i):(n.length()&&s.push({type:"block",delta:n,attributes:{}}),n=new ot.default,s.push({type:"blockEmbed",key:o,value:l[o],attributes:i.attributes??{}}))}}),n.length()&&s.push({type:"block",delta:n,attributes:{}}),s}createBlock(t,s){let n,i={};Object.entries(t).forEach(a=>{let[c,u]=a;this.query(c,g.BLOCK&g.BLOT)!=null?n=c:i[c]=u});let l=this.create(n||this.statics.defaultChild.blotName,n?t[n]:void 0);this.insertBefore(l,s||void 0);let o=l.length();return Object.entries(i).forEach(a=>{let[c,u]=a;l.formatAt(0,o,c,u)}),l}}return r})();function Gs(r,e,t){t.reduce((s,n)=>{let i=ot.Op.length(n),l=n.attributes||{};if(n.insert!=null){if(typeof n.insert=="string"){let o=n.insert;r.insertAt(s,o);let[a]=r.descendant(M,s),c=X(a);l=ot.AttributeMap.diff(c,l)||{}}else if(typeof n.insert=="object"){let o=Object.keys(n.insert)[0];if(o==null)return s;if(r.insertAt(s,o,n.insert[o]),r.scroll.query(o,g.INLINE)!=null){let[c]=r.descendant(M,s),u=X(c);l=ot.AttributeMap.diff(u,l)||{}}}}return Object.keys(l).forEach(o=>{r.formatAt(s,i,o,l[o])}),s+i},e)}var Tl=ch;f();var Y=tt(st(),1);f();var Ws={scope:g.BLOCK,whitelist:["right","center","justify"]},Ll=new z("align","align",Ws),Zs=new B("align","ql-align",Ws),br=new Q("align","text-align",Ws);f();f();var _e=class extends Q{value(e){let t=super.value(e);return t.startsWith("rgb(")?(t=t.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),`#${t.split(",").map(n=>`00${parseInt(n,10).toString(16)}`.slice(-2)).join("")}`):t}},ql=new B("color","ql-color",{scope:g.INLINE}),Ie=new _e("color","color",{scope:g.INLINE});var Sl=new B("background","ql-bg",{scope:g.INLINE}),Re=new _e("background","background-color",{scope:g.INLINE});f();var ht=class extends lt{static create(e){let t=super.create(e);return t.setAttribute("spellcheck","false"),t}code(e,t){return this.children.map(s=>s.length()<=1?"":s.domNode.innerText).join(` `).slice(e,e+t)}html(e,t){return`
    ${Wt(this.code(e,t))}
    
    `}},P=(()=>{class r extends R{static TAB=" ";static register(){d.register(ht)}}return r})(),kl=(()=>{class r extends H{}return r.blotName="code",r.tagName="CODE",r})();P.blotName="code-block";P.className="ql-code-block";P.tagName="DIV";ht.blotName="code-block-container";ht.className="ql-code-block-container";ht.tagName="DIV";ht.allowedChildren=[P];P.allowedChildren=[I,j,_t];P.requiredContainer=ht;f();var Qs={scope:g.BLOCK,whitelist:["rtl"]},yr=new z("direction","dir",Qs),Xs=new B("direction","ql-direction",Qs),vr=new Q("direction","direction",Qs);f();var Cl={scope:g.INLINE,whitelist:["serif","monospace"]},Js=new B("font","ql-font",Cl),Ys=class extends Q{value(e){return super.value(e).replace(/["']/g,"")}},Er=new Ys("font","font-family",Cl);f();var tn=new B("size","ql-size",{scope:g.INLINE,whitelist:["small","large","huge"]}),Nr=new Q("size","font-size",{scope:g.INLINE,whitelist:["10px","18px","32px"]});f();var $=tt(st(),1);var uh=nt("quill:keyboard"),hh=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey",Be=class r extends _{static match(e,t){return["altKey","ctrlKey","metaKey","shiftKey"].some(s=>!!t[s]!==e[s]&&t[s]!==null)?!1:t.key===e.key||t.key===e.which}constructor(e,t){super(e,t),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(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=dh(e);if(n==null){uh.warn("Attempted to add invalid keyboard binding",n);return}typeof t=="function"&&(t={handler:t}),typeof s=="function"&&(s={handler:s}),(Array.isArray(n.key)?n.key:[n.key]).forEach(l=>{let o=L(L(wt(L({},n),{key:l}),t),s);this.bindings[o.key]=this.bindings[o.key]||[],this.bindings[o.key].push(o)})}listen(){this.quill.root.addEventListener("keydown",e=>{if(e.defaultPrevented||e.isComposing||e.keyCode===229&&(e.key==="Enter"||e.key==="Backspace"))return;let n=(this.bindings[e.key]||[]).concat(this.bindings[e.which]||[]).filter(v=>r.match(e,v));if(n.length===0)return;let i=d.find(e.target,!0);if(i&&i.scroll!==this.quill.scroll)return;let l=this.quill.getSelection();if(l==null||!this.quill.hasFocus())return;let[o,a]=this.quill.getLine(l.index),[c,u]=this.quill.getLeaf(l.index),[h,m]=l.length===0?[c,u]:this.quill.getLeaf(l.index+l.length),p=c instanceof se?c.value().slice(0,u):"",b=h instanceof se?h.value().slice(m):"",E={collapsed:l.length===0,empty:l.length===0&&o.length()<=1,format:this.quill.getFormat(l),line:o,offset:a,prefix:p,suffix:b,event:e};n.some(v=>{if(v.collapsed!=null&&v.collapsed!==E.collapsed||v.empty!=null&&v.empty!==E.empty||v.offset!=null&&v.offset!==E.offset)return!1;if(Array.isArray(v.format)){if(v.format.every(x=>E.format[x]==null))return!1}else if(typeof v.format=="object"&&!Object.keys(v.format).every(x=>v.format[x]===!0?E.format[x]!=null:v.format[x]===!1?E.format[x]==null:Xt(v.format[x],E.format[x])))return!1;return v.prefix!=null&&!v.prefix.test(E.prefix)||v.suffix!=null&&!v.suffix.test(E.suffix)?!1:v.handler.call(this,l,E,v)!==!0})&&e.preventDefault()})}handleBackspace(e,t){let s=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(t.prefix)?2:1;if(e.index===0||this.quill.getLength()<=1)return;let n={},[i]=this.quill.getLine(e.index),l=new $.default().retain(e.index-s).delete(s);if(t.offset===0){let[o]=this.quill.getLine(e.index-1);if(o&&!(o.statics.blotName==="block"&&o.length()<=1)){let c=i.formats(),u=this.quill.getFormat(e.index-1,1);if(n=$.AttributeMap.diff(c,u)||{},Object.keys(n).length>0){let h=new $.default().retain(e.index+i.length()-2).retain(1,n);l=l.compose(h)}}}this.quill.updateContents(l,d.sources.USER),this.quill.focus()}handleDelete(e,t){let s=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(t.suffix)?2:1;if(e.index>=this.quill.getLength()-s)return;let n={},[i]=this.quill.getLine(e.index),l=new $.default().retain(e.index).delete(s);if(t.offset>=i.length()-1){let[o]=this.quill.getLine(e.index+1);if(o){let a=i.formats(),c=this.quill.getFormat(e.index,1);n=$.AttributeMap.diff(a,c)||{},Object.keys(n).length>0&&(l=l.retain(o.length()-1).retain(1,n))}}this.quill.updateContents(l,d.sources.USER),this.quill.focus()}handleDeleteRange(e){Me({range:e,quill:this.quill}),this.quill.focus()}handleEnter(e,t){let s=Object.keys(t.format).reduce((i,l)=>(this.quill.scroll.query(l,g.BLOCK)&&!Array.isArray(t.format[l])&&(i[l]=t.format[l]),i),{}),n=new $.default().retain(e.index).delete(e.length).insert(` `,s);this.quill.updateContents(n,d.sources.USER),this.quill.setSelection(e.index+1,d.sources.SILENT),this.quill.focus()}},fh={bindings:{bold:en("bold"),italic:en("italic"),underline:en("underline"),indent:{key:"Tab",format:["blockquote","indent","list"],handler(r,e){return e.collapsed&&e.offset!==0?!0:(this.quill.format("indent","+1",d.sources.USER),!1)}},outdent:{key:"Tab",shiftKey:!0,format:["blockquote","indent","list"],handler(r,e){return e.collapsed&&e.offset!==0?!0:(this.quill.format("indent","-1",d.sources.USER),!1)}},"outdent backspace":{key:"Backspace",collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler(r,e){e.format.indent!=null?this.quill.format("indent","-1",d.sources.USER):e.format.list!=null&&this.quill.format("list",!1,d.sources.USER)}},"indent code-block":Ol(!0),"outdent code-block":Ol(!1),"remove tab":{key:"Tab",shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(r){this.quill.deleteText(r.index-1,1,d.sources.USER)}},tab:{key:"Tab",handler(r,e){if(e.format.table)return!0;this.quill.history.cutoff();let t=new $.default().retain(r.index).delete(r.length).insert(" ");return this.quill.updateContents(t,d.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(r.index+1,d.sources.SILENT),!1}},"blockquote empty enter":{key:"Enter",collapsed:!0,format:["blockquote"],empty:!0,handler(){this.quill.format("blockquote",!1,d.sources.USER)}},"list empty enter":{key:"Enter",collapsed:!0,format:["list"],empty:!0,handler(r,e){let t={list:!1};e.format.indent&&(t.indent=!1),this.quill.formatLine(r.index,r.length,t,d.sources.USER)}},"checklist enter":{key:"Enter",collapsed:!0,format:{list:"checked"},handler(r){let[e,t]=this.quill.getLine(r.index),s=wt(L({},e.formats()),{list:"checked"}),n=new $.default().retain(r.index).insert(` `,s).retain(e.length()-t-1).retain(1,{list:"unchecked"});this.quill.updateContents(n,d.sources.USER),this.quill.setSelection(r.index+1,d.sources.SILENT),this.quill.scrollSelectionIntoView()}},"header enter":{key:"Enter",collapsed:!0,format:["header"],suffix:/^$/,handler(r,e){let[t,s]=this.quill.getLine(r.index),n=new $.default().retain(r.index).insert(` `,e.format).retain(t.length()-s-1).retain(1,{header:null});this.quill.updateContents(n,d.sources.USER),this.quill.setSelection(r.index+1,d.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(r){let e=this.quill.getModule("table");if(e){let[t,s,n,i]=e.getTable(r),l=mh(t,s,n,i);if(l==null)return;let o=t.offset();if(l<0){let a=new $.default().retain(o).insert(` `);this.quill.updateContents(a,d.sources.USER),this.quill.setSelection(r.index+1,r.length,d.sources.SILENT)}else if(l>0){o+=t.length();let a=new $.default().retain(o).insert(` `);this.quill.updateContents(a,d.sources.USER),this.quill.setSelection(o,d.sources.USER)}}}},"table tab":{key:"Tab",shiftKey:null,format:["table"],handler(r,e){let{event:t,line:s}=e,n=s.offset(this.quill.scroll);t.shiftKey?this.quill.setSelection(n-1,d.sources.USER):this.quill.setSelection(n+s.length(),d.sources.USER)}},"list autofill":{key:" ",shiftKey:null,collapsed:!0,format:{"code-block":!1,blockquote:!1,table:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler(r,e){if(this.quill.scroll.query("list")==null)return!0;let{length:t}=e.prefix,[s,n]=this.quill.getLine(r.index);if(n>t)return!0;let i;switch(e.prefix.trim()){case"[]":case"[ ]":i="unchecked";break;case"[x]":i="checked";break;case"-":case"*":i="bullet";break;default:i="ordered"}this.quill.insertText(r.index," ",d.sources.USER),this.quill.history.cutoff();let l=new $.default().retain(r.index-n).delete(t+1).retain(s.length()-2-n).retain(1,{list:i});return this.quill.updateContents(l,d.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(r.index-t,d.sources.SILENT),!1}},"code exit":{key:"Enter",collapsed:!0,format:["code-block"],prefix:/^$/,suffix:/^\s*$/,handler(r){let[e,t]=this.quill.getLine(r.index),s=2,n=e;for(;n!=null&&n.length()<=1&&n.formats()["code-block"];)if(n=n.prev,s-=1,s<=0){let i=new $.default().retain(r.index+e.length()-t-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(i,d.sources.USER),this.quill.setSelection(r.index-1,d.sources.SILENT),!1}return!0}},"embed left":xr("ArrowLeft",!1),"embed left shift":xr("ArrowLeft",!0),"embed right":xr("ArrowRight",!1),"embed right shift":xr("ArrowRight",!0),"table down":_l(!1),"table up":_l(!0)}};Be.DEFAULTS=fh;function Ol(r){return{key:"Tab",shiftKey:!r,format:{"code-block":!0},handler(e,t){let{event:s}=t,n=this.quill.scroll.query("code-block"),{TAB:i}=n;if(e.length===0&&!s.shiftKey){this.quill.insertText(e.index,i,d.sources.USER),this.quill.setSelection(e.index+i.length,d.sources.SILENT);return}let l=e.length===0?this.quill.getLines(e.index,1):this.quill.getLines(e),{index:o,length:a}=e;l.forEach((c,u)=>{r?(c.insertAt(0,i),u===0?o+=i.length:a+=i.length):c.domNode.textContent.startsWith(i)&&(c.deleteAt(0,i.length),u===0?o-=i.length:a-=i.length)}),this.quill.update(d.sources.USER),this.quill.setSelection(o,a,d.sources.SILENT)}}}function xr(r,e){return{key:r,shiftKey:e,altKey:null,[r==="ArrowLeft"?"prefix":"suffix"]:/^$/,handler(s){let{index:n}=s;r==="ArrowRight"&&(n+=s.length+1);let[i]=this.quill.getLeaf(n);return i instanceof C?(r==="ArrowLeft"?e?this.quill.setSelection(s.index-1,s.length+1,d.sources.USER):this.quill.setSelection(s.index-1,d.sources.USER):e?this.quill.setSelection(s.index,s.length+1,d.sources.USER):this.quill.setSelection(s.index+s.length+1,d.sources.USER),!1):!0}}}function en(r){return{key:r[0],shortKey:!0,handler(e,t){this.quill.format(r,!t.format[r],d.sources.USER)}}}function _l(r){return{key:r?"ArrowUp":"ArrowDown",collapsed:!0,format:["table"],handler(e,t){let s=r?"prev":"next",n=t.line,i=n.parent[s];if(i!=null){if(i.statics.blotName==="table-row"){let l=i.children.head,o=n;for(;o.prev!=null;)o=o.prev,l=l.next;let a=l.offset(this.quill.scroll)+Math.min(t.offset,l.length()-1);this.quill.setSelection(a,0,d.sources.USER)}}else{let l=n.table()[s];l!=null&&(r?this.quill.setSelection(l.offset(this.quill.scroll)+l.length()-1,0,d.sources.USER):this.quill.setSelection(l.offset(this.quill.scroll),0,d.sources.USER))}return!1}}}function dh(r){if(typeof r=="string"||typeof r=="number")r={key:r};else if(typeof r=="object")r=dt(r);else return null;return r.shortKey&&(r[hh]=r.shortKey,delete r.shortKey),r}function Me(r){let{quill:e,range:t}=r,s=e.getLines(t),n={};if(s.length>1){let i=s[0].formats(),l=s[s.length-1].formats();n=$.AttributeMap.diff(l,i)||{}}e.deleteText(t,d.sources.USER),Object.keys(n).length>0&&e.formatLine(t.index,1,n,d.sources.USER),e.setSelection(t.index,d.sources.SILENT)}function mh(r,e,t,s){return e.prev==null&&e.next==null?t.prev==null&&t.next==null?s===0?-1:1:t.prev==null?-1:1:e.prev==null?-1:e.next==null?1:null}f();f();var ph=/font-weight:\s*normal/,gh=["P","OL","UL"],Il=r=>r&&gh.includes(r.tagName),bh=r=>{Array.from(r.querySelectorAll("br")).filter(e=>Il(e.previousElementSibling)&&Il(e.nextElementSibling)).forEach(e=>{e.parentNode?.removeChild(e)})},yh=r=>{Array.from(r.querySelectorAll('b[style*="font-weight"]')).filter(e=>e.getAttribute("style")?.match(ph)).forEach(e=>{let t=r.createDocumentFragment();t.append(...e.childNodes),e.parentNode?.replaceChild(t,e)})};function rn(r){r.querySelector('[id^="docs-internal-guid-"]')&&(yh(r),bh(r))}f();var vh=/\bmso-list:[^;]*ignore/i,Eh=/\bmso-list:[^;]*\bl(\d+)/i,Nh=/\bmso-list:[^;]*\blevel(\d+)/i,xh=(r,e)=>{let t=r.getAttribute("style"),s=t?.match(Eh);if(!s)return null;let n=Number(s[1]),i=t?.match(Nh),l=i?Number(i[1]):1,o=new RegExp(`@list l${n}:level${l}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,"i"),a=e.match(o),c=a&&a[1]==="bullet"?"bullet":"ordered";return{id:n,indent:l,type:c,element:r}},Ah=r=>{let e=Array.from(r.querySelectorAll("[style*=mso-list]")),t=[],s=[];e.forEach(l=>{(l.getAttribute("style")||"").match(vh)?t.push(l):s.push(l)}),t.forEach(l=>l.parentNode?.removeChild(l));let n=r.documentElement.innerHTML,i=s.map(l=>xh(l,n)).filter(l=>l);for(;i.length;){let l=[],o=i.shift();for(;o;)l.push(o),o=i.length&&i[0]?.element===o.element.nextElementSibling&&i[0].id===o.id?i.shift():null;let a=document.createElement("ul");l.forEach(h=>{let m=document.createElement("li");m.setAttribute("data-list",h.type),h.indent>1&&m.setAttribute("class",`ql-indent-${h.indent-1}`),m.innerHTML=h.element.innerHTML,a.appendChild(m)});let c=l[0]?.element,{parentNode:u}=c??{};c&&u?.replaceChild(a,c),l.slice(1).forEach(h=>{let{element:m}=h;u?.removeChild(m)})}};function sn(r){r.documentElement.getAttribute("xmlns:w")==="urn:schemas-microsoft-com:office:word"&&Ah(r)}var wh=[sn,rn],Th=r=>{r.documentElement&&wh.forEach(e=>{e(r)})},Rl=Th;var Lh=nt("quill:clipboard"),qh=[[Node.TEXT_NODE,Ph],[Node.TEXT_NODE,Ml],["br",_h],[Node.ELEMENT_NODE,Ml],[Node.ELEMENT_NODE,Oh],[Node.ELEMENT_NODE,Ch],[Node.ELEMENT_NODE,Dh],["li",Bh],["ol, ul",Mh],["pre",Ih],["tr",Uh],["b",nn("bold")],["i",nn("italic")],["strike",nn("strike")],["style",Rh]],Sh=[Ll,yr].reduce((r,e)=>(r[e.keyName]=e,r),{}),Bl=[br,Re,Ie,vr,Er,Nr].reduce((r,e)=>(r[e.keyName]=e,r),{}),Dl=(()=>{class r extends _{static DEFAULTS={matchers:[]};constructor(t,s){super(t,s),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=[],qh.concat(this.options.matchers??[]).forEach(n=>{let[i,l]=n;this.addMatcher(i,l)})}addMatcher(t,s){this.matchers.push([t,s])}convert(t){let{html:s,text:n}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(i[P.blotName])return new Y.default().insert(n||"",{[P.blotName]:i[P.blotName]});if(!s)return new Y.default().insert(n||"",i);let l=this.convertHTML(s);return De(l,` `)&&(l.ops[l.ops.length-1].attributes==null||i.table)?l.compose(new Y.default().retain(l.length()-1).delete(1)):l}normalizeHTML(t){Rl(t)}convertHTML(t){let s=new DOMParser().parseFromString(t,"text/html");this.normalizeHTML(s);let n=s.body,i=new WeakMap,[l,o]=this.prepareMatching(n,i);return wr(this.quill.scroll,n,l,o,i)}dangerouslyPasteHTML(t,s){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:d.sources.API;if(typeof t=="string"){let i=this.convert({html:t,text:""});this.quill.setContents(i,s),this.quill.setSelection(0,d.sources.SILENT)}else{let i=this.convert({html:s,text:""});this.quill.updateContents(new Y.default().retain(t).concat(i),n),this.quill.setSelection(t+i.length(),d.sources.SILENT)}}onCaptureCopy(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(t.defaultPrevented)return;t.preventDefault();let[n]=this.quill.selection.getRange();if(n==null)return;let{html:i,text:l}=this.onCopy(n,s);t.clipboardData?.setData("text/plain",l),t.clipboardData?.setData("text/html",i),s&&Me({range:n,quill:this.quill})}normalizeURIList(t){return t.split(/\r?\n/).filter(s=>s[0]!=="#").join(` `)}onCapturePaste(t){if(t.defaultPrevented||!this.quill.isEnabled())return;t.preventDefault();let s=this.quill.getSelection(!0);if(s==null)return;let n=t.clipboardData?.getData("text/html"),i=t.clipboardData?.getData("text/plain");if(!n&&!i){let o=t.clipboardData?.getData("text/uri-list");o&&(i=this.normalizeURIList(o))}let l=Array.from(t.clipboardData?.files||[]);if(!n&&l.length>0){this.quill.uploader.upload(s,l);return}if(n&&l.length>0){let o=new DOMParser().parseFromString(n,"text/html");if(o.body.childElementCount===1&&o.body.firstElementChild?.tagName==="IMG"){this.quill.uploader.upload(s,l);return}}this.onPaste(s,{html:n,text:i})}onCopy(t){let s=this.quill.getText(t);return{html:this.quill.getSemanticHTML(t),text:s}}onPaste(t,s){let{text:n,html:i}=s,l=this.quill.getFormat(t.index),o=this.convert({text:n,html:i},l);Lh.log("onPaste",o,{text:n,html:i});let a=new Y.default().retain(t.index).delete(t.length).concat(o);this.quill.updateContents(a,d.sources.USER),this.quill.setSelection(a.length()-t.length,d.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(t,s){let n=[],i=[];return this.matchers.forEach(l=>{let[o,a]=l;switch(o){case Node.TEXT_NODE:i.push(a);break;case Node.ELEMENT_NODE:n.push(a);break;default:Array.from(t.querySelectorAll(o)).forEach(c=>{s.has(c)?s.get(c)?.push(a):s.set(c,[a])});break}}),[n,i]}}return r})();function Zt(r,e,t,s){return s.query(e)?r.reduce((n,i)=>{if(!i.insert)return n;if(i.attributes&&i.attributes[e])return n.push(i);let l=t?{[e]:t}:{};return n.insert(i.insert,L(L({},l),i.attributes))},new Y.default):r}function De(r,e){let t="";for(let s=r.ops.length-1;s>=0&&t.lengthl(e,i,r),new Y.default):e.nodeType===e.ELEMENT_NODE?Array.from(e.childNodes||[]).reduce((i,l)=>{let o=wr(r,l,t,s,n);return l.nodeType===e.ELEMENT_NODE&&(o=t.reduce((a,c)=>c(l,a,r),o),o=(n.get(l)||[]).reduce((a,c)=>c(l,a,r),o)),i.concat(o)},new Y.default):new Y.default}function nn(r){return(e,t,s)=>Zt(t,r,!0,s)}function Ch(r,e,t){let s=z.keys(r),n=B.keys(r),i=Q.keys(r),l={};return s.concat(n).concat(i).forEach(o=>{let a=t.query(o,g.ATTRIBUTE);a!=null&&(l[a.attrName]=a.value(r),l[a.attrName])||(a=Sh[o],a!=null&&(a.attrName===o||a.keyName===o)&&(l[a.attrName]=a.value(r)||void 0),a=Bl[o],a!=null&&(a.attrName===o||a.keyName===o)&&(a=Bl[o],l[a.attrName]=a.value(r)||void 0))}),Object.entries(l).reduce((o,a)=>{let[c,u]=a;return Zt(o,c,u,t)},e)}function Oh(r,e,t){let s=t.query(r);if(s==null)return e;if(s.prototype instanceof C){let n={},i=s.value(r);if(i!=null)return n[s.blotName]=i,new Y.default().insert(n,s.formats(r,t))}else if(s.prototype instanceof Pt&&!De(e,` `)&&e.insert(` `),"blotName"in s&&"formats"in s&&typeof s.formats=="function")return Zt(e,s.blotName,s.formats(r,t),t);return e}function _h(r,e){return De(e,` `)||e.insert(` `),e}function Ih(r,e,t){let s=t.query("code-block"),n=s&&"formats"in s&&typeof s.formats=="function"?s.formats(r,t):!0;return Zt(e,"code-block",n,t)}function Rh(){return new Y.default}function Bh(r,e,t){let s=t.query(r);if(s==null||s.blotName!=="list"||!De(e,` `))return e;let n=-1,i=r.parentNode;for(;i!=null;)["OL","UL"].includes(i.tagName)&&(n+=1),i=i.parentNode;return n<=0?e:e.reduce((l,o)=>o.insert?o.attributes&&typeof o.attributes.indent=="number"?l.push(o):l.insert(o.insert,L({indent:n},o.attributes||{})):l,new Y.default)}function Mh(r,e,t){let s=r,n=s.tagName==="OL"?"ordered":"bullet",i=s.getAttribute("data-checked");return i&&(n=i==="true"?"checked":"unchecked"),Zt(e,"list",n,t)}function Ml(r,e,t){if(!De(e,` `)){if(Rt(r,t)&&(r.childNodes.length>0||r instanceof HTMLParagraphElement))return e.insert(` `);if(e.length()>0&&r.nextSibling){let s=r.nextSibling;for(;s!=null;){if(Rt(s,t))return e.insert(` `);let n=t.query(s);if(n&&n.prototype instanceof U)return e.insert(` `);s=s.firstChild}}}return e}function Dh(r,e,t){let s={},n=r.style||{};return n.fontStyle==="italic"&&(s.italic=!0),n.textDecoration==="underline"&&(s.underline=!0),n.textDecoration==="line-through"&&(s.strike=!0),(n.fontWeight?.startsWith("bold")||parseInt(n.fontWeight,10)>=700)&&(s.bold=!0),e=Object.entries(s).reduce((i,l)=>{let[o,a]=l;return Zt(i,o,a,t)},e),parseFloat(n.textIndent||0)>0?new Y.default().insert(" ").concat(e):e}function Uh(r,e,t){let s=r.parentElement?.tagName==="TABLE"?r.parentElement:r.parentElement?.parentElement;if(s!=null){let i=Array.from(s.querySelectorAll("tr")).indexOf(r)+1;return Zt(e,"table",i,t)}return e}function Ph(r,e,t){let s=r.data;if(r.parentElement?.tagName==="O:P")return e.insert(s.trim());if(!Ul(r)){if(s.trim().length===0&&s.includes(` `)&&!kh(r,t))return e;s=s.replace(/[^\S\u00a0]/g," "),s=s.replace(/ {2,}/g," "),(r.previousSibling==null&&r.parentElement!=null&&Rt(r.parentElement,t)||r.previousSibling instanceof Element&&Rt(r.previousSibling,t))&&(s=s.replace(/^ /,"")),(r.nextSibling==null&&r.parentElement!=null&&Rt(r.parentElement,t)||r.nextSibling instanceof Element&&Rt(r.nextSibling,t))&&(s=s.replace(/ $/,"")),s=s.replaceAll("\xA0"," ")}return e.insert(s)}f();var jl=(()=>{class r extends _{static DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};lastRecorded=0;ignoreChange=!1;stack={undo:[],redo:[]};currentRange=null;constructor(t,s){super(t,s),this.quill.on(d.events.EDITOR_CHANGE,(n,i,l,o)=>{n===d.events.SELECTION_CHANGE?i&&o!==d.sources.SILENT&&(this.currentRange=i):n===d.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||o===d.sources.USER?this.record(i,l):this.transform(i)),this.currentRange=ln(this.currentRange,i))}),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(t,s){if(this.stack[t].length===0)return;let n=this.stack[t].pop();if(!n)return;let i=this.quill.getContents(),l=n.delta.invert(i);this.stack[s].push({delta:l,range:ln(n.range,l)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(n.delta,d.sources.USER),this.ignoreChange=!1,this.restoreSelection(n)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(t,s){if(t.ops.length===0)return;this.stack.redo=[];let n=t.invert(s),i=this.currentRange,l=Date.now();if(this.lastRecorded+this.options.delay>l&&this.stack.undo.length>0){let o=this.stack.undo.pop();o&&(n=n.compose(o.delta),i=o.range)}else this.lastRecorded=l;n.length()!==0&&(this.stack.undo.push({delta:n,range:i}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change("redo","undo")}transform(t){Pl(this.stack.undo,t),Pl(this.stack.redo,t)}undo(){this.change("undo","redo")}restoreSelection(t){if(t.range)this.quill.setSelection(t.range,d.sources.USER);else{let s=Hh(this.quill.scroll,t.delta);this.quill.setSelection(s,d.sources.USER)}}}return r})();function Pl(r,e){let t=e;for(let s=r.length-1;s>=0;s-=1){let n=r[s];r[s]={delta:t.transform(n.delta,!0),range:n.range&&ln(n.range,t)},t=n.delta.transform(t),r[s].delta.length()===0&&r.splice(s,1)}}function jh(r,e){let t=e.ops[e.ops.length-1];return t==null?!1:t.insert!=null?typeof t.insert=="string"&&t.insert.endsWith(` `):t.attributes!=null?Object.keys(t.attributes).some(s=>r.query(s,g.BLOCK)!=null):!1}function Hh(r,e){let t=e.reduce((n,i)=>n+(i.delete||0),0),s=e.length()-t;return jh(r,e)&&(s-=1),s}function ln(r,e){if(!r)return r;let t=e.transformPosition(r.index),s=e.transformPosition(r.index+r.length);return{index:t,length:s-t}}f();var Hl=tt(st(),1);var Fh=(()=>{class r extends _{constructor(t,s){super(t,s),t.root.addEventListener("drop",n=>{n.preventDefault();let i=null;if(document.caretRangeFromPoint)i=document.caretRangeFromPoint(n.clientX,n.clientY);else if(document.caretPositionFromPoint){let o=document.caretPositionFromPoint(n.clientX,n.clientY);i=document.createRange(),i.setStart(o.offsetNode,o.offset),i.setEnd(o.offsetNode,o.offset)}let l=i&&t.selection.normalizeNative(i);if(l){let o=t.selection.normalizedToRange(l);n.dataTransfer?.files&&this.upload(o,n.dataTransfer.files)}})}upload(t,s){let n=[];Array.from(s).forEach(i=>{i&&this.options.mimetypes?.includes(i.type)&&n.push(i)}),n.length>0&&this.options.handler.call(this,t,n)}}return r.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(e,t){if(!this.quill.scroll.query("image"))return;let s=t.map(n=>new Promise(i=>{let l=new FileReader;l.onload=()=>{i(l.result)},l.readAsDataURL(n)}));Promise.all(s).then(n=>{let i=n.reduce((l,o)=>l.insert({image:o}),new Hl.default().retain(e.index).delete(e.length));this.quill.updateContents(i,y.sources.USER),this.quill.setSelection(e.index+n.length,y.sources.SILENT)})}},r})(),Fl=Fh;var Bt=tt(st(),1);f();var $l=tt(st(),1);var $h=["insertText","insertReplacementText"],on=class extends _{constructor(e,t){super(e,t),e.root.addEventListener("beforeinput",s=>{this.handleBeforeInput(s)}),/Android/i.test(navigator.userAgent)||e.on(d.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(e){Me({range:e,quill:this.quill})}replaceText(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(e.length===0)return!1;if(t){let s=this.quill.getFormat(e.index,1);this.deleteRange(e),this.quill.updateContents(new $l.default().retain(e.index).insert(t,s),d.sources.USER)}else this.deleteRange(e);return this.quill.setSelection(e.index+t.length,0,d.sources.SILENT),!0}handleBeforeInput(e){if(this.quill.composition.isComposing||e.defaultPrevented||!$h.includes(e.inputType))return;let t=e.getTargetRanges?e.getTargetRanges()[0]:null;if(!t||t.collapsed===!0)return;let s=zh(e);if(s==null)return;let n=this.quill.selection.normalizeNative(t),i=n?this.quill.selection.normalizedToRange(n):null;i&&this.replaceText(i,s)&&e.preventDefault()}handleCompositionStart(){let e=this.quill.getSelection();e&&this.replaceText(e)}};function zh(r){return typeof r.data=="string"?r.data:r.dataTransfer?.types.includes("text/plain")?r.dataTransfer.getData("text/plain"):null}var zl=on;f();var Vh=/Mac/i.test(navigator.platform),Kh=100,Gh=r=>!!(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"||r.key==="Home"||Vh&&r.key==="a"&&r.ctrlKey===!0),an=class extends _{isListening=!1;selectionChangeDeadline=0;constructor(e,t){super(e,t),this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:["ArrowLeft","ArrowRight"],offset:0,shiftKey:null,handler(e,t){let{line:s,event:n}=t;if(!(s instanceof Z)||!s.uiNode)return!0;let i=getComputedStyle(s.domNode).direction==="rtl";return i&&n.key!=="ArrowRight"||!i&&n.key!=="ArrowLeft"?!0:(this.quill.setSelection(e.index-1,e.length+(n.shiftKey?1:0),d.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",e=>{!e.defaultPrevented&&Gh(e)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){if(this.selectionChangeDeadline=Date.now()+Kh,this.isListening)return;this.isListening=!0;let e=()=>{this.isListening=!1,Date.now()<=this.selectionChangeDeadline&&this.handleSelectionChange()};document.addEventListener("selectionchange",e,{once:!0})}handleSelectionChange(){let e=document.getSelection();if(!e)return;let t=e.getRangeAt(0);if(t.collapsed!==!0||t.startOffset!==0)return;let s=this.quill.scroll.find(t.startContainer);if(!(s instanceof Z)||!s.uiNode)return;let n=document.createRange();n.setStartAfter(s.uiNode),n.setEndAfter(s.uiNode),e.removeAllRanges(),e.addRange(n)}},Vl=an;d.register({"blots/block":R,"blots/block/embed":U,"blots/break":j,"blots/container":lt,"blots/cursor":_t,"blots/embed":fe,"blots/inline":H,"blots/scroll":Tl,"blots/text":I,"modules/clipboard":Dl,"modules/history":jl,"modules/keyboard":Be,"modules/uploader":Fl,"modules/input":zl,"modules/uiNode":Vl});var Tr=d;f();var cn=class extends B{add(e,t){let s=0;if(t==="+1"||t==="-1"){let n=this.value(e)||0;s=t==="+1"?n+1:n-1}else typeof t=="number"&&(s=t);return s===0?(this.remove(e),!0):super.add(e,s.toString())}canAdd(e,t){return super.canAdd(e,t)||super.canAdd(e,parseInt(t,10))}value(e){return parseInt(super.value(e),10)||void 0}},Wh=new cn("indent","ql-indent",{scope:g.BLOCK,whitelist:[1,2,3,4,5,6,7,8]}),Kl=Wh;f();var Zh=(()=>{class r extends R{static blotName="blockquote";static tagName="blockquote"}return r})(),Gl=Zh;f();var Qh=(()=>{class r extends R{static blotName="header";static tagName=["H1","H2","H3","H4","H5","H6"];static formats(t){return this.tagName.indexOf(t.tagName)+1}}return r})(),Wl=Qh;f();var un=(()=>{class r extends lt{}return r.blotName="list-container",r.tagName="OL",r})(),Lr=(()=>{class r extends R{static create(t){let s=super.create();return s.setAttribute("data-list",t),s}static formats(t){return t.getAttribute("data-list")||void 0}static register(){d.register(un)}constructor(t,s){super(t,s);let n=s.ownerDocument.createElement("span"),i=l=>{if(!t.isEnabled())return;let o=this.statics.formats(s,t);o==="checked"?(this.format("list","unchecked"),l.preventDefault()):o==="unchecked"&&(this.format("list","checked"),l.preventDefault())};n.addEventListener("mousedown",i),n.addEventListener("touchstart",i),this.attachUI(n)}format(t,s){t===this.statics.blotName&&s?this.domNode.setAttribute("data-list",s):super.format(t,s)}}return r.blotName="list",r.tagName="LI",r})();un.allowedChildren=[Lr];Lr.requiredContainer=un;f();var Xh=(()=>{class r extends H{static blotName="bold";static tagName=["STRONG","B"];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)}}return r})(),pe=Xh;f();var Yh=(()=>{class r extends pe{static blotName="italic";static tagName=["EM","I"]}return r})(),Zl=Yh;f();var Qt=(()=>{class r extends H{static blotName="link";static tagName="A";static SANITIZED_URL="about:blank";static PROTOCOL_WHITELIST=["http","https","mailto","tel","sms"];static create(t){let s=super.create(t);return s.setAttribute("href",this.sanitize(t)),s.setAttribute("rel","noopener noreferrer"),s.setAttribute("target","_blank"),s}static formats(t){return t.getAttribute("href")}static sanitize(t){return hn(t,this.PROTOCOL_WHITELIST)?t:this.SANITIZED_URL}format(t,s){t!==this.statics.blotName||!s?super.format(t,s):this.domNode.setAttribute("href",this.constructor.sanitize(s))}}return r})();function hn(r,e){let t=document.createElement("a");t.href=r;let s=t.href.slice(0,t.href.indexOf(":"));return e.indexOf(s)>-1}f();var Jh=(()=>{class r extends H{static blotName="script";static tagName=["SUB","SUP"];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"}}return r})(),Ql=Jh;f();var tf=(()=>{class r extends pe{static blotName="strike";static tagName=["S","STRIKE"]}return r})(),Xl=tf;f();var ef=(()=>{class r extends H{static blotName="underline";static tagName="U"}return r})(),Yl=ef;f();var rf=(()=>{class r extends fe{static blotName="formula";static className="ql-formula";static tagName="SPAN";static create(t){if(window.katex==null)throw new Error("Formula module requires KaTeX.");let s=super.create(t);return typeof t=="string"&&(window.katex.render(t,s,{throwOnError:!1,errorColor:"#f00"}),s.setAttribute("data-value",t)),s}static value(t){return t.getAttribute("data-value")}html(){let{formula:t}=this.value();return`${t}`}}return r})(),Jl=rf;f();var to=["alt","height","width"],sf=(()=>{class r extends C{static blotName="image";static tagName="IMG";static create(t){let s=super.create(t);return typeof t=="string"&&s.setAttribute("src",this.sanitize(t)),s}static formats(t){return to.reduce((s,n)=>(t.hasAttribute(n)&&(s[n]=t.getAttribute(n)),s),{})}static match(t){return/\.(jpe?g|gif|png)$/.test(t)||/^data:image\/.+;base64/.test(t)}static sanitize(t){return hn(t,["http","https","data"])?t:"//:0"}static value(t){return t.getAttribute("src")}format(t,s){to.indexOf(t)>-1?s?this.domNode.setAttribute(t,s):this.domNode.removeAttribute(t):super.format(t,s)}}return r})(),eo=sf;f();var ro=["height","width"],nf=(()=>{class r extends U{static blotName="video";static className="ql-video";static tagName="IFRAME";static create(t){let s=super.create(t);return s.setAttribute("frameborder","0"),s.setAttribute("allowfullscreen","true"),s.setAttribute("src",this.sanitize(t)),s}static formats(t){return ro.reduce((s,n)=>(t.hasAttribute(n)&&(s[n]=t.getAttribute(n)),s),{})}static sanitize(t){return Qt.sanitize(t)}static value(t){return t.getAttribute("src")}format(t,s){ro.indexOf(t)>-1?s?this.domNode.setAttribute(t,s):this.domNode.removeAttribute(t):super.format(t,s)}html(){let{video:t}=this.value();return`${t}`}}return r})(),so=nf;f();var Sr=tt(st(),1);var Ue=new B("code-token","hljs",{scope:g.INLINE}),Pe=(()=>{class r extends H{static formats(t,s){for(;t!=null&&t!==s.domNode;){if(t.classList&&t.classList.contains(P.className))return super.formats(t,s);t=t.parentNode}}constructor(t,s,n){super(t,s,n),Ue.add(this.domNode,n)}format(t,s){t!==r.blotName?super.format(t,s):s?Ue.add(this.domNode,s):(Ue.remove(this.domNode),this.domNode.classList.remove(this.statics.className))}optimize(){super.optimize(...arguments),Ue.value(this.domNode)||this.unwrap()}}return r.blotName="code-token",r.className="ql-token",r})(),J=class extends P{static create(e){let t=super.create(e);return typeof e=="string"&&t.setAttribute("data-language",e),t}static formats(e){return e.getAttribute("data-language")||"plain"}static register(){}format(e,t){e===this.statics.blotName&&t?this.domNode.setAttribute("data-language",t):super.format(e,t)}replaceWith(e,t){return this.formatAt(0,this.length(),Pe.blotName,!1),super.replaceWith(e,t)}},qr=(()=>{class r extends ht{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(t,s){t===J.blotName&&(this.forceNext=!0,this.children.forEach(n=>{n.format(t,s)}))}formatAt(t,s,n,i){n===J.blotName&&(this.forceNext=!0),super.formatAt(t,s,n,i)}highlight(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.children.head==null)return;let i=`${Array.from(this.domNode.childNodes).filter(o=>o!==this.uiNode).map(o=>o.textContent).join(` `)} `,l=J.formats(this.children.head.domNode);if(s||this.forceNext||this.cachedText!==i){if(i.trim().length>0||this.cachedText==null){let o=this.children.reduce((c,u)=>c.concat(Os(u,!1)),new Sr.default),a=t(i,l);o.diff(a).reduce((c,u)=>{let{retain:h,attributes:m}=u;return h?(m&&Object.keys(m).forEach(p=>{[J.blotName,Pe.blotName].includes(p)&&this.formatAt(c,h,p,m[p])}),c+h):c},0)}this.cachedText=i,this.forceNext=!1}}html(t,s){let[n]=this.children.find(t);return`
    ${Wt(this.code(t,s))}
    
    `}optimize(t){if(super.optimize(t),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){let s=J.formats(this.children.head.domNode);s!==this.uiNode.value&&(this.uiNode.value=s)}}}return r.allowedChildren=[J],r})();J.requiredContainer=qr;J.allowedChildren=[Pe,_t,I,j];var lf=(r,e,t)=>{if(typeof r.versionString=="string"){let s=r.versionString.split(".")[0];if(parseInt(s,10)>=11)return r.highlight(t,{language:e}).value}return r.highlight(e,t).value},je=class extends _{static register(){d.register(Pe,!0),d.register(J,!0),d.register(qr,!0)}constructor(e,t){if(super(e,t),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:i}=n;return s[i]=!0,s},{}),this.highlightBlot=this.highlightBlot.bind(this),this.initListener(),this.initTimer()}initListener(){this.quill.on(d.events.SCROLL_BLOT_MOUNT,e=>{if(!(e instanceof qr))return;let t=this.quill.root.ownerDocument.createElement("select");this.options.languages.forEach(s=>{let{key:n,label:i}=s,l=t.ownerDocument.createElement("option");l.textContent=i,l.setAttribute("value",n),t.appendChild(l)}),t.addEventListener("change",()=>{e.format(J.blotName,t.value),this.quill.root.focus(),this.highlight(e,!0)}),e.uiNode==null&&(e.attachUI(t),e.children.head&&(t.value=J.formats(e.children.head.domNode)))})}initTimer(){let e=null;this.quill.on(d.events.SCROLL_OPTIMIZE,()=>{e&&clearTimeout(e),e=setTimeout(()=>{this.highlight(),e=null},this.options.interval)})}highlight(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.quill.selection.composing)return;this.quill.update(d.sources.USER);let s=this.quill.getSelection();(e==null?this.quill.scroll.descendants(qr):[e]).forEach(i=>{i.highlight(this.highlightBlot,t)}),this.quill.update(d.sources.SILENT),s!=null&&this.quill.setSelection(s,d.sources.SILENT)}highlightBlot(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"plain";if(t=this.languages[t]?t:"plain",t==="plain")return Wt(e).split(` `).reduce((n,i,l)=>(l!==0&&n.insert(` `,{[P.blotName]:t}),n.insert(i)),new Sr.default);let s=this.quill.root.ownerDocument.createElement("div");return s.classList.add(P.className),s.innerHTML=lf(this.options.hljs,t,e),wr(this.quill.scroll,s,[(n,i)=>{let l=Ue.value(n);return l?i.compose(new Sr.default().retain(i.length(),{[Pe.blotName]:l})):i}],[(n,i)=>n.data.split(` `).reduce((l,o,a)=>(a!==0&&l.insert(` `,{[P.blotName]:t}),l.insert(o)),i)],new WeakMap)}};je.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"}]};f();var no=tt(st(),1);f();var ft=(()=>{class r extends R{static blotName="table";static tagName="TD";static create(t){let s=super.create();return t?s.setAttribute("data-row",t):s.setAttribute("data-row",Cr()),s}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,s){t===r.blotName&&s?this.domNode.setAttribute("data-row",s):super.format(t,s)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}}return r})(),Mt=(()=>{class r extends lt{static blotName="table-row";static tagName="TR";checkMerge(){if(super.checkMerge()&&this.next.children.head!=null){let t=this.children.head.formats(),s=this.children.tail.formats(),n=this.next.children.head.formats(),i=this.next.children.tail.formats();return t.table===s.table&&t.table===n.table&&t.table===i.table}return!1}optimize(t){super.optimize(t),this.children.forEach(s=>{if(s.next==null)return;let n=s.formats(),i=s.next.formats();if(n.table!==i.table){let l=this.splitAfter(s);l&&l.optimize(),this.prev&&this.prev.optimize()}})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}return r})(),xt=(()=>{class r extends lt{static blotName="table-body";static tagName="TBODY"}return r})(),kr=(()=>{class r extends lt{static blotName="table-container";static tagName="TABLE";balanceCells(){let t=this.descendants(Mt),s=t.reduce((n,i)=>Math.max(i.children.length,n),0);t.forEach(n=>{new Array(s-n.children.length).fill(0).forEach(()=>{let i;n.children.head!=null&&(i=ft.formats(n.children.head.domNode));let l=this.scroll.create(ft.blotName,i);n.appendChild(l),l.optimize()})})}cells(t){return this.rows().map(s=>s.children.at(t))}deleteColumn(t){let[s]=this.descendant(xt);s==null||s.children.head==null||s.children.forEach(n=>{let i=n.children.at(t);i?.remove()})}insertColumn(t){let[s]=this.descendant(xt);s==null||s.children.head==null||s.children.forEach(n=>{let i=n.children.at(t),l=ft.formats(n.children.head.domNode),o=this.scroll.create(ft.blotName,l);n.insertBefore(o,i)})}insertRow(t){let[s]=this.descendant(xt);if(s==null||s.children.head==null)return;let n=Cr(),i=this.scroll.create(Mt.blotName);s.children.head.children.forEach(()=>{let o=this.scroll.create(ft.blotName,n);i.appendChild(o)});let l=s.children.at(t);s.insertBefore(i,l)}rows(){let t=this.children.head;return t==null?[]:t.children.map(s=>s)}}return r.allowedChildren=[xt],r})();xt.requiredContainer=kr;xt.allowedChildren=[Mt];Mt.requiredContainer=xt;Mt.allowedChildren=[ft];ft.requiredContainer=Mt;function Cr(){return`row-${Math.random().toString(36).slice(2,6)}`}var fn=class extends _{static register(){d.register(ft),d.register(Mt),d.register(xt),d.register(kr)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants(kr).forEach(e=>{e.balanceCells()})}deleteColumn(){let[e,,t]=this.getTable();t!=null&&(e.deleteColumn(t.cellOffset()),this.quill.update(d.sources.USER))}deleteRow(){let[,e]=this.getTable();e!=null&&(e.remove(),this.quill.update(d.sources.USER))}deleteTable(){let[e]=this.getTable();if(e==null)return;let t=e.offset();e.remove(),this.quill.update(d.sources.USER),this.quill.setSelection(t,d.sources.SILENT)}getTable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.quill.getSelection();if(e==null)return[null,null,null,-1];let[t,s]=this.quill.getLine(e.index);if(t==null||t.statics.blotName!==ft.blotName)return[null,null,null,-1];let n=t.parent;return[n.parent.parent,n,t,s]}insertColumn(e){let t=this.quill.getSelection();if(!t)return;let[s,n,i]=this.getTable(t);if(i==null)return;let l=i.cellOffset();s.insertColumn(l+e),this.quill.update(d.sources.USER);let o=n.rowOffset();e===0&&(o+=1),this.quill.setSelection(t.index+o,t.length,d.sources.SILENT)}insertColumnLeft(){this.insertColumn(0)}insertColumnRight(){this.insertColumn(1)}insertRow(e){let t=this.quill.getSelection();if(!t)return;let[s,n,i]=this.getTable(t);if(i==null)return;let l=n.rowOffset();s.insertRow(l+e),this.quill.update(d.sources.USER),e>0?this.quill.setSelection(t,d.sources.SILENT):this.quill.setSelection(t.index+n.children.length,t.length,d.sources.SILENT)}insertRowAbove(){this.insertRow(0)}insertRowBelow(){this.insertRow(1)}insertTable(e,t){let s=this.quill.getSelection();if(s==null)return;let n=new Array(e).fill(0).reduce(i=>{let l=new Array(t).fill(` `).join("");return i.insert(l,{table:Cr()})},new no.default().retain(s.index));this.quill.updateContents(n,d.sources.USER),this.quill.setSelection(s.index,d.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(d.events.SCROLL_OPTIMIZE,e=>{e.some(t=>["TD","TR","TBODY","TABLE"].includes(t.target.tagName)?(this.quill.once(d.events.TEXT_CHANGE,(s,n,i)=>{i===d.sources.USER&&this.balanceTables()}),!0):!1)})}},io=fn;f();var ao=tt(st(),1);var lo=nt("quill:toolbar"),dn=(()=>{class r extends _{constructor(t,s){if(super(t,s),Array.isArray(this.options.container)){let n=document.createElement("div");n.setAttribute("role","toolbar"),of(n,this.options.container),t.container?.parentNode?.insertBefore(n,t.container),this.container=n}else typeof this.options.container=="string"?this.container=document.querySelector(this.options.container):this.container=this.options.container;if(!(this.container instanceof HTMLElement)){lo.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(n=>{let i=this.options.handlers?.[n];i&&this.addHandler(n,i)}),Array.from(this.container.querySelectorAll("button, select")).forEach(n=>{this.attach(n)}),this.quill.on(d.events.EDITOR_CHANGE,()=>{let[n]=this.quill.selection.getRange();this.update(n)})}addHandler(t,s){this.handlers[t]=s}attach(t){let s=Array.from(t.classList).find(i=>i.indexOf("ql-")===0);if(!s)return;if(s=s.slice(3),t.tagName==="BUTTON"&&t.setAttribute("type","button"),this.handlers[s]==null&&this.quill.scroll.query(s)==null){lo.warn("ignoring attaching to nonexistent format",s,t);return}let n=t.tagName==="SELECT"?"change":"click";t.addEventListener(n,i=>{let l;if(t.tagName==="SELECT"){if(t.selectedIndex<0)return;let a=t.options[t.selectedIndex];a.hasAttribute("selected")?l=!1:l=a.value||!1}else t.classList.contains("ql-active")?l=!1:l=t.value||!t.hasAttribute("value"),i.preventDefault();this.quill.focus();let[o]=this.quill.selection.getRange();if(this.handlers[s]!=null)this.handlers[s].call(this,l);else if(this.quill.scroll.query(s).prototype instanceof C){if(l=prompt(`Enter ${s}`),!l)return;this.quill.updateContents(new ao.default().retain(o.index).delete(o.length).insert({[s]:l}),d.sources.USER)}else this.quill.format(s,l,d.sources.USER);this.update(o)}),this.controls.push([s,t])}update(t){let s=t==null?{}:this.quill.getFormat(t);this.controls.forEach(n=>{let[i,l]=n;if(l.tagName==="SELECT"){let o=null;if(t==null)o=null;else if(s[i]==null)o=l.querySelector("option[selected]");else if(!Array.isArray(s[i])){let a=s[i];typeof a=="string"&&(a=a.replace(/"/g,'\\"')),o=l.querySelector(`option[value="${a}"]`)}o==null?(l.value="",l.selectedIndex=-1):o.selected=!0}else if(t==null)l.classList.remove("ql-active"),l.setAttribute("aria-pressed","false");else if(l.hasAttribute("value")){let o=s[i],a=o===l.getAttribute("value")||o!=null&&o.toString()===l.getAttribute("value")||o==null&&!l.getAttribute("value");l.classList.toggle("ql-active",a),l.setAttribute("aria-pressed",a.toString())}else{let o=s[i]!=null;l.classList.toggle("ql-active",o),l.setAttribute("aria-pressed",o.toString())}})}}return r.DEFAULTS={},r})();function oo(r,e,t){let s=document.createElement("button");s.setAttribute("type","button"),s.classList.add(`ql-${e}`),s.setAttribute("aria-pressed","false"),t!=null?(s.value=t,s.setAttribute("aria-label",`${e}: ${t}`)):s.setAttribute("aria-label",e),r.appendChild(s)}function of(r,e){Array.isArray(e[0])||(e=[e]),e.forEach(t=>{let s=document.createElement("span");s.classList.add("ql-formats"),t.forEach(n=>{if(typeof n=="string")oo(s,n);else{let i=Object.keys(n)[0],l=n[i];Array.isArray(l)?af(s,i,l):oo(s,i,l)}}),r.appendChild(s)})}function af(r,e,t){let s=document.createElement("select");s.classList.add(`ql-${e}`),t.forEach(n=>{let i=document.createElement("option");n!==!1?i.setAttribute("value",String(n)):i.setAttribute("selected","selected"),s.appendChild(i)}),r.appendChild(s)}dn.DEFAULTS={container:null,handlers:{clean(){let r=this.quill.getSelection();if(r!=null)if(r.length===0){let e=this.quill.getFormat();Object.keys(e).forEach(t=>{this.quill.scroll.query(t,g.INLINE)!=null&&this.quill.format(t,!1,d.sources.USER)})}else this.quill.removeFormat(r.index,r.length,d.sources.USER)},direction(r){let{align:e}=this.quill.getFormat();r==="rtl"&&e==null?this.quill.format("align","right",d.sources.USER):!r&&e==="right"&&this.quill.format("align",!1,d.sources.USER),this.quill.format("direction",r,d.sources.USER)},indent(r){let e=this.quill.getSelection(),t=this.quill.getFormat(e),s=parseInt(t.indent||0,10);if(r==="+1"||r==="-1"){let n=r==="+1"?1:-1;t.direction==="rtl"&&(n*=-1),this.quill.format("indent",s+n,d.sources.USER)}},link(r){r===!0&&(r=prompt("Enter link URL:")),this.quill.format("link",r,d.sources.USER)},list(r){let e=this.quill.getSelection(),t=this.quill.getFormat(e);r==="check"?t.list==="checked"||t.list==="unchecked"?this.quill.format("list",!1,d.sources.USER):this.quill.format("list","unchecked",d.sources.USER):this.quill.format("list",r,d.sources.USER)}}};f();var cf='',uf='',hf='',ff='',df='',mf='',pf='',gf='',co='',bf='',yf='',vf='',Ef='',Nf='',xf='',Af='',wf='',Tf='',Lf='',qf='',Sf='',kf='',Cf='',Of='',_f='',If='',Rf='',Bf='',Mf='',Df='',Uf='',Pf='',jf='',Dt={align:{"":cf,center:uf,right:hf,justify:ff},background:df,blockquote:mf,bold:pf,clean:gf,code:co,"code-block":co,color:bf,direction:{"":yf,rtl:vf},formula:Ef,header:{1:Nf,2:xf,3:Af,4:wf,5:Tf,6:Lf},italic:qf,image:Sf,indent:{"+1":kf,"-1":Cf},link:Of,list:{bullet:_f,check:If,ordered:Rf},script:{sub:Bf,super:Mf},strike:Df,table:Uf,underline:Pf,video:jf};f();var Hf='',uo=0;function ho(r,e){r.setAttribute(e,`${r.getAttribute(e)!=="true"}`)}var mn=class{constructor(e){this.select=e,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",t=>{switch(t.key){case"Enter":this.togglePicker();break;case"Escape":this.escape(),t.preventDefault();break;default:}}),this.select.addEventListener("change",this.update.bind(this))}togglePicker(){this.container.classList.toggle("ql-expanded"),ho(this.label,"aria-expanded"),ho(this.options,"aria-hidden")}buildItem(e){let t=document.createElement("span");t.tabIndex="0",t.setAttribute("role","button"),t.classList.add("ql-picker-item");let s=e.getAttribute("value");return s&&t.setAttribute("data-value",s),e.textContent&&t.setAttribute("data-label",e.textContent),t.addEventListener("click",()=>{this.selectItem(t,!0)}),t.addEventListener("keydown",n=>{switch(n.key){case"Enter":this.selectItem(t,!0),n.preventDefault();break;case"Escape":this.escape(),n.preventDefault();break;default:}}),t}buildLabel(){let e=document.createElement("span");return e.classList.add("ql-picker-label"),e.innerHTML=Hf,e.tabIndex="0",e.setAttribute("role","button"),e.setAttribute("aria-expanded","false"),this.container.appendChild(e),e}buildOptions(){let e=document.createElement("span");e.classList.add("ql-picker-options"),e.setAttribute("aria-hidden","true"),e.tabIndex="-1",e.id=`ql-picker-options-${uo}`,uo+=1,this.label.setAttribute("aria-controls",e.id),this.options=e,Array.from(this.select.options).forEach(t=>{let s=this.buildItem(t);e.appendChild(s),t.selected===!0&&this.selectItem(s)}),this.container.appendChild(e)}buildPicker(){Array.from(this.select.attributes).forEach(e=>{this.container.setAttribute(e.name,e.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(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=this.container.querySelector(".ql-selected");e!==s&&(s?.classList.remove("ql-selected"),e!=null&&(e.classList.add("ql-selected"),this.select.selectedIndex=Array.from(e.parentNode.children).indexOf(e),e.hasAttribute("data-value")?this.label.setAttribute("data-value",e.getAttribute("data-value")):this.label.removeAttribute("data-value"),e.hasAttribute("data-label")?this.label.setAttribute("data-label",e.getAttribute("data-label")):this.label.removeAttribute("data-label"),t&&(this.select.dispatchEvent(new Event("change")),this.close())))}update(){let e;if(this.select.selectedIndex>-1){let s=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];e=this.select.options[this.select.selectedIndex],this.selectItem(s)}else this.selectItem(null);let t=e!=null&&e!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",t)}},Ut=mn;f();var pn=class extends Ut{constructor(e,t){super(e),this.label.innerHTML=t,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(e){let t=super.buildItem(e);return t.style.backgroundColor=e.getAttribute("value")||"",t}selectItem(e,t){super.selectItem(e,t);let s=this.label.querySelector(".ql-color-label"),n=e&&e.getAttribute("data-value")||"";s&&(s.tagName==="line"?s.style.stroke=n:s.style.fill=n)}},Or=pn;f();var gn=class extends Ut{constructor(e,t){super(e),this.container.classList.add("ql-icon-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).forEach(s=>{s.innerHTML=t[s.getAttribute("data-value")||""]}),this.defaultItem=this.container.querySelector(".ql-selected"),this.selectItem(this.defaultItem)}selectItem(e,t){super.selectItem(e,t);let s=e||this.defaultItem;if(s!=null){if(this.label.innerHTML===s.innerHTML)return;this.label.innerHTML=s.innerHTML}}},_r=gn;f();var Ff=r=>{let{overflowY:e}=getComputedStyle(r,null);return e!=="visible"&&e!=="clip"},bn=class{constructor(e,t){this.quill=e,this.boundsContainer=t||document.body,this.root=e.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,Ff(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(e){let t=e.left+e.width/2-this.root.offsetWidth/2,s=e.bottom+this.quill.root.scrollTop;this.root.style.left=`${t}px`,this.root.style.top=`${s}px`,this.root.classList.remove("ql-flip");let n=this.boundsContainer.getBoundingClientRect(),i=this.root.getBoundingClientRect(),l=0;if(i.right>n.right&&(l=n.right-i.right,this.root.style.left=`${t+l}px`),i.leftn.bottom){let o=i.bottom-i.top,a=e.bottom-e.top+o;this.root.style.top=`${s-a}px`,this.root.classList.add("ql-flip")}return l}show(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}},Ir=bn;f();f();var $f=[!1,"center","right","justify"],zf=["#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"],Vf=[!1,"serif","monospace"],Kf=["1","2","3",!1],Gf=["small",!1,"large","huge"],At=class extends de{constructor(e,t){super(e,t);let s=n=>{if(!document.body.contains(e.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(i=>{i.container.contains(n.target)||i.close()})};e.emitter.listenDOM("click",document.body,s)}addModule(e){let t=super.addModule(e);return e==="toolbar"&&this.extendToolbar(t),t}buildButtons(e,t){Array.from(e).forEach(s=>{(s.getAttribute("class")||"").split(/\s+/).forEach(i=>{if(i.startsWith("ql-")&&(i=i.slice(3),t[i]!=null))if(i==="direction")s.innerHTML=t[i][""]+t[i].rtl;else if(typeof t[i]=="string")s.innerHTML=t[i];else{let l=s.value||"";l!=null&&t[i][l]&&(s.innerHTML=t[i][l])}})})}buildPickers(e,t){this.pickers=Array.from(e).map(n=>{if(n.classList.contains("ql-align")&&(n.querySelector("option")==null&&He(n,$f),typeof t.align=="object"))return new _r(n,t.align);if(n.classList.contains("ql-background")||n.classList.contains("ql-color")){let i=n.classList.contains("ql-background")?"background":"color";return n.querySelector("option")==null&&He(n,zf,i==="background"?"#ffffff":"#000000"),new Or(n,t[i])}return n.querySelector("option")==null&&(n.classList.contains("ql-font")?He(n,Vf):n.classList.contains("ql-header")?He(n,Kf):n.classList.contains("ql-size")&&He(n,Gf)),new Ut(n)});let s=()=>{this.pickers.forEach(n=>{n.update()})};this.quill.on(y.events.EDITOR_CHANGE,s)}};At.DEFAULTS=et({},de.DEFAULTS,{modules:{toolbar:{handlers:{formula(){this.quill.theme.tooltip.edit("formula")},image(){let r=this.container.querySelector("input.ql-image[type=file]");r==null&&(r=document.createElement("input"),r.setAttribute("type","file"),r.setAttribute("accept",this.quill.uploader.options.mimetypes.join(", ")),r.classList.add("ql-image"),r.addEventListener("change",()=>{let e=this.quill.getSelection(!0);this.quill.uploader.upload(e,r.files),r.value=""}),this.container.appendChild(r)),r.click()},video(){this.quill.theme.tooltip.edit("video")}}}}});var ge=class extends Ir{constructor(e,t){super(e,t),this.textbox=this.root.querySelector('input[type="text"]'),this.listen()}listen(){this.textbox.addEventListener("keydown",e=>{e.key==="Enter"?(this.save(),e.preventDefault()):e.key==="Escape"&&(this.cancel(),e.preventDefault())})}cancel(){this.hide(),this.restoreFocus()}edit(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",t=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;t!=null?this.textbox.value=t:e!==this.root.getAttribute("data-mode")&&(this.textbox.value="");let s=this.quill.getBounds(this.quill.selection.savedRange);s!=null&&this.position(s),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute(`data-${e}`)||""),this.root.setAttribute("data-mode",e)}restoreFocus(){this.quill.focus({preventScroll:!0})}save(){let{value:e}=this.textbox;switch(this.root.getAttribute("data-mode")){case"link":{let{scrollTop:t}=this.quill.root;this.linkRange?(this.quill.formatText(this.linkRange,"link",e,y.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",e,y.sources.USER)),this.quill.root.scrollTop=t;break}case"video":e=Wf(e);case"formula":{if(!e)break;let t=this.quill.getSelection(!0);if(t!=null){let s=t.index+t.length;this.quill.insertEmbed(s,this.root.getAttribute("data-mode"),e,y.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(s+1," ",y.sources.USER),this.quill.setSelection(s+2,y.sources.USER)}break}default:}this.textbox.value="",this.hide()}};function Wf(r){let e=r.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||r.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return e?`${e[1]||"https"}://www.youtube.com/embed/${e[2]}?showinfo=0`:(e=r.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?`${e[1]||"https"}://player.vimeo.com/video/${e[2]}/`:r}function He(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;e.forEach(s=>{let n=document.createElement("option");s===t?n.setAttribute("selected","selected"):n.setAttribute("value",String(s)),r.appendChild(n)})}var Zf=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],yn=class extends ge{static TEMPLATE=['','
    ','','',"
    "].join("");constructor(e,t){super(e,t),this.quill.on(y.events.EDITOR_CHANGE,(s,n,i,l)=>{if(s===y.events.SELECTION_CHANGE)if(n!=null&&n.length>0&&l===y.sources.USER){this.show(),this.root.style.left="0px",this.root.style.width="",this.root.style.width=`${this.root.offsetWidth}px`;let o=this.quill.getLines(n.index,n.length);if(o.length===1){let a=this.quill.getBounds(n);a!=null&&this.position(a)}else{let a=o[o.length-1],c=this.quill.getIndex(a),u=Math.min(a.length()-1,n.index+n.length-c),h=this.quill.getBounds(new G(c,u));h!=null&&this.position(h)}}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(y.events.SCROLL_OPTIMIZE,()=>{setTimeout(()=>{if(this.root.classList.contains("ql-hidden"))return;let e=this.quill.getSelection();if(e!=null){let t=this.quill.getBounds(e);t!=null&&this.position(t)}},1)})}cancel(){this.show()}position(e){let t=super.position(e),s=this.root.querySelector(".ql-tooltip-arrow");return s.style.marginLeft="",t!==0&&(s.style.marginLeft=`${-1*t-s.offsetWidth/2}px`),t}},Fe=class extends At{constructor(e,t){t.modules.toolbar!=null&&t.modules.toolbar.container==null&&(t.modules.toolbar.container=Zf),super(e,t),this.quill.container.classList.add("ql-bubble")}extendToolbar(e){this.tooltip=new yn(this.quill,this.options.bounds),e.container!=null&&(this.tooltip.root.appendChild(e.container),this.buildButtons(e.container.querySelectorAll("button"),Dt),this.buildPickers(e.container.querySelectorAll("select"),Dt))}};Fe.DEFAULTS=et({},At.DEFAULTS,{modules:{toolbar:{handlers:{link(r){r?this.quill.theme.tooltip.edit():this.quill.format("link",!1,d.sources.USER)}}}}});f();var Qf=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]],vn=class extends ge{static TEMPLATE=['','','',''].join("");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){let t=this.linkRange;this.restoreFocus(),this.quill.formatText(t,"link",!1,y.sources.USER),delete this.linkRange}e.preventDefault(),this.hide()}),this.quill.on(y.events.SELECTION_CHANGE,(e,t,s)=>{if(e!=null){if(e.length===0&&s===y.sources.USER){let[n,i]=this.quill.scroll.descendant(Qt,e.index);if(n!=null){this.linkRange=new G(e.index-i,n.length());let l=Qt.formats(n.domNode);this.preview.textContent=l,this.preview.setAttribute("href",l),this.show();let o=this.quill.getBounds(this.linkRange);o!=null&&this.position(o);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute("data-mode")}},Rr=class extends At{constructor(e,t){t.modules.toolbar!=null&&t.modules.toolbar.container==null&&(t.modules.toolbar.container=Qf),super(e,t),this.quill.container.classList.add("ql-snow")}extendToolbar(e){e.container!=null&&(e.container.classList.add("ql-snow"),this.buildButtons(e.container.querySelectorAll("button"),Dt),this.buildPickers(e.container.querySelectorAll("select"),Dt),this.tooltip=new vn(this.quill,this.options.bounds),e.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"k",shortKey:!0},(t,s)=>{e.handlers.link.call(e,!s.format.link)}))}};Rr.DEFAULTS=et({},At.DEFAULTS,{modules:{toolbar:{handlers:{link(r){if(r){let e=this.quill.getSelection();if(e==null||e.length===0)return;let t=this.quill.getText(e);/^\S+@\S+\.\S+$/.test(t)&&t.indexOf("mailto:")!==0&&(t=`mailto:${t}`);let{tooltip:s}=this.quill.theme;s.edit("link",t)}else this.quill.format("link",!1,d.sources.USER)}}}}});var fo=Rr;Tr.register({"attributors/attribute/direction":yr,"attributors/class/align":Zs,"attributors/class/background":Sl,"attributors/class/color":ql,"attributors/class/direction":Xs,"attributors/class/font":Js,"attributors/class/size":tn,"attributors/style/align":br,"attributors/style/background":Re,"attributors/style/color":Ie,"attributors/style/direction":vr,"attributors/style/font":Er,"attributors/style/size":Nr},!0);Tr.register({"formats/align":Zs,"formats/direction":Xs,"formats/indent":Kl,"formats/background":Re,"formats/color":Ie,"formats/font":Js,"formats/size":tn,"formats/blockquote":Gl,"formats/code-block":P,"formats/header":Wl,"formats/list":Lr,"formats/bold":pe,"formats/code":kl,"formats/italic":Zl,"formats/link":Qt,"formats/script":Ql,"formats/strike":Xl,"formats/underline":Yl,"formats/formula":Jl,"formats/image":eo,"formats/video":so,"modules/syntax":je,"modules/table":io,"modules/toolbar":dn,"themes/bubble":Fe,"themes/snow":fo,"ui/icons":Dt,"ui/picker":Ut,"ui/icon-picker":_r,"ui/color-picker":Or,"ui/tooltip":Ir},!0);var yb=Tr;export{yb as a};