You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
simplemde-markdown-editor/dist/simplemde.min.js

15 lines
271 KiB
JavaScript

/**
* simplemde v1.11.2
* Copyright Next Step Webs, Inc.
* @link https://github.com/NextStepWebs/simplemde-markdown-editor
* @license MIT
*/
7 years ago
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.SimpleMDE=e()}}(function(){var e;return function e(t,n,r){function i(a,l){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!l&&s)return s(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return i(n||e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,n,r){(function(t){(function(){function t(e){this.tokens=[],this.tokens.links={},this.options=e||h.defaults,this.rules=d.normal,this.options.gfm&&(this.options.tables?this.rules=d.tables:this.rules=d.gfm)}function i(e,t){if(this.options=t||h.defaults,this.links=e,this.rules=p.normal,this.renderer=this.options.renderer||new o,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=p.breaks:this.rules=p.gfm:this.options.pedantic&&(this.rules=p.pedantic)}function o(e){this.options=e||{}}function a(e){this.tokens=[],this.token=null,this.options=e||h.defaults,this.options.renderer=this.options.renderer||new o,this.renderer=this.options.renderer,this.renderer.options=this.options}function l(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function s(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function c(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function u(){}function f(e){for(var t,n,r=1;r<arguments.length;r++){t=arguments[r];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function h(e,n,r){if(r||"function"==typeof n){r||(r=n,n=null),n=f({},h.defaults,n||{});var i,o,s=n.highlight,c=0;try{i=t.lex(e,n)}catch(e){return r(e)}o=i.length;var u=function(e){if(e)return n.highlight=s,r(e);var t;try{t=a.parse(i,n)}catch(t){e=t}return n.highlight=s,e?r(e):r(null,t)};if(!s||s.length<3)return u();if(delete n.highlight,!o)return u();for(;c<i.length;c++)!function(e){"code"!==e.type?--o||u():s(e.text,e.lang,function(t,n){return t?u(t):null==n||n===e.text?--o||u():(e.text=n,e.escaped=!0,void(--o||u()))})}(i[c])}else try{return n&&(n=f({},h.defaults,n)),a.parse(t.lex(e,n),n)}catch(e){if(e.message+="\nPlease report this to https://github.com/chjj/marked.",(n||h.defaults).silent)return"<p>An error occured:</p><pre>"+l(e.message+"",!0)+"</pre>";throw e}}var d={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:u,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:u,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:u,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};d.bullet=/(?:[*+-]|\d+\.)/,d.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,d.item=c(d.item,"gm")(/bull/g,d.bullet)(),d.list=c(d.list)(/bull/g,d.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+d.def.source+")")(),d.blockquote=c(d.blockquote)("def",d.def)(),d._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",d.html=c(d.html)("comment",/<!--[\s\S]*?-->/)("c
function x(e,t,n,r,i){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var a=1,l=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,l/=2,s/=2,n/=2}var c;if(i){var u=-1;for(c=n;c<l;c++)if(o(e,c)===o(t,-1===u?0:c-u)){if(-1===u&&(u=c),c-u+1===s)return u*a}else-1!==u&&(c-=c-u),u=-1}else for(n+s>l&&(n=l-s),c=n;c>=0;c--){for(var f=!0,h=0;h<s;h++)if(o(e,c+h)!==o(t,h)){f=!1;break}if(f)return c}return-1}function b(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a<r;++a){var l=parseInt(t.substr(2*a,2),16);if($(l))return a;e[n+a]=l}return a}function w(e,t,n,r){return U(z(t,e.length-n),e,n,r)}function k(e,t,n,r){return U(_(t),e,n,r)}function C(e,t,n,r){return k(e,t,n,r)}function S(e,t,n,r){return U(q(t),e,n,r)}function L(e,t,n,r){return U(j(t,e.length-n),e,n,r)}function T(e,t,n){return 0===t&&n===e.length?V.fromByteArray(e):V.fromByteArray(e.slice(t,n))}function M(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o=e[i],a=null,l=o>239?4:o>223?3:o>191?2:1;if(i+l<=n){var s,c,u,f;switch(l){case 1:o<128&&(a=o);break;case 2:s=e[i+1],128==(192&s)&&(f=(31&o)<<6|63&s)>127&&(a=f);break;case 3:s=e[i+1],c=e[i+2],128==(192&s)&&128==(192&c)&&(f=(15&o)<<12|(63&s)<<6|63&c)>2047&&(f<55296||f>57343)&&(a=f);break;case 4:s=e[i+1],c=e[i+2],u=e[i+3],128==(192&s)&&128==(192&c)&&128==(192&u)&&(f=(15&o)<<18|(63&s)<<12|(63&c)<<6|63&u)>65535&&f<1114112&&(a=f)}}null===a?(a=65533,l=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|1023&a),r.push(a),i+=l}return N(r)}function N(e){var t=e.length;if(t<=Y)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Y));return n}function A(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function E(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function O(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=F(e[o]);return i}function I(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function D(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function H(e,t,n,r,o,a){if(!i.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<a)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function W(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(e,t,n,r,i){return t=+t,n>>>=0,i||W(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(e,t,n,r,23,4),n+4}function P(e,t,n,r,i){return t=+t,n>>>=0,i||W(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(e,t,n,r,52,8),n+8}function R(e){if(e=e.trim().replace(Z,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function F(e){return e<16?"0"+e.toString(16):e.toString(16)}function z(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function _(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function j(e,t){for(var n,r,i,o=[],a=0;a<e.length&&!((t-=2)<0);++a)n=e.charCodeAt(a),r=n>>8,i=n%25
;if(!r.marker.widgetNode&&0==r.from&&r.marker.inclusiveLeft&&ve(e,t,r))return!0}}function ve(e,t,n){if(null==n.to){var r=n.marker.find(1,!0);return ve(e,r.line,K(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i=void 0,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(null==i.to||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&ve(e,t,i))return!0}function ye(e){e=fe(e);for(var t=0,n=e.parent,r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var o=n.parent;o;n=o,o=n.parent)for(var a=0;a<o.children.length;++a){var l=o.children[a];if(l==n)break;t+=l.height}return t}function xe(e){if(0==e.height)return 0;for(var t,n=e.text.length,r=e;t=se(r);){var i=t.find(0,!0);r=i.from.line,n+=i.from.ch-i.to.ch}for(r=e;t=ce(r);){var o=t.find(0,!0);n-=r.text.length-o.from.ch,r=o.to.line,n+=r.text.length-o.to.ch}return n}function be(e){var t=e.display,n=e.doc;t.maxLine=M(n,n.first),t.maxLineLength=xe(t.maxLine),t.maxLineChanged=!0,n.iter(function(e){var n=xe(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function we(e,t,n,r){if(!e)return r(t,n,"ltr");for(var i=!1,o=0;o<e.length;++o){var a=e[o];(a.from<n&&a.to>t||t==n&&a.to==t)&&(r(Math.max(a.from,t),Math.min(a.to,n),1==a.level?"rtl":"ltr"),i=!0)}i||r(t,n,"ltr")}function ke(e,t,n){var r;Oa=null;for(var i=0;i<e.length;++i){var o=e[i];if(o.from<t&&o.to>t)return i;o.to==t&&(o.from!=o.to&&"before"==n?r=i:Oa=i),o.from==t&&(o.from!=o.to&&"before"!=n?r=i:Oa=i)}return null!=r?r:Oa}function Ce(e,t){var n=e.order;return null==n&&(n=e.order=Ia(e.text,t)),n}function Se(e,t,n){var r=S(e.text,t+n,n);return r<0||r>e.text.length?null:r}function Le(e,t,n){var r=Se(e,t.ch,n);return null==r?null:new W(t.line,r,n<0?"after":"before")}function Te(e,t,n,r,i){if(e){var o=Ce(n,t.doc.direction);if(o){var a,l=i<0?m(o):o[0],s=i<0==(1==l.level),c=s?"after":"before";if(l.level>0){var u=Yt(t,n);a=i<0?n.text.length-1:0;var f=Zt(t,u,a).top;a=L(function(e){return Zt(t,u,e).top==f},i<0==(1==l.level)?l.from:l.to-1,a),"before"==c&&(a=Se(n,a,1,!0))}else a=i<0?l.to:l.from;return new W(r,a,c)}}return new W(r,i<0?n.text.length:0,i<0?"before":"after")}function Me(e,t,n,r){var i=Ce(t,e.doc.direction);if(!i)return Le(t,n,r);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=ke(i,n.ch,n.sticky),a=i[o];if("ltr"==e.doc.direction&&a.level%2==0&&(r>0?a.to>n.ch:a.from<n.ch))return Le(t,n,r);var l,s=function(e,n){return Se(t,e instanceof W?e.ch:e,n)},c=function(n){return e.options.lineWrapping?(l=l||Yt(e,t),gn(e,t,l,n)):{begin:0,end:t.text.length}},u=c("before"==n.sticky?s(n,-1):n.ch);if("rtl"==e.doc.direction||1==a.level){var f=1==a.level==r<0,h=s(n,f?1:-1);if(null!=h&&(f?h<=a.to&&h<=u.end:h>=a.from&&h>=u.begin)){var d=f?"before":"after";return new W(n.line,h,d)}}var p=function(e,t,r){for(var o=function(e,t){return t?new W(n.line,s(e,1),"before"):new W(n.line,e,"after")};e>=0&&e<i.length;e+=t){var a=i[e],l=t>0==(1!=a.level),c=l?r.begin:s(r.end,-1);if(a.from<=c&&c<a.to)return o(c,l);if(c=l?a.from:s(a.to,-1),r.begin<=c&&c<r.end)return o(c,l)}},m=p(o+r,r,u);if(m)return m;var g=r>0?u.end:s(u.begin,-1);return null==g||r>0&&g==t.text.length||!(m=p(r>0?0:i.length-1,r,c(g)))?null:m}function Ne(e,t){return e._handlers&&e._handlers[t]||Da}function Ae(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var r=e._handlers,i=r&&r[t];if(i){var o=h(i,n);o>-1&&(r[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function Ee(e,t){var n=Ne(e,t);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),i=0;i<n.length;++i)n[i].apply(null,r)}function Oe(e,t,n){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ee(e,n||t.type,e,t),Pe(t)||t.codemirrorIgnore}function Ie(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)-1==h(n,t[r])&&n.push(t[r])}function De(e,t){return N
;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function On(e){e.state.focused||(e.display.input.focus(),Dn(e))}function In(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Hn(e))},100)}function Dn(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Ee(e,"focus",e,t),e.state.focused=!0,l(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),Qo&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),En(e))}function Hn(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Ee(e,"blur",e,t),e.state.focused=!1,ga(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Wn(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=wn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",a=0;a<n.length;a++)if(!n[a].hidden){e.options.fixedGutter&&(n[a].gutter&&(n[a].gutter.style.left=o),n[a].gutterBackground&&(n[a].gutterBackground.style.left=o));var l=n[a].alignable;if(l)for(var s=0;s<l.length;s++)l[s].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}}function Bn(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=H(e.options,t.first+t.size-1),i=e.display;if(n.length!=i.lineNumChars){var o=i.measure.appendChild(r("div",[r("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),a=o.firstChild.offsetWidth,l=o.offsetWidth-a;return i.lineGutter.style.width="",i.lineNumInnerWidth=Math.max(a,i.lineGutter.offsetWidth-l)+1,i.lineNumWidth=i.lineNumInnerWidth+l,i.lineNumChars=i.lineNumInnerWidth?n.length:-1,i.lineGutter.style.width=i.lineNumWidth+"px",Mr(e),!0}return!1}function Pn(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var i=t.view[r],o=void 0;if(!i.hidden){if(Zo&&Jo<8){var a=i.node.offsetTop+i.node.offsetHeight;o=a-n,n=a}else{var l=i.node.getBoundingClientRect();o=l.bottom-l.top}var s=i.line.height-o;if(o<2&&(o=yn(t)),(s>.001||s<-.001)&&(E(i.line,o),Rn(i.line),i.rest))for(var c=0;c<i.rest.length;c++)Rn(i.rest[c])}}}function Rn(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.parentNode.offsetHeight}function Fn(e,t,n){var r=n&&null!=n.top?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Ft(e));var i=n&&null!=n.bottom?n.bottom:r+e.wrapper.clientHeight,o=I(t,r),a=I(t,i);if(n&&n.ensure){var l=n.ensure.from.line,s=n.ensure.to.line;l<o?(o=l,a=I(t,ye(M(t,l))+e.wrapper.clientHeight)):Math.min(s,t.lastLine())>=a&&(o=I(t,ye(M(t,s))-e.wrapper.clientHeight),a=s)}return{from:o,to:Math.max(a,o+1)}}function zn(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,Vo||Lr(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),Vo&&Lr(e),br(e,100))}function _n(e,t,n){(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,Wn(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function jn(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}}function qn(e){var t=jn(e);return t.x*=Ja,t.y*=Ja,t}function Un(e,t){var n=jn(t),r=n.x,i=n.y,o=e.display,a=o.scroller,l=a.scrollWidth>a.clientWidth,s=a.scrollHeight>a.clientHeight;if(r&&l||i&&s){if(i&&ca&&Qo)e:for(var c=t.target,u=o.view;c!=a;c=c.parentNode)for(var f=0;f<u.length;f++)if(u[f].node==c){e.display.currentWheelTarget=c;break e}if(r&&!Vo&&!na&&null!=Ja)return i&&s&&zn(e,Math.max(0,Math.min(a.scrollT
var o=e[i],a=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var l=0;l<o.ranges.length;l++)Ai(o.ranges[l].anchor,t,n,r),Ai(o.ranges[l].head,t,n,r)}else{for(var s=0;s<o.changes.length;++s){var c=o.changes[s];if(n<c.from.line)c.from=W(c.from.line+r,c.from.ch),c.to=W(c.to.line+r,c.to.ch);else if(t<=c.to.line){a=!1;break}}a||(e.splice(0,i+1),i=0)}}}function Oi(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;Ei(e.done,n,r,i),Ei(e.undone,n,r,i)}function Ii(e,t,n,r){var i=t,o=t;return"number"==typeof t?o=M(e,_(e,t)):i=O(t),null==i?null:(r(o,i)&&e.cm&&mr(e.cm,i,n),o)}function Di(e,t,n){ye(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Qn(e,null,n)}function Hi(e,t,n,r){var i=new sl(e,n,r),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),Ii(e,t,"widget",function(t){var n=t.widgets||(t.widgets=[]);if(null==i.insertAt?n.push(i):n.splice(Math.min(n.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,o&&!ge(e,t)){var r=ye(t)<e.scrollTop;E(t,t.height+Pt(i)),r&&Qn(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),Ct(o,"lineWidgetAdded",o,i,"number"==typeof t?t:O(t)),i}function Wi(e,t,n,r,o){if(r&&r.shared)return Bi(e,t,n,r,o);if(e.cm&&!e.cm.curOp)return fr(e.cm,Wi)(e,t,n,r,o);var a=new ul(e,o),l=B(t,n);if(r&&u(r,a,!1),l>0||0==l&&!1!==a.clearWhenEmpty)return a;if(a.replacedWith&&(a.collapsed=!0,a.widgetNode=i("span",[a.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||a.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(a.widgetNode.insertLeft=!0)),a.collapsed){if(ue(e,t.line,t,n,a)||t.line!=n.line&&ue(e,n.line,t,n,a))throw new Error("Inserting collapsed marker partially overlapping an existing one");$()}a.addToHistory&&Yr(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var s,c=t.line,f=e.cm;if(e.iter(c,n.line+1,function(e){f&&a.collapsed&&!f.options.lineWrapping&&fe(e)==f.display.maxLine&&(s=!0),a.collapsed&&c!=t.line&&E(e,0),Y(e,new V(a,c==t.line?t.ch:null,c==n.line?n.ch:null)),++c}),a.collapsed&&e.iter(t.line,n.line+1,function(t){ge(e,t)&&E(t,0)}),a.clearOnEnter&&Ha(a,"beforeCursorEnter",function(){return a.clear()}),a.readOnly&&(G(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),a.collapsed&&(a.id=++cl,a.atomic=!0),f){if(s&&(f.curOp.updateMaxLine=!0),a.collapsed)pr(f,t.line,n.line+1);else if(a.className||a.title||a.startStyle||a.endStyle||a.css)for(var h=t.line;h<=n.line;h++)mr(f,h,"text");a.atomic&&mi(f.doc),Ct(f,"markerAdded",f,a)}return a}function Bi(e,t,n,r,i){r=u(r),r.shared=!1;var o=[Wi(e,t,n,r,i)],a=o[0],l=r.widgetNode;return jr(e,function(e){l&&(r.widgetNode=l.cloneNode(!0)),o.push(Wi(e,j(e,t),j(e,n),r,i));for(var s=0;s<e.linked.length;++s)if(e.linked[s].isParent)return;a=m(o)}),new fl(o,a)}function Pi(e){return e.findMarks(W(e.first,0),e.clipPos(W(e.lastLine())),function(e){return e.parent})}function Ri(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.find(),o=e.clipPos(i.from),a=e.clipPos(i.to);if(B(o,a)){var l=Wi(e,o,a,r.primary,r.primary.type);r.markers.push(l),l.parent=r}}}function Fi(e){for(var t=0;t<e.length;t++)!function(t){var n=e[t],r=[n.primary.doc];jr(n.primary.doc,function(e){return r.push(e)});for(var i=0;i<n.markers.length;i++){var o=n.markers[i];-1==h(r,o.doc)&&(o.parent=null,n.markers.splice(i--,1))}}(t)}function zi(e){var t=this;if(qi(t),!Oe(t,e)&&!Rt(t.display,e)){We(e),Zo&&(pl=+new Date);var n=Sn(t,e,!0),r=e.dataTransfer.files;if(n&&!t.isReadOnly())if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,o=Array(i),a=0,l=0;l<i;++l)!function(e,r){if(!t.options.allowDropFileTypes||-1!=h(t.options.allowDropFileTypes,e.type)){var l=new FileReader;l.onload=fr(t,function(){var e=l.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[r]=e,++a==i){n=j(t.doc,n);var s={from:n,to:n,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};ki(t.doc,s),fi(t.doc,Ir(n,Dr(s)))}}),l.readAsText(e)}}(r[l],l);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var s=e.dataTransfer.getData("Text");if(s){var c;if(t.state.draggingText&&
if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||Da).concat(n)}},Wa=function(){if(Zo&&Jo<9)return!1;var e=r("div");return"draggable"in e||"dragDrop"in e}(),Ba=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),t+=a+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},Pa=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Ra=function(){var e=r("div");return"oncopy"in e||(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Fa=null,za={},_a={},ja={},qa=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};qa.prototype.eol=function(){return this.pos>=this.string.length},qa.prototype.sol=function(){return this.pos==this.lineStart},qa.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},qa.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},qa.prototype.eat=function(e){var t=this.string.charAt(this.pos);if("string"==typeof e?t==e:t&&(e.test?e.test(t):e(t)))return++this.pos,t},qa.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},qa.prototype.eatSpace=function(){for(var e=this,t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++e.pos;return this.pos>t},qa.prototype.skipToEnd=function(){this.pos=this.string.length},qa.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},qa.prototype.backUp=function(e){this.pos-=e},qa.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=f(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?f(this.string,this.lineStart,this.tabSize):0)},qa.prototype.indentation=function(){return f(this.string,null,this.tabSize)-(this.lineStart?f(this.string,this.lineStart,this.tabSize):0)},qa.prototype.match=function(e,t,n){if("string"!=typeof e){var r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e};if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},qa.prototype.current=function(){return this.string.slice(this.start,this.pos)},qa.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}};var Ua=function(e,t,n){this.text=e,re(this,t),this.height=n?n(this):1};Ua.prototype.lineNo=function(){return O(this)},He(Ua);var Ga,$a={},Va={},Ka=null,Xa=null,Ya={left:0,right:0,top:0,bottom:0},Za=0,Ja=null;Zo?Ja=-.53:Vo?Ja=15:ta?Ja=-.7:ra&&(Ja=-1/3);var Qa=function(e,t,n){this.cm=n;var i=this.vert=r("div",[r("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=r("div",[r("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(i),e(o),Ha(i,"scroll",function(){i.clientHeight&&t(i.scrollTop,"vertical")}),Ha(o,"scroll",function(){o.clientWidth&&t(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,Zo&&Jo<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Qa.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstC
d&&null==e.anchorNode?e.addRange(d):Vo&&this.startGracePeriod()),this.rememberSelection()}},Ol.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},Ol.prototype.showMultipleSelections=function(e){n(this.cm.display.cursorDiv,e.cursors),n(this.cm.display.selectionDiv,e.selection)},Ol.prototype.rememberSelection=function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Ol.prototype.selectionInEditor=function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return o(this.div,t)},Ol.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()||this.showSelection(this.prepareSelection(),!0),this.div.focus())},Ol.prototype.blur=function(){this.div.blur()},Ol.prototype.getField=function(){return this.div},Ol.prototype.supportsTouch=function(){return!0},Ol.prototype.receivedFocus=function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():ur(this.cm,function(){return t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},Ol.prototype.selectionChanged=function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Ol.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;if(la&&ta&&this.cm.options.gutters.length&&Fo(e.anchorNode))return this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),void this.focus();if(!this.composing){this.rememberSelection();var n=jo(t,e.anchorNode,e.anchorOffset),r=jo(t,e.focusNode,e.focusOffset);n&&r&&ur(t,function(){hi(t.doc,Ir(n,r),Ca),(n.bad||r.bad)&&(t.curOp.selectionChanged=!0)})}}},Ol.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,n=e.doc.sel.primary(),r=n.from(),i=n.to();if(0==r.ch&&r.line>e.firstLine()&&(r=W(r.line-1,M(e.doc,r.line-1).length)),i.ch==M(e.doc,i.line).text.length&&i.line<e.lastLine()&&(i=W(i.line+1,0)),r.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o,a,l;r.line==t.viewFrom||0==(o=Ln(e,r.line))?(a=O(t.view[0].line),l=t.view[0].node):(a=O(t.view[o].line),l=t.view[o-1].node.nextSibling);var s,c,u=Ln(e,i.line);if(u==t.view.length-1?(s=t.viewTo-1,c=t.lineDiv.lastChild):(s=O(t.view[u+1].line)-1,c=t.view[u+1].node.previousSibling),!l)return!1;for(var f=e.doc.splitLines(_o(e,l,c,a,s)),h=N(e.doc,W(a,0),W(s,M(e.doc,s).text.length));f.length>1&&h.length>1;)if(m(f)==m(h))f.pop(),h.pop(),s--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),a++}for(var d=0,p=0,g=f[0],v=h[0],y=Math.min(g.length,v.length);d<y&&g.charCodeAt(d)==v.charCodeAt(d);)++d;for(var x=m(f),b=m(h),w=Math.min(x.length-(1==f.length?d:0),b.length-(1==h.length?d:0));p<w&&x.charCodeAt(x.length-p-1)==b.charCodeAt(b.length-p-1);)++p;if(1==f.length&&1==h.length&&a==r.line)for(;d&&d>r.ch&&x.charCodeAt(x.length-p-1)==b.charCodeAt(b.length-p-1);)d--,p++;f[f.length-1]=x.slice(0,x.length-p).replace(/^\u200b+/,""),f[0]=f[0].slice(d).replace(/\u200b+$/,"");var k=W(a,d),C=W(s,h.length?m(h).length-p:0);return f.length>1||f[0]||B(k,C)?(Ni(e.doc,f,k,C,"+input"),!0):void 0},Ol.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ol.prototype.reset=function(){this.forceCompositionEnd()},Ol.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Ol.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeo
if("!"===a&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return r.imageMarker=!0,r.image=!0,n.highlightFormatting&&(r.formatting="image"),f(r);if("["===a&&r.imageMarker&&t.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return r.imageMarker=!1,r.imageAltText=!0,n.highlightFormatting&&(r.formatting="image"),f(r);if("]"===a&&r.imageAltText){n.highlightFormatting&&(r.formatting="image");var g=f(r);return r.imageAltText=!1,r.image=!1,r.inline=r.f=m,g}if("["===a&&t.match(/[^\]]*\](\(.*\)| ?\[.*?\])/,!1)&&!r.image)return r.linkText=!0,n.highlightFormatting&&(r.formatting="link"),f(r);if("]"===a&&r.linkText&&t.match(/\(.*?\)| ?\[.*?\]/,!1)){n.highlightFormatting&&(r.formatting="link");var g=f(r);return r.linkText=!1,r.inline=r.f=m,g}if("<"===a&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=p,n.highlightFormatting&&(r.formatting="link");var g=f(r);return g?g+=" ":g="",g+k.linkInline}if("<"===a&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=p,n.highlightFormatting&&(r.formatting="link");var g=f(r);return g?g+=" ":g="",g+k.linkEmail}if("<"===a&&t.match(/^(!--|[a-z]+(?:\s+[a-z_:.\-]+(?:\s*=\s*[^ >]+)?)*\s*>)/i,!1)){var y=t.string.indexOf(">",t.pos);if(-1!=y){/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(t.string.substring(t.start,y))&&(r.md_inside=!0)}return t.backUp(1),r.htmlState=e.startState(b),o(t,r,c)}if("<"===a&&t.match(/^\/\w*?>/))return r.md_inside=!1,"tag";if("*"===a||"_"===a){for(var x=1,w=1==t.pos?" ":t.string.charAt(t.pos-2);x<3&&t.eat(a);)x++;var C=t.peek()||" ",S=!/\s/.test(C)&&(!O.test(C)||/\s/.test(w)||O.test(w)),L=!/\s/.test(w)&&(!O.test(w)||/\s/.test(C)||O.test(C)),M=null,N=null;if(x%2&&(r.em||!S||"*"!==a&&L&&!O.test(w)?r.em!=a||!L||"*"!==a&&S&&!O.test(C)||(M=!1):M=!0),x>1&&(r.strong||!S||"*"!==a&&L&&!O.test(w)?r.strong!=a||!L||"*"!==a&&S&&!O.test(C)||(N=!1):N=!0),null!=N||null!=M){n.highlightFormatting&&(r.formatting=null==M?"strong":null==N?"em":"strong em"),!0===M&&(r.em=a),!0===N&&(r.strong=a);var d=f(r);return!1===M&&(r.em=!1),!1===N&&(r.strong=!1),d}}else if(" "===a&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return f(r);t.backUp(1)}if(n.strikethrough)if("~"===a&&t.eatWhile(a)){if(r.strikethrough){n.highlightFormatting&&(r.formatting="strikethrough");var d=f(r);return r.strikethrough=!1,d}if(t.match(/^[^\s]/,!1))return r.strikethrough=!0,n.highlightFormatting&&(r.formatting="strikethrough"),f(r)}else if(" "===a&&t.match(/^~~/,!0)){if(" "===t.peek())return f(r);t.backUp(2)}return" "===a&&(t.match(/ +$/,!1)?r.trailingSpace++:r.trailingSpace&&(r.trailingSpaceNewLine=!0)),f(r)}function p(e,t){if(">"===e.next()){t.f=t.inline=d,n.highlightFormatting&&(t.formatting="link");var r=f(t);return r?r+=" ":r="",r+k.linkInline}return e.match(/^[^>]+/,!0),k.linkInline}function m(e,t){if(e.eatSpace())return null;var r=e.next();return"("===r||"["===r?(t.f=t.inline=g("("===r?")":"]"),n.highlightFormatting&&(t.formatting="link-string"),t.linkHref=!0,f(t)):"error"}function g(e){return function(t,r){if(t.next()===e){r.f=r.inline=d,n.highlightFormatting&&(r.formatting="link-string");var i=f(r);return r.linkHref=!1,i}return t.match(I[e]),r.linkHref=!0,f(r)}}function v(e,t){return e.match(/^([^\]\\]|\\.)*\]:/,!1)?(t.f=y,e.next(),n.highlightFormatting&&(t.formatting="link"),t.linkText=!0,f(t)):i(e,t,d)}function y(e,t){if(e.match(/^\]:/,!0)){t.f=t.inline=x,n.highlightFormatting&&(t.formatting="link");var r=f(t);return t.linkText=!1,r}return e.match(/^([^\]\\]|\\.)+/,!0),k.linkText}function x(e,t){return e.eatSpace()?null:(e.match(/^[^\s]+/,!0),void 0===e.peek()?t.linkTitle=!0:e.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),t.f=t.inline=d,k.linkHref+" url")}var b=e.getMode(t,"text/html"),w="null"==b.name;void 0===n.highlightFormatting&&(n.highlightFormatting=!1),void 0===n.maxBlockquoteDepth&&(n.maxBlockquoteDepth=0),void 0===n.taskLists&&(n.taskLists=!1),void 0===n.strikethrough&&(n.strikethrough=!1),void 0===n.tokenTypeOverrides&&(n.tokenTypeOverrides={});var k={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:
;o&&/editor-preview/.test(o.className)||(o=document.createElement("div"),o.className="editor-preview",n.appendChild(o)),/editor-preview-active/.test(o.className)?(o.className=o.className.replace(/\s*editor-preview-active\s*/g,""),i&&(i.className=i.className.replace(/\s*active\s*/g,""),r.className=r.className.replace(/\s*disabled-for-preview*/g,""))):(setTimeout(function(){o.className+=" editor-preview-active"},1),i&&(i.className+=" active",r.className+=" disabled-for-preview")),o.innerHTML=e.options.previewRender(e.value(),o),/editor-preview-active-side/.test(t.getWrapperElement().nextSibling.className)&&N(e)}function E(e,t,n,r){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){var i,o=n[0],a=n[1],l=e.getCursor("start"),s=e.getCursor("end");r&&(a=a.replace("#url#",r)),t?(i=e.getLine(l.line),o=i.slice(0,l.ch),a=i.slice(l.ch),e.replaceRange(o+a,{line:l.line,ch:0})):(i=e.getSelection(),e.replaceSelection(o+i+a),l.ch+=o.length,l!==s&&(s.ch+=o.length)),e.setSelection(l,s),e.focus()}}function O(e,t,n){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var r=e.getCursor("start"),i=e.getCursor("end"),o=r.line;o<=i.line;o++)!function(r){var i=e.getLine(r),o=i.search(/[^#]/);i=void 0!==t?o<=0?"bigger"==t?"###### "+i:"# "+i:6==o&&"smaller"==t?i.substr(7):1==o&&"bigger"==t?i.substr(2):"bigger"==t?i.substr(1):"#"+i:1==n?o<=0?"# "+i:o==n?i.substr(o+1):"# "+i.substr(o+1):2==n?o<=0?"## "+i:o==n?i.substr(o+1):"## "+i.substr(o+1):o<=0?"### "+i:o==n?i.substr(o+1):"### "+i.substr(o+1),e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(o);e.focus()}}function I(e,t){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var n=l(e),r=e.getCursor("start"),i=e.getCursor("end"),o={quote:/^(\s*)\>\s+/,"unordered-list":/^(\s*)(\*|\-|\+)\s+/,"ordered-list":/^(\s*)\d+\.\s+/},a={quote:"> ","unordered-list":"* ","ordered-list":"1. "},s=r.line;s<=i.line;s++)!function(r){var i=e.getLine(r);i=n[t]?i.replace(o[t],"$1"):a[t]+i,e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(s);e.focus()}}function D(e,t,n,r){if(!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)){r=void 0===r?n:r;var i,o=e.codemirror,a=l(o),s=n,c=r,u=o.getCursor("start"),f=o.getCursor("end");a[t]?(i=o.getLine(u.line),s=i.slice(0,u.ch),c=i.slice(u.ch),"bold"==t?(s=s.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),c=c.replace(/(\*\*|__)/,"")):"italic"==t?(s=s.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),c=c.replace(/(\*|_)/,"")):"strikethrough"==t&&(s=s.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),c=c.replace(/(\*\*|~~)/,"")),o.replaceRange(s+c,{line:u.line,ch:0},{line:u.line,ch:99999999999999}),"bold"==t||"strikethrough"==t?(u.ch-=2,u!==f&&(f.ch-=2)):"italic"==t&&(u.ch-=1,u!==f&&(f.ch-=1))):(i=o.getSelection(),"bold"==t?(i=i.split("**").join(""),i=i.split("__").join("")):"italic"==t?(i=i.split("*").join(""),i=i.split("_").join("")):"strikethrough"==t&&(i=i.split("~~").join("")),o.replaceSelection(s+i+c),u.ch+=n.length,f.ch=u.ch+i.length),o.setSelection(u,f),o.focus()}}function H(e){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className))for(var t,n=e.getCursor("start"),r=e.getCursor("end"),i=n.line;i<=r.line;i++)t=e.getLine(i),t=t.replace(/^[ ]*([# ]+|\*|\-|[> ]+|[0-9]+(.|\)))[ ]*/,""),e.replaceRange(t,{line:i,ch:0},{line:i,ch:99999999999999})}function W(e,t){for(var n in t)t.hasOwnProperty(n)&&(t[n]instanceof Array?e[n]=t[n].concat(e[n]instanceof Array?e[n]:[]):null!==t[n]&&"object"==typeof t[n]&&t[n].constructor===Object?e[n]=W(e[n]||{},t[n]):e[n]=t[n]);return e}function B(e){for(var t=1;t<arguments.length;t++)e=W(e,arguments[t]);return e}function P(e){var t=e.match(/[a-zA-Z0-9_\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g),n=0;if(null===t)return n;for(var r=0;r<t.length;r++)t[r].charCodeAt(0)>=19968?n+=t[r].length:n+=1;return n}function R(e){e=e||{},e.parent=this;var t=!0;if(!1===e.autoDownloadFontAwesome&&(t=!1),!0!==e.autoDownloadFontAwesome)for(var n=document.styleSheets,r=0;r<n.length;r++)n