tiny-markdown-editor 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !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,s,r,i,l,a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u={};function o(){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 a&&a)||e("object"==typeof t&&t)||function(){return this}()||Function("return this")()}function c(){return r?s:(r=1,s=function(e){try{return!!e()}catch(e){return!0}})}function h(){if(l)return i;l=1;var e=c();return i=!e((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}var p,f,d,g,m,M,T,F,D,y,C,E,k,$,b,A,w={exports:{}};function v(){if(f)return p;f=1;var e=c();return p=!e((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))}function S(){if(g)return d;g=1;var e=v(),t=Function.prototype,n=t.call,s=e&&t.bind.bind(n,n);return d=e?s:function(e){return function(){return n.apply(e,arguments)}},d}function x(){if(M)return m;M=1;var e="object"==typeof document&&document.all;return m=void 0===e&&void 0!==e?function(t){return"function"==typeof t||t===e}:function(e){return"function"==typeof e}}function L(){return F?T:(F=1,T=function(e){return null==e})}function B(){if(y)return D;y=1;var e=L(),t=TypeError;return D=function(n){if(e(n))throw new t("Can't call method on "+n);return n}}function N(){if(E)return C;E=1;var e=B(),t=Object;return C=function(n){return t(e(n))}}function H(){if($)return k;$=1;var e=S(),t=N(),n=e({}.hasOwnProperty);return k=Object.hasOwn||function(e,s){return n(t(e),s)}}var I,O,_,P,R,j,G,z,U,Z,q,V={exports:{}};function K(){if(P)return _;P=1;var e=o(),t=Object.defineProperty;return _=function(n,s){try{t(e,n,{value:s,configurable:!0,writable:!0})}catch(t){e[n]=s}return s}}function X(){if(R)return V.exports;R=1;var e=O?I:(O=1,I=!1),t=o(),n=K(),s="__core-js_shared__",r=V.exports=t[s]||n(s,{});return(r.versions||(r.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"}),V.exports}function W(){if(G)return j;G=1;var e=S(),t=x(),n=X(),s=e(Function.toString);return t(n.inspectSource)||(n.inspectSource=function(e){return s(e)}),j=n.inspectSource}function Y(){if(q)return Z;q=1;var e=x();return Z=function(t){return"object"==typeof t?null!==t:e(t)}}var J,Q,ee,te,ne,se,re,ie,le,ae,ue,oe,ce,he,pe,fe,de,ge,me,Me,Te,Fe,De,ye,Ce,Ee,ke,$e,be,Ae,we,ve,Se,xe,Le,Be,Ne,He,Ie,Oe,_e,Pe,Re,je,Ge,ze,Ue,Ze,qe,Ve,Ke,Xe,We,Ye,Je,Qe,et,tt,nt,st={};function rt(){if(te)return ee;te=1;var e=h(),t=c(),n=function(){if(Q)return J;Q=1;var e=o(),t=Y(),n=e.document,s=t(n)&&t(n.createElement);return J=function(e){return s?n.createElement(e):{}}}();return ee=!e&&!t((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))}function it(){if(ie)return re;ie=1;var e=Y(),t=String,n=TypeError;return re=function(s){if(e(s))return s;throw new n(t(s)+" is not an object")}}function lt(){if(ae)return le;ae=1;var e=v(),t=Function.prototype.call;return le=e?t.bind(t):function(){return t.apply(t,arguments)},le}function at(){if(oe)return ue;oe=1;var e=o(),t=x();return ue=function(n,s){return arguments.length<2?(r=e[n],t(r)?r:void 0):e[n]&&e[n][s];var r},ue}function ut(){if(ge)return de;ge=1;var e,t,n=o(),s=function(){if(fe)return pe;fe=1;var e=o().navigator,t=e&&e.userAgent;return pe=t?String(t):""}(),r=n.process,i=n.Deno,l=r&&r.versions||i&&i.version,a=l&&l.v8;return a&&(t=(e=a.split("."))[0]>0&&e[0]<4?1:+(e[0]+e[1])),!t&&s&&(!(e=s.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=s.match(/Chrome\/(\d+)/))&&(t=+e[1]),de=t}function ot(){if(Me)return me;Me=1;var e=ut(),t=c(),n=o().String;return me=!!Object.getOwnPropertySymbols&&!t((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&e&&e<41}))}function ct(){if(Fe)return Te;Fe=1;var e=ot();return Te=e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function ht(){if(ye)return De;ye=1;var e=at(),t=x(),n=function(){if(he)return ce;he=1;var e=S();return ce=e({}.isPrototypeOf)}(),s=ct(),r=Object;return De=s?function(e){return"symbol"==typeof e}:function(s){var i=e("Symbol");return t(i)&&n(i.prototype,r(s))}}function pt(){if(Ee)return Ce;Ee=1;var e=String;return Ce=function(t){try{return e(t)}catch(e){return"Object"}}}function ft(){if($e)return ke;$e=1;var e=x(),t=pt(),n=TypeError;return ke=function(s){if(e(s))return s;throw new n(t(s)+" is not a function")}}function dt(){if(Ae)return be;Ae=1;var e=ft(),t=L();return be=function(n,s){var r=n[s];return t(r)?void 0:e(r)}}function gt(){if(ve)return we;ve=1;var e=lt(),t=x(),n=Y(),s=TypeError;return we=function(r,i){var l,a;if("string"===i&&t(l=r.toString)&&!n(a=e(l,r)))return a;if(t(l=r.valueOf)&&!n(a=e(l,r)))return a;if("string"!==i&&t(l=r.toString)&&!n(a=e(l,r)))return a;throw new s("Can't convert object to primitive value")}}function mt(){if(xe)return Se;xe=1;var e=X();return Se=function(t,n){return e[t]||(e[t]=n||{})}}function Mt(){if(Be)return Le;Be=1;var e=S(),t=0,n=Math.random(),s=e(1..toString);return Le=function(e){return"Symbol("+(void 0===e?"":e)+")_"+s(++t+n,36)}}function Tt(){if(He)return Ne;He=1;var e=o(),t=mt(),n=H(),s=Mt(),r=ot(),i=ct(),l=e.Symbol,a=t("wks"),u=i?l.for||l:l&&l.withoutSetter||s;return Ne=function(e){return n(a,e)||(a[e]=r&&n(l,e)?l[e]:u("Symbol."+e)),a[e]}}function Ft(){if(Oe)return Ie;Oe=1;var e=lt(),t=Y(),n=ht(),s=dt(),r=gt(),i=Tt(),l=TypeError,a=i("toPrimitive");return Ie=function(i,u){if(!t(i)||n(i))return i;var o,c=s(i,a);if(c){if(void 0===u&&(u="default"),o=e(c,i,u),!t(o)||n(o))return o;throw new l("Can't convert object to primitive value")}return void 0===u&&(u="number"),r(i,u)}}function Dt(){if(Pe)return _e;Pe=1;var e=Ft(),t=ht();return _e=function(n){var s=e(n,"string");return t(s)?s:s+""}}function yt(){if(Re)return st;Re=1;var e=h(),t=rt(),n=function(){if(se)return ne;se=1;var e=h(),t=c();return ne=e&&t((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}(),s=it(),r=Dt(),i=TypeError,l=Object.defineProperty,a=Object.getOwnPropertyDescriptor,u="enumerable",o="configurable",p="writable";return st.f=e?n?function(e,t,n){if(s(e),t=r(t),s(n),"function"==typeof e&&"prototype"===t&&"value"in n&&p in n&&!n[p]){var i=a(e,t);i&&i[p]&&(e[t]=n.value,n={configurable:o in n?n[o]:i[o],enumerable:u in n?n[u]:i[u],writable:!1})}return l(e,t,n)}:l:function(e,n,a){if(s(e),n=r(n),s(a),t)try{return l(e,n,a)}catch(e){}if("get"in a||"set"in a)throw new i("Accessors not supported");return"value"in a&&(e[n]=a.value),e},st}function Ct(){return Ge?je:(Ge=1,je=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}})}function Et(){if(Ue)return ze;Ue=1;var e=h(),t=yt(),n=Ct();return ze=e?function(e,s,r){return t.f(e,s,n(1,r))}:function(e,t,n){return e[t]=n,e}}function kt(){if(qe)return Ze;qe=1;var e=mt(),t=Mt(),n=e("keys");return Ze=function(e){return n[e]||(n[e]=t(e))}}function $t(){return Ke?Ve:(Ke=1,Ve={})}function bt(){if(We)return Xe;We=1;var e,t,n,s=function(){if(U)return z;U=1;var e=o(),t=x(),n=e.WeakMap;return z=t(n)&&/native code/.test(String(n))}(),r=o(),i=Y(),l=Et(),a=H(),u=X(),c=kt(),h=$t(),p="Object already initialized",f=r.TypeError,d=r.WeakMap;if(s||u.state){var g=u.state||(u.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(a(e,m))throw new f(p);return t.facade=e,l(e,m,t),t},t=function(e){return a(e,m)?e[m]:{}},n=function(e){return a(e,m)}}return Xe={set:e,get:t,has:n,enforce:function(s){return n(s)?t(s):e(s,{})},getterFor:function(e){return function(n){var s;if(!i(n)||(s=t(n)).type!==e)throw new f("Incompatible receiver, "+e+" required");return s}}}}function At(){if(Ye)return w.exports;Ye=1;var e=S(),t=c(),n=x(),s=H(),r=h(),i=function(){if(A)return b;A=1;var e=h(),t=H(),n=Function.prototype,s=e&&Object.getOwnPropertyDescriptor,r=t(n,"name"),i=r&&"something"===function(){}.name,l=r&&(!e||e&&s(n,"name").configurable);return b={EXISTS:r,PROPER:i,CONFIGURABLE:l}}().CONFIGURABLE,l=W(),a=bt(),u=a.enforce,o=a.get,p=String,f=Object.defineProperty,d=e("".slice),g=e("".replace),m=e([].join),M=r&&!t((function(){return 8!==f((function(){}),"length",{value:8}).length})),T=String(String).split("String"),F=w.exports=function(e,t,n){"Symbol("===d(p(t),0,7)&&(t="["+g(p(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!s(e,"name")||i&&e.name!==t)&&(r?f(e,"name",{value:t,configurable:!0}):e.name=t),M&&n&&s(n,"arity")&&e.length!==n.arity&&f(e,"length",{value:n.arity});try{n&&s(n,"constructor")&&n.constructor?r&&f(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var l=u(e);return s(l,"source")||(l.source=m(T,"string"==typeof t?t:"")),e};return Function.prototype.toString=F((function(){return n(this)&&o(this).source||l(this)}),"toString"),w.exports}function wt(){if(Qe)return Je;Qe=1;var e=At(),t=yt();return Je=function(n,s,r){return r.get&&e(r.get,s,{getter:!0}),r.set&&e(r.set,s,{setter:!0}),t.f(n,s,r)}}!function(){if(nt)return u;nt=1;var e=o(),t=h(),n=wt(),s=function(){if(tt)return et;tt=1;var e=it();return et=function(){var t=e(this),n="";return t.hasIndices&&(n+="d"),t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.dotAll&&(n+="s"),t.unicode&&(n+="u"),t.unicodeSets&&(n+="v"),t.sticky&&(n+="y"),n}}(),r=c(),i=e.RegExp,l=i.prototype;t&&r((function(){var e=!0;try{i(".","d")}catch(t){e=!1}var t={},n="",s=e?"dgimsy":"gimsy",r=function(e,s){Object.defineProperty(t,e,{get:function(){return n+=s,!0}})},a={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var u in e&&(a.hasIndices="d"),a)r(u,a[u]);return Object.getOwnPropertyDescriptor(l,"flags").get.call(t)!==s||n!==s}))&&n(l,"flags",{configurable:!0,get:s})}();const vt={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:/<HTMLTagName(?:HTMLAttribute)*\s*\/?>/,HTMLCloseTag:/<\/HTMLTagName\s*>/,HTMLTagName:/[A-Za-z][A-Za-z0-9-]*/,HTMLComment:/<!--(?:[^>-]|(?:[^>-](?:[^-]|-[^-])*[^-]))-->/,HTMLPI:/<\?(?:|.|(?:[^?]|\?[^>])*)\?>/,HTMLDeclaration:/<![A-Z]+\s[^>]*>/,HTMLCDATA:/<!\[CDATA\[.*?\]\]>/,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/},St=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])/),xt=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])$/),Lt={TMH1:{regexp:/^( {0,3}#\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH1">$1</span>$$2<span class="TMMark TMMark_TMH1">$3</span>'},TMH2:{regexp:/^( {0,3}##\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH2">$1</span>$$2<span class="TMMark TMMark_TMH2">$3</span>'},TMH3:{regexp:/^( {0,3}###\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH3">$1</span>$$2<span class="TMMark TMMark_TMH3">$3</span>'},TMH4:{regexp:/^( {0,3}####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH4">$1</span>$$2<span class="TMMark TMMark_TMH4">$3</span>'},TMH5:{regexp:/^( {0,3}#####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH5">$1</span>$$2<span class="TMMark TMMark_TMH5">$3</span>'},TMH6:{regexp:/^( {0,3}######\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH6">$1</span>$$2<span class="TMMark TMMark_TMH6">$3</span>'},TMBlockquote:{regexp:/^( {0,3}>[ ]?)(.*)$/,replacement:'<span class="TMMark TMMark_TMBlockquote">$1</span>$$2'},TMCodeFenceBacktickOpen:{regexp:/^( {0,3}(?<seq>````*)\s*)([^`]*?)(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span><span class="TMInfoString">$3</span>$4'},TMCodeFenceTildeOpen:{regexp:/^( {0,3}(?<seq>~~~~*)\s*)(.*?)(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceTilde">$1</span><span class="TMInfoString">$3</span>$4'},TMCodeFenceBacktickClose:{regexp:/^( {0,3}(?<seq>````*))(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span>$3'},TMCodeFenceTildeClose:{regexp:/^( {0,3}(?<seq>~~~~*))(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceTilde">$1</span>$3'},TMBlankLine:{regexp:/^([ \t]*)$/,replacement:"$0"},TMSetextH1Marker:{regexp:/^ {0,3}=+\s*$/,replacement:'<span class="TMMark TMMark_TMSetextH1Marker">$0</span>'},TMSetextH2Marker:{regexp:/^ {0,3}-+\s*$/,replacement:'<span class="TMMark TMMark_TMSetextH1Marker">$0</span>'},TMHR:{regexp:/^( {0,3}(\*[ \t]*\*[ \t]*\*[ \t*]*)|(-[ \t]*-[ \t]*-[ \t-]*)|(_[ \t]*_[ \t]*_[ \t_]*))$/,replacement:'<span class="TMMark TMMark_TMHR">$0</span>'},TMUL:{regexp:/^( {0,3}[+*-] {1,4})(.*)$/,replacement:'<span class="TMMark TMMark_TMUL">$1</span>$$2'},TMOL:{regexp:/^( {0,3}\d{1,9}[.)] {1,4})(.*)$/,replacement:'<span class="TMMark TMMark_TMOL">$1</span>$$2'},TMIndentedCode:{regexp:/^( {4}|\t)(.*)$/,replacement:'<span class="TMMark TMMark_TMIndentedCode">$1</span>$2'},TMLinkReferenceDefinition:{regexp:/^( {0,3}\[\s*)([^\s\]](?:[^\]]|\\\])*?)(\s*\]:\s*)((?:[^\s<>]+)|(?:<(?:[^<>\\]|\\.)*>))?(\s*)((?:\((?:[^()\\]|\\.)*\))|(?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.)*'))?(\s*)$/,replacement:'<span class="TMMark TMMark_TMLinkReferenceDefinition">$1</span><span class="TMLinkLabel TMLinkLabel_Definition">$2</span><span class="TMMark TMMark_TMLinkReferenceDefinition">$3</span><span class="TMLinkDestination">$4</span>$5<span class="TMLinkTitle">$6</span>$7',labelPlaceholder:2}},Bt=[{start:/^ {0,3}<(?:script|pre|style)(?:\s|>|$)/i,end:/(?:<\/script>|<\/pre>|<\/style>)/i,paraInterrupt:!0},{start:/^ {0,3}<!--/,end:/-->/,paraInterrupt:!0},{start:/^ {0,3}<\?/,end:/\?>/,paraInterrupt:!0},{start:/^ {0,3}<![A-Z]/,end:/>/,paraInterrupt:!0},{start:/^ {0,3}<!\[CDATA\[/,end:/\]\]>/,paraInterrupt:!0},{start:/^ {0,3}(?:<|<\/)(?:KnownTag)(?:\s|>|\/>|$)/i,end:!1,paraInterrupt:!0},{start:/^ {0,3}(?:HTMLOpenTag|HTMLCloseTag)\s*$/,end:!1,paraInterrupt:!1}],Nt={escape:{regexp:/^\\(ASCIIPunctuation)/,replacement:'<span class="TMMark TMMark_TMEscape">\\</span>$1'},code:{regexp:/^(`+)((?:[^`])|(?:[^`].*?[^`]))(\1)/,replacement:'<span class="TMMark TMMark_TMCode">$1</span><code class="TMCode">$2</code><span class="TMMark TMMark_TMCode">$3</span>'},autolink:{regexp:/^<((?:Scheme:[^\s<>]*)|(?:Email))>/,replacement:'<span class="TMMark TMMark_TMAutolink">&lt;</span><span class="TMAutolink">$1</span><span class="TMMark TMMark_TMAutolink">&gt;</span>'},html:{regexp:/^((?:HTMLOpenTag)|(?:HTMLCloseTag)|(?:HTMLComment)|(?:HTMLPI)|(?:HTMLDeclaration)|(?:HTMLCDATA))/,replacement:'<span class="TMHTML">$1</span>'},linkOpen:{regexp:/^\[/,replacement:""},imageOpen:{regexp:/^!\[/,replacement:""},linkLabel:{regexp:/^(\[\s*)([^\]]*?)(\s*\])/,replacement:"",labelPlaceholder:2},default:{regexp:/^(.|(?:NotTriggerChar+))/,replacement:"$1"}},Ht=new RegExp(Object.keys(vt).join("|")),It=[...Object.keys(Nt)];for(let e of It){let t=Nt[e].regexp.source;for(;t.match(Ht);)t=t.replace(Ht,(e=>vt[e].source));Nt[e].regexp=new RegExp(t,Nt[e].regexp.flags)}for(let e of Bt){let t=e.start.source;for(;t.match(Ht);)t=t.replace(Ht,(e=>vt[e].source));e.start=new RegExp(t,e.start.flags)}function Ot(e){return(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const _t={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.Editor=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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=Nt,this.hasFocus=!0,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.customInlineGrammar=e.customInlineGrammar||{},this.mergedInlineGrammar=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={...Nt};for(const[n,s]of Object.entries(e)){const e={...s};let r=s.regexp.source;const i=new RegExp(Object.keys(vt).join("|"));for(;r.match(i);)r=r.replace(i,(e=>vt[e].source));e.regexp=new RegExp(r,s.regexp.flags),t[n]=e}return t}(this.customInlineGrammar),this.listeners={change:[],selection:[],drop:[]};let t=null;"string"==typeof e.element?t=document.getElementById(e.element):e.element&&(t=e.element),"string"==typeof e.textarea?this.textarea=document.getElementById(e.textarea):e.textarea&&(this.textarea=e.textarea),this.textarea&&(t||(t=this.textarea)),t||(t=document.getElementsByTagName("body")[0]),t&&"TEXTAREA"===t.tagName&&(this.textarea=t,t=this.textarea.parentNode),this.textarea&&(this.textarea.style.display="none"),this.undoStack=[],this.redoStack=[],this.isRestoringHistory=!1,this.maxHistory=100,this.createEditorElement(t,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",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<this.lines.length;e++){let e=document.createElement("div");this.e.appendChild(e),this.lineDirty.push(!0)}this.lineTypes=new Array(this.lines.length),this.updateFormatting(),this.fireChange(),this.isRestoringHistory||this.pushHistory()}getContent(){return this.lines.join("\n")}updateFormatting(){this.updateLineTypes(),this.updateLinkLabels(),this.applyLineTypes()}updateLinkLabels(){this.linkLabels=[];for(let e=0;e<this.lines.length;e++)"TMLinkReferenceDefinition"===this.lineTypes[e]&&this.linkLabels.push(this.lineCaptures[e][Lt.TMLinkReferenceDefinition.labelPlaceholder])}replace(e,t){return e.replace(/(\${1,2})([0-9])/g,((e,n,s)=>"$"===n?Ot(t[parseInt(s)]):`<span class="TMInlineFormatted">${this.processInlineStyles(t[parseInt(s)])}</span>`))}applyLineTypes(){for(let e=0;e<this.lines.length;e++){if(this.lineDirty[e]){let t=this.replace(this.lineReplacements[e],this.lineCaptures[e]);this.lineElements[e].className=this.lineTypes[e],this.lineElements[e].removeAttribute("style"),this.lineElements[e].innerHTML=""===t?"<br />":t}this.lineElements[e].dataset.lineNum=e.toString()}}updateLineTypes(){let e=!1,t=0,n=!1;for(let s=0;s<this.lines.length;s++){let r="TMPara",i=[this.lines[s]],l="$$0";if("TMCodeFenceBacktickOpen"===e){let n=Lt.TMCodeFenceBacktickClose.regexp.exec(this.lines[s]);n&&n.groups.seq.length>=t?(r="TMCodeFenceBacktickClose",l=Lt.TMCodeFenceBacktickClose.replacement,i=n,e=!1):(r="TMFencedCodeBacktick",l='<span class="TMFencedCode">$0<br /></span>',i=[this.lines[s]])}else if("TMCodeFenceTildeOpen"===e){let n=Lt.TMCodeFenceTildeClose.regexp.exec(this.lines[s]);n&&n.groups.seq.length>=t?(r="TMCodeFenceTildeClose",l=Lt.TMCodeFenceTildeClose.replacement,i=n,e=!1):(r="TMFencedCodeTilde",l='<span class="TMFencedCode">$0<br /></span>',i=[this.lines[s]])}if("TMPara"===r&&!1===n)for(let e of Bt)if(this.lines[s].match(e.start)&&(e.paraInterrupt||0===s||"TMPara"!==this.lineTypes[s-1]&&"TMUL"!==this.lineTypes[s-1]&&"TMOL"!==this.lineTypes[s-1]&&"TMBlockquote"!==this.lineTypes[s-1])){n=e;break}if(!1!==n&&(r="TMHTMLBlock",l='<span class="TMHTMLContent">$0<br /></span>',i=[this.lines[s]],n.end?this.lines[s].match(n.end)&&(n=!1):(s===this.lines.length-1||this.lines[s+1].match(Lt.TMBlankLine.regexp))&&(n=!1)),"TMPara"===r)for(let e in Lt)if(Lt[e].regexp){let t=Lt[e].regexp.exec(this.lines[s]);if(t){r=e,l=Lt[e].replacement,i=t;break}}if("TMCodeFenceBacktickOpen"!==r&&"TMCodeFenceTildeOpen"!==r||(e=r,t=i.groups.seq.length),"TMIndentedCode"!==r&&"TMLinkReferenceDefinition"!==r||!(s>0)||"TMPara"!==this.lineTypes[s-1]&&"TMUL"!==this.lineTypes[s-1]&&"TMOL"!==this.lineTypes[s-1]&&"TMBlockquote"!==this.lineTypes[s-1]||(r="TMPara",i=[this.lines[s]],l="$$0"),"TMSetextH2Marker"===r){let e=Lt.TMUL.regexp.exec(this.lines[s]);e&&(r="TMUL",l=Lt.TMUL.replacement,i=e)}if("TMSetextH1Marker"===r||"TMSetextH2Marker"===r)if(0===s||"TMPara"!==this.lineTypes[s-1]){let e=Lt.TMHR.regexp.exec(this.lines[s]);e?(r="TMHR",i=e,l=Lt.TMHR.replacement):(r="TMPara",i=[this.lines[s]],l="$$0")}else{let e=s-1;const t="TMSetextH1Marker"===r?"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[s]!==r&&(this.lineTypes[s]=r,this.lineDirty[s]=!0),this.lineReplacements[s]=l,this.lineCaptures[s]=i}}getSelection(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var t,n;const s=window.getSelection();let r=e?s.anchorNode:s.focusNode;if(!r)return null;let i=e?s.anchorOffset:s.focusOffset;if(r===this.e)return i<this.lines.length?{row:i,col:0}:{row:i-1,col:this.lines[i-1].length};let l=this.computeColumn(r,i);if(null===l)return null;let a=r;for(;a.parentElement!==this.e;)a=a.parentElement;let u=0;if(a.previousSibling){const e=null===(t=a.dataset)||void 0===t?void 0:t.lineNum,s=null===(n=a.previousSibling.dataset)||void 0===n?void 0:n.lineNum;if(e&&s){const t=parseInt(e);if(t===parseInt(s)+1)u=t;else for(;a.previousSibling;)u++,a=a.previousSibling}}return{row:u,col:l}}setSelection(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e)return;let{node:n,offset:s}=this.computeNodeAndOffset(e.row,e.col,!!t&&(t.row===e.row&&t.col>e.col)),r=null,i=null;if(t&&(t.row!==e.row||t.col!==e.col)){let{node:n,offset:s}=this.computeNodeAndOffset(t.row,t.col,e.row===t.row&&e.col>t.col);r=n,i=s}window.getSelection().setBaseAndExtent(n,s,r||n,r?i:s)}paste(e){let t,n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;s||(s=this.getSelection(!0)),r||(r=this.getSelection(!1)),r||(r={row:this.lines.length-1,col:this.lines[this.lines.length-1].length}),s||(s=r),s.row<r.row||s.row===r.row&&s.col<=r.col?(t=s,n=r):(t=r,n=s);let i=e.split(/(?:\r\n|\r|\n)/),l=this.lines[t.row].substr(0,t.col),a=this.lines[n.row].substr(n.col);i[0]=l.concat(i[0]);let u=i[i.length-1].length;i[i.length-1]=i[i.length-1].concat(a),this.spliceLines(t.row,1+n.row-t.row,i),r.row=t.row+i.length-1,r.col=u,this.updateFormatting(),this.setSelection(r),this.fireChange()}wrapSelection(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(this.isRestoringHistory||this.pushHistory(),n||(n=this.getSelection(!1)),s||(s=this.getSelection(!0)),!n||!s||n.row!==s.row)return;this.lineDirty[n.row]=!0;const r=n.col<s.col?n.col:s.col,i=n.col<s.col?s.col:n.col,l=this.lines[n.row].substr(0,r).concat(e),a=i===r?"":this.lines[n.row].substr(r,i-r),u=t.concat(this.lines[n.row].substr(i));this.lines[n.row]=l.concat(a,u),s.col=l.length,n.col=s.col+a.length,this.updateFormatting(),this.setSelection(n,s)}addEventListener(e,t){e.match(/^(?:change|input)$/i)&&this.listeners.change.push(t),e.match(/^(?:selection|selectionchange)$/i)&&this.listeners.selection.push(t),e.match(/^(?:drop)$/i)&&this.listeners.drop.push(t)}fireChange(){if(!this.textarea&&!this.listeners.change.length)return;const e=this.getContent();this.textarea&&(this.textarea.value=e);for(let t of this.listeners.change)t({content:e,linesDirty:[...this.lineDirty]})}handleBeforeInputEvent(e){const t=e;if("insertParagraph"!==t.inputType&&"insertLineBreak"!==t.inputType)return;this.isRestoringHistory||this.pushHistory(),e.preventDefault(),this.clearDirtyFlag();const n=this.getSelection(),s=this.getSelection(!0);if(n&&s){if(n.row!==s.row){const e=n.row<s.row?n:s,t=n.row<s.row?s:n;this.lines[e.row]=this.lines[e.row].substring(0,e.col),this.lines[t.row]=this.lines[t.row].substring(t.col),this.spliceLines(e.row+1,t.row-e.row-1),n.row=e.row+1,n.col=0}else{let e=!1;switch(this.lineTypes[n.row]){case"TMUL":e="TMUL";break;case"TMOL":e="TMOL";break;case"TMIndentedCode":e="TMIndentedCode"}const t=this.lines[n.row].substring(0,n.col<=s.col?n.col:s.col),r=this.lines[n.row].substring(n.col<=s.col?s.col:n.col);if(this.spliceLines(n.row,1,[t,r]),n.row+=1,n.col=0,e){let t=Lt[e].regexp.exec(this.lines[n.row-1]);t&&(t[2]?("TMOL"===e&&(t[1]=t[1].replace(/\d{1,9}/,(e=>(parseInt(e)+1).toString()))),this.lines[n.row]=`${t[1]}${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.lineElements.length&&this.lineElements[n.row].scrollIntoView({block:"nearest",inline:"nearest"}),this.fireChange()}}handleInputEvent(e){const t=e;if("insertCompositionText"===t.inputType)return;this.isRestoringHistory||this.pushHistory();let n=this.getSelection();("insertParagraph"!==t.inputType&&"insertLineBreak"!==t.inputType||!n)&&(this.e.firstChild?this.fixNodeHierarchy():this.e.innerHTML='<div class="TMBlankLine"><br></div>',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=[],s=0,r=e;e:for(;r;){for(let e of["escape","code","autolink","html"])if(this.mergedInlineGrammar[e]){let n=this.mergedInlineGrammar[e].regexp.exec(r);if(n){r=r.substr(n[0].length),s+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(/\$([1-9])/g,((e,t)=>Ot(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(r);if(n){r=r.substr(n[0].length),s+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(/\$([1-9])/g,((e,t)=>Ot(n[t])));continue e}}let i=r.match(this.mergedInlineGrammar.linkOpen.regexp),l=r.match(this.mergedInlineGrammar.imageOpen.regexp);if(l||i){let e=this.parseLinkOrImage(r,!!l);if(e){t=`${t}${e.output}`,r=r.substr(e.charCount),s+=e.charCount;continue e}}let a=/(^\*+)|(^_+)/.exec(r);if(a){let i=a[0].length;const l=a[0],u=a[0][0];r=r.substr(a[0].length);const o=s>0?e.substr(0,s):" ",c=s+a[0].length<e.length?r:" ",h=c.match(St),p=o.match(xt),f=c.match(/^\s/),d=o.match(/\s$/);let g=!(f||h&&!d&&!p),m=!(d||p&&!f&&!h);if("_"===u&&g&&m&&(g=!!p,m=!!h),m){let e=n.length-1;for(;i&&e>=0;)if(n[e].delimiter===u){for(;e<n.length-1;){const e=n.pop();t=`${e.output}${e.delimString.substr(0,e.count)}${t}`}if(i>=2&&n[e].count>=2?(t=`<span class="TMMark">${u}${u}</span><strong class="TMStrong">${t}</strong><span class="TMMark">${u}${u}</span>`,i-=2,n[e].count-=2):(t=`<span class="TMMark">${u}</span><em class="TMEm">${t}</em><span class="TMMark">${u}</span>`,i-=1,n[e].count-=1),0===n[e].count){t=`${n.pop().output}${t}`,e--}}else e--}i&&g&&(n.push({delimiter:u,delimString:l,count:i,output:t}),t="",i=0),i&&(t=`${t}${l.substr(0,i)}`),s+=a[0].length}else if(a=/^~~/.exec(r),a){let e=!1,i=n.length-1;for(;!e&&i>=0;)if("~"===n[i].delimiter){for(;i<n.length-1;){const e=n.pop();t=`${e.output}${e.delimString.substr(0,e.count)}${t}`}t=`<span class="TMMark">~~</span><del class="TMStrikethrough">${t}</del><span class="TMMark">~~</span>`,t=`${n.pop().output}${t}`,e=!0}else i--;e||(n.push({delimiter:"~",delimString:"~~",count:2,output:t}),t=""),s+=a[0].length,r=r.substr(a[0].length)}else{if(a=this.mergedInlineGrammar.default.regexp.exec(r),!a)throw"Infinite loop!";r=r.substr(a[0].length),s+=a[0].length,t+=this.mergedInlineGrammar.default.replacement.replace(/\$([1-9])/g,((e,t)=>Ot(a[t])))}}for(;n.length;){const e=n.pop();t=`${e.output}${e.delimString.substr(0,e.count)}${t}`}return t}computeColumn(e,t){let n,s=e;for(;s&&s.parentNode!==this.e;)s=s.parentNode;if(null===s)return null;for(e.nodeType===Node.TEXT_NODE||0===t?(n=t,s=e):t>0?(s=e.childNodes[t-1],n=s.textContent.length):(n=0,s=e);s.parentNode!==this.e;)s.previousSibling?(s=s.previousSibling,n+=s.textContent.length):s=s.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 s=this.lineElements[e];let r=s.firstChild,i=!1,l={node:s.firstChild?s.firstChild:s,offset:0};for(;r!==s;){if(!i&&r.nodeType===Node.TEXT_NODE)if(r.nodeValue.length>=t){if(!n||r.nodeValue.length!==t)return{node:r,offset:t};l={node:r,offset:t},t=0}else t-=r.nodeValue.length;!i&&r.firstChild?r=r.firstChild:r.nextSibling?(i=!1,r=r.nextSibling):(i=!0,r=r.parentNode)}return l}updateLineContentsAndFormatting(){this.clearDirtyFlag(),this.updateLineContents(),this.updateFormatting()}clearDirtyFlag(){this.lineDirty=new Array(this.lines.length);for(let e=0;e<this.lineDirty.length;e++)this.lineDirty[e]=!1}updateLineContents(){let e=this.e.childElementCount-this.lines.length;if(e){let t=0;for(;t<=this.lines.length&&t<=this.lineElements.length&&this.lineElements[t]&&this.lines[t]===this.lineElements[t].textContent&&this.lineTypes[t]===this.lineElements[t].className;)t++;let n=-1;for(;-n<this.lines.length&&-n<this.lineElements.length&&this.lines[this.lines.length+n]===this.lineElements[this.lineElements.length+n].textContent&&this.lineTypes[this.lines.length+n]===this.lineElements[this.lineElements.length+n].className;)n--;let s=this.lines.length+n+1-t;s<-e&&(s=-e),s<0&&(s=0);let r=[];for(let n=0;n<s+e;n++)r.push(this.lineElements[t+n].textContent||"");this.spliceLines(t,s,r,!1)}else for(let e=0;e<this.lineElements.length;e++){let t=this.lineElements[e],n=t.textContent||"";this.lines[e]===n&&this.lineTypes[e]===t.className||(this.lines[e]=n,this.lineTypes[e]=t.className,this.lineDirty[e]=!0)}}spliceLines(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(s)for(let n=0;n<t;n++)this.e.removeChild(this.e.childNodes[e]);let r=[],i=[];for(let t=0;t<n.length;t++)r.push(""),i.push(!0),s&&(this.e.childNodes[e]?this.e.insertBefore(document.createElement("div"),this.e.childNodes[e]):this.e.appendChild(document.createElement("div")));this.lines.splice(e,t,...n),this.lineTypes.splice(e,t,...r),this.lineDirty.splice(e,t,...i)}fixNodeHierarchy(){const e=Array.from(this.e.childNodes),t=function(e){const t=e.parentElement,n=e.nextSibling;t.removeChild(e);for(var s=arguments.length,r=new Array(s>1?s-1:0),i=1;i<s;i++)r[i-1]=arguments[i];r.forEach((e=>n?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,s=e.substr(0,n),r=t?"TMImage":"TMLink",i=n,l=1,a=!1,u=!1,o=[],c=[];e:for(;i<e.length&&!1===a;){let s=e.substr(i);for(let e of["escape","code","autolink","html"]){let t=this.mergedInlineGrammar[e].regexp.exec(s);if(t){i+=t[0].length;continue e}}if(s.match(this.mergedInlineGrammar.imageOpen.regexp))l++,i+=2;else if(s.match(this.mergedInlineGrammar.linkOpen.regexp)){if(l++,!t&&this.parseLinkOrImage(s,!1))return!1;i+=1}else s.match(/^\]/)&&(l--,0===l)?(a=e.substr(n,i-n),i++):i++}if(!1===a)return!1;let h=i<e.length?e.substr(i,1):"";if("["===h){let t=e.substr(i),n=this.mergedInlineGrammar.linkLabel.regexp.exec(t);if(!n)return!1;i+=n[0].length,o.push(n[1],n[2],n[3]),u=n[this.mergedInlineGrammar.linkLabel.labelPlaceholder]?n[this.mergedInlineGrammar.linkLabel.labelPlaceholder]:a.trim()}else if("("!==h)u=a.trim();else{i++;let t=1;for(;i<e.length&&t>0;){let n=e.substr(i),s=/^\s+/.exec(n);if(s){switch(c.length){case 0:case 1:c.push(s[0]);break;case 2:if(c[0].match(/</))c[1]=c[1].concat(s[0]);else{if(1!==t)return!1;c.push(""),c.push(s[0])}break;case 3:c.push(s[0]);break;case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(s[0]);break;case 7:c[6]=c[6].concat(s[0]);break;default:return!1}i+=s[0].length}else if(s=this.mergedInlineGrammar.escape.regexp.exec(n),s){switch(c.length){case 0:c.push("");case 1:c.push(s[0]);break;case 2:c[1]=c[1].concat(s[0]);break;case 3:case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(s[0]);break;default:return!1}i+=s[0].length}else if(c.length<2&&n.match(/^</))0===c.length&&c.push(""),c[0]=c[0].concat("<"),i++;else if(1!==c.length&&2!==c.length||!n.match(/^>/))if(s=/^["']/.exec(n),!s||0!==c.length&&1!==c.length&&4!==c.length)if(!s||5!==c.length&&6!==c.length||c[4]!==s[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}i++}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("");i++}else{if(s=/^./.exec(n),!s)throw"Infinite loop";switch(c.length){case 0:c.push("");case 1:c.push(s[0]);break;case 2:c[1]=c[1].concat(s[0]);break;case 3:case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(s[0]);break;default:return!1}i+=s[0].length}else 5===c.length&&c.push(""),c.push(s[0]),i++;else{for(;c.length<4;)c.push("");c.push(s[0]),i++}else 1===c.length&&c.push(""),c.push(">"),i++}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=`<span class="TMMark TMMark_${r}">${s}</span><span class="${r} ${o.length<3||!o[1]?t:""}">${this.processInlineStyles(a)}</span><span class="TMMark TMMark_${r}">]</span>`;return o.length>=3&&(n=n.concat(`<span class="TMMark TMMark_${r}">${o[0]}</span>`,`<span class="${t}">${o[1]}</span>`,`<span class="TMMark TMMark_${r}">${o[2]}</span>`)),{output:n,charCount:i}}if(c.length>0){for(;c.length<7;)c.push("");return{output:`<span class="TMMark TMMark_${r}">${s}</span><span class="${r}">${this.processInlineStyles(a)}</span><span class="TMMark TMMark_${r}">](${c[0]}</span><span class="${r}Destination">${c[1]}</span><span class="TMMark TMMark_${r}">${c[2]}${c[3]}${c[4]}</span><span class="${r}Title">${c[5]}</span><span class="TMMark TMMark_${r}">${c[6]})</span>`,charCount:i}}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},s=n(e),r=n(t);if(s[0]!==r[0])return null;let i;for(i=0;s[i]===r[i];i++);return s[i-1]}computeEnclosingMarkupNode(e,t,n){let s=null;if(!e)return null;if(t){if(e.row!==t.row)return null;const n=window.getSelection();if(!n)return null;s=this.computeCommonAncestor(n.focusNode,n.anchorNode)}else{const e=window.getSelection();if(!e||!e.focusNode)return null;s=e.focusNode}if(!s)return null;for(;s!==this.e;){if(s.className&&s.className.includes(n))return s;s=s.parentNode}return null}getCommandState(){let e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r={};if(n||(n=this.getSelection(!1)),s||(s=this.getSelection(!0)),!n){for(let e in _t)r[e]=null;return r}s||(s=n),s.row<n.row||s.row===n.row&&s.col<n.col?(e=s,t=n):(e=n,t=s),t.row>e.row&&0===t.col&&(t.row--,t.col=this.lines[t.row].length);for(let i in _t)if("inline"===_t[i].type&&(n&&n.row===s.row&&this.isInlineFormattingAllowed()?r[i]=!!this.computeEnclosingMarkupNode(n,s,_t[i].className)||n.col===s.col&&!!this.lines[n.row].substr(0,n.col).match(_t[i].unset.prePattern)&&!!this.lines[n.row].substr(n.col).match(_t[i].unset.postPattern):r[i]=null),"line"===_t[i].type)if(n){let n=this.lineTypes[e.row]===_t[i].className;for(let s=e.row;s<=t.row;s++)if(this.lineTypes[s]===_t[i].className!==n){n=null;break}r[i]=n}else r[i]=null;return r}setCommandState(e,t){if(this.isRestoringHistory||this.pushHistory(),"inline"===_t[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 s=this.computeEnclosingMarkupNode(n,t,_t[e].className);if(this.clearDirtyFlag(),s){this.lineDirty[n.row]=!0;const r=this.computeColumn(s,0),i=s.textContent.length,l=this.lines[n.row].substr(0,r).replace(_t[e].unset.prePattern,""),a=this.lines[n.row].substr(r,i),u=this.lines[n.row].substr(r+i).replace(_t[e].unset.postPattern,"");this.lines[n.row]=l.concat(a,u),t.col=l.length,n.col=t.col+i,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else if(n.col===t.col&&this.lines[n.row].substr(0,n.col).match(_t[e].unset.prePattern)&&this.lines[n.row].substr(n.col).match(_t[e].unset.postPattern)){this.lineDirty[n.row]=!0;const s=this.lines[n.row].substr(0,n.col).replace(_t[e].unset.prePattern,""),r=this.lines[n.row].substr(n.col).replace(_t[e].unset.postPattern,"");this.lines[n.row]=s.concat(r),n.col=t.col=s.length,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else{let{startCol:s,endCol:r}=n.col<t.col?{startCol:n.col,endCol:t.col}:{startCol:t.col,endCol:n.col},i=this.lines[n.row].substr(s,r-s).match(/^(?<leading>\s*).*\S(?<trailing>\s*)$/);i&&(s+=i.groups.leading.length,r-=i.groups.trailing.length),n.col=s,t.col=r,this.wrapSelection(_t[e].set.pre,_t[e].set.post,n,t),this.fireChange()}}else if("line"===_t[e].type){let n=this.getSelection(!0),s=this.getSelection(!1);if(n||(n=s),!s)return;this.clearDirtyFlag();let r=n.row>s.row?s:n,i=n.row>s.row?n:s;i.row>r.row&&0===i.col&&i.row--;for(let n=r.row;n<=i.row;n++)t&&this.lineTypes[n]!==_t[e].className&&(this.lines[n]=this.lines[n].replace(_t[e].set.pattern,_t[e].set.replacement.replace("$#",(n-r.row+1).toString())),this.lineDirty[n]=!0),t||this.lineTypes[n]!==_t[e].className||(this.lines[n]=this.lines[n].replace(_t[e].unset.pattern,_t[e].unset.replacement),this.lineDirty[n]=!0);this.updateFormatting(),this.setSelection({row:i.row,col:this.lines[i.row].length},{row:r.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.className&&t.nextSibling.className.includes("TMInlineFormatted"))return!0}let t=this.computeCommonAncestor(e.focusNode,e.anchorNode);if(!t)return!1;for(;t&&t!==this.e;){if(t.className&&"function"==typeof t.className.includes&&(t.className.includes("TMInlineFormatted")||t.className.includes("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(){if(this.listeners.selection&&this.listeners.selection.length){let e=this.getSelection(!1),t=this.getSelection(!0),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})}}}}));
1
+ !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,s,r,i,l,a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u={};function o(){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 a&&a)||e("object"==typeof t&&t)||function(){return this}()||Function("return this")()}function c(){return r?s:(r=1,s=function(e){try{return!!e()}catch(e){return!0}})}function h(){if(l)return i;l=1;var e=c();return i=!e((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}var p,f,d,g,m,M,T,F,D,y,C,E,k,$,b,A,w={exports:{}};function v(){if(f)return p;f=1;var e=c();return p=!e((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))}function S(){if(g)return d;g=1;var e=v(),t=Function.prototype,n=t.call,s=e&&t.bind.bind(n,n);return d=e?s:function(e){return function(){return n.apply(e,arguments)}},d}function x(){if(M)return m;M=1;var e="object"==typeof document&&document.all;return m=void 0===e&&void 0!==e?function(t){return"function"==typeof t||t===e}:function(e){return"function"==typeof e}}function L(){return F?T:(F=1,T=function(e){return null==e})}function B(){if(y)return D;y=1;var e=L(),t=TypeError;return D=function(n){if(e(n))throw new t("Can't call method on "+n);return n}}function N(){if(E)return C;E=1;var e=B(),t=Object;return C=function(n){return t(e(n))}}function H(){if($)return k;$=1;var e=S(),t=N(),n=e({}.hasOwnProperty);return k=Object.hasOwn||function(e,s){return n(t(e),s)}}var I,O,_,P,R,j,G,z,U,Z,q,V={exports:{}};function K(){if(P)return _;P=1;var e=o(),t=Object.defineProperty;return _=function(n,s){try{t(e,n,{value:s,configurable:!0,writable:!0})}catch(t){e[n]=s}return s}}function X(){if(R)return V.exports;R=1;var e=O?I:(O=1,I=!1),t=o(),n=K(),s="__core-js_shared__",r=V.exports=t[s]||n(s,{});return(r.versions||(r.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"}),V.exports}function W(){if(G)return j;G=1;var e=S(),t=x(),n=X(),s=e(Function.toString);return t(n.inspectSource)||(n.inspectSource=function(e){return s(e)}),j=n.inspectSource}function Y(){if(q)return Z;q=1;var e=x();return Z=function(t){return"object"==typeof t?null!==t:e(t)}}var J,Q,ee,te,ne,se,re,ie,le,ae,ue,oe,ce,he,pe,fe,de,ge,me,Me,Te,Fe,De,ye,Ce,Ee,ke,$e,be,Ae,we,ve,Se,xe,Le,Be,Ne,He,Ie,Oe,_e,Pe,Re,je,Ge,ze,Ue,Ze,qe,Ve,Ke,Xe,We,Ye,Je,Qe,et,tt,nt,st={};function rt(){if(te)return ee;te=1;var e=h(),t=c(),n=function(){if(Q)return J;Q=1;var e=o(),t=Y(),n=e.document,s=t(n)&&t(n.createElement);return J=function(e){return s?n.createElement(e):{}}}();return ee=!e&&!t((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))}function it(){if(ie)return re;ie=1;var e=Y(),t=String,n=TypeError;return re=function(s){if(e(s))return s;throw new n(t(s)+" is not an object")}}function lt(){if(ae)return le;ae=1;var e=v(),t=Function.prototype.call;return le=e?t.bind(t):function(){return t.apply(t,arguments)},le}function at(){if(oe)return ue;oe=1;var e=o(),t=x();return ue=function(n,s){return arguments.length<2?(r=e[n],t(r)?r:void 0):e[n]&&e[n][s];var r},ue}function ut(){if(ge)return de;ge=1;var e,t,n=o(),s=function(){if(fe)return pe;fe=1;var e=o().navigator,t=e&&e.userAgent;return pe=t?String(t):""}(),r=n.process,i=n.Deno,l=r&&r.versions||i&&i.version,a=l&&l.v8;return a&&(t=(e=a.split("."))[0]>0&&e[0]<4?1:+(e[0]+e[1])),!t&&s&&(!(e=s.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=s.match(/Chrome\/(\d+)/))&&(t=+e[1]),de=t}function ot(){if(Me)return me;Me=1;var e=ut(),t=c(),n=o().String;return me=!!Object.getOwnPropertySymbols&&!t((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&e&&e<41}))}function ct(){if(Fe)return Te;Fe=1;var e=ot();return Te=e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function ht(){if(ye)return De;ye=1;var e=at(),t=x(),n=function(){if(he)return ce;he=1;var e=S();return ce=e({}.isPrototypeOf)}(),s=ct(),r=Object;return De=s?function(e){return"symbol"==typeof e}:function(s){var i=e("Symbol");return t(i)&&n(i.prototype,r(s))}}function pt(){if(Ee)return Ce;Ee=1;var e=String;return Ce=function(t){try{return e(t)}catch(e){return"Object"}}}function ft(){if($e)return ke;$e=1;var e=x(),t=pt(),n=TypeError;return ke=function(s){if(e(s))return s;throw new n(t(s)+" is not a function")}}function dt(){if(Ae)return be;Ae=1;var e=ft(),t=L();return be=function(n,s){var r=n[s];return t(r)?void 0:e(r)}}function gt(){if(ve)return we;ve=1;var e=lt(),t=x(),n=Y(),s=TypeError;return we=function(r,i){var l,a;if("string"===i&&t(l=r.toString)&&!n(a=e(l,r)))return a;if(t(l=r.valueOf)&&!n(a=e(l,r)))return a;if("string"!==i&&t(l=r.toString)&&!n(a=e(l,r)))return a;throw new s("Can't convert object to primitive value")}}function mt(){if(xe)return Se;xe=1;var e=X();return Se=function(t,n){return e[t]||(e[t]=n||{})}}function Mt(){if(Be)return Le;Be=1;var e=S(),t=0,n=Math.random(),s=e(1..toString);return Le=function(e){return"Symbol("+(void 0===e?"":e)+")_"+s(++t+n,36)}}function Tt(){if(He)return Ne;He=1;var e=o(),t=mt(),n=H(),s=Mt(),r=ot(),i=ct(),l=e.Symbol,a=t("wks"),u=i?l.for||l:l&&l.withoutSetter||s;return Ne=function(e){return n(a,e)||(a[e]=r&&n(l,e)?l[e]:u("Symbol."+e)),a[e]}}function Ft(){if(Oe)return Ie;Oe=1;var e=lt(),t=Y(),n=ht(),s=dt(),r=gt(),i=Tt(),l=TypeError,a=i("toPrimitive");return Ie=function(i,u){if(!t(i)||n(i))return i;var o,c=s(i,a);if(c){if(void 0===u&&(u="default"),o=e(c,i,u),!t(o)||n(o))return o;throw new l("Can't convert object to primitive value")}return void 0===u&&(u="number"),r(i,u)}}function Dt(){if(Pe)return _e;Pe=1;var e=Ft(),t=ht();return _e=function(n){var s=e(n,"string");return t(s)?s:s+""}}function yt(){if(Re)return st;Re=1;var e=h(),t=rt(),n=function(){if(se)return ne;se=1;var e=h(),t=c();return ne=e&&t((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}(),s=it(),r=Dt(),i=TypeError,l=Object.defineProperty,a=Object.getOwnPropertyDescriptor,u="enumerable",o="configurable",p="writable";return st.f=e?n?function(e,t,n){if(s(e),t=r(t),s(n),"function"==typeof e&&"prototype"===t&&"value"in n&&p in n&&!n[p]){var i=a(e,t);i&&i[p]&&(e[t]=n.value,n={configurable:o in n?n[o]:i[o],enumerable:u in n?n[u]:i[u],writable:!1})}return l(e,t,n)}:l:function(e,n,a){if(s(e),n=r(n),s(a),t)try{return l(e,n,a)}catch(e){}if("get"in a||"set"in a)throw new i("Accessors not supported");return"value"in a&&(e[n]=a.value),e},st}function Ct(){return Ge?je:(Ge=1,je=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}})}function Et(){if(Ue)return ze;Ue=1;var e=h(),t=yt(),n=Ct();return ze=e?function(e,s,r){return t.f(e,s,n(1,r))}:function(e,t,n){return e[t]=n,e}}function kt(){if(qe)return Ze;qe=1;var e=mt(),t=Mt(),n=e("keys");return Ze=function(e){return n[e]||(n[e]=t(e))}}function $t(){return Ke?Ve:(Ke=1,Ve={})}function bt(){if(We)return Xe;We=1;var e,t,n,s=function(){if(U)return z;U=1;var e=o(),t=x(),n=e.WeakMap;return z=t(n)&&/native code/.test(String(n))}(),r=o(),i=Y(),l=Et(),a=H(),u=X(),c=kt(),h=$t(),p="Object already initialized",f=r.TypeError,d=r.WeakMap;if(s||u.state){var g=u.state||(u.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(a(e,m))throw new f(p);return t.facade=e,l(e,m,t),t},t=function(e){return a(e,m)?e[m]:{}},n=function(e){return a(e,m)}}return Xe={set:e,get:t,has:n,enforce:function(s){return n(s)?t(s):e(s,{})},getterFor:function(e){return function(n){var s;if(!i(n)||(s=t(n)).type!==e)throw new f("Incompatible receiver, "+e+" required");return s}}}}function At(){if(Ye)return w.exports;Ye=1;var e=S(),t=c(),n=x(),s=H(),r=h(),i=function(){if(A)return b;A=1;var e=h(),t=H(),n=Function.prototype,s=e&&Object.getOwnPropertyDescriptor,r=t(n,"name"),i=r&&"something"===function(){}.name,l=r&&(!e||e&&s(n,"name").configurable);return b={EXISTS:r,PROPER:i,CONFIGURABLE:l}}().CONFIGURABLE,l=W(),a=bt(),u=a.enforce,o=a.get,p=String,f=Object.defineProperty,d=e("".slice),g=e("".replace),m=e([].join),M=r&&!t((function(){return 8!==f((function(){}),"length",{value:8}).length})),T=String(String).split("String"),F=w.exports=function(e,t,n){"Symbol("===d(p(t),0,7)&&(t="["+g(p(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!s(e,"name")||i&&e.name!==t)&&(r?f(e,"name",{value:t,configurable:!0}):e.name=t),M&&n&&s(n,"arity")&&e.length!==n.arity&&f(e,"length",{value:n.arity});try{n&&s(n,"constructor")&&n.constructor?r&&f(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var l=u(e);return s(l,"source")||(l.source=m(T,"string"==typeof t?t:"")),e};return Function.prototype.toString=F((function(){return n(this)&&o(this).source||l(this)}),"toString"),w.exports}function wt(){if(Qe)return Je;Qe=1;var e=At(),t=yt();return Je=function(n,s,r){return r.get&&e(r.get,s,{getter:!0}),r.set&&e(r.set,s,{setter:!0}),t.f(n,s,r)}}!function(){if(nt)return u;nt=1;var e=o(),t=h(),n=wt(),s=function(){if(tt)return et;tt=1;var e=it();return et=function(){var t=e(this),n="";return t.hasIndices&&(n+="d"),t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.dotAll&&(n+="s"),t.unicode&&(n+="u"),t.unicodeSets&&(n+="v"),t.sticky&&(n+="y"),n}}(),r=c(),i=e.RegExp,l=i.prototype;t&&r((function(){var e=!0;try{i(".","d")}catch(t){e=!1}var t={},n="",s=e?"dgimsy":"gimsy",r=function(e,s){Object.defineProperty(t,e,{get:function(){return n+=s,!0}})},a={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var u in e&&(a.hasIndices="d"),a)r(u,a[u]);return Object.getOwnPropertyDescriptor(l,"flags").get.call(t)!==s||n!==s}))&&n(l,"flags",{configurable:!0,get:s})}();const vt={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:/<HTMLTagName(?:HTMLAttribute)*\s*\/?>/,HTMLCloseTag:/<\/HTMLTagName\s*>/,HTMLTagName:/[A-Za-z][A-Za-z0-9-]*/,HTMLComment:/<!--(?:[^>-]|(?:[^>-](?:[^-]|-[^-])*[^-]))-->/,HTMLPI:/<\?(?:|.|(?:[^?]|\?[^>])*)\?>/,HTMLDeclaration:/<![A-Z]+\s[^>]*>/,HTMLCDATA:/<!\[CDATA\[.*?\]\]>/,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/},St=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])/),xt=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])$/),Lt={TMH1:{regexp:/^( {0,3}#\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH1">$1</span>$$2<span class="TMMark TMMark_TMH1">$3</span>'},TMH2:{regexp:/^( {0,3}##\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH2">$1</span>$$2<span class="TMMark TMMark_TMH2">$3</span>'},TMH3:{regexp:/^( {0,3}###\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH3">$1</span>$$2<span class="TMMark TMMark_TMH3">$3</span>'},TMH4:{regexp:/^( {0,3}####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH4">$1</span>$$2<span class="TMMark TMMark_TMH4">$3</span>'},TMH5:{regexp:/^( {0,3}#####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH5">$1</span>$$2<span class="TMMark TMMark_TMH5">$3</span>'},TMH6:{regexp:/^( {0,3}######\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH6">$1</span>$$2<span class="TMMark TMMark_TMH6">$3</span>'},TMBlockquote:{regexp:/^( {0,3}>[ ]?)(.*)$/,replacement:'<span class="TMMark TMMark_TMBlockquote">$1</span>$$2'},TMCodeFenceBacktickOpen:{regexp:/^( {0,3}(?<seq>````*)\s*)([^`]*?)(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span><span class="TMInfoString">$3</span>$4'},TMCodeFenceTildeOpen:{regexp:/^( {0,3}(?<seq>~~~~*)\s*)(.*?)(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceTilde">$1</span><span class="TMInfoString">$3</span>$4'},TMCodeFenceBacktickClose:{regexp:/^( {0,3}(?<seq>````*))(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span>$3'},TMCodeFenceTildeClose:{regexp:/^( {0,3}(?<seq>~~~~*))(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceTilde">$1</span>$3'},TMBlankLine:{regexp:/^([ \t]*)$/,replacement:"$0"},TMSetextH1Marker:{regexp:/^ {0,3}=+\s*$/,replacement:'<span class="TMMark TMMark_TMSetextH1Marker">$0</span>'},TMSetextH2Marker:{regexp:/^ {0,3}-+\s*$/,replacement:'<span class="TMMark TMMark_TMSetextH1Marker">$0</span>'},TMHR:{regexp:/^( {0,3}(\*[ \t]*\*[ \t]*\*[ \t*]*)|(-[ \t]*-[ \t]*-[ \t-]*)|(_[ \t]*_[ \t]*_[ \t_]*))$/,replacement:'<span class="TMMark TMMark_TMHR">$0</span>'},TMUL:{regexp:/^( {0,3}[+*-] {1,4})(.*)$/,replacement:'<span class="TMMark TMMark_TMUL">$1</span>$$2'},TMOL:{regexp:/^( {0,3}\d{1,9}[.)] {1,4})(.*)$/,replacement:'<span class="TMMark TMMark_TMOL">$1</span>$$2'},TMIndentedCode:{regexp:/^( {4}|\t)(.*)$/,replacement:'<span class="TMMark TMMark_TMIndentedCode">$1</span>$2'},TMLinkReferenceDefinition:{regexp:/^( {0,3}\[\s*)([^\s\]](?:[^\]]|\\\])*?)(\s*\]:\s*)((?:[^\s<>]+)|(?:<(?:[^<>\\]|\\.)*>))?(\s*)((?:\((?:[^()\\]|\\.)*\))|(?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.)*'))?(\s*)$/,replacement:'<span class="TMMark TMMark_TMLinkReferenceDefinition">$1</span><span class="TMLinkLabel TMLinkLabel_Definition">$2</span><span class="TMMark TMMark_TMLinkReferenceDefinition">$3</span><span class="TMLinkDestination">$4</span>$5<span class="TMLinkTitle">$6</span>$7',labelPlaceholder:2}},Bt=[{start:/^ {0,3}<(?:script|pre|style)(?:\s|>|$)/i,end:/(?:<\/script>|<\/pre>|<\/style>)/i,paraInterrupt:!0},{start:/^ {0,3}<!--/,end:/-->/,paraInterrupt:!0},{start:/^ {0,3}<\?/,end:/\?>/,paraInterrupt:!0},{start:/^ {0,3}<![A-Z]/,end:/>/,paraInterrupt:!0},{start:/^ {0,3}<!\[CDATA\[/,end:/\]\]>/,paraInterrupt:!0},{start:/^ {0,3}(?:<|<\/)(?:KnownTag)(?:\s|>|\/>|$)/i,end:!1,paraInterrupt:!0},{start:/^ {0,3}(?:HTMLOpenTag|HTMLCloseTag)\s*$/,end:!1,paraInterrupt:!1}],Nt={escape:{regexp:/^\\(ASCIIPunctuation)/,replacement:'<span class="TMMark TMMark_TMEscape">\\</span>$1'},code:{regexp:/^(`+)((?:[^`])|(?:[^`].*?[^`]))(\1)/,replacement:'<span class="TMMark TMMark_TMCode">$1</span><code class="TMCode">$2</code><span class="TMMark TMMark_TMCode">$3</span>'},autolink:{regexp:/^<((?:Scheme:[^\s<>]*)|(?:Email))>/,replacement:'<span class="TMMark TMMark_TMAutolink">&lt;</span><span class="TMAutolink">$1</span><span class="TMMark TMMark_TMAutolink">&gt;</span>'},html:{regexp:/^((?:HTMLOpenTag)|(?:HTMLCloseTag)|(?:HTMLComment)|(?:HTMLPI)|(?:HTMLDeclaration)|(?:HTMLCDATA))/,replacement:'<span class="TMHTML">$1</span>'},linkOpen:{regexp:/^\[/,replacement:""},imageOpen:{regexp:/^!\[/,replacement:""},linkLabel:{regexp:/^(\[\s*)([^\]]*?)(\s*\])/,replacement:"",labelPlaceholder:2},default:{regexp:/^(.|(?:NotTriggerChar+))/,replacement:"$1"}},Ht=new RegExp(Object.keys(vt).join("|")),It=[...Object.keys(Nt)];for(let e of It){let t=Nt[e].regexp.source;for(;t.match(Ht);)t=t.replace(Ht,(e=>vt[e].source));Nt[e].regexp=new RegExp(t,Nt[e].regexp.flags)}for(let e of Bt){let t=e.start.source;for(;t.match(Ht);)t=t.replace(Ht,(e=>vt[e].source));e.start=new RegExp(t,e.start.flags)}function Ot(e){return(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const _t={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.Editor=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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=Nt,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={...Nt};for(const[n,s]of Object.entries(e)){const e={...s};let r=s.regexp.source;const i=new RegExp(Object.keys(vt).join("|"));for(;r.match(i);)r=r.replace(i,(e=>vt[e].source));e.regexp=new RegExp(r,s.regexp.flags),t[n]=e}return t}(this.customInlineGrammar),this.listeners={change:[],selection:[],drop:[]};let t=null;"string"==typeof e.element?t=document.getElementById(e.element):e.element&&(t=e.element),"string"==typeof e.textarea?this.textarea=document.getElementById(e.textarea):e.textarea&&(this.textarea=e.textarea),this.textarea&&(t||(t=this.textarea)),t||(t=document.getElementsByTagName("body")[0]),t&&"TEXTAREA"===t.tagName&&(this.textarea=t,t=this.textarea.parentNode),this.textarea&&(this.textarea.style.display="none"),this.undoStack=[],this.redoStack=[],this.isRestoringHistory=!1,this.maxHistory=100,this.createEditorElement(t,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",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<this.lines.length;e++){let e=document.createElement("div");this.e.appendChild(e),this.lineDirty.push(!0)}this.lineTypes=new Array(this.lines.length),this.updateFormatting(),this.fireChange(),this.isRestoringHistory||this.pushHistory()}getContent(){return this.lines.join("\n")}updateFormatting(){this.updateLineTypes(),this.updateLinkLabels(),this.applyLineTypes()}updateLinkLabels(){this.linkLabels=[];for(let e=0;e<this.lines.length;e++)"TMLinkReferenceDefinition"===this.lineTypes[e]&&this.linkLabels.push(this.lineCaptures[e][Lt.TMLinkReferenceDefinition.labelPlaceholder])}replace(e,t){return e.replace(/(\${1,2})([0-9])/g,((e,n,s)=>"$"===n?Ot(t[parseInt(s)]):`<span class="TMInlineFormatted">${this.processInlineStyles(t[parseInt(s)])}</span>`))}applyLineTypes(){for(let e=0;e<this.lines.length;e++){if(this.lineDirty[e]){let t=this.replace(this.lineReplacements[e],this.lineCaptures[e]);this.lineElements[e].className=this.lineTypes[e],this.lineElements[e].removeAttribute("style"),this.lineElements[e].innerHTML=""===t?"<br />":t}this.lineElements[e].dataset.lineNum=e.toString()}}updateLineTypes(){let e=!1,t=0,n=!1;for(let s=0;s<this.lines.length;s++){let r="TMPara",i=[this.lines[s]],l="$$0";if("TMCodeFenceBacktickOpen"===e){let n=Lt.TMCodeFenceBacktickClose.regexp.exec(this.lines[s]);n&&n.groups.seq.length>=t?(r="TMCodeFenceBacktickClose",l=Lt.TMCodeFenceBacktickClose.replacement,i=n,e=!1):(r="TMFencedCodeBacktick",l='<span class="TMFencedCode">$0<br /></span>',i=[this.lines[s]])}else if("TMCodeFenceTildeOpen"===e){let n=Lt.TMCodeFenceTildeClose.regexp.exec(this.lines[s]);n&&n.groups.seq.length>=t?(r="TMCodeFenceTildeClose",l=Lt.TMCodeFenceTildeClose.replacement,i=n,e=!1):(r="TMFencedCodeTilde",l='<span class="TMFencedCode">$0<br /></span>',i=[this.lines[s]])}if("TMPara"===r&&!1===n)for(let e of Bt)if(this.lines[s].match(e.start)&&(e.paraInterrupt||0===s||"TMPara"!==this.lineTypes[s-1]&&"TMUL"!==this.lineTypes[s-1]&&"TMOL"!==this.lineTypes[s-1]&&"TMBlockquote"!==this.lineTypes[s-1])){n=e;break}if(!1!==n&&(r="TMHTMLBlock",l='<span class="TMHTMLContent">$0<br /></span>',i=[this.lines[s]],n.end?this.lines[s].match(n.end)&&(n=!1):(s===this.lines.length-1||this.lines[s+1].match(Lt.TMBlankLine.regexp))&&(n=!1)),"TMPara"===r)for(let e in Lt)if(Lt[e].regexp){let t=Lt[e].regexp.exec(this.lines[s]);if(t){r=e,l=Lt[e].replacement,i=t;break}}if("TMCodeFenceBacktickOpen"!==r&&"TMCodeFenceTildeOpen"!==r||(e=r,t=i.groups.seq.length),"TMIndentedCode"!==r&&"TMLinkReferenceDefinition"!==r||!(s>0)||"TMPara"!==this.lineTypes[s-1]&&"TMUL"!==this.lineTypes[s-1]&&"TMOL"!==this.lineTypes[s-1]&&"TMBlockquote"!==this.lineTypes[s-1]||(r="TMPara",i=[this.lines[s]],l="$$0"),"TMSetextH2Marker"===r){let e=Lt.TMUL.regexp.exec(this.lines[s]);e&&(r="TMUL",l=Lt.TMUL.replacement,i=e)}if("TMSetextH1Marker"===r||"TMSetextH2Marker"===r)if(0===s||"TMPara"!==this.lineTypes[s-1]){let e=Lt.TMHR.regexp.exec(this.lines[s]);e?(r="TMHR",i=e,l=Lt.TMHR.replacement):(r="TMPara",i=[this.lines[s]],l="$$0")}else{let e=s-1;const t="TMSetextH1Marker"===r?"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[s]!==r&&(this.lineTypes[s]=r,this.lineDirty[s]=!0),this.lineReplacements[s]=l,this.lineCaptures[s]=i}}getSelection(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var t,n;const s=window.getSelection();let r=e?s.anchorNode:s.focusNode;if(!r)return null;let i=e?s.anchorOffset:s.focusOffset;if(r===this.e)return i<this.lines.length?{row:i,col:0}:{row:i-1,col:this.lines[i-1].length};let l=this.computeColumn(r,i);if(null===l)return null;let a=r;for(;a.parentElement!==this.e;)a=a.parentElement;let u=0;if(a.previousSibling){const e=null===(t=a.dataset)||void 0===t?void 0:t.lineNum,s=null===(n=a.previousSibling.dataset)||void 0===n?void 0:n.lineNum;if(e&&s){const t=parseInt(e);if(t===parseInt(s)+1)u=t;else for(;a.previousSibling;)u++,a=a.previousSibling}}return{row:u,col:l}}setSelection(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e)return;let{node:n,offset:s}=this.computeNodeAndOffset(e.row,e.col,!!t&&(t.row===e.row&&t.col>e.col)),r=null,i=null;if(t&&(t.row!==e.row||t.col!==e.col)){let{node:n,offset:s}=this.computeNodeAndOffset(t.row,t.col,e.row===t.row&&e.col>t.col);r=n,i=s}window.getSelection().setBaseAndExtent(n,s,r||n,r?i:s)}restoreLastSelection(){return!(!this.lastSelection||!this.lastSelection.focus)&&(this.setSelection(this.lastSelection.focus,this.lastSelection.anchor),!0)}paste(e){let t,n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;s||(s=this.getSelection(!0)),r||(r=this.getSelection(!1)),r||(r={row:this.lines.length-1,col:this.lines[this.lines.length-1].length}),s||(s=r),s.row<r.row||s.row===r.row&&s.col<=r.col?(t=s,n=r):(t=r,n=s);let i=e.split(/(?:\r\n|\r|\n)/),l=this.lines[t.row].substr(0,t.col),a=this.lines[n.row].substr(n.col);i[0]=l.concat(i[0]);let u=i[i.length-1].length;i[i.length-1]=i[i.length-1].concat(a),this.spliceLines(t.row,1+n.row-t.row,i),r.row=t.row+i.length-1,r.col=u,this.updateFormatting(),this.setSelection(r),this.fireChange()}wrapSelection(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(this.isRestoringHistory||this.pushHistory(),n||(n=this.getSelection(!1)),s||(s=this.getSelection(!0)),!n||!s||n.row!==s.row)return;this.lineDirty[n.row]=!0;const r=n.col<s.col?n.col:s.col,i=n.col<s.col?s.col:n.col,l=this.lines[n.row].substr(0,r).concat(e),a=i===r?"":this.lines[n.row].substr(r,i-r),u=t.concat(this.lines[n.row].substr(i));this.lines[n.row]=l.concat(a,u),s.col=l.length,n.col=s.col+a.length,this.updateFormatting(),this.setSelection(n,s)}addEventListener(e,t){e.match(/^(?:change|input)$/i)&&this.listeners.change.push(t),e.match(/^(?:selection|selectionchange)$/i)&&this.listeners.selection.push(t),e.match(/^(?:drop)$/i)&&this.listeners.drop.push(t)}fireChange(){if(!this.textarea&&!this.listeners.change.length)return;const e=this.getContent();this.textarea&&(this.textarea.value=e);for(let t of this.listeners.change)t({content:e,linesDirty:[...this.lineDirty]})}handleBeforeInputEvent(e){const t=e;if("insertParagraph"!==t.inputType&&"insertLineBreak"!==t.inputType)return;this.isRestoringHistory||this.pushHistory(),e.preventDefault(),this.clearDirtyFlag();const n=this.getSelection(),s=this.getSelection(!0);if(n&&s){if(n.row!==s.row){const e=n.row<s.row?n:s,t=n.row<s.row?s:n;this.lines[e.row]=this.lines[e.row].substring(0,e.col),this.lines[t.row]=this.lines[t.row].substring(t.col),this.spliceLines(e.row+1,t.row-e.row-1),n.row=e.row+1,n.col=0}else{let e=!1;switch(this.lineTypes[n.row]){case"TMUL":e="TMUL";break;case"TMOL":e="TMOL";break;case"TMIndentedCode":e="TMIndentedCode"}const t=this.lines[n.row].substring(0,n.col<=s.col?n.col:s.col),r=this.lines[n.row].substring(n.col<=s.col?s.col:n.col);if(this.spliceLines(n.row,1,[t,r]),n.row+=1,n.col=0,e){let t=Lt[e].regexp.exec(this.lines[n.row-1]);t&&(t[2]?("TMOL"===e&&(t[1]=t[1].replace(/\d{1,9}/,(e=>(parseInt(e)+1).toString()))),this.lines[n.row]=`${t[1]}${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.lineElements.length&&this.lineElements[n.row].scrollIntoView({block:"nearest",inline:"nearest"}),this.fireChange()}}handleInputEvent(e){const t=e;if("insertCompositionText"===t.inputType)return;this.isRestoringHistory||this.pushHistory();let n=this.getSelection();("insertParagraph"!==t.inputType&&"insertLineBreak"!==t.inputType||!n)&&(this.e.firstChild?this.fixNodeHierarchy():this.e.innerHTML='<div class="TMBlankLine"><br></div>',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=[],s=0,r=e;e:for(;r;){for(let e of["escape","code","autolink","html"])if(this.mergedInlineGrammar[e]){let n=this.mergedInlineGrammar[e].regexp.exec(r);if(n){r=r.substr(n[0].length),s+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(/\$([1-9])/g,((e,t)=>Ot(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(r);if(n){r=r.substr(n[0].length),s+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(/\$([1-9])/g,((e,t)=>Ot(n[t])));continue e}}let i=r.match(this.mergedInlineGrammar.linkOpen.regexp),l=r.match(this.mergedInlineGrammar.imageOpen.regexp);if(l||i){let e=this.parseLinkOrImage(r,!!l);if(e){t=`${t}${e.output}`,r=r.substr(e.charCount),s+=e.charCount;continue e}}let a=/(^\*+)|(^_+)/.exec(r);if(a){let i=a[0].length;const l=a[0],u=a[0][0];r=r.substr(a[0].length);const o=s>0?e.substr(0,s):" ",c=s+a[0].length<e.length?r:" ",h=c.match(St),p=o.match(xt),f=c.match(/^\s/),d=o.match(/\s$/);let g=!(f||h&&!d&&!p),m=!(d||p&&!f&&!h);if("_"===u&&g&&m&&(g=!!p,m=!!h),m){let e=n.length-1;for(;i&&e>=0;)if(n[e].delimiter===u){for(;e<n.length-1;){const e=n.pop();t=`${e.output}${e.delimString.substr(0,e.count)}${t}`}if(i>=2&&n[e].count>=2?(t=`<span class="TMMark">${u}${u}</span><strong class="TMStrong">${t}</strong><span class="TMMark">${u}${u}</span>`,i-=2,n[e].count-=2):(t=`<span class="TMMark">${u}</span><em class="TMEm">${t}</em><span class="TMMark">${u}</span>`,i-=1,n[e].count-=1),0===n[e].count){t=`${n.pop().output}${t}`,e--}}else e--}i&&g&&(n.push({delimiter:u,delimString:l,count:i,output:t}),t="",i=0),i&&(t=`${t}${l.substr(0,i)}`),s+=a[0].length}else if(a=/^~~/.exec(r),a){let e=!1,i=n.length-1;for(;!e&&i>=0;)if("~"===n[i].delimiter){for(;i<n.length-1;){const e=n.pop();t=`${e.output}${e.delimString.substr(0,e.count)}${t}`}t=`<span class="TMMark">~~</span><del class="TMStrikethrough">${t}</del><span class="TMMark">~~</span>`,t=`${n.pop().output}${t}`,e=!0}else i--;e||(n.push({delimiter:"~",delimString:"~~",count:2,output:t}),t=""),s+=a[0].length,r=r.substr(a[0].length)}else{if(a=this.mergedInlineGrammar.default.regexp.exec(r),!a)throw"Infinite loop!";r=r.substr(a[0].length),s+=a[0].length,t+=this.mergedInlineGrammar.default.replacement.replace(/\$([1-9])/g,((e,t)=>Ot(a[t])))}}for(;n.length;){const e=n.pop();t=`${e.output}${e.delimString.substr(0,e.count)}${t}`}return t}computeColumn(e,t){let n,s=e;for(;s&&s.parentNode!==this.e;)s=s.parentNode;if(null===s)return null;for(e.nodeType===Node.TEXT_NODE||0===t?(n=t,s=e):t>0?(s=e.childNodes[t-1],n=s.textContent.length):(n=0,s=e);s.parentNode!==this.e;)s.previousSibling?(s=s.previousSibling,n+=s.textContent.length):s=s.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 s=this.lineElements[e];let r=s.firstChild,i=!1,l={node:s.firstChild?s.firstChild:s,offset:0};for(;r!==s;){if(!i&&r.nodeType===Node.TEXT_NODE)if(r.nodeValue.length>=t){if(!n||r.nodeValue.length!==t)return{node:r,offset:t};l={node:r,offset:t},t=0}else t-=r.nodeValue.length;!i&&r.firstChild?r=r.firstChild:r.nextSibling?(i=!1,r=r.nextSibling):(i=!0,r=r.parentNode)}return l}updateLineContentsAndFormatting(){this.clearDirtyFlag(),this.updateLineContents(),this.updateFormatting()}clearDirtyFlag(){this.lineDirty=new Array(this.lines.length);for(let e=0;e<this.lineDirty.length;e++)this.lineDirty[e]=!1}updateLineContents(){let e=this.e.childElementCount-this.lines.length;if(e){let t=0;for(;t<=this.lines.length&&t<=this.lineElements.length&&this.lineElements[t]&&this.lines[t]===this.lineElements[t].textContent&&this.lineTypes[t]===this.lineElements[t].className;)t++;let n=-1;for(;-n<this.lines.length&&-n<this.lineElements.length&&this.lines[this.lines.length+n]===this.lineElements[this.lineElements.length+n].textContent&&this.lineTypes[this.lines.length+n]===this.lineElements[this.lineElements.length+n].className;)n--;let s=this.lines.length+n+1-t;s<-e&&(s=-e),s<0&&(s=0);let r=[];for(let n=0;n<s+e;n++)r.push(this.lineElements[t+n].textContent||"");this.spliceLines(t,s,r,!1)}else for(let e=0;e<this.lineElements.length;e++){let t=this.lineElements[e],n=t.textContent||"";this.lines[e]===n&&this.lineTypes[e]===t.className||(this.lines[e]=n,this.lineTypes[e]=t.className,this.lineDirty[e]=!0)}}spliceLines(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(s)for(let n=0;n<t;n++)this.e.removeChild(this.e.childNodes[e]);let r=[],i=[];for(let t=0;t<n.length;t++)r.push(""),i.push(!0),s&&(this.e.childNodes[e]?this.e.insertBefore(document.createElement("div"),this.e.childNodes[e]):this.e.appendChild(document.createElement("div")));this.lines.splice(e,t,...n),this.lineTypes.splice(e,t,...r),this.lineDirty.splice(e,t,...i)}fixNodeHierarchy(){const e=Array.from(this.e.childNodes),t=function(e){const t=e.parentElement,n=e.nextSibling;t.removeChild(e);for(var s=arguments.length,r=new Array(s>1?s-1:0),i=1;i<s;i++)r[i-1]=arguments[i];r.forEach((e=>n?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,s=e.substr(0,n),r=t?"TMImage":"TMLink",i=n,l=1,a=!1,u=!1,o=[],c=[];e:for(;i<e.length&&!1===a;){let s=e.substr(i);for(let e of["escape","code","autolink","html"]){let t=this.mergedInlineGrammar[e].regexp.exec(s);if(t){i+=t[0].length;continue e}}if(s.match(this.mergedInlineGrammar.imageOpen.regexp))l++,i+=2;else if(s.match(this.mergedInlineGrammar.linkOpen.regexp)){if(l++,!t&&this.parseLinkOrImage(s,!1))return!1;i+=1}else s.match(/^\]/)&&(l--,0===l)?(a=e.substr(n,i-n),i++):i++}if(!1===a)return!1;let h=i<e.length?e.substr(i,1):"";if("["===h){let t=e.substr(i),n=this.mergedInlineGrammar.linkLabel.regexp.exec(t);if(!n)return!1;i+=n[0].length,o.push(n[1],n[2],n[3]),u=n[this.mergedInlineGrammar.linkLabel.labelPlaceholder]?n[this.mergedInlineGrammar.linkLabel.labelPlaceholder]:a.trim()}else if("("!==h)u=a.trim();else{i++;let t=1;for(;i<e.length&&t>0;){let n=e.substr(i),s=/^\s+/.exec(n);if(s){switch(c.length){case 0:case 1:c.push(s[0]);break;case 2:if(c[0].match(/</))c[1]=c[1].concat(s[0]);else{if(1!==t)return!1;c.push(""),c.push(s[0])}break;case 3:c.push(s[0]);break;case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(s[0]);break;case 7:c[6]=c[6].concat(s[0]);break;default:return!1}i+=s[0].length}else if(s=this.mergedInlineGrammar.escape.regexp.exec(n),s){switch(c.length){case 0:c.push("");case 1:c.push(s[0]);break;case 2:c[1]=c[1].concat(s[0]);break;case 3:case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(s[0]);break;default:return!1}i+=s[0].length}else if(c.length<2&&n.match(/^</))0===c.length&&c.push(""),c[0]=c[0].concat("<"),i++;else if(1!==c.length&&2!==c.length||!n.match(/^>/))if(s=/^["']/.exec(n),!s||0!==c.length&&1!==c.length&&4!==c.length)if(!s||5!==c.length&&6!==c.length||c[4]!==s[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}i++}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("");i++}else{if(s=/^./.exec(n),!s)throw"Infinite loop";switch(c.length){case 0:c.push("");case 1:c.push(s[0]);break;case 2:c[1]=c[1].concat(s[0]);break;case 3:case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(s[0]);break;default:return!1}i+=s[0].length}else 5===c.length&&c.push(""),c.push(s[0]),i++;else{for(;c.length<4;)c.push("");c.push(s[0]),i++}else 1===c.length&&c.push(""),c.push(">"),i++}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=`<span class="TMMark TMMark_${r}">${s}</span><span class="${r} ${o.length<3||!o[1]?t:""}">${this.processInlineStyles(a)}</span><span class="TMMark TMMark_${r}">]</span>`;return o.length>=3&&(n=n.concat(`<span class="TMMark TMMark_${r}">${o[0]}</span>`,`<span class="${t}">${o[1]}</span>`,`<span class="TMMark TMMark_${r}">${o[2]}</span>`)),{output:n,charCount:i}}if(c.length>0){for(;c.length<7;)c.push("");return{output:`<span class="TMMark TMMark_${r}">${s}</span><span class="${r}">${this.processInlineStyles(a)}</span><span class="TMMark TMMark_${r}">](${c[0]}</span><span class="${r}Destination">${c[1]}</span><span class="TMMark TMMark_${r}">${c[2]}${c[3]}${c[4]}</span><span class="${r}Title">${c[5]}</span><span class="TMMark TMMark_${r}">${c[6]})</span>`,charCount:i}}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},s=n(e),r=n(t);if(s[0]!==r[0])return null;let i;for(i=0;s[i]===r[i];i++);return s[i-1]}computeEnclosingMarkupNode(e,t,n){let s=null;if(!e)return null;if(t){if(e.row!==t.row)return null;const n=window.getSelection();if(!n)return null;s=this.computeCommonAncestor(n.focusNode,n.anchorNode)}else{const e=window.getSelection();if(!e||!e.focusNode)return null;s=e.focusNode}if(!s)return null;for(;s!==this.e;){if(s.className&&s.className.includes(n))return s;s=s.parentNode}return null}getCommandState(){let e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r={};if(n||(n=this.getSelection(!1)),s||(s=this.getSelection(!0)),!n){for(let e in _t)r[e]=null;return r}s||(s=n),s.row<n.row||s.row===n.row&&s.col<n.col?(e=s,t=n):(e=n,t=s),t.row>e.row&&0===t.col&&(t.row--,t.col=this.lines[t.row].length);for(let i in _t)if("inline"===_t[i].type&&(n&&n.row===s.row&&this.isInlineFormattingAllowed()?r[i]=!!this.computeEnclosingMarkupNode(n,s,_t[i].className)||n.col===s.col&&!!this.lines[n.row].substr(0,n.col).match(_t[i].unset.prePattern)&&!!this.lines[n.row].substr(n.col).match(_t[i].unset.postPattern):r[i]=null),"line"===_t[i].type)if(n){let n=this.lineTypes[e.row]===_t[i].className;for(let s=e.row;s<=t.row;s++)if(this.lineTypes[s]===_t[i].className!==n){n=null;break}r[i]=n}else r[i]=null;return r}setCommandState(e,t){if(this.isRestoringHistory||this.pushHistory(),"inline"===_t[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 s=this.computeEnclosingMarkupNode(n,t,_t[e].className);if(this.clearDirtyFlag(),s){this.lineDirty[n.row]=!0;const r=this.computeColumn(s,0),i=s.textContent.length,l=this.lines[n.row].substr(0,r).replace(_t[e].unset.prePattern,""),a=this.lines[n.row].substr(r,i),u=this.lines[n.row].substr(r+i).replace(_t[e].unset.postPattern,"");this.lines[n.row]=l.concat(a,u),t.col=l.length,n.col=t.col+i,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else if(n.col===t.col&&this.lines[n.row].substr(0,n.col).match(_t[e].unset.prePattern)&&this.lines[n.row].substr(n.col).match(_t[e].unset.postPattern)){this.lineDirty[n.row]=!0;const s=this.lines[n.row].substr(0,n.col).replace(_t[e].unset.prePattern,""),r=this.lines[n.row].substr(n.col).replace(_t[e].unset.postPattern,"");this.lines[n.row]=s.concat(r),n.col=t.col=s.length,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else{let{startCol:s,endCol:r}=n.col<t.col?{startCol:n.col,endCol:t.col}:{startCol:t.col,endCol:n.col},i=this.lines[n.row].substr(s,r-s).match(/^(?<leading>\s*).*\S(?<trailing>\s*)$/);i&&(s+=i.groups.leading.length,r-=i.groups.trailing.length),n.col=s,t.col=r,this.wrapSelection(_t[e].set.pre,_t[e].set.post,n,t),this.fireChange()}}else if("line"===_t[e].type){let n=this.getSelection(!0),s=this.getSelection(!1);if(n||(n=s),!s)return;this.clearDirtyFlag();let r=n.row>s.row?s:n,i=n.row>s.row?n:s;i.row>r.row&&0===i.col&&i.row--;for(let n=r.row;n<=i.row;n++)t&&this.lineTypes[n]!==_t[e].className&&(this.lines[n]=this.lines[n].replace(_t[e].set.pattern,_t[e].set.replacement.replace("$#",(n-r.row+1).toString())),this.lineDirty[n]=!0),t||this.lineTypes[n]!==_t[e].className||(this.lines[n]=this.lines[n].replace(_t[e].unset.pattern,_t[e].unset.replacement),this.lineDirty[n]=!0);this.updateFormatting(),this.setSelection({row:i.row,col:this.lines[i.row].length},{row:r.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.className&&t.nextSibling.className.includes("TMInlineFormatted"))return!0}let t=this.computeCommonAncestor(e.focusNode,e.anchorNode);if(!t)return!1;for(;t&&t!==this.e;){if(t.className&&"function"==typeof t.className.includes&&(t.className.includes("TMInlineFormatted")||t.className.includes("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})}}}}));
package/lib/TinyMDE.d.ts CHANGED
@@ -43,6 +43,7 @@ export declare class Editor {
43
43
  private customInlineGrammar;
44
44
  private mergedInlineGrammar;
45
45
  private hasFocus;
46
+ private lastSelection;
46
47
  listeners: {
47
48
  change: EventHandler<ChangeEvent>[];
48
49
  selection: EventHandler<SelectionEvent>[];
@@ -70,6 +71,7 @@ export declare class Editor {
70
71
  private updateLineTypes;
71
72
  getSelection(getAnchor?: boolean): Position | null;
72
73
  setSelection(focus: Position, anchor?: Position | null): void;
74
+ restoreLastSelection(): boolean;
73
75
  paste(text: string, anchor?: Position | null, focus?: Position | null): void;
74
76
  wrapSelection(pre: string, post: string, focus?: Position | null, anchor?: Position | null): void;
75
77
  addEventListener<T extends EventType>(type: T, listener: T extends 'change' ? EventHandler<ChangeEvent> : T extends 'selection' ? EventHandler<SelectionEvent> : T extends 'drop' ? EventHandler<DropEvent> : never): void;
@@ -100,7 +102,7 @@ export declare class Editor {
100
102
  private computeEnclosingMarkupNode;
101
103
  getCommandState(focus?: Position | null, anchor?: Position | null): Record<string, boolean | null>;
102
104
  setCommandState(command: string, state: boolean): void;
103
- private isInlineFormattingAllowed;
105
+ isInlineFormattingAllowed(): boolean;
104
106
  toggleCommandState(command: string): void;
105
107
  private fireDrop;
106
108
  private fireSelection;
package/lib/TinyMDE.js CHANGED
@@ -17,6 +17,7 @@ class Editor {
17
17
  this.customInlineGrammar = {};
18
18
  this.mergedInlineGrammar = grammar_1.inlineGrammar;
19
19
  this.hasFocus = true;
20
+ this.lastSelection = null;
20
21
  this.listeners = {
21
22
  change: [],
22
23
  selection: [],
@@ -37,6 +38,7 @@ class Editor {
37
38
  this.lineDirty = [];
38
39
  this.lastCommandState = null;
39
40
  this.hasFocus = true;
41
+ this.lastSelection = null;
40
42
  this.customInlineGrammar = props.customInlineGrammar || {};
41
43
  this.mergedInlineGrammar = (0, grammar_1.createMergedInlineGrammar)(this.customInlineGrammar);
42
44
  this.listeners = {
@@ -448,6 +450,13 @@ class Editor {
448
450
  let windowSelection = window.getSelection();
449
451
  windowSelection.setBaseAndExtent(focusNode, focusOffset, anchorNode || focusNode, anchorNode ? anchorOffset : focusOffset);
450
452
  }
453
+ restoreLastSelection() {
454
+ if (this.lastSelection && this.lastSelection.focus) {
455
+ this.setSelection(this.lastSelection.focus, this.lastSelection.anchor);
456
+ return true;
457
+ }
458
+ return false;
459
+ }
451
460
  paste(text, anchor = null, focus = null) {
452
461
  if (!anchor)
453
462
  anchor = this.getSelection(true);
@@ -1534,9 +1543,14 @@ class Editor {
1534
1543
  }
1535
1544
  }
1536
1545
  fireSelection() {
1546
+ let focus = this.getSelection(false);
1547
+ let anchor = this.getSelection(true);
1548
+ // Save the current selection for restoration later
1549
+ this.lastSelection = {
1550
+ focus: focus,
1551
+ anchor: anchor
1552
+ };
1537
1553
  if (this.listeners.selection && this.listeners.selection.length) {
1538
- let focus = this.getSelection(false);
1539
- let anchor = this.getSelection(true);
1540
1554
  let commandState = this.getCommandState(focus, anchor);
1541
1555
  if (this.lastCommandState) {
1542
1556
  Object.assign(this.lastCommandState, commandState);
@@ -73,7 +73,7 @@ const DefaultCommands = {
73
73
  if (editor.isInlineFormattingAllowed())
74
74
  editor.wrapSelection("[", "]()");
75
75
  },
76
- enabled: (editor, focus, anchor) => editor.isInlineFormattingAllowed(focus, anchor) ? false : null,
76
+ enabled: (editor) => editor.isInlineFormattingAllowed() ? false : null,
77
77
  innerHTML: svg_1.default.link,
78
78
  title: "Insert link",
79
79
  hotkey: "Mod-K",
@@ -84,7 +84,7 @@ const DefaultCommands = {
84
84
  if (editor.isInlineFormattingAllowed())
85
85
  editor.wrapSelection("![", "]()");
86
86
  },
87
- enabled: (editor, focus, anchor) => editor.isInlineFormattingAllowed(focus, anchor) ? false : null,
87
+ enabled: (editor) => editor.isInlineFormattingAllowed() ? false : null,
88
88
  innerHTML: svg_1.default.image,
89
89
  title: "Insert image",
90
90
  hotkey: "Mod2-Shift-I",
@@ -275,6 +275,15 @@ class CommandBar {
275
275
  if (!this.editor)
276
276
  return;
277
277
  event.preventDefault();
278
+ // Focus the editor if it's not already focused
279
+ if (this.editor.e) {
280
+ const editorHadFocus = this.editor.e.contains(document.activeElement);
281
+ this.editor.e.focus();
282
+ // Only restore the last selection if the editor was not focused before
283
+ if (!editorHadFocus) {
284
+ this.editor.restoreLastSelection();
285
+ }
286
+ }
278
287
  if (typeof this.commands[commandName].action === "string") {
279
288
  if (this.state[commandName] === false)
280
289
  this.editor.setCommandState(commandName, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-markdown-editor",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "TinyMDE: A tiny, ultra low dependency, embeddable HTML/JavaScript Markdown editor.",
5
5
  "main": "lib/index.js",
6
6
  "files": [