!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyMDE={})}(this,(function(e){"use strict";var t,n,r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={};function s(){if(n)return t;n=1;var e=function(e){return e&&e.Math===Math&&e};return t=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof r&&r)||e("object"==typeof t&&t)||function(){return this}()||Function("return this")()}var o,a,u,l,c,h,p,f,d={};function g(){return a?o:(a=1,o=function(e){try{return!!e()}catch(e){return!0}})}function m(){if(l)return u;l=1;var e=g();return u=!e((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}function y(){if(h)return c;h=1;var e=g();return c=!e((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))}function v(){if(f)return p;f=1;var e=y(),t=Function.prototype.call;return p=e?t.bind(t):function(){return t.apply(t,arguments)},p}var M,T,D,b,F,C,E,k,w,S,x,A,L,$,O,I,H,B,N,P,_,R,j,z,G,V,U,K,q,Z,W,Y,X,Q,J,ee,te,ne,re,ie,se,oe={};function ae(){return D?T:(D=1,T=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}})}function ue(){if(F)return b;F=1;var e=y(),t=Function.prototype,n=t.call,r=e&&t.bind.bind(n,n);return b=e?r:function(e){return function(){return n.apply(e,arguments)}},b}function le(){if(E)return C;E=1;var e=ue(),t=e({}.toString),n=e("".slice);return C=function(e){return n(t(e),8,-1)}}function ce(){return x?S:(x=1,S=function(e){return null==e})}function he(){if(L)return A;L=1;var e=ce(),t=TypeError;return A=function(n){if(e(n))throw new t("Can't call method on "+n);return n}}function pe(){if(O)return $;O=1;var e=function(){if(w)return k;w=1;var e=ue(),t=g(),n=le(),r=Object,i=e("".split);return k=t((function(){return!r("z").propertyIsEnumerable(0)}))?function(e){return"String"===n(e)?i(e,""):r(e)}:r}(),t=he();return $=function(n){return e(t(n))}}function fe(){if(H)return I;H=1;var e="object"==typeof document&&document.all;return I=void 0===e&&void 0!==e?function(t){return"function"==typeof t||t===e}:function(e){return"function"==typeof e}}function de(){if(N)return B;N=1;var e=fe();return B=function(t){return"object"==typeof t?null!==t:e(t)}}function ge(){if(_)return P;_=1;var e=s(),t=fe();return P=function(n,r){return arguments.length<2?(i=e[n],t(i)?i:void 0):e[n]&&e[n][r];var i},P}function me(){if(j)return R;j=1;var e=ue();return R=e({}.isPrototypeOf)}function ye(){if(U)return V;U=1;var e,t,n=s(),r=function(){if(G)return z;G=1;var e=s().navigator,t=e&&e.userAgent;return z=t?String(t):""}(),i=n.process,o=n.Deno,a=i&&i.versions||o&&o.version,u=a&&a.v8;return u&&(t=(e=u.split("."))[0]>0&&e[0]<4?1:+(e[0]+e[1])),!t&&r&&(!(e=r.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=r.match(/Chrome\/(\d+)/))&&(t=+e[1]),V=t}function ve(){if(q)return K;q=1;var e=ye(),t=g(),n=s().String;return K=!!Object.getOwnPropertySymbols&&!t((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&e&&e<41}))}function Me(){if(W)return Z;W=1;var e=ve();return Z=e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function Te(){if(X)return Y;X=1;var e=ge(),t=fe(),n=me(),r=Me(),i=Object;return Y=r?function(e){return"symbol"==typeof e}:function(r){var s=e("Symbol");return t(s)&&n(s.prototype,i(r))}}function De(){if(J)return Q;J=1;var e=String;return Q=function(t){try{return e(t)}catch(e){return"Object"}}}function be(){if(te)return ee;te=1;var e=fe(),t=De(),n=TypeError;return ee=function(r){if(e(r))return r;throw new n(t(r)+" is not a function")}}function Fe(){if(re)return ne;re=1;var e=be(),t=ce();return ne=function(n,r){var i=n[r];return t(i)?void 0:e(i)}}function Ce(){if(se)return ie;se=1;var e=v(),t=fe(),n=de(),r=TypeError;return ie=function(i,s){var o,a;if("string"===s&&t(o=i.toString)&&!n(a=e(o,i)))return a;if(t(o=i.valueOf)&&!n(a=e(o,i)))return a;if("string"!==s&&t(o=i.toString)&&!n(a=e(o,i)))return a;throw new r("Can't convert object to primitive value")}}var Ee,ke,we,Se,xe,Ae,Le,$e,Oe,Ie,He,Be,Ne,Pe,_e,Re,je,ze,Ge,Ve,Ue,Ke,qe,Ze,We={exports:{}};function Ye(){return ke?Ee:(ke=1,Ee=!1)}function Xe(){if(Se)return we;Se=1;var e=s(),t=Object.defineProperty;return we=function(n,r){try{t(e,n,{value:r,configurable:!0,writable:!0})}catch(t){e[n]=r}return r}}function Qe(){if(xe)return We.exports;xe=1;var e=Ye(),t=s(),n=Xe(),r="__core-js_shared__",i=We.exports=t[r]||n(r,{});return(i.versions||(i.versions=[])).push({version:"3.42.0",mode:e?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.42.0/LICENSE",source:"https://github.com/zloirock/core-js"}),We.exports}function Je(){if(Le)return Ae;Le=1;var e=Qe();return Ae=function(t,n){return e[t]||(e[t]=n||{})}}function et(){if(Oe)return $e;Oe=1;var e=he(),t=Object;return $e=function(n){return t(e(n))}}function tt(){if(He)return Ie;He=1;var e=ue(),t=et(),n=e({}.hasOwnProperty);return Ie=Object.hasOwn||function(e,r){return n(t(e),r)}}function nt(){if(Ne)return Be;Ne=1;var e=ue(),t=0,n=Math.random(),r=e(1..toString);return Be=function(e){return"Symbol("+(void 0===e?"":e)+")_"+r(++t+n,36)}}function rt(){if(_e)return Pe;_e=1;var e=s(),t=Je(),n=tt(),r=nt(),i=ve(),o=Me(),a=e.Symbol,u=t("wks"),l=o?a.for||a:a&&a.withoutSetter||r;return Pe=function(e){return n(u,e)||(u[e]=i&&n(a,e)?a[e]:l("Symbol."+e)),u[e]}}function it(){if(je)return Re;je=1;var e=v(),t=de(),n=Te(),r=Fe(),i=Ce(),s=rt(),o=TypeError,a=s("toPrimitive");return Re=function(s,u){if(!t(s)||n(s))return s;var l,c=r(s,a);if(c){if(void 0===u&&(u="default"),l=e(c,s,u),!t(l)||n(l))return l;throw new o("Can't convert object to primitive value")}return void 0===u&&(u="number"),i(s,u)}}function st(){if(Ge)return ze;Ge=1;var e=it(),t=Te();return ze=function(n){var r=e(n,"string");return t(r)?r:r+""}}function ot(){if(Ue)return Ve;Ue=1;var e=s(),t=de(),n=e.document,r=t(n)&&t(n.createElement);return Ve=function(e){return r?n.createElement(e):{}}}function at(){if(qe)return Ke;qe=1;var e=m(),t=g(),n=ot();return Ke=!e&&!t((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))}function ut(){if(Ze)return d;Ze=1;var e=m(),t=v(),n=function(){if(M)return oe;M=1;var e={}.propertyIsEnumerable,t=Object.getOwnPropertyDescriptor,n=t&&!e.call({1:2},1);return oe.f=n?function(e){var n=t(this,e);return!!n&&n.enumerable}:e,oe}(),r=ae(),i=pe(),s=st(),o=tt(),a=at(),u=Object.getOwnPropertyDescriptor;return d.f=e?u:function(e,l){if(e=i(e),l=s(l),a)try{return u(e,l)}catch(e){}if(o(e,l))return r(!t(n.f,e,l),e[l])},d}var lt,ct,ht,pt,ft,dt,gt,mt={};function yt(){if(ct)return lt;ct=1;var e=m(),t=g();return lt=e&&t((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}function vt(){if(pt)return ht;pt=1;var e=de(),t=String,n=TypeError;return ht=function(r){if(e(r))return r;throw new n(t(r)+" is not an object")}}function Mt(){if(ft)return mt;ft=1;var e=m(),t=at(),n=yt(),r=vt(),i=st(),s=TypeError,o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,u="enumerable",l="configurable",c="writable";return mt.f=e?n?function(e,t,n){if(r(e),t=i(t),r(n),"function"==typeof e&&"prototype"===t&&"value"in n&&c in n&&!n[c]){var s=a(e,t);s&&s[c]&&(e[t]=n.value,n={configurable:l in n?n[l]:s[l],enumerable:u in n?n[u]:s[u],writable:!1})}return o(e,t,n)}:o:function(e,n,a){if(r(e),n=i(n),r(a),t)try{return o(e,n,a)}catch(e){}if("get"in a||"set"in a)throw new s("Accessors not supported");return"value"in a&&(e[n]=a.value),e},mt}function Tt(){if(gt)return dt;gt=1;var e=m(),t=Mt(),n=ae();return dt=e?function(e,r,i){return t.f(e,r,n(1,i))}:function(e,t,n){return e[t]=n,e}}var Dt,bt,Ft,Ct,Et,kt,wt,St,xt,At,Lt,$t,Ot,It,Ht,Bt={exports:{}};function Nt(){if(bt)return Dt;bt=1;var e=m(),t=tt(),n=Function.prototype,r=e&&Object.getOwnPropertyDescriptor,i=t(n,"name"),s=i&&"something"===function(){}.name,o=i&&(!e||e&&r(n,"name").configurable);return Dt={EXISTS:i,PROPER:s,CONFIGURABLE:o}}function Pt(){if(Ct)return Ft;Ct=1;var e=ue(),t=fe(),n=Qe(),r=e(Function.toString);return t(n.inspectSource)||(n.inspectSource=function(e){return r(e)}),Ft=n.inspectSource}function _t(){if(St)return wt;St=1;var e=Je(),t=nt(),n=e("keys");return wt=function(e){return n[e]||(n[e]=t(e))}}function Rt(){return At?xt:(At=1,xt={})}function jt(){if($t)return Lt;$t=1;var e,t,n,r=function(){if(kt)return Et;kt=1;var e=s(),t=fe(),n=e.WeakMap;return Et=t(n)&&/native code/.test(String(n))}(),i=s(),o=de(),a=Tt(),u=tt(),l=Qe(),c=_t(),h=Rt(),p="Object already initialized",f=i.TypeError,d=i.WeakMap;if(r||l.state){var g=l.state||(l.state=new d);g.get=g.get,g.has=g.has,g.set=g.set,e=function(e,t){if(g.has(e))throw new f(p);return t.facade=e,g.set(e,t),t},t=function(e){return g.get(e)||{}},n=function(e){return g.has(e)}}else{var m=c("state");h[m]=!0,e=function(e,t){if(u(e,m))throw new f(p);return t.facade=e,a(e,m,t),t},t=function(e){return u(e,m)?e[m]:{}},n=function(e){return u(e,m)}}return Lt={set:e,get:t,has:n,enforce:function(r){return n(r)?t(r):e(r,{})},getterFor:function(e){return function(n){var r;if(!o(n)||(r=t(n)).type!==e)throw new f("Incompatible receiver, "+e+" required");return r}}}}function zt(){if(Ot)return Bt.exports;Ot=1;var e=ue(),t=g(),n=fe(),r=tt(),i=m(),s=Nt().CONFIGURABLE,o=Pt(),a=jt(),u=a.enforce,l=a.get,c=String,h=Object.defineProperty,p=e("".slice),f=e("".replace),d=e([].join),y=i&&!t((function(){return 8!==h((function(){}),"length",{value:8}).length})),v=String(String).split("String"),M=Bt.exports=function(e,t,n){"Symbol("===p(c(t),0,7)&&(t="["+f(c(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!r(e,"name")||s&&e.name!==t)&&(i?h(e,"name",{value:t,configurable:!0}):e.name=t),y&&n&&r(n,"arity")&&e.length!==n.arity&&h(e,"length",{value:n.arity});try{n&&r(n,"constructor")&&n.constructor?i&&h(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var o=u(e);return r(o,"source")||(o.source=d(v,"string"==typeof t?t:"")),e};return Function.prototype.toString=M((function(){return n(this)&&l(this).source||o(this)}),"toString"),Bt.exports}function Gt(){if(Ht)return It;Ht=1;var e=fe(),t=Mt(),n=zt(),r=Xe();return It=function(i,s,o,a){a||(a={});var u=a.enumerable,l=void 0!==a.name?a.name:s;if(e(o)&&n(o,l,a),a.global)u?i[s]=o:r(s,o);else{try{a.unsafe?i[s]&&(u=!0):delete i[s]}catch(e){}u?i[s]=o:t.f(i,s,{value:o,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return i}}var Vt,Ut,Kt,qt,Zt,Wt,Yt,Xt,Qt,Jt,en,tn,nn,rn,sn,on,an,un={};function ln(){if(qt)return Kt;qt=1;var e=function(){if(Ut)return Vt;Ut=1;var e=Math.ceil,t=Math.floor;return Vt=Math.trunc||function(n){var r=+n;return(r>0?t:e)(r)}}();return Kt=function(t){var n=+t;return n!=n||0===n?0:e(n)}}function cn(){if(Wt)return Zt;Wt=1;var e=ln(),t=Math.max,n=Math.min;return Zt=function(r,i){var s=e(r);return s<0?t(s+i,0):n(s,i)}}function hn(){if(Xt)return Yt;Xt=1;var e=ln(),t=Math.min;return Yt=function(n){var r=e(n);return r>0?t(r,9007199254740991):0}}function pn(){if(Jt)return Qt;Jt=1;var e=hn();return Qt=function(t){return e(t.length)}}function fn(){if(rn)return nn;rn=1;var e=ue(),t=tt(),n=pe(),r=function(){if(tn)return en;tn=1;var e=pe(),t=cn(),n=pn(),r=function(r){return function(i,s,o){var a=e(i),u=n(a);if(0===u)return!r&&-1;var l,c=t(o,u);if(r&&s!=s){for(;u>c;)if((l=a[c++])!=l)return!0}else for(;u>c;c++)if((r||c in a)&&a[c]===s)return r||c||0;return!r&&-1}};return en={includes:r(!0),indexOf:r(!1)}}().indexOf,i=Rt(),s=e([].push);return nn=function(e,o){var a,u=n(e),l=0,c=[];for(a in u)!t(i,a)&&t(u,a)&&s(c,a);for(;o.length>l;)t(u,a=o[l++])&&(~r(c,a)||s(c,a));return c}}function dn(){return on?sn:(on=1,sn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}function gn(){if(an)return un;an=1;var e=fn(),t=dn().concat("length","prototype");return un.f=Object.getOwnPropertyNames||function(n){return e(n,t)},un}var mn,yn,vn,Mn,Tn,Dn,bn,Fn,Cn,En,kn,wn,Sn,xn,An,Ln,$n,On,In,Hn={};function Bn(){if(vn)return yn;vn=1;var e=ge(),t=ue(),n=gn(),r=(mn||(mn=1,Hn.f=Object.getOwnPropertySymbols),Hn),i=vt(),s=t([].concat);return yn=e("Reflect","ownKeys")||function(e){var t=n.f(i(e)),o=r.f;return o?s(t,o(e)):t}}function Nn(){if(Tn)return Mn;Tn=1;var e=tt(),t=Bn(),n=ut(),r=Mt();return Mn=function(i,s,o){for(var a=t(s),u=r.f,l=n.f,c=0;cc;)n.f(e,o=u[c++],a[o]);return e},ir}(),r=dn(),i=Rt(),s=or(),o=ot(),a=_t(),u="prototype",l="script",c=a("IE_PROTO"),h=function(){},p=function(e){return"<"+l+">"+e+""},f=function(e){e.write(p("")),e.close();var t=e.parentWindow.Object;return e=null,t},d=function(){try{e=new ActiveXObject("htmlfile")}catch(e){}var t,n,i;d="undefined"!=typeof document?document.domain&&e?f(e):(n=o("iframe"),i="java"+l+":",n.style.display="none",s.appendChild(n),n.src=String(i),(t=n.contentWindow.document).open(),t.write(p("document.F=Object")),t.close(),t.F):f(e);for(var a=r.length;a--;)delete d[u][r[a]];return d()};return i[c]=!0,Wn=Object.create||function(e,r){var i;return null!==e?(h[u]=t(e),i=new h,h[u]=null,i[c]=e):i=d(),void 0===r?i:n.f(i,r)}}function ur(){if(Qn)return Xn;Qn=1;var e=g(),t=s().RegExp;return Xn=e((function(){var e=t(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)}))}function lr(){if(er)return Jn;er=1;var e=g(),t=s().RegExp;return Jn=e((function(){var e=t("(?b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$c")}))}function cr(){if(nr)return tr;nr=1;var e,t,n=v(),r=ue(),i=jn(),s=zn(),o=Gn(),a=Je(),u=ar(),l=jt().get,c=ur(),h=lr(),p=a("native-string-replace",String.prototype.replace),f=RegExp.prototype.exec,d=f,g=r("".charAt),m=r("".indexOf),y=r("".replace),M=r("".slice),T=(t=/b*/g,n(f,e=/a/,"a"),n(f,t,"a"),0!==e.lastIndex||0!==t.lastIndex),D=o.BROKEN_CARET,b=void 0!==/()??/.exec("")[1];return(T||b||D||c||h)&&(d=function(e){var t,r,o,a,c,h,v,F=this,C=l(F),E=i(e),k=C.raw;if(k)return k.lastIndex=F.lastIndex,t=n(d,k,E),F.lastIndex=k.lastIndex,t;var w=C.groups,S=D&&F.sticky,x=n(s,F),A=F.source,L=0,$=E;if(S&&(x=y(x,"y",""),-1===m(x,"g")&&(x+="g"),$=M(E,F.lastIndex),F.lastIndex>0&&(!F.multiline||F.multiline&&"\n"!==g(E,F.lastIndex-1))&&(A="(?: "+A+")",$=" "+$,L++),r=new RegExp("^(?:"+A+")",x)),b&&(r=new RegExp("^"+A+"$(?!\\s)",x)),T&&(o=F.lastIndex),a=n(f,S?r:F,$),S?a?(a.input=M(a.input,L),a[0]=M(a[0],L),a.index=F.lastIndex,F.lastIndex+=a[0].length):F.lastIndex=0:T&&a&&(F.lastIndex=F.global?a.index+a[0].length:o),b&&a&&a.length>1&&n(p,a[0],r,(function(){for(c=1;c=t.length)return e.target=null,o(void 0,!0);switch(e.kind){case"keys":return o(n,!1);case"values":return o(t[n],!1)}return o([n,t[n]],!1)}),"values");var p=n.Arguments=n.Array;if(t("keys"),t("values"),t("entries"),!a&&u&&"values"!==p.name)try{i(p,"name",{value:"values"})}catch(e){}return zr}(),i=Tt(),o=Yr(),a=rt()("iterator"),u=r.values,l=function(e,n){if(e){if(e[a]!==u)try{i(e,a,u)}catch(t){e[a]=u}if(o(e,n,!0),t[n])for(var s in r)if(e[s]!==r[s])try{i(e,s,r[s])}catch(t){e[s]=r[s]}}};for(var c in t)l(e[c]&&e[c].prototype,c);l(n,"DOMTokenList")}();const ni='',ri='',ii='',si='',oi='',ai='',ui='',li='',ci='',hi='',pi='',fi='',di='',gi='\n',mi=/(Mac|iPhone|iPod|iPad)/i.test("undefined"!=typeof navigator?navigator.platform:""),yi={bold:{name:"bold",action:"bold",innerHTML:ri,title:"Bold",hotkey:"Mod-B"},italic:{name:"italic",action:"italic",innerHTML:li,title:"Italic",hotkey:"Mod-I"},strikethrough:{name:"strikethrough",action:"strikethrough",innerHTML:fi,title:"Strikethrough",hotkey:"Mod2-Shift-5"},code:{name:"code",action:"code",innerHTML:ii,title:"Format as code"},h1:{name:"h1",action:"h1",innerHTML:si,title:"Level 1 heading",hotkey:"Mod-Shift-1"},h2:{name:"h2",action:"h2",innerHTML:oi,title:"Level 2 heading",hotkey:"Mod-Shift-2"},ul:{name:"ul",action:"ul",innerHTML:di,title:"Bulleted list"},ol:{name:"ol",action:"ol",innerHTML:hi,title:"Numbered list"},blockquote:{name:"blockquote",action:"blockquote",innerHTML:ni,title:"Quote",hotkey:"Mod2-Shift-Q"},insertLink:{name:"insertLink",action:e=>{e.isInlineFormattingAllowed()&&e.wrapSelection("[","]()")},enabled:e=>!e.isInlineFormattingAllowed()&&null,innerHTML:ci,title:"Insert link",hotkey:"Mod-K"},insertImage:{name:"insertImage",action:e=>{e.isInlineFormattingAllowed()&&e.wrapSelection("![","]()")},enabled:e=>!e.isInlineFormattingAllowed()&&null,innerHTML:ui,title:"Insert image",hotkey:"Mod2-Shift-I"},hr:{name:"hr",action:e=>e.paste("\n***\n"),enabled:()=>!1,innerHTML:ai,title:"Insert horizontal line",hotkey:"Mod2-Shift-L"},undo:{name:"undo",action:e=>e.undo(),enabled:e=>!e.canUndo&&null,innerHTML:gi,title:"Undo"},redo:{name:"redo",action:e=>e.redo(),enabled:e=>!e.canRedo&&null,innerHTML:pi,title:"Redo"}};function vi(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ti(e){for(var t=1;t]+)(>|$)/g,(function(e,t,n){if(""===n)return e;var r=s[t];return Array.isArray(r)?"$"+r.join("$"):"number"==typeof r?"$"+r:""})))}if("function"==typeof i){var o=this;return e[Symbol.replace].call(this,n,(function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(r(e,o)),i.apply(this,e)}))}return e[Symbol.replace].call(this,n,i)},bi.apply(this,arguments)}var Fi,Ci,Ei,ki,wi,Si,xi,Ai,Li,$i,Oi,Ii,Hi,Bi={};function Ni(){if(Ai)return xi;Ai=1;var e=function(){if(Si)return wi;Si=1;var e=ue(),t=ln(),n=jn(),r=he(),i=e("".charAt),s=e("".charCodeAt),o=e("".slice),a=function(e){return function(a,u){var l,c,h=n(r(a)),p=t(u),f=h.length;return p<0||p>=f?e?"":void 0:(l=s(h,p))<55296||l>56319||p+1===f||(c=s(h,p+1))<56320||c>57343?e?i(h,p):l:e?o(h,p,p+2):c-56320+(l-55296<<10)+65536}};return wi={codeAt:a(!1),charAt:a(!0)}}().charAt;return xi=function(t,n,r){return n+(r?e(t,n).length:1)}}function Pi(){if($i)return Li;$i=1;var e=ue(),t=et(),n=Math.floor,r=e("".charAt),i=e("".replace),s=e("".slice),o=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,a=/\$([$&'`]|\d{1,2})/g;return Li=function(e,u,l,c,h,p){var f=l+e.length,d=c.length,g=a;return void 0!==h&&(h=t(h),g=o),i(p,g,(function(t,i){var o;switch(r(i,0)){case"$":return"$";case"&":return e;case"`":return s(u,0,l);case"'":return s(u,f);case"<":o=h[s(i,1,-1)];break;default:var a=+i;if(0===a)return t;if(a>d){var p=n(a/10);return 0===p?t:p<=d?void 0===c[p-1]?r(i,1):c[p-1]+r(i,1):t}o=c[a-1]}return void 0===o?"":o}))}}!function(){if(Hi)return Bi;Hi=1;var e=function(){if(Ci)return Fi;Ci=1;var e=y(),t=Function.prototype,n=t.apply,r=t.call;return Fi="object"==typeof Reflect&&Reflect.apply||(e?r.bind(n):function(){return r.apply(n,arguments)}),Fi}(),t=v(),n=ue(),r=function(){if(ki)return Ei;ki=1,hr();var e=v(),t=Gt(),n=cr(),r=g(),i=rt(),s=Tt(),o=i("species"),a=RegExp.prototype;return Ei=function(u,l,c,h){var p=i(u),f=!r((function(){var e={};return e[p]=function(){return 7},7!==""[u](e)})),d=f&&!r((function(){var e=!1,t=/a/;return"split"===u&&((t={}).constructor={},t.constructor[o]=function(){return t},t.flags="",t[p]=/./[p]),t.exec=function(){return e=!0,null},t[p](""),!e}));if(!f||!d||c){var g=/./[p],m=l(p,""[u],(function(t,r,i,s,o){var u=r.exec;return u===n||u===a.exec?f&&!o?{done:!0,value:e(g,r,i,s)}:{done:!0,value:e(t,i,r,s)}:{done:!1}}));t(String.prototype,u,m[0]),t(a,p,m[1])}h&&s(a[p],"sham",!0)}}(),i=g(),s=vt(),o=fe(),a=de(),u=ln(),l=hn(),c=jn(),h=he(),p=Ni(),f=Fe(),d=Pi(),m=function(){if(Ii)return Oi;Ii=1;var e=v(),t=vt(),n=fe(),r=le(),i=cr(),s=TypeError;return Oi=function(o,a){var u=o.exec;if(n(u)){var l=e(u,o,a);return null!==l&&t(l),l}if("RegExp"===r(o))return e(i,o,a);throw new s("RegExp#exec called on incompatible receiver")}}(),M=rt()("replace"),T=Math.max,D=Math.min,b=n([].concat),F=n([].push),C=n("".indexOf),E=n("".slice),k="$0"==="a".replace(/./,"$0"),w=!!/./[M]&&""===/./[M]("a","$0");r("replace",(function(n,r,i){var g=w?"$":"$0";return[function(e,n){var i=h(this),s=a(e)?f(e,M):void 0;return s?t(s,e,i,n):t(r,c(i),e,n)},function(t,n){var a=s(this),h=c(t);if("string"==typeof n&&-1===C(n,g)&&-1===C(n,"$<")){var f=i(r,a,h,n);if(f.done)return f.value}var y=o(n);y||(n=c(n));var v,M=a.global;M&&(v=a.unicode,a.lastIndex=0);for(var k,w=[];null!==(k=m(a,h))&&(F(w,k),M);){""===c(k[0])&&(a.lastIndex=p(h,l(a.lastIndex),v))}for(var S,x="",A=0,L=0;L=A&&(x+=E(h,A,I)+$,A=I+O.length)}return x+E(h,A)}]}),!!i((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$")}))||!k||w)}();var _i,Ri,ji,zi,Gi,Vi,Ui,Ki={};function qi(){return Ri?_i:(Ri=1,_i="\t\n\v\f\r                 \u2028\u2029\ufeff")}!function(){if(Ui)return Ki;Ui=1;var e=_n(),t=function(){if(zi)return ji;zi=1;var e=ue(),t=he(),n=jn(),r=qi(),i=e("".replace),s=RegExp("^["+r+"]+"),o=RegExp("(^|[^"+r+"])["+r+"]+$"),a=function(e){return function(r){var a=n(t(r));return 1&e&&(a=i(a,s,"")),2&e&&(a=i(a,o,"$1")),a}};return ji={start:a(1),end:a(2),trim:a(3)}}().trim,n=function(){if(Vi)return Gi;Vi=1;var e=Nt().PROPER,t=g(),n=qi();return Gi=function(r){return t((function(){return!!n[r]()||"​…᠎"!=="​…᠎"[r]()||e&&n[r].name!==r}))}}();e({target:"String",proto:!0,forced:n("trim")},{trim:function(){return t(this)}})}();var Zi,Wi,Yi,Xi,Qi,Ji,es,ts,ns,rs,is,ss,os,as={};function us(){if(Wi)return Zi;Wi=1;var e=fe(),t=de(),n=Jr();return Zi=function(r,i,s){var o,a;return n&&e(o=i.constructor)&&o!==s&&t(a=o.prototype)&&a!==s.prototype&&n(r,a),r}}function ls(){if(ts)return es;ts=1;var e=Mt().f;return es=function(t,n,r){r in t||e(t,r,{configurable:!0,get:function(){return n[r]},set:function(e){n[r]=e}})}}function cs(){if(rs)return ns;rs=1;var e=zt(),t=Mt();return ns=function(n,r,i){return i.get&&e(i.get,r,{getter:!0}),i.set&&e(i.set,r,{setter:!0}),t.f(n,r,i)}}function hs(){if(ss)return is;ss=1;var e=ge(),t=cs(),n=rt(),r=m(),i=n("species");return is=function(n){var s=e(n);r&&s&&!s[i]&&t(s,i,{configurable:!0,get:function(){return this}})}}!function(){if(os)return as;os=1;var e=m(),t=s(),n=ue(),r=Pn(),i=us(),o=Tt(),a=ar(),u=gn().f,l=me(),c=function(){if(Xi)return Yi;Xi=1;var e=de(),t=le(),n=rt()("match");return Yi=function(r){var i;return e(r)&&(void 0!==(i=r[n])?!!i:"RegExp"===t(r))}}(),h=jn(),p=function(){if(Ji)return Qi;Ji=1;var e=v(),t=tt(),n=me(),r=zn(),i=RegExp.prototype;return Qi=function(s){var o=s.flags;return void 0!==o||"flags"in i||t(s,"flags")||!n(i,s)?o:e(r,s)}}(),f=Gn(),d=ls(),y=Gt(),M=g(),T=tt(),D=jt().enforce,b=hs(),F=rt(),C=ur(),E=lr(),k=F("match"),w=t.RegExp,S=w.prototype,x=t.SyntaxError,A=n(S.exec),L=n("".charAt),$=n("".replace),O=n("".indexOf),I=n("".slice),H=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,B=/a/g,N=/a/g,P=new w(B)!==B,_=f.MISSED_STICKY,R=f.UNSUPPORTED_Y,j=e&&(!P||_||C||E||M((function(){return N[k]=!1,w(B)!==B||w(N)===N||"/a/i"!==String(w(B,"i"))})));if(r("RegExp",j)){for(var z=function(e,t){var n,r,s,u,f,d,g=l(S,this),m=c(e),y=void 0===t,v=[],M=e;if(!g&&m&&y&&e.constructor===z)return e;if((m||l(S,e))&&(e=e.source,y&&(t=p(M))),e=void 0===e?"":h(e),t=void 0===t?"":h(t),M=e,C&&"dotAll"in B&&(r=!!t&&O(t,"s")>-1)&&(t=$(t,/s/g,"")),n=t,_&&"sticky"in B&&(s=!!t&&O(t,"y")>-1)&&R&&(t=$(t,/y/g,"")),E&&(u=function(e){for(var t,n=e.length,r=0,i="",s=[],o=a(null),u=!1,l=!1,c=0,h="";r<=n;r++){if("\\"===(t=L(e,r)))t+=L(e,++r);else if("]"===t)u=!1;else if(!u)switch(!0){case"["===t:u=!0;break;case"("===t:if(i+=t,"?:"===I(e,r+1,r+3))continue;A(H,I(e,r+1))&&(r+=2,l=!0),c++;continue;case">"===t&&l:if(""===h||T(o,h))throw new x("Invalid capture group name");o[h]=!0,s[s.length]=[h,c],l=!1,h="";continue}l?h+=t:i+=t}return[i,s]}(e),e=u[0],v=u[1]),f=i(w(e,t),g?this:S,z),(r||s||v.length)&&(d=D(f),r&&(d.dotAll=!0,d.raw=z(function(e){for(var t,n=e.length,r=0,i="",s=!1;r<=n;r++)"\\"!==(t=L(e,r))?s||"."!==t?("["===t?s=!0:"]"===t&&(s=!1),i+=t):i+="[\\s\\S]":i+=t+L(e,++r);return i}(e),n)),s&&(d.sticky=!0),v.length&&(d.groups=v)),e!==M)try{o(f,"source",""===M?"(?:)":M)}catch(e){}return f},G=u(w),V=0;G.length>V;)d(z,w,G[V++]);S.constructor=z,z.prototype=S,y(t,"RegExp",z,{constructor:!0})}b("RegExp")}();var ps,fs={};!function(){if(ps)return fs;ps=1;var e=s(),t=m(),n=cs(),r=zn(),i=g(),o=e.RegExp,a=o.prototype;t&&i((function(){var e=!0;try{o(".","d")}catch(t){e=!1}var t={},n="",r=e?"dgimsy":"gimsy",i=function(e,r){Object.defineProperty(t,e,{get:function(){return n+=r,!0}})},s={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var u in e&&(s.hasIndices="d"),s)i(u,s[u]);return Object.getOwnPropertyDescriptor(a,"flags").get.call(t)!==r||n!==r}))&&n(a,"flags",{configurable:!0,get:r})}();const ds={ASCIIPunctuation:/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/,NotTriggerChar:/[^`_*[\]()<>!~]/,Scheme:/[A-Za-z][A-Za-z0-9+.-]{1,31}/,Email:/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/,HTMLOpenTag://,HTMLCloseTag:/<\/HTMLTagName\s*>/,HTMLTagName:/[A-Za-z][A-Za-z0-9-]*/,HTMLComment://,HTMLPI:/<\?(?:|.|(?:[^?]|\?[^>])*)\?>/,HTMLDeclaration:/]*>/,HTMLCDATA://,HTMLAttribute:/\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:HTMLAttValue)?/,HTMLAttValue:/\s*=\s*(?:(?:'[^']*')|(?:"[^"]*")|(?:[^\s"'=<>`]+))/,KnownTag:/address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul/},gs=new RegExp(/^(?:[!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B])/),ms=new RegExp(/(?:[!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B])$/),ys={TMH1:{regexp:/^( {0,3}#\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'$1$$2$3'},TMH2:{regexp:/^( {0,3}##\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'$1$$2$3'},TMH3:{regexp:/^( {0,3}###\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'$1$$2$3'},TMH4:{regexp:/^( {0,3}####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'$1$$2$3'},TMH5:{regexp:/^( {0,3}#####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'$1$$2$3'},TMH6:{regexp:/^( {0,3}######\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'$1$$2$3'},TMBlockquote:{regexp:/^( {0,3}>[ ]?)(.*)$/,replacement:'$1$$2'},TMCodeFenceBacktickOpen:{regexp:bi(/^( {0,3}(````*)\s*)([^`]*?)(\s*)$/,{seq:2}),replacement:'$1$3$4'},TMCodeFenceTildeOpen:{regexp:bi(/^( {0,3}(~~~~*)\s*)(.*?)(\s*)$/,{seq:2}),replacement:'$1$3$4'},TMCodeFenceBacktickClose:{regexp:bi(/^( {0,3}(````*))(\s*)$/,{seq:2}),replacement:'$1$3'},TMCodeFenceTildeClose:{regexp:bi(/^( {0,3}(~~~~*))(\s*)$/,{seq:2}),replacement:'$1$3'},TMBlankLine:{regexp:/^([ \t]*)$/,replacement:"$0"},TMSetextH1Marker:{regexp:/^ {0,3}=+\s*$/,replacement:'$0'},TMSetextH2Marker:{regexp:/^ {0,3}-+\s*$/,replacement:'$0'},TMHR:{regexp:/^( {0,3}(\*[ \t]*\*[ \t]*\*[ \t*]*)|(-[ \t]*-[ \t]*-[ \t-]*)|(_[ \t]*_[ \t]*_[ \t_]*))$/,replacement:'$0'},TMUL:{regexp:/^( {0,3}[+*-] {1,4})(.*)$/,replacement:'$1$$2'},TMOL:{regexp:/^( {0,3}\d{1,9}[.)] {1,4})(.*)$/,replacement:'$1$$2'},TMIndentedCode:{regexp:/^( {4}|\t)(.*)$/,replacement:'$1$2'},TMLinkReferenceDefinition:{regexp:/^( {0,3}\[\s*)([^\s\]](?:[^\]]|\\\])*?)(\s*\]:\s*)((?:[^\s<>]+)|(?:<(?:[^<>\\]|\\.)*>))?(\s*)((?:\((?:[^()\\]|\\.)*\))|(?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.)*'))?(\s*)$/,replacement:'$1$2$3$4$5$6$7',labelPlaceholder:2}},vs=[{start:/^ {0,3}<(?:script|pre|style)(?:\s|>|$)/i,end:/(?:<\/script>|<\/pre>|<\/style>)/i,paraInterrupt:!0},{start:/^ {0,3}/,paraInterrupt:!0},{start:/^ {0,3}<\?/,end:/\?>/,paraInterrupt:!0},{start:/^ {0,3}/,paraInterrupt:!0},{start:/^ {0,3}/,paraInterrupt:!0},{start:/^ {0,3}(?:<|<\/)(?:KnownTag)(?:\s|>|\/>|$)/i,end:!1,paraInterrupt:!0},{start:/^ {0,3}(?:HTMLOpenTag|HTMLCloseTag)\s*$/,end:!1,paraInterrupt:!1}],Ms={escape:{regexp:/^\\(ASCIIPunctuation)/,replacement:'\\$1'},code:{regexp:/^(`+)((?:[^`])|(?:[^`].*?[^`]))(\1)/,replacement:'$1$2$3'},autolink:{regexp:/^<((?:Scheme:[^\s<>]*)|(?:Email))>/,replacement:'<$1>'},html:{regexp:/^((?:HTMLOpenTag)|(?:HTMLCloseTag)|(?:HTMLComment)|(?:HTMLPI)|(?:HTMLDeclaration)|(?:HTMLCDATA))/,replacement:'$1'},linkOpen:{regexp:/^\[/,replacement:""},imageOpen:{regexp:/^!\[/,replacement:""},linkLabel:{regexp:/^(\[\s*)([^\]]*?)(\s*\])/,replacement:"",labelPlaceholder:2},default:{regexp:/^(.|(?:NotTriggerChar+))/,replacement:"$1"}},Ts=new RegExp(Object.keys(ds).join("|")),Ds=[...Object.keys(Ms)];for(let e of Ds){let t=Ms[e].regexp.source;for(;t.match(Ts);)t=t.replace(Ts,(e=>ds[e].source));Ms[e].regexp=new RegExp(t,Ms[e].regexp.flags)}for(let e of vs){let t=e.start.source;for(;t.match(Ts);)t=t.replace(Ts,(e=>ds[e].source));e.start=new RegExp(t,e.start.flags)}function bs(e){return(e||"").replace(/&/g,"&").replace(//g,">")}const Fs={bold:{type:"inline",className:"TMStrong",set:{pre:"**",post:"**"},unset:{prePattern:/(?:\*\*|__)$/,postPattern:/^(?:\*\*|__)/}},italic:{type:"inline",className:"TMEm",set:{pre:"*",post:"*"},unset:{prePattern:/(?:\*|_)$/,postPattern:/^(?:\*|_)/}},code:{type:"inline",className:"TMCode",set:{pre:"`",post:"`"},unset:{prePattern:/`+$/,postPattern:/^`+/}},strikethrough:{type:"inline",className:"TMStrikethrough",set:{pre:"~~",post:"~~"},unset:{prePattern:/~~$/,postPattern:/^~~/}},h1:{type:"line",className:"TMH1",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"# $2"},unset:{pattern:/^( {0,3}#\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h2:{type:"line",className:"TMH2",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"## $2"},unset:{pattern:/^( {0,3}##\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h3:{type:"line",className:"TMH3",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"### $2"},unset:{pattern:/^( {0,3}###\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h4:{type:"line",className:"TMH4",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"#### $2"},unset:{pattern:/^( {0,3}####\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h5:{type:"line",className:"TMH5",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"##### $2"},unset:{pattern:/^( {0,3}#####\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h6:{type:"line",className:"TMH6",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"###### $2"},unset:{pattern:/^( {0,3}######\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},ul:{type:"line",className:"TMUL",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"- $2"},unset:{pattern:/^( {0,3}[+*-] {1,4})(.*)$/,replacement:"$2"}},ol:{type:"line",className:"TMOL",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"$#. $2"},unset:{pattern:/^( {0,3}\d{1,9}[.)] {1,4})(.*)$/,replacement:"$2"}},blockquote:{type:"line",className:"TMBlockquote",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"> $2"},unset:{pattern:/^( {0,3}>[ ]?)(.*)$/,replacement:"$2"}}};e.CommandBar=class{constructor(e){this.e=null,this.editor=null,this.commands={},this.buttons={},this.state={},this.hotkeys=[],this.e=null,this.editor=null,this.commands={},this.buttons={},this.state={},this.hotkeys=[];let t=null;"string"==typeof e.element?t=document.getElementById(e.element):e.element&&(t=e.element),t||(t=document.body),this.createCommandBarElement(t,e.commands||["bold","italic","strikethrough","|","code","|","h1","h2","|","ul","ol","|","blockquote","hr","|","undo","redo","|","insertLink","insertImage"]),document.addEventListener("keydown",(e=>this.handleKeydown(e))),e.editor&&this.setEditor(e.editor)}createCommandBarElement(e,t){this.e=document.createElement("div"),this.e.className="TMCommandBar";for(let e of t)if("|"===e){let e=document.createElement("div");e.className="TMCommandDivider",this.e.appendChild(e)}else{let t;if("string"==typeof e){if(!yi[e])continue;t=e,this.commands[t]=yi[t]}else{if("object"!=typeof e||!e.name)continue;t=e.name,this.commands[t]={},yi[t]&&Object.assign(this.commands[t],yi[t]),Object.assign(this.commands[t],e)}let n=this.commands[t].title||t;if(this.commands[t].hotkey){const e=this.commands[t].hotkey.split("-");let r=[],i=[];for(let t=0;tthis.handleClick(t,e))),this.e.appendChild(this.buttons[t])}e.appendChild(this.e)}handleClick(e,t){if(this.editor){if(t.preventDefault(),this.editor.e){const e=this.editor.e.contains(document.activeElement);this.editor.e.focus(),e||this.editor.restoreLastSelection()}"string"==typeof this.commands[e].action?!1===this.state[e]?this.editor.setCommandState(e,!0):this.editor.setCommandState(e,!1):"function"==typeof this.commands[e].action&&this.commands[e].action(this.editor)}}setEditor(e){this.editor=e,e.addEventListener("selection",(e=>this.handleSelection(e)))}handleSelection(e){if(e.commandState)for(let t in this.commands)void 0===e.commandState[t]?this.commands[t].enabled?this.state[t]=this.commands[t].enabled(this.editor,e.focus,e.anchor):this.state[t]=!e.focus&&null:this.state[t]=e.commandState[t],!0===this.state[t]?this.buttons[t].className="TMCommandButton TMCommandButton_Active":!1===this.state[t]?this.buttons[t].className="TMCommandButton TMCommandButton_Inactive":this.buttons[t].className="TMCommandButton TMCommandButton_Disabled"}handleKeydown(e){if(this.editor&&this.editor.e&&this.editor.e.contains(document.activeElement))e:for(let t of this.hotkeys)if(t.key&&e.key.toLowerCase()===t.key||t.code&&e.code===t.code){for(let n of t.modifiers)if(!e[n])continue e;return void this.handleClick(t.command,e)}}},e.Editor=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t;this.e=null,this.textarea=null,this.lines=[],this.lineElements=[],this.lineTypes=[],this.lineCaptures=[],this.lineReplacements=[],this.linkLabels=[],this.lineDirty=[],this.lastCommandState=null,this.customInlineGrammar={},this.mergedInlineGrammar=Ms,this.hasFocus=!0,this.lastSelection=null,this.listeners={change:[],selection:[],drop:[]},this.undoStack=[],this.redoStack=[],this.isRestoringHistory=!1,this.maxHistory=100,this.e=null,this.textarea=null,this.lines=[],this.lineElements=[],this.lineTypes=[],this.lineCaptures=[],this.lineReplacements=[],this.linkLabels=[],this.lineDirty=[],this.lastCommandState=null,this.hasFocus=!0,this.lastSelection=null,this.customInlineGrammar=e.customInlineGrammar||{},this.mergedInlineGrammar=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Ti({},Ms);for(const[n,r]of Object.entries(e)){const e=Ti({},r);let i=r.regexp.source;const s=new RegExp(Object.keys(ds).join("|"));for(;i.match(s);)i=i.replace(s,(e=>ds[e].source));e.regexp=new RegExp(i,r.regexp.flags),t[n]=e}return t}(this.customInlineGrammar),this.listeners={change:[],selection:[],drop:[]};let n=null;"string"==typeof e.element?n=document.getElementById(e.element):e.element&&(n=e.element),"string"==typeof e.textarea?this.textarea=document.getElementById(e.textarea):e.textarea&&(this.textarea=e.textarea),this.textarea&&(n||(n=this.textarea)),n||(n=document.getElementsByTagName("body")[0]),n&&"TEXTAREA"===n.tagName&&(this.textarea=n,n=this.textarea.parentNode),this.textarea&&(this.textarea.style.display="none"),this.placeholder=void 0!==e.placeholder?e.placeholder:(null===(t=this.textarea)||void 0===t?void 0:t.placeholder)||void 0,this.undoStack=[],this.redoStack=[],this.isRestoringHistory=!1,this.maxHistory=100,this.createEditorElement(n,e),this.setContent("string"==typeof e.content?e.content:this.textarea?this.textarea.value:"# Hello TinyMDE!\nEdit **here**"),this.e.addEventListener("keydown",(e=>this.handleUndoRedoKey(e)))}get canUndo(){return this.undoStack.length>=2}get canRedo(){return this.redoStack.length>0}pushHistory(){this.isRestoringHistory||(this.pushCurrentState(),this.redoStack=[])}pushCurrentState(){this.undoStack.push({content:this.getContent(),selection:this.getSelection(),anchor:this.getSelection(!0)}),this.undoStack.length>this.maxHistory&&this.undoStack.shift()}undo(){if(this.undoStack.length<2)return;this.isRestoringHistory=!0,this.pushCurrentState();const e=this.undoStack.pop();this.redoStack.push(e);const t=this.undoStack[this.undoStack.length-1];this.setContent(t.content),t.selection&&this.setSelection(t.selection,t.anchor),this.undoStack.pop(),this.isRestoringHistory=!1}redo(){if(!this.redoStack.length)return;this.isRestoringHistory=!0,this.pushCurrentState();const e=this.redoStack.pop();this.setContent(e.content),e.selection&&this.setSelection(e.selection,e.anchor),this.isRestoringHistory=!1}handleUndoRedoKey(e){(/Mac|iPod|iPhone|iPad/.test(navigator.platform)?e.metaKey:e.ctrlKey)&&!e.altKey&&("z"===e.key||"Z"===e.key?(e.shiftKey?this.redo():this.undo(),e.preventDefault()):"y"!==e.key&&"Y"!==e.key||(this.redo(),e.preventDefault()))}createEditorElement(e,t){t&&void 0!==t.editor?"string"==typeof t.editor?this.e=document.getElementById(t.editor):this.e=t.editor:this.e=document.createElement("div"),this.e.classList.add("TinyMDE"),this.e.contentEditable="true",this.e.style.whiteSpace="pre-wrap",this.e.style.webkitUserModify="read-write-plaintext-only",this.placeholder&&this.e.setAttribute("data-placeholder",this.placeholder),void 0===t.editor&&(this.textarea&&this.textarea.parentNode===e&&this.textarea.nextSibling?e.insertBefore(this.e,this.textarea.nextSibling):e.appendChild(this.e)),this.e.addEventListener("input",(e=>this.handleInputEvent(e))),this.e.addEventListener("beforeinput",(e=>this.handleBeforeInputEvent(e))),this.e.addEventListener("compositionend",(e=>this.handleInputEvent(e))),document.addEventListener("selectionchange",(e=>{this.hasFocus&&this.handleSelectionChangeEvent(e)})),this.e.addEventListener("blur",(()=>this.hasFocus=!1)),this.e.addEventListener("focus",(()=>this.hasFocus=!0)),this.e.addEventListener("paste",(e=>this.handlePaste(e))),this.e.addEventListener("drop",(e=>this.handleDrop(e))),this.lineElements=this.e.childNodes}setContent(e){for(;this.e.firstChild;)this.e.removeChild(this.e.firstChild);this.lines=e.split(/(?:\r\n|\r|\n)/),this.lineDirty=[];for(let e=0;e"$"===n?bs(t[parseInt(r)]):''.concat(this.processInlineStyles(t[parseInt(r)]),"")))}applyLineTypes(){for(let e=0;e":t}this.lineElements[e].dataset.lineNum=e.toString()}}updateLineTypes(){let e=!1,t=0,n=!1;for(let r=0;r=t?(i="TMCodeFenceBacktickClose",o=ys.TMCodeFenceBacktickClose.replacement,s=n,e=!1):(i="TMFencedCodeBacktick",o='$0
',s=[this.lines[r]])}else if("TMCodeFenceTildeOpen"===e){let n=ys.TMCodeFenceTildeClose.regexp.exec(this.lines[r]);n&&n.groups.seq.length>=t?(i="TMCodeFenceTildeClose",o=ys.TMCodeFenceTildeClose.replacement,s=n,e=!1):(i="TMFencedCodeTilde",o='$0
',s=[this.lines[r]])}if("TMPara"===i&&!1===n)for(let e of vs)if(this.lines[r].match(e.start)&&(e.paraInterrupt||0===r||"TMPara"!==this.lineTypes[r-1]&&"TMUL"!==this.lineTypes[r-1]&&"TMOL"!==this.lineTypes[r-1]&&"TMBlockquote"!==this.lineTypes[r-1])){n=e;break}if(!1!==n&&(i="TMHTMLBlock",o='$0
',s=[this.lines[r]],n.end?this.lines[r].match(n.end)&&(n=!1):(r===this.lines.length-1||this.lines[r+1].match(ys.TMBlankLine.regexp))&&(n=!1)),"TMPara"===i)for(let e in ys)if(ys[e].regexp){let t=ys[e].regexp.exec(this.lines[r]);if(t){i=e,o=ys[e].replacement,s=t;break}}if("TMCodeFenceBacktickOpen"!==i&&"TMCodeFenceTildeOpen"!==i||(e=i,t=s.groups.seq.length),"TMIndentedCode"!==i&&"TMLinkReferenceDefinition"!==i||!(r>0)||"TMPara"!==this.lineTypes[r-1]&&"TMUL"!==this.lineTypes[r-1]&&"TMOL"!==this.lineTypes[r-1]&&"TMBlockquote"!==this.lineTypes[r-1]||(i="TMPara",s=[this.lines[r]],o="$$0"),"TMSetextH2Marker"===i){let e=ys.TMUL.regexp.exec(this.lines[r]);e&&(i="TMUL",o=ys.TMUL.replacement,s=e)}if("TMSetextH1Marker"===i||"TMSetextH2Marker"===i)if(0===r||"TMPara"!==this.lineTypes[r-1]){let e=ys.TMHR.regexp.exec(this.lines[r]);e?(i="TMHR",s=e,o=ys.TMHR.replacement):(i="TMPara",s=[this.lines[r]],o="$$0")}else{let e=r-1;const t="TMSetextH1Marker"===i?"TMSetextH1":"TMSetextH2";do{this.lineTypes[e]!==t&&(this.lineTypes[e]=t,this.lineDirty[e]=!0),this.lineReplacements[e]="$$0",this.lineCaptures[e]=[this.lines[e]],e--}while(e>=0&&"TMPara"===this.lineTypes[e])}this.lineTypes[r]!==i&&(this.lineTypes[r]=i,this.lineDirty[r]=!0),this.lineReplacements[r]=o,this.lineCaptures[r]=s}}getSelection(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var t,n;const r=window.getSelection();let i=e?r.anchorNode:r.focusNode;if(!i)return null;let s=e?r.anchorOffset:r.focusOffset;if(i===this.e)return s1&&void 0!==arguments[1]?arguments[1]:null;if(!e)return;let{node:n,offset:r}=this.computeNodeAndOffset(e.row,e.col,!!t&&(t.row===e.row&&t.col>e.col)),i=null,s=null;if(t&&(t.row!==e.row||t.col!==e.col)){let{node:n,offset:r}=this.computeNodeAndOffset(t.row,t.col,e.row===t.row&&e.col>t.col);i=n,s=r}window.getSelection().setBaseAndExtent(n,r,i||n,i?s:r)}restoreLastSelection(){return!(!this.lastSelection||!this.lastSelection.focus)&&(this.setSelection(this.lastSelection.focus,this.lastSelection.anchor),!0)}paste(e){let t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;r||(r=this.getSelection(!0)),i||(i=this.getSelection(!1)),i||(i={row:this.lines.length-1,col:this.lines[this.lines.length-1].length}),r||(r=i),r.row2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(this.isRestoringHistory||this.pushHistory(),n||(n=this.getSelection(!1)),r||(r=this.getSelection(!0)),!n||!r||n.row!==r.row)return;this.lineDirty[n.row]=!0;const i=n.col0){e.preventDefault(),this.isRestoringHistory||this.pushHistory(),this.clearDirtyFlag();const t=this.lines[n.row-1].length;return this.lines[n.row-1]=this.lines[n.row-1]+this.lines[n.row],this.lineDirty[n.row-1]=!0,this.spliceLines(n.row,1),this.updateFormatting(),this.setSelection({row:n.row-1,col:t}),void this.fireChange()}if(!i&&n.col===this.lines[n.row].length&&n.row(parseInt(e)+1).toString()))),this.lines[n.row]="".concat(t[1]).concat(this.lines[n.row]),this.lineDirty[n.row]=!0,n.col=t[1].length):(this.lines[n.row-1]="",this.lineDirty[n.row-1]=!0))}}this.updateFormatting(),this.setSelection(n),n&&n.row
',this.updateLineContentsAndFormatting(),n&&this.setSelection(n),this.fireChange())}handleSelectionChangeEvent(e){this.fireSelection()}handlePaste(e){this.isRestoringHistory||this.pushHistory(),e.preventDefault();let t=e.clipboardData.getData("text/plain");this.paste(t)}handleDrop(e){e.preventDefault(),this.fireDrop(e.dataTransfer)}processInlineStyles(e){let t="",n=[],r=0,i=e;e:for(;i;){for(let e of["escape","code","autolink","html"])if(this.mergedInlineGrammar[e]){let n=this.mergedInlineGrammar[e].regexp.exec(i);if(n){i=i.substr(n[0].length),r+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(/\$([1-9])/g,((e,t)=>bs(n[t])));continue e}}for(let e in this.customInlineGrammar)if("escape"!==e&&"code"!==e&&"autolink"!==e&&"html"!==e&&"linkOpen"!==e&&"imageOpen"!==e&&"linkLabel"!==e&&"default"!==e){let n=this.mergedInlineGrammar[e].regexp.exec(i);if(n){i=i.substr(n[0].length),r+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(/\$([1-9])/g,((e,t)=>bs(n[t])));continue e}}let s=i.match(this.mergedInlineGrammar.linkOpen.regexp),o=i.match(this.mergedInlineGrammar.imageOpen.regexp);if(o||s){let e=this.parseLinkOrImage(i,!!o);if(e){t="".concat(t).concat(e.output),i=i.substr(e.charCount),r+=e.charCount;continue e}}let a=/(^\*+)|(^_+)/.exec(i);if(a){let s=a[0].length;const o=a[0],u=a[0][0];i=i.substr(a[0].length);const l=r>0?e.substr(0,r):" ",c=r+a[0].length=0;)if(n[e].delimiter===u){for(;e=2&&n[e].count>=2?(t=''.concat(u).concat(u,'').concat(t,'').concat(u).concat(u,""),s-=2,n[e].count-=2):(t=''.concat(u,'').concat(t,'').concat(u,""),s-=1,n[e].count-=1),0===n[e].count){let r=n.pop();t="".concat(r.output).concat(t),e--}}else e--}s&&g&&(n.push({delimiter:u,delimString:o,count:s,output:t}),t="",s=0),s&&(t="".concat(t).concat(o.substr(0,s))),r+=a[0].length}else if(a=/^~~/.exec(i),a){let e=!1,s=n.length-1;for(;!e&&s>=0;)if("~"===n[s].delimiter){for(;s~~'.concat(t,'~~');let r=n.pop();t="".concat(r.output).concat(t),e=!0}else s--;e||(n.push({delimiter:"~",delimString:"~~",count:2,output:t}),t=""),r+=a[0].length,i=i.substr(a[0].length)}else{if(a=this.mergedInlineGrammar.default.regexp.exec(i),!a)throw"Infinite loop!";i=i.substr(a[0].length),r+=a[0].length,t+=this.mergedInlineGrammar.default.replacement.replace(/\$([1-9])/g,((e,t)=>bs(a[t])))}}for(;n.length;){const e=n.pop();t="".concat(e.output).concat(e.delimString.substr(0,e.count)).concat(t)}return t}computeColumn(e,t){let n,r=e;for(;r&&r.parentNode!==this.e;)r=r.parentNode;if(null===r)return null;for(e.nodeType===Node.TEXT_NODE||0===t?(n=t,r=e):t>0?(r=e.childNodes[t-1],n=r.textContent.length):(n=0,r=e);r.parentNode!==this.e;)r.previousSibling?(r=r.previousSibling,n+=r.textContent.length):r=r.parentNode;return n}computeNodeAndOffset(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e>=this.lineElements.length&&(e=this.lineElements.length-1,t=this.lines[e].length),t>this.lines[e].length&&(t=this.lines[e].length);const r=this.lineElements[e];let i=r.firstChild,s=!1,o={node:r.firstChild?r.firstChild:r,offset:0};for(;i!==r;){if(!s&&i.nodeType===Node.TEXT_NODE)if(i.nodeValue.length>=t){if(!n||i.nodeValue.length!==t)return{node:i,offset:t};o={node:i,offset:t},t=0}else t-=i.nodeValue.length;!s&&i.firstChild?i=i.firstChild:i.nextSibling?(s=!1,i=i.nextSibling):(s=!0,i=i.parentNode)}return o}updateLineContentsAndFormatting(){this.clearDirtyFlag(),this.updateLineContents(),this.updateFormatting()}clearDirtyFlag(){this.lineDirty=new Array(this.lines.length);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(r)for(let n=0;n1?r-1:0),s=1;sn?t.insertBefore(e,n):t.appendChild(e)))};e.forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE||"DIV"!==e.tagName){const n=document.createElement("div");t(e,n),n.appendChild(e)}else if(0===e.childNodes.length)e.appendChild(document.createElement("br"));else{const n=Array.from(e.childNodes);if(n.some((e=>e.nodeType===Node.ELEMENT_NODE&&"DIV"===e.tagName)))return t(e,...n)}}))}parseLinkOrImage(e,t){let n=t?2:1,r=e.substr(0,n),i=t?"TMImage":"TMLink",s=n,o=1,a=!1,u=!1,l=[],c=[];e:for(;s0;){let n=e.substr(s),r=/^\s+/.exec(n);if(r){switch(c.length){case 0:case 1:c.push(r[0]);break;case 2:if(c[0].match(//))if(r=/^["']/.exec(n),!r||0!==c.length&&1!==c.length&&4!==c.length)if(!r||5!==c.length&&6!==c.length||c[4]!==r[0])if(n.match(/^\(/)){switch(c.length){case 0:c.push("");case 1:c.push("");case 2:c[1]=c[1].concat("("),c[0].match(/<$/)||t++;break;case 3:c.push("");case 4:c.push("(");break;case 5:c.push("");case 6:if("("===c[4])return!1;c[5]=c[5].concat("(");break;default:return!1}s++}else if(n.match(/^\)/)){if(c.length<=2){for(;c.length<2;)c.push("");c[0].match(/<$/)||t--,t>0&&(c[1]=c[1].concat(")"))}else 5===c.length||6===c.length?"("===c[4]?(5===c.length&&c.push(""),c.push(")")):5===c.length?c.push(")"):c[5]=c[5].concat(")"):t--;if(0===t)for(;c.length<7;)c.push("");s++}else{if(r=/^./.exec(n),!r)throw"Infinite loop";switch(c.length){case 0:c.push("");case 1:c.push(r[0]);break;case 2:c[1]=c[1].concat(r[0]);break;case 3:case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(r[0]);break;default:return!1}s+=r[0].length}else 5===c.length&&c.push(""),c.push(r[0]),s++;else{for(;c.length<4;)c.push("");c.push(r[0]),s++}else 1===c.length&&c.push(""),c.push(">"),s++}if(t>0)return!1}if(!1!==u){let e=!1;for(let t of this.linkLabels)if(t===u){e=!0;break}let t=e?"TMLinkLabel TMLinkLabel_Valid":"TMLinkLabel TMLinkLabel_Invalid",n='').concat(r,'').concat(this.processInlineStyles(a),']');return l.length>=3&&(n=n.concat('').concat(l[0],""),'').concat(l[1],""),'').concat(l[2],""))),{output:n,charCount:s}}if(c.length>0){for(;c.length<7;)c.push("");return{output:'').concat(r,'').concat(this.processInlineStyles(a),'](').concat(c[0],'').concat(bs(c[1]),'').concat(c[2]).concat(c[3]).concat(c[4],'').concat(bs(c[5]),'').concat(c[6],")"),charCount:s}}return!1}computeCommonAncestor(e,t){if(!e||!t)return null;if(e===t)return e;const n=e=>{let t=[];for(;e;)t.unshift(e),e=e.parentNode;return t},r=n(e),i=n(t);if(r[0]!==i[0])return null;let s;for(s=0;r[s]===i[s];s++);return r[s-1]}computeEnclosingMarkupNode(e,t,n){let r=null;if(!e)return null;if(t){if(e.row!==t.row)return null;const n=window.getSelection();if(!n)return null;r=this.computeCommonAncestor(n.focusNode,n.anchorNode)}else{const e=window.getSelection();if(!e||!e.focusNode)return null;r=e.focusNode}if(!r)return null;for(;r!==this.e;){if(r.classList&&r.classList.contains(n))return r;r=r.parentNode}return null}getCommandState(){let e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i={};if(n||(n=this.getSelection(!1)),r||(r=this.getSelection(!0)),!n){for(let e in Fs)i[e]=null;return i}r||(r=n),r.rowe.row&&0===t.col&&(t.row--,t.col=this.lines[t.row].length);for(let s in Fs)if("inline"===Fs[s].type&&(n&&n.row===r.row&&this.isInlineFormattingAllowed()?i[s]=!!this.computeEnclosingMarkupNode(n,r,Fs[s].className)||n.col===r.col&&!!this.lines[n.row].substr(0,n.col).match(Fs[s].unset.prePattern)&&!!this.lines[n.row].substr(n.col).match(Fs[s].unset.postPattern):i[s]=null),"line"===Fs[s].type)if(n){let n=this.lineTypes[e.row]===Fs[s].className;for(let r=e.row;r<=t.row;r++)if(this.lineTypes[r]===Fs[s].className!==n){n=null;break}i[s]=n}else i[s]=null;return i}setCommandState(e,t){if(this.isRestoringHistory||this.pushHistory(),"inline"===Fs[e].type){let t=this.getSelection(!0),n=this.getSelection(!1);if(t||(t=n),!t)return;if(t.row!==n.row)return;if(!this.isInlineFormattingAllowed())return;let r=this.computeEnclosingMarkupNode(n,t,Fs[e].className);if(this.clearDirtyFlag(),r){this.lineDirty[n.row]=!0;const i=this.computeColumn(r,0),s=r.textContent.length,o=this.lines[n.row].substr(0,i).replace(Fs[e].unset.prePattern,""),a=this.lines[n.row].substr(i,s),u=this.lines[n.row].substr(i+s).replace(Fs[e].unset.postPattern,"");this.lines[n.row]=o.concat(a,u),t.col=o.length,n.col=t.col+s,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else if(n.col===t.col&&this.lines[n.row].substr(0,n.col).match(Fs[e].unset.prePattern)&&this.lines[n.row].substr(n.col).match(Fs[e].unset.postPattern)){this.lineDirty[n.row]=!0;const r=this.lines[n.row].substr(0,n.col).replace(Fs[e].unset.prePattern,""),i=this.lines[n.row].substr(n.col).replace(Fs[e].unset.postPattern,"");this.lines[n.row]=r.concat(i),n.col=t.col=r.length,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else{let{startCol:r,endCol:i}=n.colr.row?r:n,s=n.row>r.row?n:r;s.row>i.row&&0===s.col&&s.row--;for(let n=i.row;n<=s.row;n++)t&&this.lineTypes[n]!==Fs[e].className&&(this.lines[n]=this.lines[n].replace(Fs[e].set.pattern,Fs[e].set.replacement.replace("$#",(n-i.row+1).toString())),this.lineDirty[n]=!0),t||this.lineTypes[n]!==Fs[e].className||(this.lines[n]=this.lines[n].replace(Fs[e].unset.pattern,Fs[e].unset.replacement),this.lineDirty[n]=!0);this.updateFormatting(),this.setSelection({row:s.row,col:this.lines[s.row].length},{row:i.row,col:0}),this.fireChange()}}isInlineFormattingAllowed(){const e=window.getSelection();if(!e||!e.focusNode||!e.anchorNode)return!1;if(e.isCollapsed&&3===e.focusNode.nodeType&&e.focusOffset===e.focusNode.nodeValue.length){let t;for(t=e.focusNode;t&&null===t.nextSibling;t=t.parentNode);if(t&&t.nextSibling&&t.nextSibling.classList&&t.nextSibling.classList.contains("TMInlineFormatted"))return!0}let t=this.computeCommonAncestor(e.focusNode,e.anchorNode);if(!t)return!1;for(;t&&t!==this.e;){if(t.classList&&(t.classList.contains("TMInlineFormatted")||t.classList.contains("TMBlankLine")))return!0;t=t.parentNode}return!1}toggleCommandState(e){this.lastCommandState||(this.lastCommandState=this.getCommandState()),this.setCommandState(e,!this.lastCommandState[e])}fireDrop(e){for(let t of this.listeners.drop)t({dataTransfer:e})}fireSelection(){let e=this.getSelection(!1),t=this.getSelection(!0);if(this.lastSelection={focus:e,anchor:t},this.listeners.selection&&this.listeners.selection.length){let n=this.getCommandState(e,t);this.lastCommandState?Object.assign(this.lastCommandState,n):this.lastCommandState=Object.assign({},n);for(let n of this.listeners.selection)n({focus:e,anchor:t,commandState:this.lastCommandState})}}}}));