!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.CodeMirror=t()}(this,function(){"use strict";function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function t(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function n(e,n){return t(e).appendChild(n)}function i(e,t,n,i){var r=document.createElement(e);if(n&&(r.className=n),i&&(r.style.cssText=i),"string"==typeof t)r.appendChild(document.createTextNode(t));else if(t)for(var o=0;os||s>=t)return a+(t-o);a+=s-o,a+=n-a%n,o=s+1}}function h(e,t){for(var n=0;n=t)return i+Math.min(a,t-r);if(r+=o-i,r+=n-r%n,i=o+1,r>=t)return i}}function p(e){for(;Qs.length<=e;)Qs.push(g(Qs)+" ");return Qs[e]}function g(e){return e[e.length-1]}function m(e,t){for(var n=[],i=0;i"€"&&(e.toUpperCase()!=e.toLowerCase()||Ys.test(e))}function w(e,t){return t?t.source.indexOf("\\w")>-1&&x(e)?!0:t.test(e):x(e)}function k(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function C(e){return e.charCodeAt(0)>=768&&Zs.test(e)}function _(e,t,n){for(;(0>n?t>0:tn?-1:1;;){if(t==n)return t;var r=(t+n)/2,o=0>i?Math.ceil(r):Math.floor(r);if(o==t)return e(o)?t:n;e(o)?n=o:t=o+i}}function S(e,t,n,i){if(!e)return i(t,n,"ltr",0);for(var r=!1,o=0;ot||t==n&&a.to==t)&&(i(Math.max(a.from,t),Math.min(a.to,n),1==a.level?"rtl":"ltr",o),r=!0)}r||i(t,n,"ltr")}function T(e,t,n){var i;el=null;for(var r=0;rt)return r;o.to==t&&(o.from!=o.to&&"before"==n?i=r:el=r),o.from==t&&(o.from!=o.to&&"before"!=n?i=r:el=r)}return null!=i?i:el}function E(e,t){var n=e.order;return null==n&&(n=e.order=tl(e.text,t)),n}function M(e,t){return e._handlers&&e._handlers[t]||nl}function A(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var i=e._handlers,r=i&&i[t];if(r){var o=h(r,n);o>-1&&(i[t]=r.slice(0,o).concat(r.slice(o+1)))}}}function L(e,t){var n=M(e,t);if(n.length)for(var i=Array.prototype.slice.call(arguments,2),r=0;r0}function I(e){e.prototype.on=function(e,t){il(this,e,t)},e.prototype.off=function(e,t){A(this,e,t)}}function O(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function P(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function z(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function H(e){O(e),P(e)}function B(e){return e.target||e.srcElement}function V(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),js&&e.ctrlKey&&1==t&&(t=3),t}function F(e){if(null==Ws){var t=i("span","​");n(e,i("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Ws=t.offsetWidth<=1&&t.offsetHeight>2&&!(ks&&8>Cs))}var r=Ws?i("span","​"):i("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function R(e){if(null!=qs)return qs;var i=n(e,document.createTextNode("AخA")),r=zs(i,0,1).getBoundingClientRect(),o=zs(i,1,2).getBoundingClientRect();return t(e),r&&r.left!=r.right?qs=o.right-r.right<3:!1}function W(e){if(null!=ll)return ll;var t=n(e,i("span","x")),r=t.getBoundingClientRect(),o=zs(t,0,1).getBoundingClientRect();return ll=Math.abs(r.left-o.left)>1}function q(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),cl[e]=t}function U(e,t){ul[e]=t}function J(e){if("string"==typeof e&&ul.hasOwnProperty(e))e=ul[e];else if(e&&"string"==typeof e.name&&ul.hasOwnProperty(e.name)){var t=ul[e.name];"string"==typeof t&&(t={name:t}),e=b(t,e),e.name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return J("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return J("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function G(e,t){t=J(t);var n=cl[t.name];if(!n)return G(e,"text/plain");var i=n(e,t);if(dl.hasOwnProperty(t.name)){var r=dl[t.name];for(var o in r)r.hasOwnProperty(o)&&(i.hasOwnProperty(o)&&(i["_"+o]=i[o]),i[o]=r[o])}if(i.name=t.name,t.helperType&&(i.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)i[a]=t.modeProps[a];return i}function K(e,t){var n=dl.hasOwnProperty(e)?dl[e]:dl[e]={};u(t,n)}function X(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var i in t){var r=t[i];r instanceof Array&&(r=r.concat([])),n[i]=r}return n}function Q(e,t){for(var n;e.innerMode&&(n=e.innerMode(t),n&&n.mode!=e);)t=n.state,e=n.mode;return n||{mode:e,state:t}}function Y(e,t,n){return e.startState?e.startState(t,n):!0}function Z(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var i=0;;++i){var r=n.children[i],o=r.chunkSize();if(o>t){n=r;break}t-=o}return n.lines[t]}function et(e,t,n){var i=[],r=t.line;return e.iter(t.line,n.line+1,function(e){var o=e.text;r==n.line&&(o=o.slice(0,n.ch)),r==t.line&&(o=o.slice(t.ch)),i.push(o),++r}),i}function tt(e,t,n){var i=[];return e.iter(t,n,function(e){i.push(e.text)}),i}function nt(e,t){var n=t-e.height;if(n)for(var i=e;i;i=i.parent)i.height+=n}function it(e){if(null==e.parent)return null;for(var t=e.parent,n=h(t.lines,e),i=t.parent;i;t=i,i=i.parent)for(var r=0;i.children[r]!=t;++r)n+=i.children[r].chunkSize();return n+t.first}function rt(e,t){var n=e.first;e:do{for(var i=0;it){e=r;continue e}t-=o,n+=r.chunkSize()}return n}while(!e.lines);for(var a=0;at)break;t-=l}return n+a}function ot(e,t){return t>=e.first&&tn?st(n,Z(e,n).text.length):gt(t,Z(e,t.line).text.length)}function gt(e,t){var n=e.ch;return null==n||n>t?st(e.line,t):0>n?st(e.line,0):e}function mt(e,t){for(var n=[],i=0;ic;){var i=r[l];i>e&&r.splice(l,1,e,r[l+1],i),l+=2,c=Math.min(e,i)}if(t)if(s.opaque)r.splice(n,l-n,e,"overlay "+t),l=n+2;else for(;l>n;n+=2){var o=r[n+1];r[n+1]=(o?o+" ":"")+"overlay "+t}},o),n.state=a,n.baseTokens=null,n.baseTokenPos=1},l=0;le.options.maxHighlightLength&&X(e.doc.mode,i.state),o=vt(e,t,i);r&&(i.state=r),t.stateAfter=i.save(!r),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function bt(e,t,n){var i=e.doc,r=e.display;if(!i.mode.startState)return new pl(i,!0,t);var o=St(e,t,n),a=o>i.first&&Z(i,o-1).stateAfter,s=a?pl.fromSaved(i,a,o):new pl(i,Y(i.mode),o);return i.iter(o,t,function(n){xt(e,n.text,s);var i=s.line;n.stateAfter=i==t-1||0==i%5||i>=r.viewFrom&&ir;r++){i&&(i[0]=Q(e,n).mode);var o=e.token(t,n);if(t.pos>t.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}function Ct(e,t,n,i){var r,o=e.doc,a=o.mode;t=pt(o,t);var s,l=Z(o,t.line),c=bt(e,t.line,n),u=new hl(l.text,e.options.tabSize,c);for(i&&(s=[]);(i||u.pose.options.maxHighlightLength?(s=!1,a&&xt(e,t,i,d.pos),d.pos=t.length,l=null):l=_t(kt(n,d,i.state,h),o),h){var f=h[0].name;f&&(l="m-"+(l?f+" "+l:f))}if(!s||u!=l){for(;ca;--s){if(s<=o.first)return o.first;var l=Z(o,s-1),c=l.stateAfter;if(c&&(!n||s+(c instanceof fl?c.lookAhead:0)<=o.modeFrontier))return s;var u=d(l.text,null,e.options.tabSize);(null==r||i>u)&&(r=s-1,i=u)}return r}function Tt(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontiern;i--){var r=Z(e,i).stateAfter;if(r&&(!(r instanceof fl)||i+r.lookAhead=t:o.to>t);(i||(i=[])).push(new At(a,o.from,l?null:o.to))}}return i}function It(e,t,n){var i;if(e)for(var r=0;r=t:o.to>t);if(s||o.from==t&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var l=null==o.from||(a.inclusiveLeft?o.from<=t:o.from0&&s)for(var w=0;wk;++k)y.push(b);y.push(l)}return y}function Pt(e){for(var t=0;t0)){var u=[l,1],d=lt(c.from,s.from),f=lt(c.to,s.to);(0>d||!a.inclusiveLeft&&!d)&&u.push({from:c.from,to:s.from}),(f>0||!a.inclusiveRight&&!f)&&u.push({from:s.to,to:c.to}),r.splice.apply(r,u),l+=u.length-3}}return r}function Ht(e){var t=e.markedSpans;if(t){for(var n=0;nt)&&(!n||Rt(n,o.marker)<0)&&(n=o.marker)}return n}function Gt(e,t,n,i,r){var o=Z(e,t),a=vl&&o.markedSpans;if(a)for(var s=0;s=0&&0>=d||0>=u&&d>=0)&&(0>=u&&(l.marker.inclusiveRight&&r.inclusiveLeft?lt(c.to,n)>=0:lt(c.to,n)>0)||u>=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?lt(c.from,i)<=0:lt(c.from,i)<0)))return!0}}}function Kt(e){for(var t;t=qt(e);)e=t.find(-1,!0).line;return e}function Xt(e){for(var t;t=Ut(e);)e=t.find(1,!0).line;return e}function Qt(e){for(var t,n;t=Ut(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function Yt(e,t){var n=Z(e,t),i=Kt(n);return n==i?t:it(i)}function Zt(e,t){if(t>e.lastLine())return t;var n,i=Z(e,t);if(!en(e,i))return t;for(;n=Ut(i);)i=n.find(1,!0).line;return it(i)+1}function en(e,t){var n=vl&&t.markedSpans;if(n)for(var i=void 0,r=0;rt.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function an(e,t,n,i){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),Ht(e),Bt(e,n);var r=i?i(e):1;r!=e.height&&nt(e,r)}function sn(e){e.parent=null,Ht(e)}function ln(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?wl:xl;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function cn(e,t){var n=r("span",null,null,_s?"padding-right: .1px":null),i={pre:r("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var a=o?t.rest[o-1]:t.line,s=void 0;i.pos=0,i.addToken=dn,R(e.display.measure)&&(s=E(a,e.doc.direction))&&(i.addToken=fn(i.addToken,s)),i.map=[];var c=t!=e.display.externalMeasured&&it(a);gn(a,i,yt(e,a,c)),a.styleClasses&&(a.styleClasses.bgClass&&(i.bgClass=l(a.styleClasses.bgClass,i.bgClass||"")),a.styleClasses.textClass&&(i.textClass=l(a.styleClasses.textClass,i.textClass||""))),0==i.map.length&&i.map.push(0,0,i.content.appendChild(F(e.display.measure))),0==o?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(_s){var u=i.content.lastChild;(/\bcm-tab\b/.test(u.className)||u.querySelector&&u.querySelector(".cm-tab"))&&(i.content.className="cm-tab-wrap-hack")}return L(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=l(i.pre.className,i.textClass||"")),i}function un(e){var t=i("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function dn(e,t,n,r,o,a,s){if(t){var l,c=e.splitSpaces?hn(t,e.trailingSpace):t,u=e.cm.state.specialChars,d=!1;if(u.test(t)){l=document.createDocumentFragment();for(var h=0;;){u.lastIndex=h;var f=u.exec(t),g=f?f.index-h:t.length-h;if(g){var m=document.createTextNode(c.slice(h,h+g));ks&&9>Cs?l.appendChild(i("span",[m])):l.appendChild(m),e.map.push(e.pos,e.pos+g,m),e.col+=g,e.pos+=g}if(!f)break;h+=g+1;var v=void 0;if(" "==f[0]){var y=e.cm.options.tabSize,b=y-e.col%y;v=l.appendChild(i("span",p(b),"cm-tab")),v.setAttribute("role","presentation"),v.setAttribute("cm-text"," "),e.col+=b}else"\r"==f[0]||"\n"==f[0]?(v=l.appendChild(i("span","\r"==f[0]?"␍":"␤","cm-invalidchar")),v.setAttribute("cm-text",f[0]),e.col+=1):(v=e.cm.options.specialCharPlaceholder(f[0]),v.setAttribute("cm-text",f[0]),ks&&9>Cs?l.appendChild(i("span",[v])):l.appendChild(v),e.col+=1);e.map.push(e.pos,e.pos+1,v),e.pos++}}else e.col+=t.length,l=document.createTextNode(c),e.map.push(e.pos,e.pos+t.length,l),ks&&9>Cs&&(d=!0),e.pos+=t.length;if(e.trailingSpace=32==c.charCodeAt(t.length-1),n||r||o||d||a){var x=n||"";r&&(x+=r),o&&(x+=o);var w=i("span",[l],x,a);if(s)for(var k in s)s.hasOwnProperty(k)&&"style"!=k&&"class"!=k&&w.setAttribute(k,s[k]);return e.content.appendChild(w)}e.content.appendChild(l)}}function hn(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,i="",r=0;rc&&d.from<=c));h++);if(d.to>=u)return e(n,i,r,o,a,s,l);e(n,i.slice(0,d.to-c),r,o,null,s,l),o=null,i=i.slice(d.to-c),c=d.to}}}function pn(e,t,n,i){var r=!i&&n.widgetNode;r&&e.map.push(e.pos,e.pos+t,r),!i&&e.cm.display.input.needsContentAttribute&&(r||(r=e.content.appendChild(document.createElement("span"))),r.setAttribute("cm-marker",n.id)),r&&(e.cm.display.input.setUneditable(r),e.content.appendChild(r)),e.pos+=t,e.trailingSpace=!1}function gn(e,t,n){var i=e.markedSpans,r=e.text,o=0;if(i)for(var a,s,l,c,u,d,h,f=r.length,p=0,g=1,m="",v=0;;){if(v==p){l=c=u=s="",h=null,d=null,v=1/0;for(var y=[],b=void 0,x=0;xp||k.collapsed&&w.to==p&&w.from==p)){if(null!=w.to&&w.to!=p&&v>w.to&&(v=w.to,c=""),k.className&&(l+=" "+k.className),k.css&&(s=(s?s+";":"")+k.css),k.startStyle&&w.from==p&&(u+=" "+k.startStyle),k.endStyle&&w.to==v&&(b||(b=[])).push(k.endStyle,w.to),k.title&&((h||(h={})).title=k.title),k.attributes)for(var C in k.attributes)(h||(h={}))[C]=k.attributes[C];k.collapsed&&(!d||Rt(d.marker,k)<0)&&(d=w)}else w.from>p&&v>w.from&&(v=w.from)}if(b)for(var _=0;_=f)break;for(var S=Math.min(f,v);;){if(m){var T=p+m.length;if(!d){var E=T>S?m.slice(0,S-p):m;t.addToken(t,E,a?a+l:l,u,p+E.length==v?c:"",s,h)}if(T>=S){m=m.slice(S-p),p=S;break}p=T,u=""}m=r.slice(o,o=n[g++]),a=ln(n[g++],t.cm.options)}}else for(var M=1;Mo;o=i){var a=new mn(e.doc,Z(e.doc,o),o);i=o+a.size,r.push(a)}return r}function yn(e){kl?kl.ops.push(e):e.ownsGroup=kl={ops:[e],delayedCallbacks:[]}}function bn(e){var t=e.delayedCallbacks,n=0;do{for(;nCs&&(e.node.style.zIndex=2)),e.node}function $n(e,t){var n=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(n&&(n+=" CodeMirror-linebackground"),t.background)n?t.background.className=n:(t.background.parentNode.removeChild(t.background),t.background=null);else if(n){var r=_n(t);t.background=r.insertBefore(i("div",null,n),r.firstChild),e.display.input.setUneditable(t.background)}}function Sn(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):cn(e,t)}function Tn(e,t){var n=t.text.className,i=Sn(e,t);t.text==t.node&&(t.node=i.pre),t.text.parentNode.replaceChild(i.pre,t.text),t.text=i.pre,i.bgClass!=t.bgClass||i.textClass!=t.textClass?(t.bgClass=i.bgClass,t.textClass=i.textClass,En(e,t)):n&&(t.text.className=n)}function En(e,t){$n(e,t),t.line.wrapClass?_n(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var n=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=n||""}function Mn(e,t,n,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var o=_n(t);t.gutterBackground=i("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),o.insertBefore(t.gutterBackground,t.text)}var a=t.line.gutterMarkers;if(e.options.lineNumbers||a){var s=_n(t),l=t.gutter=i("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(l),s.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||a&&a["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(i("div",at(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),a)for(var c=0;c2&&o.push((l.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Wn(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var i=0;in)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function qn(e,t){t=Kt(t);var i=it(t),r=e.display.externalMeasured=new mn(e.doc,t,i);r.lineN=i;var o=r.built=cn(e,r);return r.text=o.pre,n(e.display.lineMeasure,o.pre),r}function Un(e,t,n,i){return Kn(e,Gn(e,t),n,i)}function Jn(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&tt?(r=0,o=1,a="left"):l>t?(r=t-s,o=r+1):(c==e.length-3||t==l&&e[c+3]>t)&&(o=l-s,r=o-1,t>=l&&(a="right")),null!=r){if(i=e[c+2],s==l&&n==(i.insertLeft?"left":"right")&&(a=n),"left"==n&&0==r)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)i=e[(c-=3)+2],a="left";if("right"==n&&r==l-s)for(;c=0&&(n=e[r]).left==n.right;r--);return n}function Yn(e,t,n,i){var r,o=Xn(t.map,n,i),a=o.node,s=o.start,l=o.end,c=o.collapse;if(3==a.nodeType){for(var u=0;4>u;u++){for(;s&&C(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+lCs&&0==s&&l==o.coverEnd-o.coverStart?a.parentNode.getBoundingClientRect():Qn(zs(a,s,l).getClientRects(),i),r.left||r.right||0==s)break;l=s,s-=1,c="right"}ks&&11>Cs&&(r=Zn(e.display.measure,r))}else{s>0&&(c=i="right");var d;r=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==i?d.length-1:0]:a.getBoundingClientRect()}if(ks&&9>Cs&&!s&&(!r||!r.left&&!r.right)){var h=a.parentNode.getClientRects()[0];r=h?{left:h.left,right:h.left+xi(e.display),top:h.top,bottom:h.bottom}:_l}for(var f=r.top-t.rect.top,p=r.bottom-t.rect.top,g=(f+p)/2,m=t.view.measure.heights,v=0;v=i.text.length?(c=i.text.length,u="before"):0>=c&&(c=0,u="after"),!l)return a("before"==u?c-1:c,"before"==u);var d=T(l,c,u),h=el,f=s(c,d,"before"==u);return null!=h&&(f.other=s(c,h,"before"!=u)),f}function ui(e,t){var n=0;t=pt(e.doc,t),e.options.lineWrapping||(n=xi(e.display)*t.ch);var i=Z(e.doc,t.line),r=nn(i)+Pn(e.display);return{left:n,right:n,top:r,bottom:r+i.height}}function di(e,t,n,i,r){var o=st(e,t,n);return o.xRel=r,i&&(o.outside=i),o}function hi(e,t,n){var i=e.doc;if(n+=e.display.viewOffset,0>n)return di(i.first,0,null,-1,-1);var r=rt(i,n),o=i.first+i.size-1;if(r>o)return di(i.first+i.size-1,Z(i,o).text.length,null,1,1);0>t&&(t=0);for(var a=Z(i,r);;){var s=mi(e,a,r,t,n),l=Jt(a,s.ch+(s.xRel>0||s.outside>0?1:0));if(!l)return s;var c=l.find(1);if(c.line==r)return c;a=Z(i,r=c.line)}}function fi(e,t,n,i){i-=oi(t);var r=t.text.length,o=$(function(t){return Kn(e,n,t-1).bottom<=i},r,0);return r=$(function(t){return Kn(e,n,t).top>i},o,r),{begin:o,end:r}}function pi(e,t,n,i){n||(n=Gn(e,t));var r=ai(e,t,Kn(e,n,i),"line").top;return fi(e,t,n,r)}function gi(e,t,n,i){return e.bottom<=n?!1:e.top>n?!0:(i?e.left:e.right)>t}function mi(e,t,n,i,r){r-=nn(t);var o=Gn(e,t),a=oi(t),s=0,l=t.text.length,c=!0,u=E(t,e.doc.direction);if(u){var d=(e.options.lineWrapping?yi:vi)(e,t,n,o,u,i,r);c=1!=d.level,s=c?d.from:d.to-1,l=c?d.to:d.from-1}var h,f,p=null,g=null,m=$(function(t){var n=Kn(e,o,t);return n.top+=a,n.bottom+=a,gi(n,i,r,!1)?(n.top<=r&&n.left<=i&&(p=t,g=n),!0):!1},s,l),v=!1;if(g){var y=i-g.left=x.bottom?1:0}return m=_(t.text,m,1),di(n,m,f,v,i-h)}function vi(e,t,n,i,r,o,a){var s=$(function(s){var l=r[s],c=1!=l.level;return gi(ci(e,st(n,c?l.to:l.from,c?"before":"after"),"line",t,i),o,a,!0)},0,r.length-1),l=r[s];if(s>0){var c=1!=l.level,u=ci(e,st(n,c?l.from:l.to,c?"after":"before"),"line",t,i);gi(u,o,a,!0)&&u.top>a&&(l=r[s-1])}return l}function yi(e,t,n,i,r,o,a){var s=fi(e,t,i,a),l=s.begin,c=s.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var u=null,d=null,h=0;h=c||f.to<=l)){var p=1!=f.level,g=Kn(e,i,p?Math.min(c,f.to)-1:Math.max(l,f.from)).right,m=o>g?o-g+1e9:g-o;(!u||d>m)&&(u=f,d=m)}}return u||(u=r[r.length-1]),u.fromc&&(u={from:u.from,to:c,level:u.level}),u}function bi(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==bl){bl=i("pre",null,"CodeMirror-line-like");for(var r=0;49>r;++r)bl.appendChild(document.createTextNode("x")),bl.appendChild(i("br"));bl.appendChild(document.createTextNode("x"))}n(e.measure,bl);var o=bl.offsetHeight/50;return o>3&&(e.cachedTextHeight=o),t(e.measure),o||1}function xi(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=i("span","xxxxxxxxxx"),r=i("pre",[t],"CodeMirror-line-like");n(e.measure,r);var o=t.getBoundingClientRect(),a=(o.right-o.left)/10;return a>2&&(e.cachedCharWidth=a),a||10}function wi(e){for(var t=e.display,n={},i={},r=t.gutters.clientLeft,o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a){var s=e.display.gutterSpecs[a].className;n[s]=o.offsetLeft+o.clientLeft+r,i[s]=o.clientWidth}return{fixedPos:ki(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:i,wrapperWidth:t.wrapper.clientWidth}}function ki(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function Ci(e){var t=bi(e.display),n=e.options.lineWrapping,i=n&&Math.max(5,e.display.scroller.clientWidth/xi(e.display)-3);return function(r){if(en(e.doc,r))return 0;var o=0;if(r.widgets)for(var a=0;a0&&(l=Z(e.doc,c.line).text).length==c.ch){var u=d(l,l.length,e.options.tabSize)-l.length;c=st(c.line,Math.max(0,Math.round((o-Hn(e.display).left)/xi(e.display))-u))}return c}function Si(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var n=e.display.view,i=0;it)return i}function Ti(e,t,n,i){null==t&&(t=e.doc.first),null==n&&(n=e.doc.first+e.doc.size),i||(i=0);var r=e.display;if(i&&nt)&&(r.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=r.viewTo)vl&&Yt(e.doc,t)r.viewFrom?Mi(e):(r.viewFrom+=i,r.viewTo+=i);else if(t<=r.viewFrom&&n>=r.viewTo)Mi(e);else if(t<=r.viewFrom){var o=Ai(e,n,n+i,1);o?(r.view=r.view.slice(o.index),r.viewFrom=o.lineN,r.viewTo+=i):Mi(e)}else if(n>=r.viewTo){var a=Ai(e,t,t,-1);a?(r.view=r.view.slice(0,a.index),r.viewTo=a.lineN):Mi(e)}else{var s=Ai(e,t,t,-1),l=Ai(e,n,n+i,1);s&&l?(r.view=r.view.slice(0,s.index).concat(vn(e,s.lineN,l.lineN)).concat(r.view.slice(l.index)),r.viewTo+=i):Mi(e)}var c=r.externalMeasured;c&&(n=r.lineN&&t=i.viewTo)){var o=i.view[Si(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==h(a,n)&&a.push(n)}}}function Mi(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Ai(e,t,n,i){var r,o=Si(e,t),a=e.display.view;if(!vl||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var s=e.display.viewFrom,l=0;o>l;l++)s+=a[l].size;if(s!=t){if(i>0){if(o==a.length-1)return null;r=s+a[o].size-t,o++}else r=s-t;t+=r,n+=r}for(;Yt(e.doc,n)!=n;){if(o==(0>i?0:a.length-1))return null;n+=i*a[o-(0>i?1:0)].size,o+=i}return{index:o,lineN:n}}function Li(e,t,n){var i=e.display,r=i.view;0==r.length||t>=i.viewTo||n<=i.viewFrom?(i.view=vn(e,t,n),i.viewFrom=t):(i.viewFrom>t?i.view=vn(e,t,i.viewFrom).concat(i.view):i.viewFromn&&(i.view=i.view.slice(0,Si(e,n)))),i.viewTo=n}function Di(e){for(var t=e.display.view,n=0,i=0;i=e.display.viewTo||s.to().linet&&(t=0),t=Math.round(t),r=Math.round(r),l.appendChild(i("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==n?d-e:n)+"px;\n height: "+(r-t)+"px"))}function o(t,n,i){function o(n,i){return li(e,st(t,n),"div",f,i)}function a(t,n,i){var r=pi(e,f,null,t),a="ltr"==n==("after"==i)?"left":"right",s="after"==i?r.begin:r.end-(/\s/.test(f.text.charAt(r.end-1))?2:1);return o(s,a)[a]}var l,c,f=Z(s,t),p=f.text.length,g=E(f,s.direction);return S(g,n||0,null==i?p:i,function(e,t,s,f){var m="ltr"==s,v=o(e,m?"left":"right"),y=o(t-1,m?"right":"left"),b=null==n&&0==e,x=null==i&&t==p,w=0==f,k=!g||f==g.length-1;if(y.top-v.top<=3){var C=(h?b:x)&&w,_=(h?x:b)&&k,$=C?u:(m?v:y).left,S=_?d:(m?y:v).right;r($,v.top,S-$,v.bottom)}else{var T,E,M,A;m?(T=h&&b&&w?u:v.left,E=h?d:a(e,s,"before"),M=h?u:a(t,s,"after"),A=h&&x&&k?d:y.right):(T=h?a(e,s,"before"):u,E=!h&&b&&w?d:v.right,M=!h&&x&&k?u:y.left,A=h?a(t,s,"after"):d),r(T,v.top,E-T,v.bottom),v.bottom0?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 Hi(e){e.state.focused||(e.display.input.focus(),Vi(e))}function Bi(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Fi(e))},100)}function Vi(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(L(e,"focus",e,t),e.state.focused=!0,s(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),_s&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),zi(e))}function Fi(e,t){e.state.delayingBlurEvent||(e.state.focused&&(L(e,"blur",e,t),e.state.focused=!1,Vs(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Ri(e){for(var t=e.display,n=t.lineDiv.offsetTop,i=0;iCs){var l=r.node.offsetTop+r.node.offsetHeight;a=l-n,n=l}else{var c=r.node.getBoundingClientRect();a=c.bottom-c.top,!o&&r.text.firstChild&&(s=r.text.firstChild.getBoundingClientRect().right-c.left-1)}var u=r.line.height-a;if((u>.005||-.005>u)&&(nt(r.line,a),Wi(r.line),r.rest))for(var d=0;de.display.sizerWidth){var h=Math.ceil(s/xi(e.display));h>e.display.maxLineLength&&(e.display.maxLineLength=h,e.display.maxLine=r.line,e.display.maxLineChanged=!0)}}}}function Wi(e){if(e.widgets)for(var t=0;ts?(o=s,a=rt(t,nn(Z(t,s))+e.wrapper.clientHeight)):Math.min(l,t.lastLine())>=a&&(o=rt(t,nn(Z(t,l))-e.wrapper.clientHeight),a=l)}return{from:o,to:Math.max(a,o+1)}}function Ui(e,t){if(!D(e,"scrollCursorIntoView")){var n=e.display,r=n.sizer.getBoundingClientRect(),o=null;if(t.top+r.top<0?o=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!As){var a=i("div","​",null,"position: absolute;\n top: "+(t.top-n.viewOffset-Pn(e.display))+"px;\n height: "+(t.bottom-t.top+Bn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(a),a.scrollIntoView(o),e.display.lineSpace.removeChild(a)}}}function Ji(e,t,n,i){null==i&&(i=0);var r;e.options.lineWrapping||t!=n||(t=t.ch?st(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t,n="before"==t.sticky?st(t.line,t.ch+1,"before"):t);for(var o=0;5>o;o++){var a=!1,s=ci(e,t),l=n&&n!=t?ci(e,n):s;r={left:Math.min(s.left,l.left),top:Math.min(s.top,l.top)-i,right:Math.max(s.left,l.left),bottom:Math.max(s.bottom,l.bottom)+i};var c=Ki(e,r),u=e.doc.scrollTop,d=e.doc.scrollLeft;if(null!=c.scrollTop&&(nr(e,c.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(a=!0)),null!=c.scrollLeft&&(rr(e,c.scrollLeft),Math.abs(e.doc.scrollLeft-d)>1&&(a=!0)),!a)break}return r}function Gi(e,t){var n=Ki(e,t);null!=n.scrollTop&&nr(e,n.scrollTop),null!=n.scrollLeft&&rr(e,n.scrollLeft)}function Ki(e,t){var n=e.display,i=bi(e.display);t.top<0&&(t.top=0);var r=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:n.scroller.scrollTop,o=Fn(e),a={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s=e.doc.height+zn(n),l=t.tops-i;if(t.topr+o){var u=Math.min(t.top,(c?s:t.bottom)-o);u!=r&&(a.scrollTop=u)}var d=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft,h=Vn(e)-(e.options.fixedGutter?n.gutters.offsetWidth:0),f=t.right-t.left>h;return f&&(t.right=t.left+h),t.left<10?a.scrollLeft=0:t.lefth+d-3&&(a.scrollLeft=t.right+(f?0:10)-h),a}function Xi(e,t){null!=t&&(er(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Qi(e){er(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Yi(e,t,n){(null!=t||null!=n)&&er(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function Zi(e,t){er(e),e.curOp.scrollToPos=t}function er(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=ui(e,t.from),i=ui(e,t.to);tr(e,n,i,t.margin)}}function tr(e,t,n,i){var r=Ki(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-i,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+i});Yi(e,r.scrollLeft,r.scrollTop)}function nr(e,t){Math.abs(e.doc.scrollTop-t)<2||(ys||Er(e,{top:t}),ir(e,t,!0),ys&&Er(e),wr(e,100))}function ir(e,t,n){t=Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t),(e.display.scroller.scrollTop!=t||n)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function rr(e,t,n,i){t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),(!(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||i)&&(e.doc.scrollLeft=t,Dr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function or(e){var t=e.display,n=t.gutters.offsetWidth,i=Math.round(e.doc.height+zn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:i,scrollHeight:i+Bn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function ar(e,t){t||(t=or(e));var n=e.display.barWidth,i=e.display.barHeight;sr(e,t);for(var r=0;4>r&&n!=e.display.barWidth||i!=e.display.barHeight;r++)n!=e.display.barWidth&&e.options.lineWrapping&&Ri(e),sr(e,or(e)),n=e.display.barWidth,i=e.display.barHeight}function sr(e,t){var n=e.display,i=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=i.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=i.bottom)+"px",n.heightForcer.style.borderBottom=i.bottom+"px solid transparent",i.right&&i.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=i.bottom+"px",n.scrollbarFiller.style.width=i.right+"px"):n.scrollbarFiller.style.display="",i.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=i.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}function lr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&Vs(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Tl[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),il(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,n){"horizontal"==n?rr(e,t):nr(e,t)},e),e.display.scrollbars.addClass&&s(e.display.wrapper,e.display.scrollbars.addClass)}function cr(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++El},yn(e.curOp)}function ur(e){var t=e.curOp;t&&xn(t,function(e){for(var t=0;t=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Ml(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function fr(e){e.updatedDisplay=e.mustUpdate&&Sr(e.cm,e.update)}function pr(e){var t=e.cm,n=t.display;e.updatedDisplay&&Ri(t),e.barMeasure=or(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Un(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Bn(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-Vn(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function gr(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft=e.display.viewTo)){var n=+new Date+e.options.workTime,i=bt(e,t.highlightFrontier),r=[];t.iter(i.line,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(i.line>=e.display.viewFrom){var a=o.styles,s=o.text.length>e.options.maxHighlightLength?X(t.mode,i.state):null,l=vt(e,o,i,!0);s&&(i.state=s),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var d=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),h=0;!d&&hn?(wr(e,e.options.workDelay),!0):void 0}),t.highlightFrontier=i.line,t.modeFrontier=Math.max(t.modeFrontier,i.line),r.length&&vr(e,function(){for(var t=0;t=i.viewFrom&&n.visible.to<=i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&0==Di(e))return!1;Nr(e)&&(Mi(e),n.dims=wi(e));var o=r.first+r.size,a=Math.max(n.visible.from-e.options.viewportMargin,r.first),s=Math.min(o,n.visible.to+e.options.viewportMargin);i.viewFroms&&i.viewTo-s<20&&(s=Math.min(o,i.viewTo)),vl&&(a=Yt(e.doc,a),s=Zt(e.doc,s));var l=a!=i.viewFrom||s!=i.viewTo||i.lastWrapHeight!=n.wrapperHeight||i.lastWrapWidth!=n.wrapperWidth;Li(e,a,s),i.viewOffset=nn(Z(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var c=Di(e);if(!l&&0==c&&!n.force&&i.renderedView==i.view&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo))return!1;var u=_r(e);return c>4&&(i.lineDiv.style.display="none"),Mr(e,i.updateLineNumbers,n.dims),c>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,$r(u),t(i.cursorDiv),t(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,l&&(i.lastWrapHeight=n.wrapperHeight,i.lastWrapWidth=n.wrapperWidth,wr(e,400)),i.updateLineNumbers=null,!0}function Tr(e,t){for(var n=t.viewport,i=!0;(i&&e.options.lineWrapping&&t.oldDisplayWidth!=Vn(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+zn(e.display)-Fn(e),n.top)}),t.visible=qi(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&Sr(e,t);i=!1){Ri(e);var r=or(e);Ni(e),ar(e,r),Lr(e,r),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Er(e,t){var n=new Ml(e,t);if(Sr(e,n)){Ri(e),Tr(e,n);var i=or(e);Ni(e),ar(e,i),Lr(e,i),n.finish()}}function Mr(e,n,i){function r(t){var n=t.nextSibling;return _s&&js&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var o=e.display,a=e.options.lineNumbers,s=o.lineDiv,l=s.firstChild,c=o.view,u=o.viewFrom,d=0;d=n&&f.lineNumber;f.changes&&(h(f.changes,"gutter")>-1&&(p=!1),Cn(e,f,u,i)),p&&(t(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(at(e.options,u)))),l=f.node.nextSibling}else{var g=Ln(e,f,u,i);s.insertBefore(g,l)}u+=f.size}for(;l;)l=r(l)}function Ar(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Lr(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Bn(e)+"px"}function Dr(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var i=ki(t)-t.scroller.scrollLeft+e.doc.scrollLeft,r=t.gutters.offsetWidth,o=i+"px",a=0;aCs&&(a.gutters.style.zIndex=-1,a.scroller.style.paddingRight=0),_s||ys&&Ns||(a.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(a.wrapper):e(a.wrapper)),a.viewFrom=a.viewTo=t.first,a.reportedViewFrom=a.reportedViewTo=t.first,a.view=[],a.renderedView=null,a.externalMeasured=null,a.viewOffset=0,a.lastWrapHeight=a.lastWrapWidth=0,a.updateLineNumbers=null,a.nativeBarWidth=a.barHeight=a.barWidth=0,a.scrollbarsClipped=!1,a.lineNumWidth=a.lineNumInnerWidth=a.lineNumChars=null,a.alignWidgets=!1,a.cachedCharWidth=a.cachedTextHeight=a.cachedPaddingH=null,a.maxLine=null,a.maxLineLength=0,a.maxLineChanged=!1,a.wheelDX=a.wheelDY=a.wheelStartX=a.wheelStartY=null,a.shift=!1,a.selForContextMenu=null,a.activeTouch=null,a.gutterSpecs=jr(o.gutters,o.lineNumbers),Ir(a),n.init(a)}function zr(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 Hr(e){var t=zr(e);return t.x*=Ll,t.y*=Ll,t}function Br(e,t){var n=zr(t),i=n.x,r=n.y,o=e.display,a=o.scroller,s=a.scrollWidth>a.clientWidth,l=a.scrollHeight>a.clientHeight;if(i&&s||r&&l){if(r&&js&&_s)e:for(var c=t.target,u=o.view;c!=a;c=c.parentNode)for(var d=0;dh?f=Math.max(0,f+h-50):p=Math.min(e.doc.height,p+h+50),Er(e,{top:f,bottom:p})}20>Al&&(null==o.wheelStartX?(o.wheelStartX=a.scrollLeft,o.wheelStartY=a.scrollTop,o.wheelDX=i,o.wheelDY=r,setTimeout(function(){if(null!=o.wheelStartX){var e=a.scrollLeft-o.wheelStartX,t=a.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,n&&(Ll=(Ll*Al+n)/(Al+1),++Al)}},200)):(o.wheelDX+=i,o.wheelDY+=r))}}function Vr(e,t,n){var i=e&&e.options.selectionsMayTouch,r=t[n];t.sort(function(e,t){return lt(e.from(),t.from())}),n=h(t,r);for(var o=1;o0:l>=0){var c=ht(s.from(),a.from()),u=dt(s.to(),a.to()),d=s.empty()?a.from()==a.head:s.from()==s.head;n>=o&&--n,t.splice(--o,2,new Nl(d?u:c,d?c:u))}}return new Dl(t,n) }function Fr(e,t){return new Dl([new Nl(e,t||e)],0)}function Rr(e){return e.text?st(e.from.line+e.text.length-1,g(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Wr(e,t){if(lt(e,t.from)<0)return e;if(lt(e,t.to)<=0)return Rr(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,i=e.ch;return e.line==t.to.line&&(i+=Rr(t).ch-t.to.ch),st(n,i)}function qr(e,t){for(var n=[],i=0;io;++o)n.push(new yl(c[o],r(o),i));return n}var s=t.from,l=t.to,c=t.text,u=Z(e,s.line),d=Z(e,l.line),h=g(c),f=r(c.length-1),p=l.line-s.line;if(t.full)e.insert(0,a(0,c.length)),e.remove(c.length,e.size-c.length);else if(Xr(e,t)){var m=a(0,c.length-1);o(d,d.text,f),p&&e.remove(s.line,p),m.length&&e.insert(s.line,m)}else if(u==d)if(1==c.length)o(u,u.text.slice(0,s.ch)+h+u.text.slice(l.ch),f);else{var v=a(1,c.length-1);v.push(new yl(h+u.text.slice(l.ch),f,i)),o(u,u.text.slice(0,s.ch)+c[0],r(0)),e.insert(s.line+1,v)}else if(1==c.length)o(u,u.text.slice(0,s.ch)+c[0]+d.text.slice(l.ch),r(0)),e.remove(s.line+1,p);else{o(u,u.text.slice(0,s.ch)+c[0],r(0)),o(d,h+d.text.slice(l.ch),f);var y=a(1,c.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,y)}wn(e,"change",e,t)}function Yr(e,t,n){function i(e,r,o){if(e.linked)for(var a=0;a1&&!e.done[e.done.length-2].ranges?(e.done.pop(),g(e.done)):void 0}function ao(e,t,n,i){var r=e.history;r.undone.length=0;var o,a,s=+new Date;if((r.lastOp==i||r.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&r.lastModTime>s-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=oo(r,r.lastOp==i)))a=g(o.changes),0==lt(t.from,t.to)&&0==lt(t.from,a.to)?a.to=Rr(t):o.changes.push(io(e,t));else{var l=g(r.done);for(l&&l.ranges||co(e.sel,r.done),o={changes:[io(e,t)],generation:r.generation},r.done.push(o);r.done.length>r.undoDepth;)r.done.shift(),r.done[0].ranges||r.done.shift()}r.done.push(n),r.generation=++r.maxGeneration,r.lastModTime=r.lastSelTime=s,r.lastOp=r.lastSelOp=i,r.lastOrigin=r.lastSelOrigin=t.origin,a||L(e,"historyAdded")}function so(e,t,n,i){var r=t.charAt(0);return"*"==r||"+"==r&&n.ranges.length==i.ranges.length&&n.somethingSelected()==i.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function lo(e,t,n,i){var r=e.history,o=i&&i.origin;n==r.lastSelOp||o&&r.lastSelOrigin==o&&(r.lastModTime==r.lastSelTime&&r.lastOrigin==o||so(e,o,g(r.done),t))?r.done[r.done.length-1]=t:co(t,r.done),r.lastSelTime=+new Date,r.lastSelOrigin=o,r.lastSelOp=n,i&&i.clearRedo!==!1&&ro(r.undone)}function co(e,t){var n=g(t);n&&n.ranges&&n.equals(e)||t.push(e)}function uo(e,t,n,i){var r=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,i),function(n){n.markedSpans&&((r||(r=t["spans_"+e.id]={}))[o]=n.markedSpans),++o})}function ho(e){if(!e)return null;for(var t,n=0;n-1&&(g(s)[d]=c[d],delete c[d])}}}return i}function mo(e,t,n,i){if(i){var r=e.anchor;if(n){var o=lt(t,r)<0;o!=lt(n,r)<0?(r=t,t=n):o!=lt(t,n)<0&&(t=n)}return new Nl(r,t)}return new Nl(n||t,t)}function vo(e,t,n,i,r){null==r&&(r=e.cm&&(e.cm.display.shift||e.extend)),Co(e,new Dl([mo(e.sel.primary(),t,n,r)],0),i)}function yo(e,t,n){for(var i=[],r=e.cm&&(e.cm.display.shift||e.extend),o=0;o=t.ch:s.to>t.ch))){if(r&&(L(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!l.atomic)continue;if(n){var d=l.find(0>i?1:-1),h=void 0;if((0>i?u:c)&&(d=Ao(e,d,-i,d&&d.line==t.line?o:null)),d&&d.line==t.line&&(h=lt(d,n))&&(0>i?0>h:h>0))return Eo(e,d,t,i,r)}var f=l.find(0>i?-1:1);return(0>i?c:u)&&(f=Ao(e,f,i,f.line==t.line?o:null)),f?Eo(e,f,t,i,r):null}}return t}function Mo(e,t,n,i,r){var o=i||1,a=Eo(e,t,n,o,r)||!r&&Eo(e,t,n,o,!0)||Eo(e,t,n,-o,r)||!r&&Eo(e,t,n,-o,!0);return a?a:(e.cantEdit=!0,st(e.first,0))}function Ao(e,t,n,i){return 0>n&&0==t.ch?t.line>e.first?pt(e,st(t.line-1)):null:n>0&&t.ch==(i||Z(e,t.line)).text.length?t.line=0;--r)jo(e,{from:i[r].from,to:i[r].to,text:r?[""]:t.text,origin:t.origin});else jo(e,t)}}function jo(e,t){if(1!=t.text.length||""!=t.text[0]||0!=lt(t.from,t.to)){var n=qr(e,t);ao(e,t,n,e.cm?e.cm.curOp.id:0/0),Po(e,t,n,Ot(e,t));var i=[];Yr(e,function(e,n){n||-1!=h(i,e.history)||(Fo(e.history,t),i.push(e.history)),Po(e,t,null,Ot(e,t))})}}function Io(e,t,n){var i=e.cm&&e.cm.state.suppressEdits;if(!i||n){for(var r,o=e.history,a=e.sel,s="undo"==t?o.done:o.undone,l="undo"==t?o.undone:o.done,c=0;c=0;--p){var m=f(p);if(m)return m.v}}}}function Oo(e,t){if(0!=t&&(e.first+=t,e.sel=new Dl(m(e.sel.ranges,function(e){return new Nl(st(e.anchor.line+t,e.anchor.ch),st(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Ti(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,i=n.viewFrom;ie.lastLine())){if(t.from.lineo&&(t={from:t.from,to:st(o,Z(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=et(e,t.from,t.to),n||(n=qr(e,t)),e.cm?zo(e.cm,t,i):Qr(e,t,i),_o(e,n,Gs),e.cantEdit&&Mo(e,st(e.firstLine(),0))&&(e.cantEdit=!1)}}function zo(e,t,n){var i=e.doc,r=e.display,o=t.from,a=t.to,s=!1,l=o.line;e.options.lineWrapping||(l=it(Kt(Z(i,o.line))),i.iter(l,a.line+1,function(e){return e==r.maxLine?(s=!0,!0):void 0})),i.sel.contains(t.from,t.to)>-1&&N(e),Qr(i,t,n,Ci(e)),e.options.lineWrapping||(i.iter(l,o.line+t.text.length,function(e){var t=rn(e);t>r.maxLineLength&&(r.maxLine=e,r.maxLineLength=t,r.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),Tt(i,o.line),wr(e,400);var c=t.text.length-(a.line-o.line)-1;t.full?Ti(e):o.line!=a.line||1!=t.text.length||Xr(e.doc,t)?Ti(e,o.line,a.line+1,c):Ei(e,o.line,"text");var u=j(e,"changes"),d=j(e,"change");if(d||u){var h={from:o,to:a,text:t.text,removed:t.removed,origin:t.origin};d&&wn(e,"change",e,h),u&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Ho(e,t,n,i,r){var o;i||(i=n),lt(i,n)<0&&(o=[i,n],n=o[0],i=o[1]),"string"==typeof t&&(t=e.splitLines(t)),No(e,{from:n,to:i,text:t,origin:r})}function Bo(e,t,n,i){n0||0==s&&a.clearWhenEmpty!==!1)return a;if(a.replacedWith&&(a.collapsed=!0,a.widgetNode=r("span",[a.replacedWith],"CodeMirror-widget"),i.handleMouseEvents||a.widgetNode.setAttribute("cm-ignore-events","true"),i.insertLeft&&(a.widgetNode.insertLeft=!0)),a.collapsed){if(Gt(e,t.line,t,n,a)||t.line!=n.line&&Gt(e,n.line,t,n,a))throw new Error("Inserting collapsed marker partially overlapping an existing one");Mt()}a.addToHistory&&ao(e,{from:t,to:n,origin:"markText"},e.sel,0/0);var l,c=t.line,d=e.cm;if(e.iter(c,n.line+1,function(e){d&&a.collapsed&&!d.options.lineWrapping&&Kt(e)==d.display.maxLine&&(l=!0),a.collapsed&&c!=t.line&&nt(e,0),Nt(e,new At(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){en(e,t)&&nt(t,0)}),a.clearOnEnter&&il(a,"beforeCursorEnter",function(){return a.clear()}),a.readOnly&&(Et(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),a.collapsed&&(a.id=++Il,a.atomic=!0),d){if(l&&(d.curOp.updateMaxLine=!0),a.collapsed)Ti(d,t.line,n.line+1);else if(a.className||a.startStyle||a.endStyle||a.css||a.attributes||a.title)for(var h=t.line;h<=n.line;h++)Ei(d,h,"text");a.atomic&&So(d.doc),wn(d,"markerAdded",d,a)}return a}function Ko(e,t,n,i,r){i=u(i),i.shared=!1;var o=[Go(e,t,n,i,r)],a=o[0],s=i.widgetNode;return Yr(e,function(e){s&&(i.widgetNode=s.cloneNode(!0)),o.push(Go(e,pt(e,t),pt(e,n),i,r));for(var l=0;ll;++l)s(i[l],l);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1)return t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20),void 0;try{var c=e.dataTransfer.getData("Text");if(c){var u;if(t.state.draggingText&&!t.state.draggingText.copy&&(u=t.listSelections()),_o(t.doc,Fr(n,n)),u)for(var d=0;d=0;t--)Ho(e.doc,"",i[t].from,i[t].to,"+delete");Qi(e)})}function ga(e,t,n){var i=_(e.text,t+n,n);return 0>i||i>e.text.length?null:i}function ma(e,t,n){var i=ga(e,t.ch,n);return null==i?null:new st(t.line,i,0>n?"after":"before")}function va(e,t,n,i,r){if(e){var o=E(n,t.doc.direction);if(o){var a,s=0>r?g(o):o[0],l=0>r==(1==s.level),c=l?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var u=Gn(t,n);a=0>r?n.text.length-1:0;var d=Kn(t,u,a).top;a=$(function(e){return Kn(t,u,e).top==d},0>r==(1==s.level)?s.from:s.to-1,a),"before"==c&&(a=ga(n,a,1))}else a=0>r?s.to:s.from;return new st(i,a,c)}}return new st(i,0>r?n.text.length:0,0>r?"before":"after")}function ya(e,t,n,i){var r=E(t,e.doc.direction);if(!r)return ma(t,n,i);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=T(r,n.ch,n.sticky),a=r[o];if("ltr"==e.doc.direction&&0==a.level%2&&(i>0?a.to>n.ch:a.fromi,h=l(n,d?1:-1);if(null!=h&&(d?h<=a.to&&h<=u.end:h>=a.from&&h>=u.begin)){var f=d?"before":"after";return new st(n.line,h,f)}}var p=function(e,t,i){for(var o=function(e,t){return t?new st(n.line,l(e,1),"before"):new st(n.line,e,"after")};e>=0&&e0==(1!=a.level),c=s?i.begin:l(i.end,-1);if(a.from<=c&&c0?u.end:l(u.begin,-1);return null==m||i>0&&m==t.text.length||!(g=p(i>0?0:r.length-1,i,c(m)))?null:g}function ba(e,t){var n=Z(e.doc,t),i=Kt(n);return i!=n&&(t=it(i)),va(!0,e,i,t,1)}function xa(e,t){var n=Z(e.doc,t),i=Xt(n);return i!=n&&(t=it(i)),va(!0,e,n,t,-1)}function wa(e,t){var n=ba(e,t.line),i=Z(e.doc,n.line),r=E(i,e.doc.direction);if(!r||0==r[0].level){var o=Math.max(0,i.text.search(/\S/)),a=t.line==n.line&&t.ch<=o&&t.ch;return st(n.line,a?0:o,n.sticky)}return n}function ka(e,t,n){if("string"==typeof t&&(t=Jl[t],!t))return!1;e.display.input.ensurePolled();var i=e.display.shift,r=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),r=t(e)!=Js}finally{e.display.shift=i,e.state.suppressEdits=!1}return r}function Ca(e,t,n){for(var i=0;iCs&&27==e.keyCode&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=16==n||e.shiftKey;var i=Sa(t,e);Ts&&(Kl=i?n:null,!i&&88==n&&!sl&&(js?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),ys&&!js&&!i&&46==n&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),18!=n||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||Ma(t)}}function Ma(e){function t(e){18!=e.keyCode&&e.altKey||(Vs(n,"CodeMirror-crosshair"),A(document,"keyup",t),A(document,"mouseover",t))}var n=e.display.lineDiv;s(n,"CodeMirror-crosshair"),il(document,"keyup",t),il(document,"mouseover",t)}function Aa(e){16==e.keyCode&&(this.doc.sel.shift=!1),D(this,e)}function La(e){var t=this;if(!(On(t.display,e)||D(t,e)||e.ctrlKey&&!e.altKey||js&&e.metaKey)){var n=e.keyCode,i=e.charCode;if(Ts&&n==Kl)return Kl=null,O(e),void 0;if(!Ts||e.which&&!(e.which<10)||!Sa(t,e)){var r=String.fromCharCode(null==i?n:i);"\b"!=r&&(Ta(t,e,r)||t.display.input.onKeyPress(e))}}}function Da(e,t){var n=+new Date;return Zl&&Zl.compare(n,e,t)?(Yl=Zl=null,"triple"):Yl&&Yl.compare(n,e,t)?(Zl=new Ql(n,e,t),Yl=null,"double"):(Yl=new Ql(n,e,t),Zl=null,"single")}function Na(e){var t=this,n=t.display;if(!(D(t,e)||n.activeTouch&&n.input.supportsTouch())){if(n.input.ensurePolled(),n.shift=e.shiftKey,On(n,e))return _s||(n.scroller.draggable=!1,setTimeout(function(){return n.scroller.draggable=!0},100)),void 0;if(!Fa(t,e)){var i=$i(t,e),r=V(e),o=i?Da(i,r):"single";window.focus(),1==r&&t.state.selectingText&&t.state.selectingText(e),i&&ja(t,r,i,o,e)||(1==r?i?Oa(t,i,o,e):B(e)==n.scroller&&O(e):2==r?(i&&vo(t.doc,i),setTimeout(function(){return n.input.focus()},20)):3==r&&(Bs?t.display.input.onContextMenu(e):Bi(t)))}}}function ja(e,t,n,i,r){var o="Click";return"double"==i?o="Double"+o:"triple"==i&&(o="Triple"+o),o=(1==t?"Left":2==t?"Middle":"Right")+o,_a(e,da(o,r),r,function(t){if("string"==typeof t&&(t=Jl[t]),!t)return!1;var i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i=t(e,n)!=Js}finally{e.state.suppressEdits=!1}return i})}function Ia(e,t,n){var i=e.getOption("configureMouse"),r=i?i(e,t,n):{};if(null==r.unit){var o=Is?n.shiftKey&&n.metaKey:n.altKey;r.unit=o?"rectangle":"single"==t?"char":"double"==t?"word":"line"}return(null==r.extend||e.doc.extend)&&(r.extend=e.doc.extend||n.shiftKey),null==r.addNew&&(r.addNew=js?n.metaKey:n.ctrlKey),null==r.moveOnDrag&&(r.moveOnDrag=!(js?n.altKey:n.ctrlKey)),r}function Oa(e,t,n,i){ks?setTimeout(c(Hi,e),0):e.curOp.focus=a();var r,o=Ia(e,n,i),s=e.doc.sel;e.options.dragDrop&&rl&&!e.isReadOnly()&&"single"==n&&(r=s.contains(t))>-1&&(lt((r=s.ranges[r]).from(),t)<0||t.xRel>0)&&(lt(r.to(),t)>0||t.xRel<0)?Pa(e,i,t,o):Ha(e,i,t,o)}function Pa(e,t,n,i){var r=e.display,o=!1,a=yr(e,function(t){_s&&(r.scroller.draggable=!1),e.state.draggingText=!1,A(r.wrapper.ownerDocument,"mouseup",a),A(r.wrapper.ownerDocument,"mousemove",s),A(r.scroller,"dragstart",l),A(r.scroller,"drop",a),o||(O(t),i.addNew||vo(e.doc,n,null,null,i.extend),_s||ks&&9==Cs?setTimeout(function(){r.wrapper.ownerDocument.body.focus(),r.input.focus()},20):r.input.focus())}),s=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},l=function(){return o=!0};_s&&(r.scroller.draggable=!0),e.state.draggingText=a,a.copy=!i.moveOnDrag,r.scroller.dragDrop&&r.scroller.dragDrop(),il(r.wrapper.ownerDocument,"mouseup",a),il(r.wrapper.ownerDocument,"mousemove",s),il(r.scroller,"dragstart",l),il(r.scroller,"drop",a),Bi(e),setTimeout(function(){return r.input.focus()},20)}function za(e,t,n){if("char"==n)return new Nl(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new Nl(st(t.line,0),pt(e.doc,st(t.line+1,0)));var i=n(e,t);return new Nl(i.from,i.to)}function Ha(e,t,n,i){function r(t){if(0!=lt(v,t))if(v=t,"rectangle"==i.unit){for(var r=[],o=e.options.tabSize,a=d(Z(c,n.line).text,n.ch,o),s=d(Z(c,t.line).text,t.ch,o),l=Math.min(a,s),g=Math.max(a,s),m=Math.min(n.line,t.line),y=Math.min(e.lastLine(),Math.max(n.line,t.line));y>=m;m++){var b=Z(c,m).text,x=f(b,l,o);l==g?r.push(new Nl(st(m,x),st(m,x))):b.length>x&&r.push(new Nl(st(m,x),st(m,f(b,g,o))))}r.length||r.push(new Nl(n,n)),Co(c,Vr(e,p.ranges.slice(0,h).concat(r),h),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var w,k=u,C=za(e,t,i.unit),_=k.anchor;lt(C.anchor,_)>0?(w=C.head,_=ht(k.from(),C.anchor)):(w=C.anchor,_=dt(k.to(),C.head));var $=p.ranges.slice(0);$[h]=Ba(e,new Nl(pt(c,_),w)),Co(c,Vr(e,$,h),Ks)}}function o(t){var n=++b,s=$i(e,t,!0,"rectangle"==i.unit);if(s)if(0!=lt(s,v)){e.curOp.focus=a(),r(s);var u=qi(l,c);(s.line>=u.to||s.liney.bottom?20:0;d&&setTimeout(yr(e,function(){b==n&&(l.scroller.scrollTop+=d,o(t))}),50)}}function s(t){e.state.selectingText=!1,b=1/0,t&&(O(t),l.input.focus()),A(l.wrapper.ownerDocument,"mousemove",x),A(l.wrapper.ownerDocument,"mouseup",w),c.history.lastSelOrigin=null}var l=e.display,c=e.doc;O(t);var u,h,p=c.sel,g=p.ranges;if(i.addNew&&!i.extend?(h=c.sel.contains(n),u=h>-1?g[h]:new Nl(n,n)):(u=c.sel.primary(),h=c.sel.primIndex),"rectangle"==i.unit)i.addNew||(u=new Nl(n,n)),n=$i(e,t,!0,!0),h=-1;else{var m=za(e,n,i.unit);u=i.extend?mo(u,m.anchor,m.head,i.extend):m}i.addNew?-1==h?(h=g.length,Co(c,Vr(e,g.concat([u]),h),{scroll:!1,origin:"*mouse"})):g.length>1&&g[h].empty()&&"char"==i.unit&&!i.extend?(Co(c,Vr(e,g.slice(0,h).concat(g.slice(h+1)),0),{scroll:!1,origin:"*mouse"}),p=c.sel):bo(c,h,u,Ks):(h=0,Co(c,new Dl([u],0),Ks),p=c.sel);var v=n,y=l.wrapper.getBoundingClientRect(),b=0,x=yr(e,function(e){0!==e.buttons&&V(e)?o(e):s(e)}),w=yr(e,s);e.state.selectingText=w,il(l.wrapper.ownerDocument,"mousemove",x),il(l.wrapper.ownerDocument,"mouseup",w)}function Ba(e,t){var n=t.anchor,i=t.head,r=Z(e.doc,n.line);if(0==lt(n,i)&&n.sticky==i.sticky)return t;var o=E(r);if(!o)return t;var a=T(o,n.ch,n.sticky),s=o[a];if(s.from!=n.ch&&s.to!=n.ch)return t;var l=a+(s.from==n.ch==(1!=s.level)?0:1);if(0==l||l==o.length)return t;var c;if(i.line!=n.line)c=(i.line-n.line)*("ltr"==e.doc.direction?1:-1)>0;else{var u=T(o,i.ch,i.sticky),d=u-a||(i.ch-n.ch)*(1==s.level?-1:1);c=u==l-1||u==l?0>d:d>0}var h=o[l+(c?-1:0)],f=c==(1==h.level),p=f?h.from:h.to,g=f?"after":"before";return n.ch==p&&n.sticky==g?t:new Nl(new st(n.line,p,g),i)}function Va(e,t,n,i){var r,o;if(t.touches)r=t.touches[0].clientX,o=t.touches[0].clientY;else try{r=t.clientX,o=t.clientY}catch(t){return!1}if(r>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;i&&O(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!j(e,n))return z(t);o-=s.top-a.viewOffset;for(var l=0;l=r){var u=rt(e.doc,o),d=e.display.gutterSpecs[l];return L(e,n,e,u,d.className,t),z(t)}}}function Fa(e,t){return Va(e,t,"gutterClick",!0)}function Ra(e,t){On(e.display,t)||Wa(e,t)||D(e,t,"contextmenu")||Bs||e.display.input.onContextMenu(t)}function Wa(e,t){return j(e,"gutterContextMenu")?Va(e,t,"gutterContextMenu",!1):!1}function qa(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),ni(e)}function Ua(e){function t(t,i,r,o){e.defaults[t]=i,r&&(n[t]=o?function(e,t,n){n!=ec&&r(e,t,n)}:r)}var n=e.optionHandlers;e.defineOption=t,e.Init=ec,t("value","",function(e,t){return e.setValue(t)},!0),t("mode",null,function(e,t){e.doc.modeOption=t,Gr(e)},!0),t("indentUnit",2,Gr,!0),t("indentWithTabs",!1),t("smartIndent",!0),t("tabSize",4,function(e){Kr(e),ni(e),Ti(e)},!0),t("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var n=[],i=e.doc.first;e.doc.iter(function(e){for(var r=0;;){var o=e.text.indexOf(t,r);if(-1==o)break;r=o+t.length,n.push(st(i,o))}i++});for(var r=n.length-1;r>=0;r--)Ho(e.doc,t,n[r],st(n[r].line,n[r].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(e,t,n){e.state.specialChars=new RegExp(t.source+(t.test(" ")?"":"| "),"g"),n!=ec&&e.refresh()}),t("specialCharPlaceholder",un,function(e){return e.refresh()},!0),t("electricChars",!0),t("inputStyle",Ns?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor") },!0),t("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),t("autocorrect",!1,function(e,t){return e.getInputField().autocorrect=t},!0),t("autocapitalize",!1,function(e,t){return e.getInputField().autocapitalize=t},!0),t("rtlMoveVisually",!Os),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){qa(e),Or(e)},!0),t("keyMap","default",function(e,t,n){var i=fa(t),r=n!=ec&&fa(n);r&&r.detach&&r.detach(e,i),i.attach&&i.attach(e,r||null)}),t("extraKeys",null),t("configureMouse",null),t("lineWrapping",!1,Ga,!0),t("gutters",[],function(e,t){e.display.gutterSpecs=jr(t,e.options.lineNumbers),Or(e)},!0),t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?ki(e.display)+"px":"0",e.refresh()},!0),t("coverGutterNextToScrollbar",!1,function(e){return ar(e)},!0),t("scrollbarStyle","native",function(e){lr(e),ar(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e,t){e.display.gutterSpecs=jr(e.options.gutters,t),Or(e)},!0),t("firstLineNumber",1,Or,!0),t("lineNumberFormatter",function(e){return e},Or,!0),t("showCursorWhenSelecting",!1,Ni,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("pasteLinesPerSelection",!0),t("selectionsMayTouch",!1),t("readOnly",!1,function(e,t){"nocursor"==t&&(Fi(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),t("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),t("dragDrop",!0,Ja),t("allowDropFileTypes",null),t("cursorBlinkRate",530),t("cursorScrollMargin",0),t("cursorHeight",1,Ni,!0),t("singleCursorHeightPerLine",!0,Ni,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,Kr,!0),t("addModeClass",!1,Kr,!0),t("pollInterval",100),t("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),t("historyEventDelay",1250),t("viewportMargin",10,function(e){return e.refresh()},!0),t("maxHighlightLength",1e4,Kr,!0),t("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),t("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),t("autofocus",null),t("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0),t("phrases",null)}function Ja(e,t,n){var i=n&&n!=ec;if(!t!=!i){var r=e.display.dragFunctions,o=t?il:A;o(e.display.scroller,"dragstart",r.start),o(e.display.scroller,"dragenter",r.enter),o(e.display.scroller,"dragover",r.over),o(e.display.scroller,"dragleave",r.leave),o(e.display.scroller,"drop",r.drop)}}function Ga(e){e.options.lineWrapping?(s(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Vs(e.display.wrapper,"CodeMirror-wrap"),on(e)),_i(e),Ti(e),ni(e),setTimeout(function(){return ar(e)},100)}function Ka(e,t){var n=this;if(!(this instanceof Ka))return new Ka(e,t);this.options=t=t?u(t):{},u(tc,t,!1);var i=t.value;"string"==typeof i?i=new Hl(i,t.mode,null,t.lineSeparator,t.direction):t.mode&&(i.modeOption=t.mode),this.doc=i;var r=new Ka.inputStyles[t.inputStyle](this),o=this.display=new Pr(e,i,r,t);o.wrapper.CodeMirror=this,qa(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),lr(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new Rs,keySeq:null,specialChars:null},t.autofocus&&!Ns&&o.input.focus(),ks&&11>Cs&&setTimeout(function(){return n.display.input.reset(!0)},20),Xa(this),ra(),cr(this),this.curOp.forceUpdate=!0,Zr(this,i),t.autofocus&&!Ns||this.hasFocus()?setTimeout(c(Vi,this),20):Fi(this);for(var a in nc)nc.hasOwnProperty(a)&&nc[a](n,t[a],ec);Nr(this),t.finishInit&&t.finishInit(this);for(var s=0;s400}var r=e.display;il(r.scroller,"mousedown",yr(e,Na)),ks&&11>Cs?il(r.scroller,"dblclick",yr(e,function(t){if(!D(e,t)){var n=$i(e,t);if(n&&!Fa(e,t)&&!On(e.display,t)){O(t);var i=e.findWordAt(n);vo(e.doc,i.anchor,i.head)}}})):il(r.scroller,"dblclick",function(t){return D(e,t)||O(t)}),il(r.scroller,"contextmenu",function(t){return Ra(e,t)});var o,a={end:0};il(r.scroller,"touchstart",function(t){if(!D(e,t)&&!n(t)&&!Fa(e,t)){r.input.ensurePolled(),clearTimeout(o);var i=+new Date;r.activeTouch={start:i,moved:!1,prev:i-a.end<=300?a:null},1==t.touches.length&&(r.activeTouch.left=t.touches[0].pageX,r.activeTouch.top=t.touches[0].pageY)}}),il(r.scroller,"touchmove",function(){r.activeTouch&&(r.activeTouch.moved=!0)}),il(r.scroller,"touchend",function(n){var o=r.activeTouch;if(o&&!On(r,n)&&null!=o.left&&!o.moved&&new Date-o.start<300){var a,s=e.coordsChar(r.activeTouch,"page");a=!o.prev||i(o,o.prev)?new Nl(s,s):!o.prev.prev||i(o,o.prev.prev)?e.findWordAt(s):new Nl(st(s.line,0),pt(e.doc,st(s.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),O(n)}t()}),il(r.scroller,"touchcancel",t),il(r.scroller,"scroll",function(){r.scroller.clientHeight&&(nr(e,r.scroller.scrollTop),rr(e,r.scroller.scrollLeft,!0),L(e,"scroll",e))}),il(r.scroller,"mousewheel",function(t){return Br(e,t)}),il(r.scroller,"DOMMouseScroll",function(t){return Br(e,t)}),il(r.wrapper,"scroll",function(){return r.wrapper.scrollTop=r.wrapper.scrollLeft=0}),r.dragFunctions={enter:function(t){D(e,t)||H(t)},over:function(t){D(e,t)||(ta(e,t),H(t))},start:function(t){return ea(e,t)},drop:yr(e,Zo),leave:function(t){D(e,t)||na(e)}};var s=r.input.getField();il(s,"keyup",function(t){return Aa.call(e,t)}),il(s,"keydown",yr(e,Ea)),il(s,"keypress",yr(e,La)),il(s,"focus",function(t){return Vi(e,t)}),il(s,"blur",function(t){return Fi(e,t)})}function Qa(e,t,n,i){var r,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?r=bt(e,t).state:n="prev");var a=e.options.tabSize,s=Z(o,t),l=d(s.text,null,a);s.stateAfter&&(s.stateAfter=null);var c,u=s.text.match(/^\s*/)[0];if(i||/\S/.test(s.text)){if("smart"==n&&(c=o.mode.indent(r,s.text.slice(u.length),s.text),c==Js||c>150)){if(!i)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>o.first?d(Z(o,t-1).text,null,a):0:"add"==n?c=l+e.options.indentUnit:"subtract"==n?c=l-e.options.indentUnit:"number"==typeof n&&(c=l+n),c=Math.max(0,c);var h="",f=0;if(e.options.indentWithTabs)for(var g=Math.floor(c/a);g;--g)f+=a,h+=" ";if(c>f&&(h+=p(c-f)),h!=u)return Ho(o,h,st(t,0),st(t,u.length),"+input"),s.stateAfter=null,!0;for(var m=0;ma,l=ol(t),c=null;if(s&&i.ranges.length>1)if(rc&&rc.text.join("\n")==t){if(0==i.ranges.length%rc.text.length){c=[];for(var u=0;u=0;h--){var f=i.ranges[h],p=f.from(),v=f.to();f.empty()&&(n&&n>0?p=st(p.line,p.ch-n):e.state.overwrite&&!s?v=st(v.line,Math.min(Z(o,v.line).text.length,v.ch+g(l).length)):s&&rc&&rc.lineWise&&rc.text.join("\n")==t&&(p=v=st(p.line,0)));var y={from:p,to:v,text:c?c[h%c.length]:l,origin:r||(s?"paste":e.state.cutIncoming>a?"cut":"+input")};No(e.doc,y),wn(e,"inputRead",e,y)}t&&!s&&ts(e,t),Qi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=d),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function es(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");return n?(e.preventDefault(),t.isReadOnly()||t.options.disableInput||vr(t,function(){return Za(t,n,0,null,"paste")}),!0):void 0}function ts(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,i=n.ranges.length-1;i>=0;i--){var r=n.ranges[i];if(!(r.head.ch>100||i&&n.ranges[i-1].head.line==r.head.line)){var o=e.getModeAt(r.head),a=!1;if(o.electricChars){for(var s=0;s-1){a=Qa(e,r.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Z(e.doc,r.head.line).text.slice(0,r.head.ch))&&(a=Qa(e,r.head.line,"smart"));a&&wn(e,"electricInput",e,r.head.line)}}}function ns(e){for(var t=[],n=[],i=0;ii&&(Qa(t,o.head.line,e,!0),i=o.head.line,r==t.doc.sel.primIndex&&Qi(t));else{var a=o.from(),s=o.to(),l=Math.max(i,a.line);i=Math.min(t.lastLine(),s.line-(s.ch?0:1))+1;for(var c=l;i>c;++c)Qa(t,c,e);var u=t.doc.sel.ranges;0==a.ch&&n.length==u.length&&u[r].from().ch>0&&bo(t.doc,r,new Nl(a,u[r].to()),Gs)}}}),getTokenAt:function(e,t){return Ct(this,e,t)},getLineTokens:function(e,t){return Ct(this,st(e),t,!0)},getTokenTypeAt:function(e){e=pt(this.doc,e);var t,n=yt(this,Z(this.doc,e.line)),i=0,r=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var a=i+r>>1;if((a?n[2*a-1]:0)>=o)r=a;else{if(!(n[2*a+1]s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(t).state).mode:n},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var i=this,r=[];if(!n.hasOwnProperty(t))return r;var o=n[t],a=this.getModeAt(e);if("string"==typeof a[t])o[a[t]]&&r.push(o[a[t]]);else if(a[t])for(var s=0;so&&(e=o,r=!0),i=Z(this.doc,e)}else i=e;return ai(this,i,{top:0,left:0},t||"page",n||r).top+(r?this.doc.height-nn(i):0)},defaultTextHeight:function(){return bi(this.display)},defaultCharWidth:function(){return xi(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,i,r){var o=this.display;e=ci(this,pt(this.doc,e));var a=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==i)a=e.top;else if("above"==i||"near"==i){var l=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==i||e.bottom+t.offsetHeight>l)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=l&&(a=e.bottom),s+t.offsetWidth>c&&(s=c-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==r?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==r?s=0:"middle"==r&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),n&&Gi(this,{left:s,top:a,right:s+t.offsetWidth,bottom:a+t.offsetHeight})},triggerOnKeyDown:br(Ea),triggerOnKeyPress:br(La),triggerOnKeyUp:Aa,triggerOnMouseDown:br(Na),execCommand:function(e){return Jl.hasOwnProperty(e)?Jl[e].call(null,this):void 0},triggerElectric:br(function(e){ts(this,e)}),findPosH:function(e,t,n,i){var r=this,o=1;0>t&&(o=-1,t=-t);for(var a=pt(this.doc,e),s=0;t>s&&(a=as(r.doc,a,o,n,i),!a.hitSide);++s);return a},moveH:br(function(e,t){var n=this;this.extendSelectionsBy(function(i){return n.display.shift||n.doc.extend||i.empty()?as(n.doc,i.head,e,t,n.options.rtlMoveVisually):0>e?i.from():i.to()},Xs)}),deleteH:br(function(e,t){var n=this.doc.sel,i=this.doc;n.somethingSelected()?i.replaceSelection("",null,"+delete"):pa(this,function(n){var r=as(i,n.head,e,t,!1);return 0>e?{from:r,to:n.head}:{from:n.head,to:r}})}),findPosV:function(e,t,n,i){var r=this,o=1,a=i;0>t&&(o=-1,t=-t);for(var s=pt(this.doc,e),l=0;t>l;++l){var c=ci(r,s,"div");if(null==a?a=c.left:c.left=a,s=ss(r,c,o,n),s.hitSide)break}return s},moveV:br(function(e,t){var n=this,i=this.doc,r=[],o=!this.display.shift&&!i.extend&&i.sel.somethingSelected();if(i.extendSelectionsBy(function(a){if(o)return 0>e?a.from():a.to();var s=ci(n,a.head,"div");null!=a.goalColumn&&(s.left=a.goalColumn),r.push(s.left);var l=ss(n,s,e,t);return"page"==t&&a==i.sel.primary()&&Xi(n,li(n,l,"div").top-s.top),l},Xs),r.length)for(var a=0;a0&&s(n.charAt(i-1));)--i;for(;r.5)&&_i(this),L(this,"refresh",this)}),swapDoc:br(function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),Zr(this,e),ni(this),this.display.input.reset(),Yi(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,wn(this,"swapDoc",this,t),t}),phrase:function(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},I(e),e.registerHelper=function(t,i,r){n.hasOwnProperty(t)||(n[t]=e[t]={_global:[]}),n[t][i]=r},e.registerGlobalHelper=function(t,i,r,o){e.registerHelper(t,i,o),n[t]._global.push({pred:r,val:o})}}function as(e,t,n,i,r){function o(){var i=t.line+n;return i=e.first+e.size?!1:(t=new st(i,t.ch,t.sticky),c=Z(e,i))}function a(i){var a;if(a=r?ya(e.cm,c,t,n):ma(c,t,n),null==a){if(i||!o())return!1;t=va(r,e.cm,c,t.line,n)}else t=a;return!0}var s=t,l=n,c=Z(e,t.line);if("char"==i)a();else if("column"==i)a(!0);else if("word"==i||"group"==i)for(var u=null,d="group"==i,h=e.cm&&e.cm.getHelper(t,"wordChars"),f=!0;!(0>n)||a(!f);f=!1){var p=c.text.charAt(t.ch)||"\n",g=w(p,h)?"w":d&&"\n"==p?"n":!d||/\s/.test(p)?null:"p";if(!d||f||g||(g="s"),u&&u!=g){0>n&&(n=1,a(),t.sticky="after");break}if(g&&(u=g),n>0&&!a(!f))break}var m=Mo(e,t,s,l,!0);return ct(s,m)&&(m.hitSide=!0),m}function ss(e,t,n,i){var r,o=e.doc,a=t.left;if("page"==i){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),l=Math.max(s-.5*bi(e.display),3);r=(n>0?t.bottom:t.top)+n*l}else"line"==i&&(r=n>0?t.bottom+3:t.top-3);for(var c;c=hi(e,a,r),c.outside;){if(0>n?0>=r:r>=o.height){c.hitSide=!0;break}r+=5*n}return c}function ls(e,t){var n=Jn(e,t.line);if(!n||n.hidden)return null;var i=Z(e.doc,t.line),r=Wn(n,i,t.line),o=E(i,e.doc.direction),a="left";if(o){var s=T(o,t.ch);a=s%2?"right":"left"}var l=Xn(r.map,t.ch,a);return l.offset="right"==l.collapse?l.end:l.start,l}function cs(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function us(e,t){return t&&(e.bad=!0),e}function ds(e,t,n,i,r){function o(e){return function(t){return t.id==e}}function a(){u&&(c+=d,h&&(c+=d),u=h=!1)}function s(e){e&&(a(),c+=e)}function l(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return s(n),void 0;var c,f=t.getAttribute("cm-marker");if(f){var p=e.findMarks(st(i,0),st(r+1,0),o(+f));return p.length&&(c=p[0].find(0))&&s(et(e.doc,c.from,c.to).join(d)),void 0}if("false"==t.getAttribute("contenteditable"))return;var g=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;g&&a();for(var m=0;mr?u.map:d[r],a=0;ar?e.line:e.rest[r]),c=o[a]+i;return(0>i||s!=t)&&(c=o[a+(i?1:0)]),st(l,c)}}}var r=e.text.firstChild,a=!1;if(!t||!o(r,t))return us(st(it(e.line),0),!0);if(t==r&&(a=!0,t=r.childNodes[n],n=0,!t)){var s=e.rest?g(e.rest):e.line;return us(st(it(s),s.text.length),a)}var l=3==t.nodeType?t:null,c=t;for(l||1!=t.childNodes.length||3!=t.firstChild.nodeType||(l=t.firstChild,n&&(n=l.nodeValue.length));c.parentNode!=r;)c=c.parentNode;var u=e.measure,d=u.maps,h=i(l,c,n);if(h)return us(h,a);for(var f=c.nextSibling,p=l?l.nodeValue.length-n:0;f;f=f.nextSibling){if(h=i(f,f.firstChild,0))return us(st(h.line,h.ch-p),a);p+=f.textContent.length}for(var m=c.previousSibling,v=n;m;m=m.previousSibling){if(h=i(m,m.firstChild,-1))return us(st(h.line,h.ch+v),a);v+=m.textContent.length}}function ps(e,t){function n(){e.value=c.getValue()}if(t=t?u(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var i=a();t.autofocus=i==e||null!=e.getAttribute("autofocus")&&i==document.body}var r;if(e.form&&(il(e.form,"submit",n),!t.leaveSubmitMethodAlone)){var o=e.form;r=o.submit;try{var s=o.submit=function(){n(),o.submit=r,o.submit(),o.submit=s}}catch(l){}}t.finishInit=function(i){i.save=n,i.getTextArea=function(){return e},i.toTextArea=function(){i.toTextArea=isNaN,n(),e.parentNode.removeChild(i.getWrapperElement()),e.style.display="",e.form&&(A(e.form,"submit",n),t.leaveSubmitMethodAlone||"function"!=typeof e.form.submit||(e.form.submit=r))}},e.style.display="none";var c=Ka(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return c}function gs(e){e.off=A,e.on=il,e.wheelEventPixels=Hr,e.Doc=Hl,e.splitLines=ol,e.countColumn=d,e.findColumn=f,e.isWordChar=x,e.Pass=Js,e.signal=L,e.Line=yl,e.changeEnd=Rr,e.scrollbarModel=Tl,e.Pos=st,e.cmpPos=lt,e.modes=cl,e.mimeModes=ul,e.resolveMode=J,e.getMode=G,e.modeExtensions=dl,e.extendMode=K,e.copyState=X,e.startState=Y,e.innerMode=Q,e.commands=Jl,e.keyMap=Ul,e.keyName=ha,e.isModifierKey=ua,e.lookupKey=ca,e.normalizeKeyMap=la,e.StringStream=hl,e.SharedTextMarker=Pl,e.TextMarker=Ol,e.LineWidget=jl,e.e_preventDefault=O,e.e_stopPropagation=P,e.e_stop=H,e.addClass=s,e.contains=o,e.rmClass=Vs,e.keyNames=Fl}var ms=navigator.userAgent,vs=navigator.platform,ys=/gecko\/\d/i.test(ms),bs=/MSIE \d/.test(ms),xs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ms),ws=/Edge\/(\d+)/.exec(ms),ks=bs||xs||ws,Cs=ks&&(bs?document.documentMode||6:+(ws||xs)[1]),_s=!ws&&/WebKit\//.test(ms),$s=_s&&/Qt\/\d+\.\d+/.test(ms),Ss=!ws&&/Chrome\//.test(ms),Ts=/Opera\//.test(ms),Es=/Apple Computer/.test(navigator.vendor),Ms=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ms),As=/PhantomJS/.test(ms),Ls=!ws&&/AppleWebKit/.test(ms)&&/Mobile\/\w+/.test(ms),Ds=/Android/.test(ms),Ns=Ls||Ds||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ms),js=Ls||/Mac/.test(vs),Is=/\bCrOS\b/.test(ms),Os=/win/i.test(vs),Ps=Ts&&ms.match(/Version\/(\d*\.\d*)/);Ps&&(Ps=Number(Ps[1])),Ps&&Ps>=15&&(Ts=!1,_s=!0);var zs,Hs=js&&($s||Ts&&(null==Ps||12.11>Ps)),Bs=ys||ks&&Cs>=9,Vs=function(t,n){var i=t.className,r=e(n).exec(i);if(r){var o=i.slice(r.index+r[0].length);t.className=i.slice(0,r.index)+(o?r[1]+o:"")}};zs=document.createRange?function(e,t,n,i){var r=document.createRange();return r.setEnd(i||e,n),r.setStart(e,t),r}:function(e,t,n){var i=document.body.createTextRange();try{i.moveToElementText(e.parentNode)}catch(r){return i}return i.collapse(!0),i.moveEnd("character",n),i.moveStart("character",t),i};var Fs=function(e){e.select()};Ls?Fs=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:ks&&(Fs=function(e){try{e.select()}catch(t){}});var Rs=function(){this.id=null,this.f=null,this.time=0,this.handler=c(this.onTimeout,this)};Rs.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},Rs.prototype.set=function(e,t){this.f=t;var n=+new Date+e;(!this.id||n=e?n.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1785>=e?i.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,n){this.level=e,this.from=t,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",i="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,a=/[LRr]/,s=/[Lb1n]/,l=/[1n]/;return function(n,i){var c="ltr"==i?"L":"R";if(0==n.length||"ltr"==i&&!r.test(n))return!1;for(var u=n.length,d=[],h=0;u>h;++h)d.push(e(n.charCodeAt(h)));for(var f=0,p=c;u>f;++f){var m=d[f];"m"==m?d[f]=p:p=m}for(var v=0,y=c;u>v;++v){var b=d[v];"1"==b&&"r"==y?d[v]="n":a.test(b)&&(y=b,"r"==b&&(d[v]="R"))}for(var x=1,w=d[0];u-1>x;++x){var k=d[x];"+"==k&&"1"==w&&"1"==d[x+1]?d[x]="1":","!=k||w!=d[x+1]||"1"!=w&&"n"!=w||(d[x]=w),w=k}for(var C=0;u>C;++C){var _=d[C];if(","==_)d[C]="N";else if("%"==_){var $=void 0;for($=C+1;u>$&&"%"==d[$];++$);for(var S=C&&"!"==d[C-1]||u>$&&"1"==d[$]?"1":"N",T=C;$>T;++T)d[T]=S;C=$-1}}for(var E=0,M=c;u>E;++E){var A=d[E];"L"==M&&"1"==A?d[E]="L":a.test(A)&&(M=A)}for(var L=0;u>L;++L)if(o.test(d[L])){var D=void 0;for(D=L+1;u>D&&o.test(d[D]);++D);for(var N="L"==(L?d[L-1]:c),j="L"==(u>D?d[D]:c),I=N==j?N?"L":"R":c,O=L;D>O;++O)d[O]=I;L=D-1}for(var P,z=[],H=0;u>H;)if(s.test(d[H])){var B=H;for(++H;u>H&&s.test(d[H]);++H);z.push(new t(0,B,H))}else{var V=H,F=z.length;for(++H;u>H&&"L"!=d[H];++H);for(var R=V;H>R;)if(l.test(d[R])){R>V&&z.splice(F,0,new t(1,V,R));var W=R;for(++R;H>R&&l.test(d[R]);++R);z.splice(F,0,new t(2,W,R)),V=R}else++R;H>V&&z.splice(F,0,new t(1,V,H))}return"ltr"==i&&(1==z[0].level&&(P=n.match(/^\s+/))&&(z[0].from=P[0].length,z.unshift(new t(0,0,P[0].length))),1==g(z).level&&(P=n.match(/\s+$/))&&(g(z).to-=P[0].length,z.push(new t(0,u-P[0].length,u)))),"rtl"==i?z.reverse():z}}(),nl=[],il=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var i=e._handlers||(e._handlers={});i[t]=(i[t]||nl).concat(n)}},rl=function(){if(ks&&9>Cs)return!1;var e=i("div");return"draggable"in e||"dragDrop"in e}(),ol=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],i=e.length;i>=t;){var r=e.indexOf("\n",t);-1==r&&(r=e.length);var o=e.slice(t,"\r"==e.charAt(r-1)?r-1:r),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),t+=a+1):(n.push(o),t=r+1)}return n}:function(e){return e.split(/\r\n?|\n/)},al=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(n){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},sl=function(){var e=i("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),ll=null,cl={},ul={},dl={},hl=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};hl.prototype.eol=function(){return this.pos>=this.string.length},hl.prototype.sol=function(){return this.pos==this.lineStart},hl.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},hl.prototype.next=function(){return this.post},hl.prototype.eatSpace=function(){for(var e=this,t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++e.pos;return this.pos>t},hl.prototype.skipToEnd=function(){this.pos=this.string.length},hl.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},hl.prototype.backUp=function(e){this.pos-=e},hl.prototype.column=function(){return this.lastColumnPos0?null:(i&&t!==!1&&(this.pos+=i[0].length),i)}var r=function(e){return n?e.toLowerCase():e},o=this.string.substr(this.pos,e.length); return r(o)==r(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},hl.prototype.current=function(){return this.string.slice(this.start,this.pos)},hl.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},hl.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},hl.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var fl=function(e,t){this.state=e,this.lookAhead=t},pl=function(e,t,n,i){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=i||0,this.baseTokens=null,this.baseTokenPos=1};pl.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},pl.prototype.baseToken=function(e){var t=this;if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)t.baseTokenPos+=2;var n=this.baseTokens[this.baseTokenPos+1];return{type:n&&n.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},pl.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},pl.fromSaved=function(e,t,n){return t instanceof fl?new pl(e,X(e.mode,t.state),n,t.lookAhead):new pl(e,X(e.mode,t),n)},pl.prototype.save=function(e){var t=e!==!1?X(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new fl(t,this.maxLookAhead):t};var gl=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n},ml=!1,vl=!1,yl=function(e,t,n){this.text=e,Bt(this,t),this.height=n?n(this):1};yl.prototype.lineNo=function(){return it(this)},I(yl);var bl,xl={},wl={},kl=null,Cl=null,_l={left:0,right:0,top:0,bottom:0},$l=function(e,t,n){this.cm=n;var r=this.vert=i("div",[i("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=i("div",[i("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=o.tabIndex=-1,e(r),e(o),il(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),il(o,"scroll",function(){o.clientWidth&&t(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,ks&&8>Cs&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};$l.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,i=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?i+"px":"0";var r=e.viewHeight-(t?i:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+r)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?i+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?i:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==i&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?i:0,bottom:t?i:0}},$l.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},$l.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},$l.prototype.zeroWidthHack=function(){var e=js&&!Ms?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Rs,this.disableVert=new Rs},$l.prototype.enableZeroWidthBar=function(e,t,n){function i(){var r=e.getBoundingClientRect(),o="vert"==n?document.elementFromPoint(r.right-1,(r.top+r.bottom)/2):document.elementFromPoint((r.right+r.left)/2,r.bottom-1);o!=e?e.style.pointerEvents="none":t.set(1e3,i)}e.style.pointerEvents="auto",t.set(1e3,i)},$l.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Sl=function(){};Sl.prototype.update=function(){return{bottom:0,right:0}},Sl.prototype.setScrollLeft=function(){},Sl.prototype.setScrollTop=function(){},Sl.prototype.clear=function(){};var Tl={"native":$l,"null":Sl},El=0,Ml=function(e,t,n){var i=e.display;this.viewport=t,this.visible=qi(i,e.doc,t),this.editorIsHidden=!i.wrapper.offsetWidth,this.wrapperHeight=i.wrapper.clientHeight,this.wrapperWidth=i.wrapper.clientWidth,this.oldDisplayWidth=Vn(e),this.force=n,this.dims=wi(e),this.events=[]};Ml.prototype.signal=function(e,t){j(e,t)&&this.events.push(arguments)},Ml.prototype.finish=function(){for(var e=this,t=0;t=0&<(e,r.to())<=0)return i}return-1};var Nl=function(e,t){this.anchor=e,this.head=t};Nl.prototype.from=function(){return ht(this.anchor,this.head)},Nl.prototype.to=function(){return dt(this.anchor,this.head)},Nl.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},Wo.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=this,i=e,r=e+t;r>i;++i){var o=n.lines[i];n.height-=o.height,sn(o),wn(o,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){var i=this;this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;re;++e)if(n(i.lines[e]))return!0}},qo.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){var n=this;this.size-=t;for(var i=0;ie){var a=Math.min(t,o-e),s=r.height;if(r.removeInner(e,a),n.height-=s-r.height,o==a&&(n.children.splice(i--,1),r.parent=null),0==(t-=a))break;e=0}else e-=o}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Wo))){var l=[];this.collapse(l),this.children=[new Wo(l)],this.children[0].parent=this}},collapse:function(e){for(var t=this,n=0;n=e){if(o.insertInner(e,t,n),o.lines&&o.lines.length>50){for(var s=o.lines.length%25+25,l=s;l10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var i=this,r=0;re){var s=Math.min(t,a-e);if(o.iterN(e,s,n))return!0;if(0==(t-=s))break;e=0}else e-=a}}};var jl=function(e,t,n){var i=this;if(n)for(var r in n)n.hasOwnProperty(r)&&(i[r]=n[r]);this.doc=e,this.node=t};jl.prototype.clear=function(){var e=this,t=this.doc.cm,n=this.line.widgets,i=this.line,r=it(i);if(null!=r&&n){for(var o=0;ot.display.maxLineLength&&(t.display.maxLine=u,t.display.maxLineLength=d,t.display.maxLineChanged=!0)}null!=r&&t&&this.collapsed&&Ti(t,r,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&So(t.doc)),t&&wn(t,"markerCleared",t,this,r,o),n&&ur(t),this.parent&&this.parent.clear()}},Ol.prototype.find=function(e,t){var n=this;null==e&&"bookmark"==this.type&&(e=1);for(var i,r,o=0;o=0;c--)No(i,r[c]);l?ko(this,l):this.cm&&Qi(this.cm)}),undo:xr(function(){Io(this,"undo")}),redo:xr(function(){Io(this,"redo")}),undoSelection:xr(function(){Io(this,"undo",!0)}),redoSelection:xr(function(){Io(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,i=0;i=e.ch)&&t.push(r.marker.parent||r.marker)}return t},findMarks:function(e,t,n){e=pt(this,e),t=pt(this,t);var i=[],r=e.line;return this.iter(e.line,t.line+1,function(o){var a=o.markedSpans;if(a)for(var s=0;s=l.to||null==l.from&&r!=e.line||null!=l.from&&r==t.line&&l.from>=t.ch||n&&!n(l.marker)||i.push(l.marker.parent||l.marker)}++r}),i},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var i=0;ie?(t=e,!0):(e-=o,++n,void 0)}),pt(this,st(n,t))},indexFromPos:function(e){e=pt(this,e);var t=e.ch;if(e.linet&&(t=e.from),null!=e.to&&e.toRl;Rl++)Fl[Rl+48]=Fl[Rl+96]=String(Rl);for(var Wl=65;90>=Wl;Wl++)Fl[Wl]=String.fromCharCode(Wl);for(var ql=1;12>=ql;ql++)Fl[ql+111]=Fl[ql+63235]="F"+ql;var Ul={};Ul.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Ul.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Ul.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Ul.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Ul["default"]=js?Ul.macDefault:Ul.pcDefault;var Jl={selectAll:Lo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Gs)},killLine:function(e){return pa(e,function(t){if(t.empty()){var n=Z(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)r=new st(r.line,r.ch+1),e.replaceRange(o.charAt(r.ch-1)+o.charAt(r.ch-2),st(r.line,r.ch-2),r,"+transpose");else if(r.line>e.doc.first){var a=Z(e.doc,r.line-1).text;a&&(r=new st(r.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),st(r.line-1,a.length-1),r,"+transpose"))}n.push(new Nl(r,r))}e.setSelections(n)})},newlineAndIndent:function(e){return vr(e,function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var i=0;ie&&0==lt(t,this.pos)&&n==this.button};var Yl,Zl,ec={toString:function(){return"CodeMirror.Init"}},tc={},nc={};Ka.defaults=tc,Ka.optionHandlers=nc;var ic=[];Ka.defineInitHook=function(e){return ic.push(e)};var rc=null,oc=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Rs,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};oc.prototype.init=function(e){function t(e){if(!D(r,e)){if(r.somethingSelected())Ya({lineWise:!1,text:r.getSelections()}),"cut"==e.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var t=ns(r);Ya({lineWise:!0,text:t.text}),"cut"==e.type&&r.operation(function(){r.setSelections(t.ranges,0,Gs),r.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var n=rc.text.join("\n");if(e.clipboardData.setData("Text",n),e.clipboardData.getData("Text")==n)return e.preventDefault(),void 0}var a=rs(),s=a.firstChild;r.display.lineSpace.insertBefore(a,r.display.lineSpace.firstChild),s.value=rc.text.join("\n");var l=document.activeElement;Fs(s),setTimeout(function(){r.display.lineSpace.removeChild(a),l.focus(),l==o&&i.showPrimarySelection()},50)}}var n=this,i=this,r=i.cm,o=i.div=e.lineDiv;is(o,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize),il(o,"paste",function(e){D(r,e)||es(e,r)||11>=Cs&&setTimeout(yr(r,function(){return n.updateFromDOM()}),20)}),il(o,"compositionstart",function(e){n.composing={data:e.data,done:!1}}),il(o,"compositionupdate",function(e){n.composing||(n.composing={data:e.data,done:!1})}),il(o,"compositionend",function(e){n.composing&&(e.data!=n.composing.data&&n.readFromDOMSoon(),n.composing.done=!0)}),il(o,"touchstart",function(){return i.forceCompositionEnd()}),il(o,"input",function(){n.composing||n.readFromDOMSoon()}),il(o,"copy",t),il(o,"cut",t)},oc.prototype.prepareSelection=function(){var e=ji(this.cm,!1);return e.focus=this.cm.state.focused,e},oc.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},oc.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},oc.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,n=t.doc.sel.primary(),i=n.from(),r=n.to();if(t.display.viewTo==t.display.viewFrom||i.line>=t.display.viewTo||r.line=t.display.viewFrom&&ls(t,i)||{node:s[0].measure.map[2],offset:0},c=r.linee.firstLine()&&(i=st(i.line-1,Z(e.doc,i.line-1).length)),r.ch==Z(e.doc,r.line).text.length&&r.linet.viewTo-1)return!1;var o,a,s;i.line==t.viewFrom||0==(o=Si(e,i.line))?(a=it(t.view[0].line),s=t.view[0].node):(a=it(t.view[o].line),s=t.view[o-1].node.nextSibling);var l,c,u=Si(e,r.line);if(u==t.view.length-1?(l=t.viewTo-1,c=t.lineDiv.lastChild):(l=it(t.view[u+1].line)-1,c=t.view[u+1].node.previousSibling),!s)return!1;for(var d=e.doc.splitLines(ds(e,s,c,a,l)),h=et(e.doc,st(a,0),st(l,Z(e.doc,l).text.length));d.length>1&&h.length>1;)if(g(d)==g(h))d.pop(),h.pop(),l--;else{if(d[0]!=h[0])break;d.shift(),h.shift(),a++}for(var f=0,p=0,m=d[0],v=h[0],y=Math.min(m.length,v.length);y>f&&m.charCodeAt(f)==v.charCodeAt(f);)++f;for(var b=g(d),x=g(h),w=Math.min(b.length-(1==d.length?f:0),x.length-(1==h.length?f:0));w>p&&b.charCodeAt(b.length-p-1)==x.charCodeAt(x.length-p-1);)++p;if(1==d.length&&1==h.length&&a==i.line)for(;f&&f>i.ch&&b.charCodeAt(b.length-p-1)==x.charCodeAt(x.length-p-1);)f--,p++;d[d.length-1]=b.slice(0,b.length-p).replace(/^\u200b+/,""),d[0]=d[0].slice(f).replace(/\u200b+$/,"");var k=st(a,f),C=st(l,h.length?g(h).length-p:0);return d.length>1||d[0]||lt(k,C)?(Ho(e.doc,d,k,C,"+input"),!0):void 0},oc.prototype.ensurePolled=function(){this.forceCompositionEnd()},oc.prototype.reset=function(){this.forceCompositionEnd()},oc.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},oc.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()},80))},oc.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&vr(this.cm,function(){return Ti(e.cm)})},oc.prototype.setUneditable=function(e){e.contentEditable="false"},oc.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||yr(this.cm,Za)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},oc.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},oc.prototype.onContextMenu=function(){},oc.prototype.resetPosition=function(){},oc.prototype.needsContentAttribute=!0;var ac=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Rs,this.hasSelection=!1,this.composing=null};ac.prototype.init=function(e){function t(e){if(!D(r,e)){if(r.somethingSelected())Ya({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var t=ns(r);Ya({lineWise:!0,text:t.text}),"cut"==e.type?r.setSelections(t.ranges,null,Gs):(i.prevInput="",o.value=t.text.join("\n"),Fs(o))}"cut"==e.type&&(r.state.cutIncoming=+new Date)}}var n=this,i=this,r=this.cm;this.createField(e);var o=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),Ls&&(o.style.width="0px"),il(o,"input",function(){ks&&Cs>=9&&n.hasSelection&&(n.hasSelection=null),i.poll()}),il(o,"paste",function(e){D(r,e)||es(e,r)||(r.state.pasteIncoming=+new Date,i.fastPoll())}),il(o,"cut",t),il(o,"copy",t),il(e.scroller,"paste",function(t){if(!On(e,t)&&!D(r,t)){if(!o.dispatchEvent)return r.state.pasteIncoming=+new Date,i.focus(),void 0;var n=new Event("paste");n.clipboardData=t.clipboardData,o.dispatchEvent(n)}}),il(e.lineSpace,"selectstart",function(t){On(e,t)||O(t)}),il(o,"compositionstart",function(){var e=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}}),il(o,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},ac.prototype.createField=function(){this.wrapper=rs(),this.textarea=this.wrapper.firstChild},ac.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,i=ji(e);if(e.options.moveInputWithCursor){var r=ci(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();i.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,r.top+a.top-o.top)),i.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,r.left+a.left-o.left))}return i},ac.prototype.showSelection=function(e){var t=this.cm,i=t.display;n(i.cursorDiv,e.cursors),n(i.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},ac.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&Fs(this.textarea),ks&&Cs>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",ks&&Cs>=9&&(this.hasSelection=null))}},ac.prototype.getField=function(){return this.textarea},ac.prototype.supportsTouch=function(){return!1},ac.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!Ns||a()!=this.textarea))try{this.textarea.focus()}catch(e){}},ac.prototype.blur=function(){this.textarea.blur()},ac.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},ac.prototype.receivedFocus=function(){this.slowPoll()},ac.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},ac.prototype.fastPoll=function(){function e(){var i=n.poll();i||t?(n.pollingFast=!1,n.slowPoll()):(t=!0,n.polling.set(60,e))}var t=!1,n=this;n.pollingFast=!0,n.polling.set(20,e)},ac.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,i=this.prevInput;if(this.contextMenuPending||!t.state.focused||al(n)&&!i&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var r=n.value;if(r==i&&!t.somethingSelected())return!1;if(ks&&Cs>=9&&this.hasSelection===r||js&&/[\uf700-\uf7ff]/.test(r))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=r.charCodeAt(0);if(8203!=o||i||(i="​"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var a=0,s=Math.min(i.length,r.length);s>a&&i.charCodeAt(a)==r.charCodeAt(a);)++a;return vr(t,function(){Za(t,r.slice(a),i.length-a,null,e.composing?"*compose":null),r.length>1e3||r.indexOf("\n")>-1?n.value=e.prevInput="":e.prevInput=r,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ac.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},ac.prototype.onKeyPress=function(){ks&&Cs>=9&&(this.hasSelection=null),this.fastPoll()},ac.prototype.onContextMenu=function(e){function t(){if(null!=a.selectionStart){var e=r.somethingSelected(),t="​"+(e?a.value:"");a.value="⇚",a.value=t,i.prevInput=e?"":"​",a.selectionStart=1,a.selectionEnd=t.length,o.selForContextMenu=r.doc.sel}}function n(){if(i.contextMenuPending==n&&(i.contextMenuPending=!1,i.wrapper.style.cssText=d,a.style.cssText=u,ks&&9>Cs&&o.scrollbars.setScrollTop(o.scroller.scrollTop=l),null!=a.selectionStart)){(!ks||ks&&9>Cs)&&t();var e=0,s=function(){o.selForContextMenu==r.doc.sel&&0==a.selectionStart&&a.selectionEnd>0&&"​"==i.prevInput?yr(r,Lo)(r):e++<10?o.detectingSelectAll=setTimeout(s,500):(o.selForContextMenu=null,o.input.reset())};o.detectingSelectAll=setTimeout(s,200)}}var i=this,r=i.cm,o=r.display,a=i.textarea;i.contextMenuPending&&i.contextMenuPending();var s=$i(r,e),l=o.scroller.scrollTop;if(s&&!Ts){var c=r.options.resetSelectionOnContextMenu;c&&-1==r.doc.sel.contains(s)&&yr(r,Co)(r.doc,Fr(s),Gs);var u=a.style.cssText,d=i.wrapper.style.cssText,h=i.wrapper.offsetParent.getBoundingClientRect();i.wrapper.style.cssText="position: static",a.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(ks?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var f;if(_s&&(f=window.scrollY),o.input.focus(),_s&&window.scrollTo(null,f),o.input.reset(),r.somethingSelected()||(a.value=i.prevInput=" "),i.contextMenuPending=n,o.selForContextMenu=r.doc.sel,clearTimeout(o.detectingSelectAll),ks&&Cs>=9&&t(),Bs){H(e);var p=function(){A(window,"mouseup",p),setTimeout(n,20)};il(window,"mouseup",p)}else setTimeout(n,50)}},ac.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e},ac.prototype.setUneditable=function(){},ac.prototype.needsContentAttribute=!1,Ua(Ka),os(Ka);var sc="iter insert remove copy getEditor constructor".split(" ");for(var lc in Hl.prototype)Hl.prototype.hasOwnProperty(lc)&&h(sc,lc)<0&&(Ka.prototype[lc]=function(e){return function(){return e.apply(this.doc,arguments)}}(Hl.prototype[lc]));return I(Hl),Ka.inputStyles={textarea:ac,contenteditable:oc},Ka.defineMode=function(e){Ka.defaults.mode||"null"==e||(Ka.defaults.mode=e),q.apply(this,arguments)},Ka.defineMIME=U,Ka.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Ka.defineMIME("text/plain","null"),Ka.defineExtension=function(e,t){Ka.prototype[e]=t},Ka.defineDocExtension=function(e,t){Hl.prototype[e]=t},Ka.fromTextArea=ps,gs(Ka),Ka.version="5.50.2",Ka}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var t={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},n={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};e.defineMode("xml",function(i,r){function o(e,t){function n(n){return t.tokenize=n,n(e,t)}var i=e.next();if("<"==i)return e.eat("!")?e.eat("[")?e.match("CDATA[")?n(l("atom","]]>")):null:e.match("--")?n(l("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(c(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=l("meta","?>"),"meta"):(S=e.eat("/")?"closeTag":"openTag",t.tokenize=a,"tag bracket");if("&"==i){var r;return r=e.eat("#")?e.eat("x")?e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):e.eatWhile(/[\d]/)&&e.eat(";"):e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),r?"atom":"error"}return e.eatWhile(/[^&<]/),null}function a(e,t){var n=e.next();if(">"==n||"/"==n&&e.eat(">"))return t.tokenize=o,S=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return S="equals",null;if("<"==n){t.tokenize=o,t.state=f,t.tagName=t.tagStart=null;var i=t.tokenize(e,t);return i?i+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=s(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function s(e){var t=function(t,n){for(;!t.eol();)if(t.next()==e){n.tokenize=a;break}return"string"};return t.isInAttribute=!0,t}function l(e,t){return function(n,i){for(;!n.eol();){if(n.match(t)){i.tokenize=o;break}n.next()}return e}}function c(e){return function(t,n){for(var i;null!=(i=t.next());){if("<"==i)return n.tokenize=c(e+1),n.tokenize(t,n);if(">"==i){if(1==e){n.tokenize=o;break}return n.tokenize=c(e-1),n.tokenize(t,n)}}return"meta"}}function u(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n,(C.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}function d(e){e.context&&(e.context=e.context.prev)}function h(e,t){for(var n;;){if(!e.context)return;if(n=e.context.tagName,!C.contextGrabbers.hasOwnProperty(n)||!C.contextGrabbers[n].hasOwnProperty(t))return;d(e)}}function f(e,t,n){return"openTag"==e?(n.tagStart=t.column(),p):"closeTag"==e?g:f}function p(e,t,n){return"word"==e?(n.tagName=t.current(),T="tag",y):C.allowMissingTagName&&"endTag"==e?(T="tag bracket",y(e,t,n)):(T="error",p)}function g(e,t,n){if("word"==e){var i=t.current();return n.context&&n.context.tagName!=i&&C.implicitlyClosed.hasOwnProperty(n.context.tagName)&&d(n),n.context&&n.context.tagName==i||C.matchClosing===!1?(T="tag",m):(T="tag error",v)}return C.allowMissingTagName&&"endTag"==e?(T="tag bracket",m(e,t,n)):(T="error",v)}function m(e,t,n){return"endTag"!=e?(T="error",m):(d(n),f)}function v(e,t,n){return T="error",m(e,t,n)}function y(e,t,n){if("word"==e)return T="attribute",b;if("endTag"==e||"selfcloseTag"==e){var i=n.tagName,r=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==e||C.autoSelfClosers.hasOwnProperty(i)?h(n,i):(h(n,i),n.context=new u(n,i,r==n.indented)),f}return T="error",y}function b(e,t,n){return"equals"==e?x:(C.allowMissing||(T="error"),y(e,t,n))}function x(e,t,n){return"string"==e?w:"word"==e&&C.allowUnquoted?(T="string",y):(T="error",y(e,t,n))}function w(e,t,n){return"string"==e?w:y(e,t,n)}var k=i.indentUnit,C={},_=r.htmlMode?t:n;for(var $ in _)C[$]=_[$];for(var $ in r)C[$]=r[$];var S,T;return o.isInText=!0,{startState:function(e){var t={tokenize:o,state:f,indented:e||0,tagName:null,tagStart:null,context:null};return null!=e&&(t.baseIndent=e),t},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;S=null;var n=t.tokenize(e,t);return(n||S)&&"comment"!=n&&(T=null,t.state=t.state(S||n,e,t),T&&(n="error"==T?n+" error":T)),n},indent:function(t,n,i){var r=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+k;if(r&&r.noIndent)return e.Pass;if(t.tokenize!=a&&t.tokenize!=o)return i?i.match(/^(\s*)/)[0].length:0;if(t.tagName)return C.multilineTagIndentPastTag!==!1?t.tagStart+t.tagName.length+2:t.tagStart+k*(C.multilineTagIndentFactor||1);if(C.alignCDATA&&/$/,blockCommentStart:"",configuration:C.htmlMode?"html":"xml",helperType:C.htmlMode?"html":"xml",skipAttribute:function(e){e.state==x&&(e.state=y)},xmlCurrentTag:function(e){return e.tagName?{name:e.tagName,close:"closeTag"==e.type}:null},xmlCurrentContext:function(e){for(var t=[],n=e.context;n;n=n.prev)n.tagName&&t.push(n.tagName);return t.reverse()}}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){for(var t={},n=0;n*\/]/.test(n)?i(null,"select-op"):"."==n&&e.match(/^-?[_a-z][_a-z0-9-]*/i)?i("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(n)?i(null,n):e.match(/[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/.test(e.current().toLowerCase())&&(t.tokenize=a),i("variable callee","variable")):/[\w\\\-]/.test(n)?(e.eatWhile(/[\w\\\-]/),i("property","word")):i(null,null):/[\d.]/.test(e.peek())?(e.eatWhile(/[\w.%]/),i("number","unit")):e.match(/^-[\w\\\-]*/)?(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?i("variable-2","variable-definition"):i("variable-2","variable")):e.match(/^\w+-/)?i("meta","meta"):void 0}function o(e){return function(t,n){for(var r,o=!1;null!=(r=t.next());){if(r==e&&!o){")"==e&&t.backUp(1);break}o=!o&&"\\"==r}return(r==e||!o&&")"!=e)&&(n.tokenize=null),i("string","string")}}function a(e,t){return e.next(),t.tokenize=e.match(/\s*[\"\')]/,!1)?null:o(")"),i(null,"(")}function s(e,t,n){this.type=e,this.indent=t,this.prev=n}function l(e,t,n,i){return e.context=new s(n,t.indentation()+(i===!1?0:m),e.context),n}function c(e){return e.context.prev&&(e.context=e.context.prev),e.context.type}function u(e,t,n){return L[n.context.type](e,t,n)}function d(e,t,n,i){for(var r=i||1;r>0;r--)n.context=n.context.prev;return u(e,t,n)}function h(e){var t=e.current().toLowerCase();g=T.hasOwnProperty(t)?"atom":S.hasOwnProperty(t)?"keyword":"variable"}var f=n.inline;n.propertyKeywords||(n=e.resolveMode("text/css"));var p,g,m=t.indentUnit,v=n.tokenHooks,y=n.documentTypes||{},b=n.mediaTypes||{},x=n.mediaFeatures||{},w=n.mediaValueKeywords||{},k=n.propertyKeywords||{},C=n.nonStandardPropertyKeywords||{},_=n.fontProperties||{},$=n.counterDescriptors||{},S=n.colorKeywords||{},T=n.valueKeywords||{},E=n.allowNested,M=n.lineComment,A=n.supportsAtComponent===!0,L={};return L.top=function(e,t,n){if("{"==e)return l(n,t,"block");if("}"==e&&n.context.prev)return c(n);if(A&&/@component/i.test(e))return l(n,t,"atComponentBlock");if(/^@(-moz-)?document$/i.test(e))return l(n,t,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(e))return l(n,t,"atBlock");if(/^@(font-face|counter-style)/i.test(e))return n.stateArg=e,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(e))return"keyframes";if(e&&"@"==e.charAt(0))return l(n,t,"at");if("hash"==e)g="builtin";else if("word"==e)g="tag";else{if("variable-definition"==e)return"maybeprop";if("interpolation"==e)return l(n,t,"interpolation");if(":"==e)return"pseudo";if(E&&"("==e)return l(n,t,"parens")}return n.context.type},L.block=function(e,t,n){if("word"==e){var i=t.current().toLowerCase();return k.hasOwnProperty(i)?(g="property","maybeprop"):C.hasOwnProperty(i)?(g="string-2","maybeprop"):E?(g=t.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(g+=" error","maybeprop")}return"meta"==e?"block":E||"hash"!=e&&"qualifier"!=e?L.top(e,t,n):(g="error","block")},L.maybeprop=function(e,t,n){return":"==e?l(n,t,"prop"):u(e,t,n)},L.prop=function(e,t,n){if(";"==e)return c(n);if("{"==e&&E)return l(n,t,"propBlock");if("}"==e||"{"==e)return d(e,t,n);if("("==e)return l(n,t,"parens");if("hash"!=e||/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(t.current())){if("word"==e)h(t);else if("interpolation"==e)return l(n,t,"interpolation")}else g+=" error";return"prop"},L.propBlock=function(e,t,n){return"}"==e?c(n):"word"==e?(g="property","maybeprop"):n.context.type},L.parens=function(e,t,n){return"{"==e||"}"==e?d(e,t,n):")"==e?c(n):"("==e?l(n,t,"parens"):"interpolation"==e?l(n,t,"interpolation"):("word"==e&&h(t),"parens")},L.pseudo=function(e,t,n){return"meta"==e?"pseudo":"word"==e?(g="variable-3",n.context.type):u(e,t,n)},L.documentTypes=function(e,t,n){return"word"==e&&y.hasOwnProperty(t.current())?(g="tag",n.context.type):L.atBlock(e,t,n)},L.atBlock=function(e,t,n){if("("==e)return l(n,t,"atBlock_parens");if("}"==e||";"==e)return d(e,t,n);if("{"==e)return c(n)&&l(n,t,E?"block":"top");if("interpolation"==e)return l(n,t,"interpolation");if("word"==e){var i=t.current().toLowerCase();g="only"==i||"not"==i||"and"==i||"or"==i?"keyword":b.hasOwnProperty(i)?"attribute":x.hasOwnProperty(i)?"property":w.hasOwnProperty(i)?"keyword":k.hasOwnProperty(i)?"property":C.hasOwnProperty(i)?"string-2":T.hasOwnProperty(i)?"atom":S.hasOwnProperty(i)?"keyword":"error"}return n.context.type},L.atComponentBlock=function(e,t,n){return"}"==e?d(e,t,n):"{"==e?c(n)&&l(n,t,E?"block":"top",!1):("word"==e&&(g="error"),n.context.type)},L.atBlock_parens=function(e,t,n){return")"==e?c(n):"{"==e||"}"==e?d(e,t,n,2):L.atBlock(e,t,n)},L.restricted_atBlock_before=function(e,t,n){return"{"==e?l(n,t,"restricted_atBlock"):"word"==e&&"@counter-style"==n.stateArg?(g="variable","restricted_atBlock_before"):u(e,t,n)},L.restricted_atBlock=function(e,t,n){return"}"==e?(n.stateArg=null,c(n)):"word"==e?(g="@font-face"==n.stateArg&&!_.hasOwnProperty(t.current().toLowerCase())||"@counter-style"==n.stateArg&&!$.hasOwnProperty(t.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},L.keyframes=function(e,t,n){return"word"==e?(g="variable","keyframes"):"{"==e?l(n,t,"top"):u(e,t,n)},L.at=function(e,t,n){return";"==e?c(n):"{"==e||"}"==e?d(e,t,n):("word"==e?g="tag":"hash"==e&&(g="builtin"),"at")},L.interpolation=function(e,t,n){return"}"==e?c(n):"{"==e||";"==e?d(e,t,n):("word"==e?g="variable":"variable"!=e&&"("!=e&&")"!=e&&(g="error"),"interpolation")},{startState:function(e){return{tokenize:null,state:f?"block":"top",stateArg:null,context:new s(f?"block":"top",e||0,null)}},token:function(e,t){if(!t.tokenize&&e.eatSpace())return null;var n=(t.tokenize||r)(e,t);return n&&"object"==typeof n&&(p=n[1],n=n[0]),g=n,"comment"!=p&&(t.state=L[t.state](p,e,t)),g},indent:function(e,t){var n=e.context,i=t&&t.charAt(0),r=n.indent;return"prop"!=n.type||"}"!=i&&")"!=i||(n=n.prev),n.prev&&("}"!=i||"block"!=n.type&&"top"!=n.type&&"interpolation"!=n.type&&"restricted_atBlock"!=n.type?(")"==i&&("parens"==n.type||"atBlock_parens"==n.type)||"{"==i&&("at"==n.type||"atBlock"==n.type))&&(r=Math.max(0,n.indent-m)):(n=n.prev,r=n.indent)),r},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * ",lineComment:M,fold:"brace"}});var i=["domain","regexp","url","url-prefix"],r=t(i),o=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],a=t(o),s=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover"],l=t(s),c=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive"],u=t(c),d=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","mix-blend-mode","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],h=t(d),f=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],p=t(f),g=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],m=t(g),v=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],y=t(v),b=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],x=t(b),w=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],k=t(w),C=i.concat(o).concat(s).concat(c).concat(d).concat(f).concat(b).concat(w); e.registerHelper("hintWords","css",C),e.defineMIME("text/css",{documentTypes:r,mediaTypes:a,mediaFeatures:l,mediaValueKeywords:u,propertyKeywords:h,nonStandardPropertyKeywords:p,fontProperties:m,counterDescriptors:y,colorKeywords:x,valueKeywords:k,tokenHooks:{"/":function(e,t){return e.eat("*")?(t.tokenize=n,n(e,t)):!1}},name:"css"}),e.defineMIME("text/x-scss",{mediaTypes:a,mediaFeatures:l,mediaValueKeywords:u,propertyKeywords:h,nonStandardPropertyKeywords:p,colorKeywords:x,valueKeywords:k,fontProperties:m,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=n,n(e,t)):["operator","operator"]},":":function(e){return e.match(/\s*\{/,!1)?[null,null]:!1},$:function(e){return e.match(/^[\w-]+/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(e){return e.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"}),e.defineMIME("text/x-less",{mediaTypes:a,mediaFeatures:l,mediaValueKeywords:u,propertyKeywords:h,nonStandardPropertyKeywords:p,colorKeywords:x,valueKeywords:k,fontProperties:m,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=n,n(e,t)):["operator","operator"]},"@":function(e){return e.eat("{")?[null,"interpolation"]:e.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i,!1)?!1:(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"}),e.defineMIME("text/x-gss",{documentTypes:r,mediaTypes:a,mediaFeatures:l,propertyKeywords:h,nonStandardPropertyKeywords:p,fontProperties:m,counterDescriptors:y,colorKeywords:x,valueKeywords:k,supportsAtComponent:!0,tokenHooks:{"/":function(e,t){return e.eat("*")?(t.tokenize=n,n(e,t)):!1}},name:"css",helperType:"gss"})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("javascript",function(t,n){function i(e){for(var t,n=!1,i=!1;null!=(t=e.next());){if(!n){if("/"==t&&!i)return;"["==t?i=!0:i&&"]"==t&&(i=!1)}n=!n&&"\\"==t}}function r(e,t,n){return Bt=e,Vt=n,t}function o(e,t){var n=e.next();if('"'==n||"'"==n)return t.tokenize=a(n),t.tokenize(e,t);if("."==n&&e.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return r("number","number");if("."==n&&e.match(".."))return r("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return r(n);if("="==n&&e.eat(">"))return r("=>","operator");if("0"==n&&e.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return r("number","number");if(/\d/.test(n))return e.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),r("number","number");if("/"==n)return e.eat("*")?(t.tokenize=s,s(e,t)):e.eat("/")?(e.skipToEnd(),r("comment","comment")):Ht(e,t,1)?(i(e),e.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),r("regexp","string-2")):(e.eat("="),r("operator","operator",e.current()));if("`"==n)return t.tokenize=l,l(e,t);if("#"==n)return e.skipToEnd(),r("error","error");if("<"==n&&e.match("!--")||"-"==n&&e.match("->"))return e.skipToEnd(),r("comment","comment");if(Kt.test(n))return">"==n&&t.lexical&&">"==t.lexical.type||(e.eat("=")?("!"==n||"="==n)&&e.eat("="):/[<>*+\-]/.test(n)&&(e.eat(n),">"==n&&e.eat(n))),r("operator","operator",e.current());if(Jt.test(n)){e.eatWhile(Jt);var o=e.current();if("."!=t.lastType){if(Gt.propertyIsEnumerable(o)){var c=Gt[o];return r(c.type,c.style,o)}if("async"==o&&e.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/,!1))return r("async","keyword",o)}return r("variable","variable",o)}}function a(e){return function(t,n){var i,a=!1;if(Wt&&"@"==t.peek()&&t.match(Xt))return n.tokenize=o,r("jsonld-keyword","meta");for(;null!=(i=t.next())&&(i!=e||a);)a=!a&&"\\"==i;return a||(n.tokenize=o),r("string","string")}}function s(e,t){for(var n,i=!1;n=e.next();){if("/"==n&&i){t.tokenize=o;break}i="*"==n}return r("comment","comment")}function l(e,t){for(var n,i=!1;null!=(n=e.next());){if(!i&&("`"==n||"$"==n&&e.eat("{"))){t.tokenize=o;break}i=!i&&"\\"==n}return r("quasi","string-2",e.current())}function c(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var n=e.string.indexOf("=>",e.start);if(!(0>n)){if(Ut){var i=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(e.string.slice(e.start,n));i&&(n=i.index)}for(var r=0,o=!1,a=n-1;a>=0;--a){var s=e.string.charAt(a),l=Qt.indexOf(s);if(l>=0&&3>l){if(!r){++a;break}if(0==--r){"("==s&&(o=!0);break}}else if(l>=3&&6>l)++r;else if(Jt.test(s))o=!0;else if(/["'\/`]/.test(s))for(;;--a){if(0==a)return;var c=e.string.charAt(a-1);if(c==s&&"\\"!=e.string.charAt(a-2)){a--;break}}else if(o&&!r){++a;break}}o&&!r&&(t.fatArrowAt=a)}}function u(e,t,n,i,r,o){this.indented=e,this.column=t,this.type=n,this.prev=r,this.info=o,null!=i&&(this.align=i)}function d(e,t){for(var n=e.localVars;n;n=n.next)if(n.name==t)return!0;for(var i=e.context;i;i=i.prev)for(var n=i.vars;n;n=n.next)if(n.name==t)return!0}function h(e,t,n,i,r){var o=e.cc;for(Zt.state=e,Zt.stream=r,Zt.marked=null,Zt.cc=o,Zt.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);;){var a=o.length?o.pop():qt?M:T;if(a(n,i)){for(;o.length&&o[o.length-1].lex;)o.pop()();return Zt.marked?Zt.marked:"variable"==n&&d(e,i)?"variable-2":t}}}function f(){for(var e=arguments.length-1;e>=0;e--)Zt.cc.push(arguments[e])}function p(){return f.apply(null,arguments),!0}function g(e,t){for(var n=t;n;n=n.next)if(n.name==e)return!0;return!1}function m(e){var t=Zt.state;if(Zt.marked="def",t.context)if("var"==t.lexical.info&&t.context&&t.context.block){var i=v(e,t.context);if(null!=i)return t.context=i,void 0}else if(!g(e,t.localVars))return t.localVars=new x(e,t.localVars),void 0;n.globalVars&&!g(e,t.globalVars)&&(t.globalVars=new x(e,t.globalVars))}function v(e,t){if(t){if(t.block){var n=v(e,t.prev);return n?n==t.prev?t:new b(n,t.vars,!0):null}return g(e,t.vars)?t:new b(t.prev,new x(e,t.vars),!1)}return null}function y(e){return"public"==e||"private"==e||"protected"==e||"abstract"==e||"readonly"==e}function b(e,t,n){this.prev=e,this.vars=t,this.block=n}function x(e,t){this.name=e,this.next=t}function w(){Zt.state.context=new b(Zt.state.context,Zt.state.localVars,!1),Zt.state.localVars=en}function k(){Zt.state.context=new b(Zt.state.context,Zt.state.localVars,!0),Zt.state.localVars=null}function C(){Zt.state.localVars=Zt.state.context.vars,Zt.state.context=Zt.state.context.prev}function _(e,t){var n=function(){var n=Zt.state,i=n.indented;if("stat"==n.lexical.type)i=n.lexical.indented;else for(var r=n.lexical;r&&")"==r.type&&r.align;r=r.prev)i=r.indented;n.lexical=new u(i,Zt.stream.column(),e,null,n.lexical,t)};return n.lex=!0,n}function $(){var e=Zt.state;e.lexical.prev&&(")"==e.lexical.type&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function S(e){function t(n){return n==e?p():";"==e||"}"==n||")"==n||"]"==n?f():p(t)}return t}function T(e,t){return"var"==e?p(_("vardef",t),ct,S(";"),$):"keyword a"==e?p(_("form"),L,T,$):"keyword b"==e?p(_("form"),T,$):"keyword d"==e?Zt.stream.match(/^\s*$/,!1)?p():p(_("stat"),N,S(";"),$):"debugger"==e?p(S(";")):"{"==e?p(_("}"),k,X,$,C):";"==e?p():"if"==e?("else"==Zt.state.lexical.info&&Zt.state.cc[Zt.state.cc.length-1]==$&&Zt.state.cc.pop()(),p(_("form"),L,T,$,gt)):"function"==e?p(bt):"for"==e?p(_("form"),mt,T,$):"class"==e||Ut&&"interface"==t?(Zt.marked="keyword",p(_("form","class"==e?e:t),_t,$)):"variable"==e?Ut&&"declare"==t?(Zt.marked="keyword",p(T)):Ut&&("module"==t||"enum"==t||"type"==t)&&Zt.stream.match(/^\s*\w/,!1)?(Zt.marked="keyword","enum"==t?p(Ot):"type"==t?p(wt,S("operator"),tt,S(";")):p(_("form"),ut,S("{"),_("}"),X,$,$)):Ut&&"namespace"==t?(Zt.marked="keyword",p(_("form"),M,T,$)):Ut&&"abstract"==t?(Zt.marked="keyword",p(T)):p(_("stat"),R):"switch"==e?p(_("form"),L,S("{"),_("}","switch"),k,X,$,$,C):"case"==e?p(M,S(":")):"default"==e?p(S(":")):"catch"==e?p(_("form"),w,E,T,$,C):"export"==e?p(_("stat"),Et,$):"import"==e?p(_("stat"),At,$):"async"==e?p(T):"@"==t?p(M,T):f(_("stat"),M,S(";"),$)}function E(e){return"("==e?p(kt,S(")")):void 0}function M(e,t){return D(e,t,!1)}function A(e,t){return D(e,t,!0)}function L(e){return"("!=e?f():p(_(")"),M,S(")"),$)}function D(e,t,n){if(Zt.state.fatArrowAt==Zt.stream.start){var i=n?H:z;if("("==e)return p(w,_(")"),G(kt,")"),$,S("=>"),i,C);if("variable"==e)return f(w,ut,S("=>"),i,C)}var r=n?I:j;return Yt.hasOwnProperty(e)?p(r):"function"==e?p(bt,r):"class"==e||Ut&&"interface"==t?(Zt.marked="keyword",p(_("form"),Ct,$)):"keyword c"==e||"async"==e?p(n?A:M):"("==e?p(_(")"),N,S(")"),$,r):"operator"==e||"spread"==e?p(n?A:M):"["==e?p(_("]"),It,$,r):"{"==e?K(q,"}",null,r):"quasi"==e?f(O,r):"new"==e?p(B(n)):"import"==e?p(M):p()}function N(e){return e.match(/[;\}\)\],]/)?f():f(M)}function j(e,t){return","==e?p(M):I(e,t,!1)}function I(e,t,n){var i=0==n?j:I,r=0==n?M:A;return"=>"==e?p(w,n?H:z,C):"operator"==e?/\+\+|--/.test(t)||Ut&&"!"==t?p(i):Ut&&"<"==t&&Zt.stream.match(/^([^>]|<.*?>)*>\s*\(/,!1)?p(_(">"),G(tt,">"),$,i):"?"==t?p(M,S(":"),r):p(r):"quasi"==e?f(O,i):";"!=e?"("==e?K(A,")","call",i):"."==e?p(W,i):"["==e?p(_("]"),N,S("]"),$,i):Ut&&"as"==t?(Zt.marked="keyword",p(tt,i)):"regexp"==e?(Zt.state.lastType=Zt.marked="operator",Zt.stream.backUp(Zt.stream.pos-Zt.stream.start-1),p(r)):void 0:void 0}function O(e,t){return"quasi"!=e?f():"${"!=t.slice(t.length-2)?p(O):p(M,P)}function P(e){return"}"==e?(Zt.marked="string-2",Zt.state.tokenize=l,p(O)):void 0}function z(e){return c(Zt.stream,Zt.state),f("{"==e?T:M)}function H(e){return c(Zt.stream,Zt.state),f("{"==e?T:A)}function B(e){return function(t){return"."==t?p(e?F:V):"variable"==t&&Ut?p(at,e?I:j):f(e?A:M)}}function V(e,t){return"target"==t?(Zt.marked="keyword",p(j)):void 0}function F(e,t){return"target"==t?(Zt.marked="keyword",p(I)):void 0}function R(e){return":"==e?p($,T):f(j,S(";"),$)}function W(e){return"variable"==e?(Zt.marked="property",p()):void 0}function q(e,t){if("async"==e)return Zt.marked="property",p(q);if("variable"==e||"keyword"==Zt.style){if(Zt.marked="property","get"==t||"set"==t)return p(U);var n;return Ut&&Zt.state.fatArrowAt==Zt.stream.start&&(n=Zt.stream.match(/^\s*:\s*/,!1))&&(Zt.state.fatArrowAt=Zt.stream.pos+n[0].length),p(J)}return"number"==e||"string"==e?(Zt.marked=Wt?"property":Zt.style+" property",p(J)):"jsonld-keyword"==e?p(J):Ut&&y(t)?(Zt.marked="keyword",p(q)):"["==e?p(M,Q,S("]"),J):"spread"==e?p(A,J):"*"==t?(Zt.marked="keyword",p(q)):":"==e?f(J):void 0}function U(e){return"variable"!=e?f(J):(Zt.marked="property",p(bt))}function J(e){return":"==e?p(A):"("==e?f(bt):void 0}function G(e,t,n){function i(r,o){if(n?n.indexOf(r)>-1:","==r){var a=Zt.state.lexical;return"call"==a.info&&(a.pos=(a.pos||0)+1),p(function(n,i){return n==t||i==t?f():f(e)},i)}return r==t||o==t?p():n&&n.indexOf(";")>-1?f(e):p(S(t))}return function(n,r){return n==t||r==t?p():f(e,i)}}function K(e,t,n){for(var i=3;i"),tt):void 0}function nt(e){return"=>"==e?p(tt):void 0}function it(e,t){return"variable"==e||"keyword"==Zt.style?(Zt.marked="property",p(it)):"?"==t||"number"==e||"string"==e?p(it):":"==e?p(tt):"["==e?p(S("variable"),Y,S("]"),it):"("==e?f(xt,it):void 0}function rt(e,t){return"variable"==e&&Zt.stream.match(/^\s*[?:]/,!1)||"?"==t?p(rt):":"==e?p(tt):"spread"==e?p(rt):f(tt)}function ot(e,t){return"<"==t?p(_(">"),G(tt,">"),$,ot):"|"==t||"."==e||"&"==t?p(tt):"["==e?p(tt,S("]"),ot):"extends"==t||"implements"==t?(Zt.marked="keyword",p(tt)):"?"==t?p(tt,S(":"),tt):void 0}function at(e,t){return"<"==t?p(_(">"),G(tt,">"),$,ot):void 0}function st(){return f(tt,lt)}function lt(e,t){return"="==t?p(tt):void 0}function ct(e,t){return"enum"==t?(Zt.marked="keyword",p(Ot)):f(ut,Q,ft,pt)}function ut(e,t){return Ut&&y(t)?(Zt.marked="keyword",p(ut)):"variable"==e?(m(t),p()):"spread"==e?p(ut):"["==e?K(ht,"]"):"{"==e?K(dt,"}"):void 0}function dt(e,t){return"variable"!=e||Zt.stream.match(/^\s*:/,!1)?("variable"==e&&(Zt.marked="property"),"spread"==e?p(ut):"}"==e?f():"["==e?p(M,S("]"),S(":"),dt):p(S(":"),ut,ft)):(m(t),p(ft))}function ht(){return f(ut,ft)}function ft(e,t){return"="==t?p(A):void 0}function pt(e){return","==e?p(ct):void 0}function gt(e,t){return"keyword b"==e&&"else"==t?p(_("form","else"),T,$):void 0}function mt(e,t){return"await"==t?p(mt):"("==e?p(_(")"),vt,$):void 0}function vt(e){return"var"==e?p(ct,yt):"variable"==e?p(yt):f(yt)}function yt(e,t){return")"==e?p():";"==e?p(yt):"in"==t||"of"==t?(Zt.marked="keyword",p(M,yt)):f(M,yt)}function bt(e,t){return"*"==t?(Zt.marked="keyword",p(bt)):"variable"==e?(m(t),p(bt)):"("==e?p(w,_(")"),G(kt,")"),$,Z,T,C):Ut&&"<"==t?p(_(">"),G(st,">"),$,bt):void 0}function xt(e,t){return"*"==t?(Zt.marked="keyword",p(xt)):"variable"==e?(m(t),p(xt)):"("==e?p(w,_(")"),G(kt,")"),$,Z,C):Ut&&"<"==t?p(_(">"),G(st,">"),$,xt):void 0}function wt(e,t){return"keyword"==e||"variable"==e?(Zt.marked="type",p(wt)):"<"==t?p(_(">"),G(st,">"),$):void 0}function kt(e,t){return"@"==t&&p(M,kt),"spread"==e?p(kt):Ut&&y(t)?(Zt.marked="keyword",p(kt)):Ut&&"this"==e?p(Q,ft):f(ut,Q,ft)}function Ct(e,t){return"variable"==e?_t(e,t):$t(e,t)}function _t(e,t){return"variable"==e?(m(t),p($t)):void 0}function $t(e,t){return"<"==t?p(_(">"),G(st,">"),$,$t):"extends"==t||"implements"==t||Ut&&","==e?("implements"==t&&(Zt.marked="keyword"),p(Ut?tt:M,$t)):"{"==e?p(_("}"),St,$):void 0}function St(e,t){return"async"==e||"variable"==e&&("static"==t||"get"==t||"set"==t||Ut&&y(t))&&Zt.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?(Zt.marked="keyword",p(St)):"variable"==e||"keyword"==Zt.style?(Zt.marked="property",p(Ut?Tt:bt,St)):"number"==e||"string"==e?p(Ut?Tt:bt,St):"["==e?p(M,Q,S("]"),Ut?Tt:bt,St):"*"==t?(Zt.marked="keyword",p(St)):Ut&&"("==e?f(xt,St):";"==e||","==e?p(St):"}"==e?p():"@"==t?p(M,St):void 0}function Tt(e,t){if("?"==t)return p(Tt);if(":"==e)return p(tt,ft);if("="==t)return p(A);var n=Zt.state.lexical.prev,i=n&&"interface"==n.info;return f(i?xt:bt)}function Et(e,t){return"*"==t?(Zt.marked="keyword",p(jt,S(";"))):"default"==t?(Zt.marked="keyword",p(M,S(";"))):"{"==e?p(G(Mt,"}"),jt,S(";")):f(T)}function Mt(e,t){return"as"==t?(Zt.marked="keyword",p(S("variable"))):"variable"==e?f(A,Mt):void 0}function At(e){return"string"==e?p():"("==e?f(M):f(Lt,Dt,jt)}function Lt(e,t){return"{"==e?K(Lt,"}"):("variable"==e&&m(t),"*"==t&&(Zt.marked="keyword"),p(Nt))}function Dt(e){return","==e?p(Lt,Dt):void 0}function Nt(e,t){return"as"==t?(Zt.marked="keyword",p(Lt)):void 0}function jt(e,t){return"from"==t?(Zt.marked="keyword",p(M)):void 0}function It(e){return"]"==e?p():f(G(A,"]"))}function Ot(){return f(_("form"),ut,S("{"),_("}"),G(Pt,"}"),$,$)}function Pt(){return f(ut,ft)}function zt(e,t){return"operator"==e.lastType||","==e.lastType||Kt.test(t.charAt(0))||/[,.]/.test(t.charAt(0))}function Ht(e,t,n){return t.tokenize==o&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(t.lastType)||"quasi"==t.lastType&&/\{\s*$/.test(e.string.slice(0,e.pos-(n||0)))}var Bt,Vt,Ft=t.indentUnit,Rt=n.statementIndent,Wt=n.jsonld,qt=n.json||Wt,Ut=n.typescript,Jt=n.wordCharacters||/[\w$\xa1-\uffff]/,Gt=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),n=e("keyword b"),i=e("keyword c"),r=e("keyword d"),o=e("operator"),a={type:"atom",style:"atom"};return{"if":e("if"),"while":t,"with":t,"else":n,"do":n,"try":n,"finally":n,"return":r,"break":r,"continue":r,"new":e("new"),"delete":i,"void":i,"throw":i,"debugger":e("debugger"),"var":e("var"),"const":e("var"),let:e("var"),"function":e("function"),"catch":e("catch"),"for":e("for"),"switch":e("switch"),"case":e("case"),"default":e("default"),"in":o,"typeof":o,"instanceof":o,"true":a,"false":a,"null":a,undefined:a,NaN:a,Infinity:a,"this":e("this"),"class":e("class"),"super":e("atom"),yield:i,"export":e("export"),"import":e("import"),"extends":i,await:i}}(),Kt=/[+\-*&%=<>!?|~^@]/,Xt=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,Qt="([{}])",Yt={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},Zt={state:null,column:null,marked:null,cc:null},en=new x("this",new x("arguments",null));return C.lex=!0,$.lex=!0,{startState:function(e){var t={tokenize:o,lastType:"sof",cc:[],lexical:new u((e||0)-Ft,0,"block",!1),localVars:n.localVars,context:n.localVars&&new b(null,null,!1),indented:e||0};return n.globalVars&&"object"==typeof n.globalVars&&(t.globalVars=n.globalVars),t},token:function(e,t){if(e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),c(e,t)),t.tokenize!=s&&e.eatSpace())return null;var n=t.tokenize(e,t);return"comment"==Bt?n:(t.lastType="operator"!=Bt||"++"!=Vt&&"--"!=Vt?Bt:"incdec",h(t,n,Bt,Vt,e))},indent:function(t,i){if(t.tokenize==s)return e.Pass;if(t.tokenize!=o)return 0;var r,a=i&&i.charAt(0),l=t.lexical;if(!/^\s*else\b/.test(i))for(var c=t.cc.length-1;c>=0;--c){var u=t.cc[c];if(u==$)l=l.prev;else if(u!=gt)break}for(;!("stat"!=l.type&&"form"!=l.type||"}"!=a&&(!(r=t.cc[t.cc.length-1])||r!=j&&r!=I||/^[,\.=+\-*:?[\(]/.test(i)));)l=l.prev;Rt&&")"==l.type&&"stat"==l.prev.type&&(l=l.prev);var d=l.type,h=a==d;return"vardef"==d?l.indented+("operator"==t.lastType||","==t.lastType?l.info.length+1:0):"form"==d&&"{"==a?l.indented:"form"==d?l.indented+Ft:"stat"==d?l.indented+(zt(t,i)?Rt||Ft:0):"switch"!=l.info||h||0==n.doubleIndentSwitch?l.align?l.column+(h?0:1):l.indented+(h?0:Ft):l.indented+(/^(?:case|default)\b/.test(i)?Ft:2*Ft)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:qt?null:"/*",blockCommentEnd:qt?null:"*/",blockCommentContinue:qt?null:" * ",lineComment:qt?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:qt?"json":"javascript",jsonldMode:Wt,jsonMode:qt,expressionAllowed:Ht,skipExpression:function(e){var t=e.cc[e.cc.length-1];(t==M||t==A)&&e.cc.pop()}}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,n){var i=e.current(),r=i.search(t);return r>-1?e.backUp(i.length-r):i.match(/<\/?$/)&&(e.backUp(i.length),e.match(t,!1)||e.match(i)),n}function n(e){var t=l[e];return t?t:l[e]=new RegExp("\\s+"+e+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")}function i(e,t){var i=e.match(n(t));return i?/^\s*(.*?)\s*$/.exec(i[2])[1]:""}function r(e,t){return new RegExp((t?"^":"")+"","i")}function o(e,t){for(var n in e)for(var i=t[n]||(t[n]=[]),r=e[n],o=r.length-1;o>=0;o--)i.unshift(r[o])}function a(e,t){for(var n=0;n\s\/]/.test(i.current())&&(s=o.htmlState.tagName&&o.htmlState.tagName.toLowerCase())&&u.hasOwnProperty(s))o.inTag=s+" ";else if(o.inTag&&h&&/>$/.test(i.current())){var f=/^([\S]+) (.*)/.exec(o.inTag);o.inTag=null;var p=">"==i.current()&&a(u[f[1]],f[2]),g=e.getMode(n,p),m=r(f[1],!0),v=r(f[1],!1);o.token=function(e,n){return e.match(m,!1)?(n.token=l,n.localState=n.localMode=null,null):t(e,v,n.localMode.token(e,n.localState))},o.localMode=g,o.localState=e.startState(g,c.indent(o.htmlState,"",""))}else o.inTag&&(o.inTag+=i.current(),i.eol()&&(o.inTag+=" "));return d}var c=e.getMode(n,{name:"xml",htmlMode:!0,multilineTagIndentFactor:i.multilineTagIndentFactor,multilineTagIndentPastTag:i.multilineTagIndentPastTag}),u={},d=i&&i.tags,h=i&&i.scriptTypes;if(o(s,u),d&&o(d,u),h)for(var f=h.length-1;f>=0;f--)u.script.unshift(["type",h[f].matches,h[f].mode]);return{startState:function(){var t=e.startState(c);return{token:l,inTag:null,localMode:null,localState:null,htmlState:t}},copyState:function(t){var n;return t.localState&&(n=e.copyState(t.localMode,t.localState)),{token:t.token,inTag:t.inTag,localMode:t.localMode,localState:n,htmlState:e.copyState(c,t.htmlState)}},token:function(e,t){return t.token(e,t)},indent:function(t,n,i){return!t.localMode||/^\s*<\//.test(n)?c.indent(t.htmlState,n,i):t.localMode.indent?t.localMode.indent(t.localState,n,i):e.Pass},innerMode:function(e){return{state:e.localState||e.htmlState,mode:e.localMode||c}}}},"xml","javascript","css"),e.defineMIME("text/html","htmlmixed")}),function(){function e(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32}e.prototype.diff_main=function(e,t,n,i){if("undefined"==typeof i&&(i=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1e3*this.Diff_Timeout),null==e||null==t)throw Error("Null input. (diff_main)");if(e==t)return e?[[0,e]]:[];"undefined"==typeof n&&(n=!0);var r=n,o=this.diff_commonPrefix(e,t);n=e.substring(0,o),e=e.substring(o),t=t.substring(o);var o=this.diff_commonSuffix(e,t),a=e.substring(e.length-o);return e=e.substring(0,e.length-o),t=t.substring(0,t.length-o),e=this.diff_compute_(e,t,r,i),n&&e.unshift([0,n]),a&&e.push([0,a]),this.diff_cleanupMerge(e),e},e.prototype.diff_compute_=function(e,t,n,i){if(!e)return[[1,t]];if(!t)return[[-1,e]];var r=e.length>t.length?e:t,o=e.length>t.length?t:e,a=r.indexOf(o);return-1!=a?(n=[[1,r.substring(0,a)],[0,o],[1,r.substring(a+o.length)]],e.length>t.length&&(n[0][0]=n[2][0]=-1),n):1==o.length?[[-1,e],[1,t]]:(r=this.diff_halfMatch_(e,t))?(o=r[0],e=r[1],a=r[2],t=r[3],r=r[4],o=this.diff_main(o,a,n,i),n=this.diff_main(e,t,n,i),o.concat([[0,r]],n)):n&&100=1&&r>=1){for(e.splice(t-i-r,i+r),t=t-i-r,i=this.diff_main(o,a,!1,n),r=i.length-1;r>=0;r--)e.splice(t,0,i[r]);t+=i.length}i=r=0,a=o=""}t++}return e.pop(),e},e.prototype.diff_bisect_=function(e,t,n){for(var i=e.length,r=t.length,o=Math.ceil((i+r)/2),a=o,s=2*o,l=Array(s),c=Array(s),u=0;s>u;u++)l[u]=-1,c[u]=-1;l[a+1]=0,c[a+1]=0;for(var u=i-r,d=0!=u%2,h=0,f=0,p=0,g=0,m=0;o>m&&!((new Date).getTime()>n);m++){for(var v=-m+h;m-f>=v;v+=2){var y,b=a+v;y=v==-m||v!=m&&l[b-1]y&&r>x&&e.charAt(y)==t.charAt(x);)y++,x++;if(l[b]=y,y>i)f+=2;else if(x>r)h+=2;else if(d&&(b=a+u-v,b>=0&&s>b&&-1!=c[b])){var w=i-c[b];if(y>=w)return this.diff_bisectSplit_(e,t,y,x,n)}}for(v=-m+p;m-g>=v;v+=2){for(b=a+v,w=v==-m||v!=m&&c[b-1]w&&r>y&&e.charAt(i-w-1)==t.charAt(r-y-1);)w++,y++;if(c[b]=w,w>i)g+=2;else if(y>r)p+=2;else if(!d&&(b=a+u-v,b>=0&&s>b&&-1!=l[b]&&(y=l[b],x=a+y-b,w=i-w,y>=w)))return this.diff_bisectSplit_(e,t,y,x,n)}}return[[-1,e],[1,t]]},e.prototype.diff_bisectSplit_=function(e,t,n,i,r){var o=e.substring(0,n),a=t.substring(0,i);return e=e.substring(n),t=t.substring(i),o=this.diff_main(o,a,!1,r),r=this.diff_main(e,t,!1,r),o.concat(r)},e.prototype.diff_linesToChars_=function(e,t){function n(e){for(var t="",n=0,o=-1,a=i.length;on;)e.substring(o,r)==t.substring(o,r)?o=n=r:i=r,r=Math.floor((i-n)/2+n);return r},e.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var n=0,i=Math.min(e.length,t.length),r=i,o=0;r>n;)e.substring(e.length-r,e.length-o)==t.substring(t.length-r,t.length-o)?o=n=r:i=r,r=Math.floor((i-n)/2+n);return r},e.prototype.diff_commonOverlap_=function(e,t){var n=e.length,i=t.length;if(0==n||0==i)return 0;if(n>i?e=e.substring(n-i):i>n&&(t=t.substring(0,n)),n=Math.min(n,i),e==t)return n;for(var i=0,r=1;;){var o=e.substring(n-r),o=t.indexOf(o);if(-1==o)return i;r+=o,(0==o||e.substring(n-r)==t.substring(0,r))&&(i=r,r++)}},e.prototype.diff_halfMatch_=function(e,t){function n(e,t,n){for(var i,r,o,s,l=e.substring(n,n+Math.floor(e.length/4)),c=-1,u="";-1!=(c=t.indexOf(l,c+1));){var d=a.diff_commonPrefix(e.substring(n),t.substring(c)),h=a.diff_commonSuffix(e.substring(0,n),t.substring(0,c));u.length=e.length?[i,r,o,s,u]:null}if(0>=this.Diff_Timeout)return null;var i=e.length>t.length?e:t,r=e.length>t.length?t:e;if(4>i.length||2*r.lengthi[4].length?s:i:i:s;var l;return e.length>t.length?(s=o[0],i=o[1],r=o[2],l=o[3]):(r=o[0],l=o[1],s=o[2],i=o[3]),o=o[4],[s,i,r,l,o]},e.prototype.diff_cleanupSemantic=function(e){for(var t=!1,n=[],i=0,r=null,o=0,a=0,s=0,l=0,c=0;o0?n[i-1]:-1,c=l=s=a=0,r=null,t=!0)),o++;for(t&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),o=1;o=r?(i>=t.length/2||i>=n.length/2)&&(e.splice(o,0,[0,n.substring(0,i)]),e[o-1][1]=t.substring(0,t.length-i),e[o+1][1]=n.substring(i),o++):(r>=t.length/2||r>=n.length/2)&&(e.splice(o,0,[0,t.substring(0,r)]),e[o-1][0]=1,e[o-1][1]=n.substring(0,n.length-r),e[o+1][0]=-1,e[o+1][1]=t.substring(r),o++),o++),o++},e.prototype.diff_cleanupSemanticLossless=function(t){function n(t,n){if(!t||!n)return 6;var i=t.charAt(t.length-1),r=n.charAt(0),o=i.match(e.nonAlphaNumericRegex_),a=r.match(e.nonAlphaNumericRegex_),s=o&&i.match(e.whitespaceRegex_),l=a&&r.match(e.whitespaceRegex_),i=s&&i.match(e.linebreakRegex_),r=l&&r.match(e.linebreakRegex_),c=i&&t.match(e.blanklineEndRegex_),u=r&&n.match(e.blanklineStartRegex_);return c||u?5:i||r?4:o&&!s&&l?3:s||l?2:o||a?1:0}for(var i=1;i=u&&(u=d,s=r,l=o,c=a)}t[i-1][1]!=s&&(s?t[i-1][1]=s:(t.splice(i-1,1),i--),t[i][1]=l,c?t[i+1][1]=c:(t.splice(i+1,1),i--))}i++}},e.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,e.whitespaceRegex_=/\s/,e.linebreakRegex_=/[\r\n]/,e.blanklineEndRegex_=/\n\r?\n$/,e.blanklineStartRegex_=/^\r?\n\r?\n/,e.prototype.diff_cleanupEfficiency=function(e){for(var t=!1,n=[],i=0,r=null,o=0,a=!1,s=!1,l=!1,c=!1;o0?n[i-1]:-1,l=c=!1),t=!0)),o++;t&&this.diff_cleanupMerge(e)},e.prototype.diff_cleanupMerge=function(e){e.push([0,""]);for(var t,n=0,i=0,r=0,o="",a="";n1?(0!==i&&0!==r&&(t=this.diff_commonPrefix(a,o),0!==t&&(n-i-r>0&&0==e[n-i-r-1][0]?e[n-i-r-1][1]+=a.substring(0,t):(e.splice(0,0,[0,a.substring(0,t)]),n++),a=a.substring(t),o=o.substring(t)),t=this.diff_commonSuffix(a,o),0!==t&&(e[n][1]=a.substring(a.length-t)+e[n][1],a=a.substring(0,a.length-t),o=o.substring(0,o.length-t))),0===i?e.splice(n-r,i+r,[1,a]):0===r?e.splice(n-i,i+r,[-1,o]):e.splice(n-i-r,i+r,[-1,o],[1,a]),n=n-i-r+(i?1:0)+(r?1:0)+1):0!==n&&0==e[n-1][0]?(e[n-1][1]+=e[n][1],e.splice(n,1)):n++,i=r=0,a=o=""}for(""===e[e.length-1][1]&&e.pop(),i=!1,n=1;nt));n++)o=i,a=r;return e.length!=n&&-1===e[n][0]?a:a+(t-o)},e.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,i=//g,o=/\n/g,a=0;a");switch(s){case 1:t[a]=''+l+"";break;case-1:t[a]=''+l+"";break;case 0:t[a]=""+l+""}}return t.join("")},e.prototype.diff_text1=function(e){for(var t=[],n=0;nthis.Match_MaxBits)throw Error("Pattern too long for this browser.");var r=this.match_alphabet_(t),o=this,a=this.Match_Threshold,s=e.indexOf(t,n);-1!=s&&(a=Math.min(i(0,s),a),s=e.lastIndexOf(t,n+t.length),-1!=s&&(a=Math.min(i(0,s),a)));for(var l,c,u,d=1<l;)i(f,n+c)<=a?l=c:h=c,c=Math.floor((h-l)/2+l);h=c,l=Math.max(1,n-c+1);var p=Math.min(n+c,e.length)+t.length;for(c=Array(p+2),c[p+1]=(1<=l;p--){var g=r[e.charAt(p-1)];if(c[p]=0===f?(1|c[p+1]<<1)&g:(1|c[p+1]<<1)&g|(1|(u[p+1]|u[p])<<1)|u[p+1],c[p]&d&&(g=i(f,p-1),a>=g)){if(a=g,s=p-1,!(s>n))break;l=Math.max(1,2*n-s)}}if(i(f+1,n)>a)break;u=c}return s},e.prototype.match_alphabet_=function(e){for(var t={},n=0;n=2*this.Patch_Margin&&o&&(this.patch_addContext_(t,l),i.push(t),t=new e.patch_obj,o=0,l=r,a=s)}1!==u&&(a+=d.length),-1!==u&&(s+=d.length)}return o&&(this.patch_addContext_(t,l),i.push(t)),i},e.prototype.patch_deepCopy=function(t){for(var n=[],i=0;ithis.Match_MaxBits?(a=this.match_main(t,l.substring(0,this.Match_MaxBits),s),-1!=a&&(c=this.match_main(t,l.substring(l.length-this.Match_MaxBits),s+l.length-this.Match_MaxBits),-1==c||a>=c)&&(a=-1)):a=this.match_main(t,l,s),-1==a)r[o]=!1,i-=e[o].length2-e[o].length1;else if(r[o]=!0,i=a-s,s=-1==c?t.substring(a,a+l.length):t.substring(a,c+this.Match_MaxBits),l==s)t=t.substring(0,a)+this.diff_text2(e[o].diffs)+t.substring(a+l.length);else if(s=this.diff_main(l,s,!1),l.length>this.Match_MaxBits&&this.diff_levenshtein(s)/l.length>this.Patch_DeleteThreshold)r[o]=!1;else{this.diff_cleanupSemanticLossless(s);for(var u,l=0,c=0;c=i;i++)n+=String.fromCharCode(i);for(i=0;ir[0][1].length){var o=t-r[0][1].length;r[0][1]=n.substring(r[0][1].length)+r[0][1],i.start1-=o,i.start2-=o,i.length1+=o,i.length2+=o}return i=e[e.length-1],r=i.diffs,0==r.length||0!=r[r.length-1][0]?(r.push([0,n]),i.length1+=t,i.length2+=t):t>r[r.length-1][1].length&&(o=t-r[r.length-1][1].length,r[r.length-1][1]+=n.substring(0,o),i.length1+=o,i.length2+=o),n},e.prototype.patch_splitMax=function(t){for(var n=this.Match_MaxBits,i=0;i2*n?(l.length1+=u.length,o+=u.length,c=!1,l.diffs.push([s,u]),r.diffs.shift()):(u=u.substring(0,n-l.length1-this.Patch_Margin),l.length1+=u.length,o+=u.length,0===s?(l.length2+=u.length,a+=u.length):c=!1,l.diffs.push([s,u]),u==r.diffs[0][1]?r.diffs.shift():r.diffs[0][1]=r.diffs[0][1].substring(u.length))}s=this.diff_text2(l.diffs),s=s.substring(s.length-this.Patch_Margin),u=this.diff_text1(r.diffs).substring(0,this.Patch_Margin),""!==u&&(l.length1+=u.length,l.length2+=u.length,0!==l.diffs.length&&0===l.diffs[l.diffs.length-1][0]?l.diffs[l.diffs.length-1][1]+=u:l.diffs.push([0,u])),c||t.splice(++i,0,l)}}},e.prototype.patch_toText=function(e){for(var t=[],n=0;nr)return!1;var o=n.getScrollInfo();if("align"==e.mv.options.connect)m=o.top;else{var s,l,c=.5*o.clientHeight,u=o.top+c,d=n.lineAtHeight(u,"local"),h=M(e.chunks,d,t),f=a(n,t?h.edit:h.orig),p=a(i,t?h.orig:h.edit),g=(u-f.top)/(f.bot-f.top),m=p.top-c+g*(p.bot-p.top);if(m>o.top&&(l=o.top/c)<1)m=m*l+o.top*(1-l);else if((s=o.height-o.clientHeight-o.top)s&&(l=s/c)<1&&(m=m*l+(v.height-v.clientHeight-s)*(1-l))}}return i.scrollTo(o.left,m),i.state.scrollSetAt=r,i.state.scrollSetBy=e,!0}function a(e,t){var n=t.after;return null==n&&(n=e.lastLine()+1),{top:e.heightAtLine(t.before||0,"local"),bot:e.heightAtLine(n,"local")}}function s(t,n,i){t.lockScroll=n,n&&0!=i&&o(t,DIFF_INSERT)&&f(t),(n?e.addClass:e.rmClass)(t.lockButton,"CodeMirror-merge-scrolllock-enabled")}function l(e,t,n){for(var i=n.classLocation,r=0;r20||n.from-o.to>20?(c(e,n.marked,r),h(e,t,i,n.marked,o.from,o.to,r),n.from=o.from,n.to=o.to):(o.fromn.to&&(h(e,t,i,n.marked,n.to,o.to,r),n.to=o.to))})}function d(e,t,n,i,r,o){for(var a=n.classLocation,s=e.getLineHandle(t),l=0;lc;++c)i.push(d(e,c,a,!0,c==t,c==n-1));t==n&&s==n&&l==n&&(s?i.push(d(e,s-1,a,!1,!1,!0)):i.push(d(e,s,a,!1,!0,!1)))}for(var l=U(0,0),c=U(r,0),u=e.clipPos(U(o-1)),h=n==DIFF_DELETE?a.del:a.insert,f=0,p=!1,g=0;gb&&(p&&(s(f,b),p=!1),f=x)}else if(p=!0,v==n){var w=z(l,y,!0),k=V(c,l),C=B(u,w);F(k,C)||i.push(e.markText(k,C,{className:h})),l=w}}p&&s(f,l.line+1)}function f(e){if(e.showDifferences){if(e.svg){I(e.svg);var t=e.gap.offsetWidth;O(e.svg,"width",t,"height",e.gap.offsetHeight)}e.copyButtons&&I(e.copyButtons);for(var n=e.edit.getViewport(),i=e.orig.getViewport(),r=e.mv.wrap.getBoundingClientRect().top,o=r-e.edit.getScrollerElement().getBoundingClientRect().top+e.edit.getScrollInfo().top,a=r-e.orig.getScrollerElement().getBoundingClientRect().top+e.orig.getScrollInfo().top,s=0;s=n.from&&l.origFrom<=i.to&&l.origTo>=i.from&&w(e,l,a,o,t)}}}function p(e,t){for(var n=0,i=0,r=0;re&&o.editFrom<=e)return null;if(o.editFrom>e)break;n=o.editTo,i=o.origTo}return i+(e-n)}function g(e,t,n){for(var i=e.state.trackAlignable,r=e.firstLine(),o=0,a=[],s=0;;s++){for(var l=t[s],c=l?n?l.origFrom:l.editFrom:1e9;o=u)){if(!(c>=u))break;a.push(u)}}if(!l)break;a.push(r=n?l.origTo:l.editTo)}return a}function m(e,t,n,i){var r=0,o=0,a=0,s=0;e:for(;;r++){var l=e[r],c=t[o];if(!l&&null==c)break;for(var u=l?l[0]:1e9,d=null==c?1e9:c;ad){o++,r--;continue e}if(h.editTo>u){if(h.editFrom<=u)continue e;break}s+=h.origTo-h.origFrom-(h.editTo-h.editFrom),a++}if(u==d-s)l[i]=d,o++;else if(d-s>u)l[i]=u+s;else{var f=[d-s,null,null];f[i]=d,e.splice(r,0,f),o++}}}function v(e,t){var n=g(e.edit,e.chunks,!1),i=[];if(t)for(var r=0,o=0;r1&&n.push(x(e[o],t[o],s))}}function x(e,t,n){var i=!0;t>e.lastLine()&&(t--,i=!1);var r=document.createElement("div");return r.className="CodeMirror-merge-spacer",r.style.height=n+"px",r.style.minWidth="1px",e.addLineWidget(t,r,{height:n,above:i,mergeSpacer:!0,handleMouseEvents:!0})}function w(e,t,n,i,r){var o="left"==e.type,a=e.orig.heightAtLine(t.origFrom,"local",!0)-n;if(e.svg){var s=a,l=e.edit.heightAtLine(t.editFrom,"local",!0)-i;if(o){var c=s;s=l,l=c}var u=e.orig.heightAtLine(t.origTo,"local",!0)-n,d=e.edit.heightAtLine(t.editTo,"local",!0)-i;if(o){var c=u;u=d,d=c}var h=" C "+r/2+" "+l+" "+r/2+" "+s+" "+(r+2)+" "+s,f=" C "+r/2+" "+u+" "+r/2+" "+d+" -1 "+d;O(e.svg.appendChild(document.createElementNS(J,"path")),"d","M -1 "+l+h+" L "+(r+2)+" "+u+f+" z","class",e.classes.connect)}if(e.copyButtons){var p=e.copyButtons.appendChild(j("div","left"==e.type?"⇝":"⇜","CodeMirror-merge-copy")),g=e.mv.options.allowEditingOriginals;if(p.title=e.edit.phrase(g?"Push to left":"Revert chunk"),p.chunk=t,p.style.top=(t.origTo>t.origFrom?a:e.edit.heightAtLine(t.editFrom,"local")-i)+"px",g){var m=e.edit.heightAtLine(t.editFrom,"local")-i,v=e.copyButtons.appendChild(j("div","right"==e.type?"⇝":"⇜","CodeMirror-merge-copy-reverse"));v.title="Push to right",v.chunk={editFrom:t.origFrom,editTo:t.origTo,origFrom:t.editFrom,origTo:t.editTo},v.style.top=m+"px","right"==e.type?v.style.left="2px":v.style.right="2px"}}}function k(e,t,n,i){if(!e.diffOutOfDate){var r=i.origTo>n.lastLine()?U(i.origFrom-1):U(i.origFrom,0),o=U(i.origTo,0),a=i.editTo>t.lastLine()?U(i.editFrom-1):U(i.editFrom,0),s=U(i.editTo,0),l=e.mv.options.revertChunk;l?l(e.mv,n,r,o,t,a,s):t.replaceRange(n.getRange(r,o),a,s)}}function C(t){var n=t.lockButton=j("div",null,"CodeMirror-merge-scrolllock"),i=j("div",[n],"CodeMirror-merge-scrolllock-wrap");e.on(n,"click",function(){s(t,!t.lockScroll)});var r=[i];if(t.mv.options.revertButtons!==!1&&(t.copyButtons=j("div",null,"CodeMirror-merge-copybuttons-"+t.type),e.on(t.copyButtons,"click",function(e){var n=e.target||e.srcElement;if(n.chunk)return"CodeMirror-merge-copy-reverse"==n.className?(k(t,t.orig,t.edit,n.chunk),void 0):(k(t,t.edit,t.orig,n.chunk),void 0)}),r.unshift(t.copyButtons)),"align"!=t.mv.options.connect){var o=document.createElementNS&&document.createElementNS(J,"svg");o&&!o.createSVGRect&&(o=null),t.svg=o,o&&r.push(o)}return t.gap=j("div",r,"CodeMirror-merge-gap")}function _(e){return"string"==typeof e?e:e.getValue()}function $(e,t,n){X||(X=new diff_match_patch);for(var i=X.diff_main(e,t),r=0;ru&&(a&&t.push({origFrom:i,origTo:d,editFrom:n,editTo:u}),n=f,i=p)}else z(l==DIFF_INSERT?r:o,s[1])}return(n<=r.line||i<=o.line)&&t.push({origFrom:i,origTo:o.line+1,editFrom:n,editTo:r.line+1}),t}function T(e,t){if(t==e.length-1)return!0;var n=e[t+1][1];return 1==n.length&&t1||t==e.length-3)&&10==n.charCodeAt(0))}function E(e,t){if(0==t)return!0;var n=e[t-1][1];return 10!=n.charCodeAt(n.length-1)?!1:1==t?!0:(n=e[t-2][1],10==n.charCodeAt(n.length-1))}function M(e,t,n){for(var i,r,o,a,s=0;st?(r=l.editFrom,a=l.origFrom):u>t&&(r=l.editTo,a=l.origTo)),t>=u?(i=l.editTo,o=l.origTo):t>=c&&(i=l.editFrom,o=l.origFrom)}return{edit:{before:i,after:r},orig:{before:o,after:a}}}function A(t,n,i){function r(){a.clear(),t.removeLineClass(n,"wrap","CodeMirror-merge-collapsed-line")}t.addLineClass(n,"wrap","CodeMirror-merge-collapsed-line");var o=document.createElement("span");o.className="CodeMirror-merge-collapsed-widget",o.title=t.phrase("Identical text collapsed. Click to expand.");var a=t.markText(U(n,0),U(i-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:o,clearOnEnter:!0});return a.explicitlyCleared&&r(),e.on(o,"click",r),a.on("clear",r),e.on(o,"click",r),{mark:a,clear:r}}function L(e,t){function n(){for(var e=0;e=0&&s=o;o++)n.push(!0);e.left&&D(e.left,t,r,n),e.right&&D(e.right,t,r,n);for(var s=0;st){var u=[{line:l,cm:i}];e.left&&u.push({line:p(l,e.left.chunks),cm:e.left.orig}),e.right&&u.push({line:p(l,e.right.chunks),cm:e.right.orig});var d=L(c,u);e.options.onCollapse&&e.options.onCollapse(e,l,c,d)}}}function j(e,t,n,i){var r=document.createElement(e);if(n&&(r.className=n),i&&(r.style.cssText=i),"string"==typeof t)r.appendChild(document.createTextNode(t));else if(t)for(var o=0;o0;--t)e.removeChild(e.firstChild)}function O(e){for(var t=1;t0?e:t}function F(e,t){return e.line==t.line&&e.ch==t.ch}function R(e,t,n){for(var i=e.length-1;i>=0;i--){var r=e[i],o=(n?r.origTo:r.editTo)-1;if(t>o)return o}}function W(e,t,n){for(var i=0;it)return o}}function q(t,i){var r=null,o=t.state.diffViews,a=t.getCursor().line;if(o)for(var s=0;si?R(l.chunks,a,c):W(l.chunks,a,c);null==u||null!=r&&!(0>i?u>r:r>u)||(r=u)}return null==r?e.Pass:(t.setCursor(r,0),void 0)}var U=e.Pos,J="http://www.w3.org/2000/svg";t.prototype={constructor:t,init:function(t,n,i){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=e(t,P({value:n,readOnly:!this.mv.options.allowEditingOriginals},P(i))),"align"==this.mv.options.connect&&(this.edit.state.trackAlignable||(this.edit.state.trackAlignable=new H(this.edit)),this.orig.state.trackAlignable=new H(this.orig)),this.lockButton.title=this.edit.phrase("Toggle locked scrolling"),this.orig.state.diffViews=[this];var r=i.chunkClassLocation||"background";"[object Array]"!=Object.prototype.toString.call(r)&&(r=[r]),this.classes.classLocation=r,this.diff=$(_(n),_(i.value),this.mv.options.ignoreWhitespace),this.chunks=S(this.diff),this.diffOutOfDate=this.dealigned=!1,this.needsScrollSync=null,this.showDifferences=i.showDifferences!==!1},registerEvents:function(e){this.forceUpdate=i(this),s(this,!0,!1),r(this,e)},setShowDifferences:function(e){e=e!==!1,e!=this.showDifferences&&(this.showDifferences=e,this.forceUpdate("full"))}};var G=!1,K=e.MergeView=function(n,i){if(!(this instanceof K))return new K(n,i);this.options=i;var r=i.origLeft,o=null==i.origRight?i.orig:i.origRight,a=null!=r,s=null!=o,l=1+(a?1:0)+(s?1:0),c=[],u=this.left=null,d=this.right=null,h=this;if(a){u=this.left=new t(this,"left");var p=j("div",null,"CodeMirror-merge-pane CodeMirror-merge-left");c.push(p),c.push(C(u))}var g=j("div",null,"CodeMirror-merge-pane CodeMirror-merge-editor");if(c.push(g),s){d=this.right=new t(this,"right"),c.push(C(d));var m=j("div",null,"CodeMirror-merge-pane CodeMirror-merge-right");c.push(m)}(s?m:g).className+=" CodeMirror-merge-pane-rightmost",c.push(j("div",null,null,"height: 0; clear: both;"));var v=this.wrap=n.appendChild(j("div",c,"CodeMirror-merge CodeMirror-merge-"+l+"pane"));this.edit=e(g,P(i)),u&&u.init(p,r,i),d&&d.init(m,o,i),i.collapseIdentical&&this.editor().operation(function(){N(h,i.collapseIdentical)}),"align"==i.connect&&(this.aligners=[],y(this.left||this.right,!0)),u&&u.registerEvents(d),d&&d.registerEvents(u);var b=function(){u&&f(u),d&&f(d)};e.on(window,"resize",b);var x=setInterval(function(){for(var t=v.parentNode;t&&t!=document.body;t=t.parentNode);t||(clearInterval(x),e.off(window,"resize",b))},5e3)};K.prototype={constructor:K,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(e){this.right&&this.right.setShowDifferences(e),this.left&&this.left.setShowDifferences(e)},rightChunks:function(){return this.right?(n(this.right),this.right.chunks):void 0},leftChunks:function(){return this.left?(n(this.left),this.left.chunks):void 0}};var X,Q=1,Y=2,Z=4;H.prototype={signal:function(){e.signal(this,"realign"),this.height=this.cm.doc.height},set:function(e,t){for(var n=-1;n0)break}this.signal(),this.alignable.splice(n,0,e,t)},find:function(e){for(var t=0;t=l||(r>l?this.alignable.splice(s--,2):this.alignable[s]+=i)}if(o>-1){var c=this.alignable[o+1];c==Y?this.alignable.splice(o,2):this.alignable[o+1]=c&~Y}a>-1&&n&&this.set(e+n,Y)}},e.commands.goNextDiff=function(e){return q(e,1)},e.commands.goPrevDiff=function(e){return q(e,-1)}});