full-text-rss/admin/codemirror/codemirror.js
2014-05-15 22:49:16 +02:00

1 line
58 KiB
JavaScript

var CodeMirror=function(){"use strict";function e(r,i){function un(e){if(s.onDragEvent&&s.onDragEvent(ln,I(e)))return;U(e)}function fn(e){return e>=0&&e<At.size}function cn(e){return D(At,e)}function hn(e,t){Vt=!0;var n=t-e.height;for(var r=e;r;r=r.parent)r.height+=n}function pn(e){var t={line:0,ch:0};Mn(t,{line:At.size-1,ch:cn(At.size-1).text.length},pt(e),t,t),qt=!0}function dn(e){var t=[];return At.iter(0,At.size,function(e){t.push(e.text)}),t.join(e||"\n")}function vn(e){R.scrollTop!=Bt&&(Bt=St.scrollTop=R.scrollTop,rr([]))}function mn(e){s.fixedGutter&&bt.style.left!=St.scrollLeft+"px"&&(bt.style.left=St.scrollLeft+"px"),St.scrollTop!=Bt&&(Bt=St.scrollTop,R.scrollTop!=Bt&&(R.scrollTop=Bt),rr([])),s.onScroll&&s.onScroll(ln)}function gn(e){function u(t){g&&(St.draggable=!1),jt=!1,l(),c(),Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)<10&&(q(t),hr(n.line,n.ch,!0),Qn())}function m(e){if(i=="single")fr(n,e);else if(i=="double"){var t=br(e);it(e,d)?fr(t.from,v):fr(d,t.to)}else i=="triple"&&(it(e,d)?fr(v,dr({line:e.line,ch:0})):fr(d,dr({line:e.line+1,ch:0})))}function y(e){var t=Zr(e,!0);if(t&&!rt(t,a)){Mt||An(),a=t,m(t),qt=!1;var n=nr();if(t.line>=n.to||t.line<n.from)f=setTimeout(hi(function(){y(e)}),150)}}function b(e){clearTimeout(f);var t=Zr(e);t&&m(t),q(e),Qn(),qt=!0,w(),l()}ar(X(e,"shiftKey"));for(var t=z(e);t!=xt;t=t.parentNode)if(t.parentNode==Et&&t!=wt)return;for(var t=z(e);t!=xt;t=t.parentNode)if(t.parentNode==yt)return s.onGutterClick&&s.onGutterClick(ln,ct(yt.childNodes,t)+Kt,e),q(e);var n=Zr(e);switch(W(e)){case 3:h&&ei(e);return;case 2:n&&hr(n.line,n.ch,!0),setTimeout(Qn,20),q(e);return}if(!n){z(e)==St&&q(e);return}Mt||An();var r=+(new Date),i="single";if(Ht&&Ht.time>r-400&&rt(Ht.pos,n))i="triple",q(e),setTimeout(Qn,20),wr(n.line);else if(Pt&&Pt.time>r-400&&rt(Pt.pos,n)){i="double",Ht={time:r,pos:n},q(e);var o=br(n);fr(o.from,o.to)}else Pt={time:r,pos:n};var a=n,f;if(s.dragDrop&&K&&!s.readOnly&&!rt(_t.from,_t.to)&&!it(n,_t.from)&&!it(_t.to,n)&&i=="single"){g&&(St.draggable=!0);var l=V(document,"mouseup",hi(u),!0),c=V(St,"drop",hi(u),!0);jt=!0,St.dragDrop&&St.dragDrop();return}q(e),i=="single"&&hr(n.line,n.ch,!0);var d=_t.from,v=_t.to,w=V(document,"mousemove",hi(function(e){clearTimeout(f),q(e),!p&&!W(e)?b(e):y(e)}),!0),l=V(document,"mouseup",hi(b),!0)}function yn(e){for(var t=z(e);t!=xt;t=t.parentNode)if(t.parentNode==yt)return q(e);q(e)}function bn(e){if(s.onDragEvent&&s.onDragEvent(ln,I(e)))return;q(e);var t=Zr(e,!0),n=e.dataTransfer.files;if(!t||s.readOnly)return;if(n&&n.length&&window.FileReader&&window.File){var r=n.length,i=Array(r),o=0,u=function(e,n){var s=new FileReader;s.onload=function(){i[n]=s.result,++o==r&&(t=dr(t),hi(function(){var e=qn(i.join(""),t,t);fr(t,e)})())},s.readAsText(e)};for(var a=0;a<r;++a)u(n[a],a)}else{if(jt&&!it(t,_t.from)&&!it(_t.to,t))return;try{var i=e.dataTransfer.getData("Text");i&&pi(function(){var e=_t.from,n=_t.to;fr(t,t),jt&&qn("",e,n),Rn(i),Qn()})}catch(e){}}}function wn(e){var t=Wn();e.dataTransfer.setData("Text",t);if(h||y||b){var n=ot("img");n.scr="data:image/gif;base64,R0lGODdhAgACAIAAAAAAAP///ywAAAAAAgACAAACAoRRADs=",e.dataTransfer.setDragImage(n,0,0)}}function En(e,t){if(typeof e=="string"){e=u[e];if(!e)return!1}var n=Dt;try{s.readOnly&&(It=!0),t&&(Dt=null),e(ln)}catch(r){if(r!=J)throw r;return!1}finally{Dt=n,It=!1}return!0}function xn(e){function u(){o=!0}var t=f(s.keyMap),n=t.auto;clearTimeout(Sn),n&&!c(e)&&(Sn=setTimeout(function(){f(s.keyMap)==t&&(s.keyMap=n.call?n.call(null,ln):n)},50));var r=vt[X(e,"keyCode")],i=!1;if(r==null||e.altGraphKey)return!1;X(e,"altKey")&&(r="Alt-"+r),X(e,"ctrlKey")&&(r="Ctrl-"+r),X(e,"metaKey")&&(r="Cmd-"+r);var o=!1;return X(e,"shiftKey")?i=l("Shift-"+r,s.extraKeys,s.keyMap,function(e){return En(e,!0)},u)||l(r,s.extraKeys,s.keyMap,function(e){if(typeof e=="string"&&/^go[A-Z]/.test(e))return En(e)},u):i=l(r,s.extraKeys,s.keyMap,En,u),o&&(i=!1),i&&(q(e),ti(),p&&(e.oldKeyCode=e.keyCode,e.keyCode=0)),i}function Tn(e,t){var n=l("'"+t+"'",s.extraKeys,s.keyMap,function(e){return En(e,!0)});return n&&(q(e),ti()),n}function Cn(e){Mt||An(),p&&e.keyCode==27&&(e.returnValue=!1),rn&&Jn()&&(rn=!1);if(s.onKeyEvent&&s.onKeyEvent(ln,I(e)))return;var t=X(e,"keyCode");ar(t==16||X(e,"shiftKey"));var r=xn(e);b&&(Nn=r?t:null,!r&&t==88&&X(e,n?"metaKey":"ctrlKey")&&Rn(""))}function kn(e){rn&&Jn();if(s.onKeyEvent&&s.onKeyEvent(ln,I(e)))return;var t=X(e,"keyCode"),n=X(e,"charCode");if(b&&t==Nn){Nn=null,q(e);return}if((b&&(!e.which||e.which<10)||E)&&xn(e))return;var r=String.fromCharCode(n==null?t:n);s.electricChars&&Lt.electricChars&&s.smartIndent&&!s.readOnly&&Lt.electricChars.indexOf(r)>-1&&setTimeout(hi(function(){Sr(_t.to.line,"smart")}),75);if(Tn(e,r))return;Vn()}function Ln(e){if(s.onKeyEvent&&s.onKeyEvent(ln,I(e)))return;X(e,"keyCode")==16&&(Dt=null)}function An(){if(s.readOnly=="nocursor")return;Mt||(s.onFocus&&s.onFocus(ln),Mt=!0,St.className.search(/\bCodeMirror-focused\b/)==-1&&(St.className+=" CodeMirror-focused"),Xt||Kn(!0)),Xn(),ti()}function On(){Mt&&(s.onBlur&&s.onBlur(ln),Mt=!1,Yt&&hi(function(){Yt&&(Yt(),Yt=null)})(),St.className=St.className.replace(" CodeMirror-focused","")),clearInterval(kt),setTimeout(function(){Mt||(Dt=null)},150)}function Mn(e,t,n,r,i){if(It)return;if(on){var o=[];At.iter(e.line,t.line+1,function(e){o.push(e.text)}),on.addChange(e.line,n.length,o);while(on.done.length>s.undoDepth)on.done.shift()}Hn(e,t,n,r,i)}function _n(e,t){if(!e.length)return;var n=e.pop(),r=[];for(var i=n.length-1;i>=0;i-=1){var s=n[i],o=[],u=s.start+s.added;At.iter(s.start,u,function(e){o.push(e.text)}),r.push({start:s.start,added:s.old.length,old:o});var a={line:s.start+s.old.length-1,ch:lt(o[o.length-1],s.old[s.old.length-1])};Hn({line:s.start,ch:0},{line:u-1,ch:cn(u-1).text.length},s.old,a,a)}qt=!0,t.push(r)}function Dn(){_n(on.done,on.undone)}function Pn(){_n(on.undone,on.done)}function Hn(e,t,n,r,i){function x(e){return e<=Math.min(t.line,t.line+g)?e:e+g}if(It)return;var o=!1,u=Zt.text.length;s.lineWrapping||At.iter(e.line,t.line+1,function(e){if(!e.hidden&&e.text.length==u)return o=!0,!0});if(e.line!=t.line||n.length>1)Vt=!0;var a=t.line-e.line,f=cn(e.line),l=cn(t.line);if(e.ch==0&&t.ch==0&&n[n.length-1]==""){var c=[],h=null;e.line?(h=cn(e.line-1),h.fixMarkEnds(l)):l.fixMarkStarts();for(var p=0,d=n.length-1;p<d;++p)c.push(A.inheritMarks(n[p],h));a&&At.remove(e.line,a,$t),c.length&&At.insert(e.line,c)}else if(f==l)if(n.length==1)f.replace(e.ch,t.ch,n[0]);else{l=f.split(t.ch,n[n.length-1]),f.replace(e.ch,null,n[0]),f.fixMarkEnds(l);var c=[];for(var p=1,d=n.length-1;p<d;++p)c.push(A.inheritMarks(n[p],f));c.push(l),At.insert(e.line+1,c)}else if(n.length==1)f.replace(e.ch,null,n[0]),l.replace(null,t.ch,""),f.append(l),At.remove(e.line+1,a,$t);else{var c=[];f.replace(e.ch,null,n[0]),l.replace(null,t.ch,n[n.length-1]),f.fixMarkEnds(l);for(var p=1,d=n.length-1;p<d;++p)c.push(A.inheritMarks(n[p],f));a>1&&At.remove(e.line+1,a-1,$t),At.insert(e.line+1,c)}if(s.lineWrapping){var v=Math.max(5,St.clientWidth/Qr()-3);At.iter(e.line,e.line+n.length,function(e){if(e.hidden)return;var t=Math.ceil(e.text.length/v)||1;t!=e.height&&hn(e,t)})}else At.iter(e.line,e.line+n.length,function(e){var t=e.text;!e.hidden&&t.length>u&&(Zt=e,u=t.length,tn=!0,o=!1)}),o&&(en=!0);var m=[],g=n.length-a-1;for(var p=0,y=Ot.length;p<y;++p){var b=Ot[p];b<e.line?m.push(b):b>t.line&&m.push(b+g)}var w=e.line+Math.min(n.length,500);oi(e.line,w),m.push(w),Ot=m,ai(100),Ut.push({from:e.line,to:t.line+1,diff:g});var E={from:e,to:t,text:n};if(zt){for(var S=zt;S.next;S=S.next);S.next=E}else zt=E;lr(dr(r),dr(i),x(_t.from.line),x(_t.to.line))}function Bn(){var e=At.height*$r()+2*Gr();return e-1>St.offsetHeight?e:!1}function jn(e){var t=Bn();R.style.display=t?"block":"none",t?(F.style.height=Et.style.minHeight=t+"px",R.style.height=St.clientHeight+"px",e!=null&&(R.scrollTop=St.scrollTop=e)):Et.style.minHeight="",wt.style.top=Jt*$r()+"px"}function Fn(){var e=ot("div",null,"CodeMirror-scrollbar-inner","height: 200px"),t=ot("div",[e],"CodeMirror-scrollbar","position: absolute; left: -9999px; height: 100px;");document.body.appendChild(t);var n=t.offsetWidth<=1;return document.body.removeChild(t),n}function In(){Zt=cn(0),tn=!0;var e=Zt.text.length;At.iter(1,At.size,function(t){var n=t.text;!t.hidden&&n.length>e&&(e=n.length,Zt=t)}),en=!1}function qn(e,t,n){function r(r){if(it(r,t))return r;if(!it(n,r))return i;var s=r.line+e.length-(n.line-t.line)-1,o=r.ch;return r.line==n.line&&(o+=e[e.length-1].length-(n.ch-(n.line==t.line?t.ch:0))),{line:s,ch:o}}t=dr(t),n?n=dr(n):n=t,e=pt(e);var i;return Un(e,t,n,function(e){return i=e,{from:r(_t.from),to:r(_t.to)}}),i}function Rn(e,t){Un(pt(e),_t.from,_t.to,function(e){return t=="end"?{from:e,to:e}:t=="start"?{from:_t.from,to:_t.from}:{from:_t.from,to:e}})}function Un(e,t,n,r){var i=e.length==1?e[0].length+t.ch:e[e.length-1].length,s=r({line:t.line+e.length-1,ch:i});Mn(t,n,e,s.from,s.to)}function zn(e,t,n){var r=e.line,i=t.line;if(r==i)return cn(r).text.slice(e.ch,t.ch);var s=[cn(r).text.slice(e.ch)];return At.iter(r+1,i,function(e){s.push(e.text)}),s.push(cn(i).text.slice(0,t.ch)),s.join(n||"\n")}function Wn(e){return zn(_t.from,_t.to,e)}function Xn(){if(rn)return;Nt.set(s.pollInterval,function(){fi(),Jn(),Mt&&Xn(),li()})}function Vn(){function t(){fi();var n=Jn();!n&&!e?(e=!0,Nt.set(60,t)):(rn=!1,Xn()),li()}var e=!1;rn=!0,Nt.set(20,t)}function Jn(){if(Xt||!Mt||dt(L)||s.readOnly)return!1;var e=L.value;if(e==$n)return!1;Dt=null;var t=0,n=Math.min($n.length,e.length);while(t<n&&$n[t]==e[t])++t;return t<$n.length?_t.from={line:_t.from.line,ch:_t.from.ch-($n.length-t)}:Ft&&rt(_t.from,_t.to)&&(_t.to={line:_t.to.line,ch:Math.min(cn(_t.to.line).text.length,_t.to.ch+(e.length-t))}),Rn(e.slice(t),"end"),e.length>1e3?L.value=$n="":$n=e,!0}function Kn(e){rt(_t.from,_t.to)?e&&($n=L.value=""):($n="",L.value=Wn(),nt(L))}function Qn(){s.readOnly!="nocursor"&&L.focus()}function Gn(){var e=Z.getBoundingClientRect();if(p&&e.top==e.bottom)return;var t=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(e.top<0||e.bottom>t)&&Yn()}function Yn(){var e=Zn();er(e.x,e.y,e.x,e.yBot)}function Zn(){var e=Rr(_t.inverted?_t.from:_t.to),t=s.lineWrapping?Math.min(e.x,gt.offsetWidth):e.x;return{x:t,y:e.y,yBot:e.yBot}}function er(e,t,n,r){var i=tr(e,t,n,r);i.scrollLeft!=null&&(St.scrollLeft=i.scrollLeft),i.scrollTop!=null&&(R.scrollTop=St.scrollTop=i.scrollTop)}function tr(e,t,n,r){var i=Yr(),o=Gr();t+=o,r+=o,e+=i,n+=i;var u=St.clientHeight,a=R.scrollTop,f={},l=Bn()||Infinity,c=t<o+10,h=r+o>l-10;t<a?f.scrollTop=c?0:Math.max(0,t):r>a+u&&(f.scrollTop=(h?l:r)-u);var p=St.clientWidth,d=St.scrollLeft,v=s.fixedGutter?bt.clientWidth:0,m=e<v+i+10;return e<d+v||m?(m&&(e=0),f.scrollLeft=Math.max(0,e-10-v)):n>p+d-3&&(f.scrollLeft=n+10-p),f}function nr(e){var t=$r(),n=(e!=null?e:R.scrollTop)-Gr(),r=Math.max(0,Math.floor(n/t)),i=Math.ceil((n+St.clientHeight)/t);return{from:H(At,r),to:H(At,i)}}function rr(e,t,n){function d(){var e=Q.firstChild,t=!1;return At.iter(Kt,Qt,function(n){if(!e)return;if(!n.hidden){var r=Math.round(e.offsetHeight/c)||1;n.height!=r&&(hn(n,r),Vt=t=!0)}e=e.nextSibling}),t}if(!St.clientWidth){Kt=Qt=Jt=0;return}var r=nr(n);if(e!==!0&&e.length==0&&r.from>Kt&&r.to<Qt){jn(n);return}var i=Math.max(r.from-100,0),o=Math.min(At.size,r.to+100);Kt<i&&i-Kt<20&&(i=Kt),Qt>o&&Qt-o<20&&(o=Math.min(At.size,Qt));var u=e===!0?[]:ir([{from:Kt,to:Qt,domStart:0}],e),a=0;for(var f=0;f<u.length;++f){var l=u[f];l.from<i&&(l.domStart+=i-l.from,l.from=i),l.to>o&&(l.to=o),l.from>=l.to?u.splice(f--,1):a+=l.to-l.from}if(a==o-i&&i==Kt&&o==Qt){jn(n);return}u.sort(function(e,t){return e.domStart-t.domStart});var c=$r(),h=bt.style.display;Q.style.display="none",sr(i,o,u),Q.style.display=bt.style.display="";var p=i!=Kt||o!=Qt||Gt!=St.clientHeight+c;p&&(Gt=St.clientHeight+c),Kt=i,Qt=o,Jt=B(At,i);if(Q.childNodes.length!=Qt-Kt)throw new Error("BAD PATCH! "+JSON.stringify(u)+" size="+(Qt-Kt)+" nodes="+Q.childNodes.length);if(s.lineWrapping){d();var v=Bn(),m=v?"block":"none";R.style.display!=m&&(R.style.display=m,v&&(F.style.height=v+"px"),d())}return bt.style.display=h,(p||Vt)&&or()&&s.lineWrapping&&d()&&or(),jn(n),ur(),!t&&s.onUpdate&&s.onUpdate(ln),!0}function ir(e,t){for(var n=0,r=t.length||0;n<r;++n){var i=t[n],s=[],o=i.diff||0;for(var u=0,a=e.length;u<a;++u){var f=e[u];i.to<=f.from&&i.diff?s.push({from:f.from+o,to:f.to+o,domStart:f.domStart}):i.to<=f.from||i.from>=f.to?s.push(f):(i.from>f.from&&s.push({from:f.from,to:i.from,domStart:f.domStart}),i.to<f.to&&s.push({from:i.to+o,to:f.to+o,domStart:f.domStart+(i.to-f.from)}))}e=s}return e}function sr(e,t,n){function r(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}if(!n.length)ut(Q);else{var i=0,s=Q.firstChild,o;for(var u=0;u<n.length;++u){var a=n[u];while(a.domStart>i)s=r(s),i++;for(var f=0,l=a.to-a.from;f<l;++f)s=s.nextSibling,i++}while(s)s=r(s)}var c=n.shift(),s=Q.firstChild,f=e;At.iter(e,t,function(e){c&&c.to==f&&(c=n.shift());if(!c||c.from>f){if(e.hidden)var t=ot("pre");else{var t=e.getElement(Cr);e.className&&(t.className=e.className);if(e.bgClassName){var r=ot("pre","\u00a0",e.bgClassName,"position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2");t=ot("div",[r,t],null,"position: relative")}}Q.insertBefore(t,s)}else s=s.nextSibling;++f})}function or(){if(!s.gutter&&!s.lineNumbers)return;var e=wt.offsetHeight,t=St.clientHeight;bt.style.height=(e-t<2?t:e)+"px";var n=document.createDocumentFragment(),r=Kt,i;At.iter(Kt,Math.max(Qt,Kt+1),function(e){if(e.hidden)n.appendChild(ot("pre"));else{var t=e.gutterMarker,o=s.lineNumbers?s.lineNumberFormatter(r+s.firstLineNumber):null;t&&t.text?o=t.text.replace("%N%",o!=null?o:""):o==null&&(o="\u00a0");var u=n.appendChild(ot("pre",null,t&&t.style));u.innerHTML=o;for(var a=1;a<e.height;++a)u.appendChild(ot("br")),u.appendChild(document.createTextNode("\u00a0"));t||(i=r)}++r}),bt.style.display="none",at(yt,n);if(i!=null&&s.lineNumbers){var o=yt.childNodes[i-Kt],u=String(At.size).length,a=tt(o.firstChild),f="";while(a.length+f.length<u)f+="\u00a0";f&&o.insertBefore(document.createTextNode(f),o.firstChild)}bt.style.display="";var l=Math.abs((parseInt(gt.style.marginLeft)||0)-bt.offsetWidth)>2;return gt.style.marginLeft=bt.offsetWidth+"px",Vt=!1,l}function ur(){var e=rt(_t.from,_t.to),t=Rr(_t.from,!0),n=e?t:Rr(_t.to,!0),r=_t.inverted?t:n,i=$r(),o=et(xt),u=et(Q);O.style.top=Math.max(0,Math.min(St.offsetHeight,r.y+u.top-o.top))+"px",O.style.left=Math.max(0,Math.min(St.offsetWidth,r.x+u.left-o.left))+"px";if(e)Z.style.top=r.y+"px",Z.style.left=(s.lineWrapping?Math.min(r.x,gt.offsetWidth):r.x)+"px",Z.style.display="",Y.style.display="none";else{var a=t.y==n.y,f=document.createDocumentFragment(),l=gt.clientWidth||gt.offsetWidth,c=gt.clientHeight||gt.offsetHeight,h=function(e,t,n,r){var i=m?"width: "+(n?l-n-e:l)+"px":"right: "+n+"px";f.appendChild(ot("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; "+i+"; height: "+r+"px"))};if(_t.from.ch&&t.y>=0){var p=a?l-n.x:0;h(t.x,t.y,p,i)}var d=Math.max(0,t.y+(_t.from.ch?i:0)),v=Math.min(n.y,c)-d;v>.2*i&&h(0,d,0,v),(!a||!_t.from.ch)&&n.y<c-.5*i&&h(0,n.y,l-n.x,i),at(Y,f),Z.style.display="none",Y.style.display=""}}function ar(e){e?Dt=Dt||(_t.inverted?_t.to:_t.from):Dt=null}function fr(e,t){var n=Dt&&dr(Dt);n&&(it(n,e)?e=n:it(t,n)&&(t=n)),lr(e,t),Rt=!0}function lr(e,t,n,r){sn=null,n==null&&(n=_t.from.line,r=_t.to.line);if(rt(_t.from,e)&&rt(_t.to,t))return;if(it(t,e)){var i=t;t=e,e=i}if(e.line!=n){var o=cr(e,n,_t.from.ch);o?e=o:jr(e.line,!1)}t.line!=r&&(t=cr(t,r,_t.to.ch)),rt(e,t)?_t.inverted=!1:rt(e,_t.to)?_t.inverted=!1:rt(t,_t.from)&&(_t.inverted=!0);if(s.autoClearEmptyLines&&rt(_t.from,_t.to)){var u=_t.inverted?e:t;if(u.line!=_t.from.line&&_t.from.line<At.size){var a=cn(_t.from.line);/^\s+$/.test(a.text)&&setTimeout(hi(function(){if(a.parent&&/^\s+$/.test(a.text)){var e=P(a);qn("",{line:e,ch:0},{line:e,ch:a.text.length})}},10))}}_t.from=e,_t.to=t,Wt=!0}function cr(e,t,n){function r(t){var r=e.line+t,i=t==1?At.size:-1;while(r!=i){var o=cn(r);if(!o.hidden){var u=e.ch;if(s||u>n||u>o.text.length)u=o.text.length;return{line:r,ch:u}}r+=t}}var i=cn(e.line),s=e.ch==i.text.length&&e.ch!=n;return i.hidden?e.line>=t?r(1)||r(-1):r(-1)||r(1):e}function hr(e,t,n){var r=dr({line:e,ch:t||0});(n?fr:lr)(r,r)}function pr(e){return Math.max(0,Math.min(e,At.size-1))}function dr(e){if(e.line<0)return{line:0,ch:0};if(e.line>=At.size)return{line:At.size-1,ch:cn(At.size-1).text.length};var t=e.ch,n=cn(e.line).text.length;return t==null||t>n?{line:e.line,ch:n}:t<0?{line:e.line,ch:0}:e}function vr(e,t){function o(){for(var t=r+e,n=e<0?-1:At.size;t!=n;t+=e){var i=cn(t);if(!i.hidden)return r=t,s=i,!0}}function u(t){if(i==(e<0?0:s.text.length)){if(!!t||!o())return!1;i=e<0?s.text.length:0}else i+=e;return!0}var n=_t.inverted?_t.from:_t.to,r=n.line,i=n.ch,s=cn(r);if(t=="char")u();else if(t=="column")u(!0);else if(t=="word"){var a=!1;for(;;){if(e<0&&!u())break;if(ht(s.text.charAt(i)))a=!0;else if(a){e<0&&(e=1,u());break}if(e>0&&!u())break}}return{line:r,ch:i}}function mr(e,t){var n=e<0?_t.from:_t.to;if(Dt||rt(_t.from,_t.to))n=vr(e,t);hr(n.line,n.ch,!0)}function gr(e,t){rt(_t.from,_t.to)?e<0?qn("",vr(e,t),_t.to):qn("",_t.from,vr(e,t)):qn("",_t.from,_t.to),Rt=!0}function yr(e,t){var n=0,r=Rr(_t.inverted?_t.from:_t.to,!0);sn!=null&&(r.x=sn),t=="page"?n=Math.min(St.clientHeight,window.innerHeight||document.documentElement.clientHeight):t=="line"&&(n=$r());var i=Ur(r.x,r.y+n*e+2);t=="page"&&(R.scrollTop+=Rr(i,!0).y-r.y),hr(i.line,i.ch,!0),sn=r.x}function br(e){var t=cn(e.line).text,n=e.ch,r=e.ch;if(t){e.after===!1||r==t.length?--n:++r;var i=t.charAt(n),s=ht(i)?ht:/\s/.test(i)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!ht(e)};while(n>0&&s(t.charAt(n-1)))--n;while(r<t.length&&s(t.charAt(r)))++r}return{from:{line:e.line,ch:n},to:{line:e.line,ch:r}}}function wr(e){fr({line:e,ch:0},dr({line:e+1,ch:0}))}function Er(e){if(rt(_t.from,_t.to))return Sr(_t.from.line,e);var t=_t.to.line-(_t.to.ch?0:1);for(var n=_t.from.line;n<=t;++n)Sr(n,e)}function Sr(e,t){t||(t="add");if(t=="smart")if(!Lt.indent)t="prev";else var n=si(e);var r=cn(e),i=r.indentation(s.tabSize),o=r.text.match(/^\s*/)[0],u;t=="smart"&&(u=Lt.indent(n,r.text.slice(o.length),r.text),u==J&&(t="prev")),t=="prev"?e?u=cn(e-1).indentation(s.tabSize):u=0:t=="add"?u=i+s.indentUnit:t=="subtract"&&(u=i-s.indentUnit),u=Math.max(0,u);var a=u-i,f="",l=0;if(s.indentWithTabs)for(var c=Math.floor(u/s.tabSize);c;--c)l+=s.tabSize,f+=" ";while(l<u)++l,f+=" ";qn(f,{line:e,ch:0},{line:e,ch:o.length})}function xr(){Lt=e.getMode(s,s.mode),At.iter(0,At.size,function(e){e.stateAfter=null}),Ot=[0],ai()}function Tr(){var e=s.gutter||s.lineNumbers;bt.style.display=e?"":"none",e?Vt=!0:Q.parentNode.style.marginLeft=0}function Nr(e,t){if(s.lineWrapping){xt.className+=" CodeMirror-wrap";var n=St.clientWidth/Qr()-3;At.iter(0,At.size,function(e){if(e.hidden)return;var t=Math.ceil(e.text.length/n)||1;t!=1&&hn(e,t)}),gt.style.minWidth=ft.style.left=""}else xt.className=xt.className.replace(" CodeMirror-wrap",""),In(),At.iter(0,At.size,function(e){e.height!=1&&!e.hidden&&hn(e,1)});Ut.push({from:0,to:At.size})}function Cr(e){var t=s.tabSize-e%s.tabSize,n=nn[t];if(n)return n;for(var r="",i=0;i<t;++i)r+=" ";var o=ot("span",r,"cm-tab");return nn[t]={element:o,width:t}}function kr(){St.className=St.className.replace(/\s*cm-s-\S+/g,"")+s.theme.replace(/(^|\s)\s*/g," cm-s-")}function Lr(){var e=a[s.keyMap].style;xt.className=xt.className.replace(/\s*cm-keymap-\S+/g,"")+(e?" cm-keymap-"+e:"")}function Ar(){this.set=[]}function Or(e,t,n){function i(e,t,n,i){cn(e).addMark(new C(t,n,i,r))}e=dr(e),t=dr(t);var r=new Ar;if(!it(e,t))return r;if(e.line==t.line)i(e.line,e.ch,t.ch,n);else{i(e.line,e.ch,null,n);for(var s=e.line+1,o=t.line;s<o;++s)i(s,null,null,n);i(t.line,null,t.ch,n)}return Ut.push({from:e.line,to:t.line+1}),r}function Mr(e){e=dr(e);var t=new k(e.ch);return cn(e.line).addMark(t),t}function _r(e){e=dr(e);var t=[],n=cn(e.line).marked;if(!n)return t;for(var r=0,i=n.length;r<i;++r){var s=n[r];(s.from==null||s.from<=e.ch)&&(s.to==null||s.to>=e.ch)&&t.push(s.marker||s)}return t}function Dr(e,t,n){return typeof e=="number"&&(e=cn(pr(e))),e.gutterMarker={text:t,style:n},Vt=!0,e}function Pr(e){typeof e=="number"&&(e=cn(pr(e))),e.gutterMarker=null,Vt=!0}function Hr(e,t){var n=e,r=e;return typeof e=="number"?r=cn(pr(e)):n=P(e),n==null?null:t(r,n)?(Ut.push({from:n,to:n+1}),r):null}function Br(e,t,n){return Hr(e,function(e){if(e.className!=t||e.bgClassName!=n)return e.className=t,e.bgClassName=n,!0})}function jr(e,t){return Hr(e,function(e,n){if(e.hidden!=t){e.hidden=t,s.lineWrapping||(t&&e.text.length==Zt.text.length?en=!0:!t&&e.text.length>Zt.text.length&&(Zt=e,en=!1)),hn(e,t?0:1);var r=_t.from.line,i=_t.to.line;if(t&&(r==n||i==n)){var o=r==n?cr({line:r,ch:0},r,0):_t.from,u=i==n?cr({line:i,ch:0},i,0):_t.to;if(!u)return;lr(o,u)}return Vt=!0}})}function Fr(e){if(typeof e=="number"){if(!fn(e))return null;var t=e;e=cn(e);if(!e)return null}else{var t=P(e);if(t==null)return null}var n=e.gutterMarker;return{line:t,handle:e,text:e.text,markerText:n&&n.text,markerClass:n&&n.style,lineClass:e.className,bgClass:e.bgClassName}}function Ir(e,t){function i(e){return qr(n,e).left}if(t<=0)return 0;var n=cn(e),r=n.text,s=0,o=0,u=r.length,a,f=Math.min(u,Math.ceil(t/Qr()));for(;;){var l=i(f);if(!(l<=t&&f<u)){a=l,u=f;break}f=Math.min(u,Math.ceil(f*1.2))}if(t>a)return u;f=Math.floor(u*.8),l=i(f),l<t&&(s=f,o=l);for(;;){if(u-s<=1)return a-t>t-o?s:u;var c=Math.ceil((s+u)/2),h=i(c);h>t?(u=c,a=h):(s=c,o=h)}}function qr(e,t){if(t==0)return{top:0,left:0};var n=s.lineWrapping&&t<e.text.length&&G.test(e.text.slice(t-1,t+1)),r=e.getElement(Cr,t,n);at(mt,r);var i=r.anchor,o=i.offsetTop,u=i.offsetLeft;if(p&&o==0&&u==0){var a=ot("span","x");i.parentNode.insertBefore(a,i.nextSibling),o=a.offsetTop}return{top:o,left:u}}function Rr(e,t){var n,r=$r(),i=r*(B(At,e.line)-(t?Jt:0));if(e.ch==0)n=0;else{var o=qr(cn(e.line),e.ch);n=o.left,s.lineWrapping&&(i+=Math.max(0,o.top))}return{x:n,y:i,yBot:i+r}}function Ur(e,t){function h(e){var t=qr(u,e);if(f){var r=Math.round(t.top/n);return c=r!=l,Math.max(0,t.left+(r-l)*St.clientWidth)}return t.left}if(t<0)return{line:0,ch:0};var n=$r(),r=Qr(),i=Jt+Math.floor(t/n),o=H(At,i);if(o>=At.size)return{line:At.size-1,ch:cn(At.size-1).text.length};var u=cn(o),a=u.text,f=s.lineWrapping,l=f?i-B(At,o):0;if(e<=0&&l==0)return{line:o,ch:0};var c=!1,p=0,d=0,v=a.length,m,g=Math.min(v,Math.ceil((e+l*St.clientWidth*.9)/r));for(;;){var y=h(g);if(!(y<=e&&g<v)){m=y,v=g;break}g=Math.min(v,Math.ceil(g*1.2))}if(e>m)return{line:o,ch:v};g=Math.floor(v*.8),y=h(g),y<e&&(p=g,d=y);for(;;){if(v-p<=1){var b=e-d<m-e;return{line:o,ch:b?p:v,after:b}}var w=Math.ceil((p+v)/2),E=h(w);E>e?(v=w,m=E,c&&(m+=1e3)):(p=w,d=E)}}function zr(e){var t=Rr(e,!0),n=et(gt);return{x:n.left+t.x,y:n.top+t.y,yBot:n.top+t.yBot}}function $r(){if(Vr==null){Vr=ot("pre");for(var e=0;e<49;++e)Vr.appendChild(document.createTextNode("x")),Vr.appendChild(ot("br"));Vr.appendChild(document.createTextNode("x"))}var t=Q.clientHeight;return t==Xr?Wr:(Xr=t,at(mt,Vr.cloneNode(!0)),Wr=mt.firstChild.offsetHeight/50||1,ut(mt),Wr)}function Qr(){if(St.clientWidth==Kr)return Jr;Kr=St.clientWidth;var e=ot("span","x"),t=ot("pre",[e]);return at(mt,t),Jr=e.offsetWidth||10}function Gr(){return gt.offsetTop}function Yr(){return gt.offsetLeft}function Zr(e,t){var n=et(St,!0),r,i;try{r=e.clientX,i=e.clientY}catch(e){return null}if(!t&&(r-n.left>St.clientWidth||i-n.top>St.clientHeight))return null;var s=et(gt,!0);return Ur(r-s.left,i-s.top)}function ei(e){function o(){var e=pt(L.value).join("\n");e!=i&&!s.readOnly&&hi(Rn)(e,"end"),O.style.position="relative",L.style.cssText=r,v&&(R.scrollTop=n),Xt=!1,Kn(!0),Xn()}var t=Zr(e),n=R.scrollTop;if(!t||b)return;(rt(_t.from,_t.to)||it(t,_t.from)||!it(t,_t.to))&&hi(hr)(t.line,t.ch);var r=L.style.cssText;O.style.position="absolute",L.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: white; "+"border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",Xt=!0;var i=L.value=Wn();Qn(),nt(L);if(h){U(e);var u=V(window,"mouseup",function(){u(),setTimeout(o,20)},!0)}else setTimeout(o,50)}function ti(){clearInterval(kt);var e=!0;Z.style.visibility="",kt=setInterval(function(){Z.style.visibility=(e=!e)?"":"hidden"},650)}function ri(e){function v(e,t,n){if(!e.text)return;var r=e.styles,i=o?0:e.text.length-1,s;for(var a=o?0:r.length-2,f=o?r.length:-2;a!=f;a+=2*u){var l=r[a];if(r[a+1]!=h){i+=u*l.length;continue}for(var c=o?0:l.length-1,v=o?l.length:-1;c!=v;c+=u,i+=u)if(i>=t&&i<n&&d.test(s=l.charAt(c))){var m=ni[s];if(m.charAt(1)==">"==o)p.push(s);else{if(p.pop()!=m.charAt(0))return{pos:i,match:!1};if(!p.length)return{pos:i,match:!0}}}}}var t=_t.inverted?_t.from:_t.to,n=cn(t.line),r=t.ch-1,i=r>=0&&ni[n.text.charAt(r)]||ni[n.text.charAt(++r)];if(!i)return;var s=i.charAt(0),o=i.charAt(1)==">",u=o?1:-1,a=n.styles;for(var f=r+1,l=0,c=a.length;l<c;l+=2)if((f-=a[l].length)<=0){var h=a[l+1];break}var p=[n.text.charAt(r)],d=/[(){}[\]]/;for(var l=t.line,c=o?Math.min(l+100,At.size):Math.max(-1,l-100);l!=c;l+=u){var n=cn(l),m=l==t.line,g=v(n,m&&o?r+1:0,m&&!o?r:n.text.length);if(g)break}g||(g={pos:null,match:!1});var h=g.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket",y=Or({line:t.line,ch:r},{line:t.line,ch:r+1},h),b=g.pos!=null&&Or({line:l,ch:g.pos},{line:l,ch:g.pos+1},h),w=hi(function(){y.clear(),b&&b.clear()});e?setTimeout(w,800):Yt=w}function ii(e){var t,n;for(var r=e,i=e-40;r>i;--r){if(r==0)return 0;var o=cn(r-1);if(o.stateAfter)return r;var u=o.indentation(s.tabSize);if(n==null||t>u)n=r-1,t=u}return n}function si(e){var t=ii(e),n=t&&cn(t-1).stateAfter;return n?n=x(Lt,n):n=T(Lt),At.iter(t,e,function(e){e.highlight(Lt,n,s.tabSize),e.stateAfter=x(Lt,n)}),t<e&&Ut.push({from:t,to:e}),e<At.size&&!cn(e).stateAfter&&Ot.push(e),n}function oi(e,t){var n=si(e);At.iter(e,t,function(e){e.highlight(Lt,n,s.tabSize),e.stateAfter=x(Lt,n)})}function ui(){var e=+(new Date)+s.workTime,t=Ot.length;while(Ot.length){if(!cn(Kt).stateAfter)var n=Kt;else var n=Ot.pop();if(n>=At.size)continue;var r=ii(n),i=r&&cn(r-1).stateAfter;i?i=x(Lt,i):i=T(Lt);var o=0,u=Lt.compareStates,a=!1,f=r,l=!1;At.iter(f,At.size,function(t){var r=t.stateAfter;if(+(new Date)>e)return Ot.push(f),ai(s.workDelay),a&&Ut.push({from:n,to:f+1}),l=!0;var c=t.highlight(Lt,i,s.tabSize);c&&(a=!0),t.stateAfter=x(Lt,i);var h=null;if(u){var p=r&&u(r,i);p!=J&&(h=!!p)}h==null&&(c!==!1||!r?o=0:++o>3&&(!Lt.indent||Lt.indent(r,"")==Lt.indent(i,""))&&(h=!0));if(h)return!0;++f});if(l)return;a&&Ut.push({from:n,to:f+1})}t&&s.onHighlightComplete&&s.onHighlightComplete(ln)}function ai(e){if(!Ot.length)return;Ct.set(e,hi(ui))}function fi(){qt=Rt=zt=null,Ut=[],Wt=!1,$t=[]}function li(){en&&In();if(tn&&!s.lineWrapping){var e=ft.offsetWidth,t=qr(Zt,Zt.text.length).left;ft.style.left=t+"px",gt.style.minWidth=t+e+"px",tn=!1}var n,r;if(Wt){var i=Zn();n=tr(i.x,i.y,i.x,i.yBot)}if(Ut.length||n&&n.scrollTop!=null)r=rr(Ut,!0,n&&n.scrollTop);r||(Wt&&ur(),Vt&&or()),n&&Yn(),Wt&&(Gn(),ti()),Mt&&!Xt&&(qt===!0||qt!==!1&&Wt)&&Kn(Rt),Wt&&s.matchBrackets&&setTimeout(hi(function(){Yt&&(Yt(),Yt=null),rt(_t.from,_t.to)&&ri(!1)}),20);var o=Wt,u=$t;zt&&s.onChange&&ln&&s.onChange(ln,zt),o&&s.onCursorActivity&&s.onCursorActivity(ln);for(var a=0;a<u.length;++a)u[a](ln);r&&s.onUpdate&&s.onUpdate(ln)}function hi(e){return function(){ci++||fi();try{var t=e.apply(this,arguments)}finally{--ci||li()}return t}}function pi(e){on.startCompound();try{return e()}finally{on.endCompound()}}var s={},w=e.defaults;for(var N in w)w.hasOwnProperty(N)&&(s[N]=(i&&i.hasOwnProperty(N)?i:w)[N]);var L=ot("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em");L.setAttribute("wrap","off"),L.setAttribute("autocorrect","off"),L.setAttribute("autocapitalize","off");var O=ot("div",[L],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),F=ot("div",null,"CodeMirror-scrollbar-inner"),R=ot("div",[F],"CodeMirror-scrollbar"),Q=ot("div"),Y=ot("div",null,null,"position: relative; z-index: -1"),Z=ot("pre","\u00a0","CodeMirror-cursor"),ft=ot("pre","\u00a0","CodeMirror-cursor","visibility: hidden"),mt=ot("div",null,null,"position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden;"),gt=ot("div",[mt,Z,ft,Y,Q],null,"position: relative; z-index: 0"),yt=ot("div",null,"CodeMirror-gutter-text"),bt=ot("div",[yt],"CodeMirror-gutter"),wt=ot("div",[bt,ot("div",[gt],"CodeMirror-lines")],null,"position: relative"),Et=ot("div",[wt],null,"position: relative"),St=ot("div",[Et],"CodeMirror-scroll");St.setAttribute("tabIndex","-1");var xt=ot("div",[O,R,St],"CodeMirror"+(s.lineWrapping?" CodeMirror-wrap":""));r.appendChild?r.appendChild(xt):r(xt),kr(),Lr(),t&&(L.style.width="0px"),g||(St.draggable=!0),gt.style.outline="none",s.tabindex!=null&&(L.tabIndex=s.tabindex),s.autofocus&&Qn(),!s.gutter&&!s.lineNumbers&&(bt.style.display="none"),E&&(O.style.height="1px",O.style.position="absolute"),S?R.className+=Fn()?" cm-sb-overlap":" cm-sb-nonoverlap":d&&(R.className+=" cm-sb-ie7");try{Qr()}catch(Tt){throw Tt.message.match(/runtime/i)&&(Tt=new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)")),Tt}var Nt=new $,Ct=new $,kt,Lt,At=new _([new M([new A("")])]),Ot,Mt;xr();var _t={from:{line:0,ch:0},to:{line:0,ch:0},inverted:!1},Dt,Pt,Ht,Bt=0,jt,Ft=!1,It=!1,qt,Rt,Ut,zt,Wt,Xt,Vt,$t,Jt=0,Kt=0,Qt=0,Gt=0,Yt,Zt=cn(0),en=!1,tn=!0,nn={},rn=!1,sn=null;hi(function(){pn(s.value||""),qt=!1})();var on=new j;V(St,"mousedown",hi(gn)),V(St,"dblclick",hi(yn)),V(gt,"selectstart",q),h||V(St,"contextmenu",ei),V(St,"scroll",mn),V(R,"scroll",vn),V(R,"mousedown",function(){Mt&&setTimeout(Qn,0)}),V(window,"resize",function(){rr(!0)}),V(L,"keyup",hi(Ln)),V(L,"input",Vn),V(L,"keydown",hi(Cn)),V(L,"keypress",hi(kn)),V(L,"focus",An),V(L,"blur",On),s.dragDrop&&(V(St,"dragstart",wn),V(St,"dragenter",un),V(St,"dragover",un),V(St,"drop",hi(bn))),V(St,"paste",function(){Qn(),Vn()}),V(L,"paste",Vn),V(L,"cut",hi(function(){s.readOnly||Rn("")})),E&&V(Et,"mouseup",function(){document.activeElement==L&&L.blur(),Qn()});var an;try{an=document.activeElement==L}catch(Tt){}an||s.autofocus?setTimeout(An,20):On();var ln=xt.CodeMirror={getValue:dn,setValue:hi(pn),getSelection:Wn,replaceSelection:hi(Rn),focus:function(){window.focus(),Qn(),An(),Vn()},setOption:function(e,t){var n=s[e];s[e]=t,e=="mode"||e=="indentUnit"?xr():e=="readOnly"&&t=="nocursor"?(On(),L.blur()):e=="readOnly"&&!t?Kn(!0):e=="theme"?kr():e=="lineWrapping"&&n!=t?hi(Nr)():e=="tabSize"?rr(!0):e=="keyMap"&&Lr();if(e=="lineNumbers"||e=="gutter"||e=="firstLineNumber"||e=="theme"||e=="lineNumberFormatter")Tr(),rr(!0)},getOption:function(e){return s[e]},undo:hi(Dn),redo:hi(Pn),indentLine:hi(function(e,t){typeof t!="string"&&(t==null?t=s.smartIndent?"smart":"prev":t=t?"add":"subtract"),fn(e)&&Sr(e,t)}),indentSelection:hi(Er),historySize:function(){return{undo:on.done.length,redo:on.undone.length}},clearHistory:function(){on=new j},setHistory:function(e){on=new j,on.done=e.done,on.undone=e.undone},getHistory:function(){return on.time=0,{done:on.done.concat([]),undone:on.undone.concat([])}},matchBrackets:hi(function(){ri(!0)}),getTokenAt:hi(function(e){return e=dr(e),cn(e.line).getTokenAt(Lt,si(e.line),e.ch)}),getStateAfter:function(e){return e=pr(e==null?At.size-1:e),si(e+1)},cursorCoords:function(e,t){return e==null&&(e=_t.inverted),this.charCoords(e?_t.from:_t.to,t)},charCoords:function(e,t){return e=dr(e),t=="local"?Rr(e,!1):t=="div"?Rr(e,!0):zr(e)},coordsChar:function(e){var t=et(gt);return Ur(e.x-t.left,e.y-t.top)},markText:hi(Or),setBookmark:Mr,findMarksAt:_r,setMarker:hi(Dr),clearMarker:hi(Pr),setLineClass:hi(Br),hideLine:hi(function(e){return jr(e,!0)}),showLine:hi(function(e){return jr(e,!1)}),onDeleteLine:function(e,t){if(typeof e=="number"){if(!fn(e))return null;e=cn(e)}return(e.handlers||(e.handlers=[])).push(t),e},lineInfo:Fr,addWidget:function(e,t,n,r,i){e=Rr(dr(e));var s=e.yBot,o=e.x;t.style.position="absolute",Et.appendChild(t);if(r=="over")s=e.y;else if(r=="near"){var u=Math.max(St.offsetHeight,At.height*$r()),a=Math.max(Et.clientWidth,gt.clientWidth)-Yr();e.yBot+t.offsetHeight>u&&e.y>t.offsetHeight&&(s=e.y-t.offsetHeight),o+t.offsetWidth>a&&(o=a-t.offsetWidth)}t.style.top=s+Gr()+"px",t.style.left=t.style.right="",i=="right"?(o=Et.clientWidth-t.offsetWidth,t.style.right="0px"):(i=="left"?o=0:i=="middle"&&(o=(Et.clientWidth-t.offsetWidth)/2),t.style.left=o+Yr()+"px"),n&&er(o,s,o+t.offsetWidth,s+t.offsetHeight)},lineCount:function(){return At.size},clipPos:dr,getCursor:function(e){return e==null&&(e=_t.inverted),st(e?_t.from:_t.to)},somethingSelected:function(){return!rt(_t.from,_t.to)},setCursor:hi(function(e,t,n){t==null&&typeof e.line=="number"?hr(e.line,e.ch,n):hr(e,t,n)}),setSelection:hi(function(e,t,n){(n?fr:lr)(dr(e),dr(t||e))}),getLine:function(e){if(fn(e))return cn(e).text},getLineHandle:function(e){if(fn(e))return cn(e)},setLine:hi(function(e,t){fn(e)&&qn(t,{line:e,ch:0},{line:e,ch:cn(e).text.length})}),removeLine:hi(function(e){fn(e)&&qn("",{line:e,ch:0},dr({line:e+1,ch:0}))}),replaceRange:hi(qn),getRange:function(e,t,n){return zn(dr(e),dr(t),n)},triggerOnKeyDown:hi(Cn),execCommand:function(e){return u[e](ln)},moveH:hi(mr),deleteH:hi(gr),moveV:hi(yr),toggleOverwrite:function(){Ft?(Ft=!1,Z.className=Z.className.replace(" CodeMirror-overwrite","")):(Ft=!0,Z.className+=" CodeMirror-overwrite")},posFromIndex:function(e){var t=0,n;return At.iter(0,At.size,function(r){var i=r.text.length+1;if(i>e)return n=e,!0;e-=i,++t}),dr({line:t,ch:n})},indexFromPos:function(e){if(e.line<0||e.ch<0)return 0;var t=e.ch;return At.iter(0,e.line,function(e){t+=e.text.length+1}),t},scrollTo:function(e,t){e!=null&&(St.scrollLeft=e),t!=null&&(R.scrollTop=St.scrollTop=t),rr([])},getScrollInfo:function(){return{x:St.scrollLeft,y:R.scrollTop,height:R.scrollHeight,width:St.scrollWidth}},setSize:function(e,t){function n(e){return e=String(e),/^\d+$/.test(e)?e+"px":e}e!=null&&(xt.style.width=n(e)),t!=null&&(St.style.height=n(t)),ln.refresh()},operation:function(e){return hi(e)()},compoundChange:function(e){return pi(e)},refresh:function(){rr(!0,null,Bt),R.scrollHeight>Bt&&(R.scrollTop=Bt)},getInputField:function(){return L},getWrapperElement:function(){return xt},getScrollerElement:function(){return St},getGutterElement:function(){return bt}},Sn,Nn=null,$n="";Ar.prototype.clear=hi(function(){var e=Infinity,t=-Infinity;for(var n=0,r=this.set.length;n<r;++n){var i=this.set[n],s=i.marked;if(!s||!i.parent)continue;var o=P(i);e=Math.min(e,o),t=Math.max(t,o);for(var u=0;u<s.length;++u)s[u].marker==this&&s.splice(u--,1)}e!=Infinity&&Ut.push({from:e,to:t+1})}),Ar.prototype.find=function(){var e,t;for(var n=0,r=this.set.length;n<r;++n){var i=this.set[n],s=i.marked;for(var o=0;o<s.length;++o){var u=s[o];if(u.marker==this)if(u.from!=null||u.to!=null){var a=P(i);a!=null&&(u.from!=null&&(e={line:a,ch:u.from}),u.to!=null&&(t={line:a,ch:u.to}))}}}return{from:e,to:t}};var Wr,Xr,Vr,Jr,Kr=0,ni={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},ci=0;for(var di in o)o.propertyIsEnumerable(di)&&!ln.propertyIsEnumerable(di)&&(ln[di]=o[di]);return ln}function f(e){return typeof e=="string"?a[e]:e}function l(e,t,n,r,i){function s(t){t=f(t);var n=t[e];if(n===!1)return i&&i(),!0;if(n!=null&&r(n))return!0;if(t.nofallthrough)return i&&i(),!0;var o=t.fallthrough;if(o==null)return!1;if(Object.prototype.toString.call(o)!="[object Array]")return s(o);for(var u=0,a=o.length;u<a;++u)if(s(o[u]))return!0;return!1}return t&&s(t)?!0:s(n)}function c(e){var t=vt[X(e,"keyCode")];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function x(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function T(e,t,n){return e.startState?e.startState(t,n):!0}function N(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8}function C(e,t,n,r){this.from=e,this.to=t,this.style=n,this.marker=r}function k(e){this.from=e,this.to=e,this.line=null}function A(e,t){this.styles=t||[e,null],this.text=e,this.height=1}function O(e,t,n,r){for(var i=0,s=0,o=0;s<t;i+=2){var u=n[i],a=s+u.length;o==0?(a>e&&r.push(u.slice(e-s,Math.min(u.length,t-s)),n[i+1]),a>=e&&(o=1)):o==1&&(a>t?r.push(u.slice(0,t-s),n[i+1]):r.push(u,n[i+1])),s=a}}function M(e){this.lines=e,this.parent=null;for(var t=0,n=e.length,r=0;t<n;++t)e[t].parent=this,r+=e[t].height;this.height=r}function _(e){this.children=e;var t=0,n=0;for(var r=0,i=e.length;r<i;++r){var s=e[r];t+=s.chunkSize(),n+=s.height,s.parent=this}this.size=t,this.height=n,this.parent=null}function D(e,t){while(!e.lines)for(var n=0;;++n){var r=e.children[n],i=r.chunkSize();if(t<i){e=r;break}t-=i}return e.lines[t]}function P(e){if(e.parent==null)return null;var t=e.parent,n=ct(t.lines,e);for(var r=t.parent;r;t=r,r=r.parent)for(var i=0,s=r.children.length;;++i){if(r.children[i]==t)break;n+=r.children[i].chunkSize()}return n}function H(e,t){var n=0;e:do{for(var r=0,i=e.children.length;r<i;++r){var s=e.children[r],o=s.height;if(t<o){e=s;continue e}t-=o,n+=s.chunkSize()}return n}while(!e.lines);for(var r=0,i=e.lines.length;r<i;++r){var u=e.lines[r],a=u.height;if(t<a)break;t-=a}return n+r}function B(e,t){var n=0;e:do{for(var r=0,i=e.children.length;r<i;++r){var s=e.children[r],o=s.chunkSize();if(t<o){e=s;continue e}t-=o,n+=s.height}return n}while(!e.lines);for(var r=0;r<t;++r)n+=e.lines[r].height;return n}function j(){this.time=0,this.done=[],this.undone=[],this.compound=0,this.closed=!1}function F(){U(this)}function I(e){return e.stop||(e.stop=F),e}function q(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function R(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function U(e){q(e),R(e)}function z(e){return e.target||e.srcElement}function W(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),n&&e.ctrlKey&&t==1&&(t=3),t}function X(e,t){var n=e.override&&e.override.hasOwnProperty(t);return n?e.override[t]:e[t]}function V(e,t,n,r){if(typeof e.addEventListener=="function"){e.addEventListener(t,n,!1);if(r)return function(){e.removeEventListener(t,n,!1)}}else{var i=function(e){n(e||window.event)};e.attachEvent("on"+t,i);if(r)return function(){e.detachEvent("on"+t,i)}}}function $(){this.id=null}function Y(e,t,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var r=0,i=0;r<t;++r)e.charAt(r)==" "?i+=n-i%n:++i;return i}function Z(e){return e.currentStyle?e.currentStyle:window.getComputedStyle(e,null)}function et(e,t){try{var n=e.getBoundingClientRect();n={top:n.top,left:n.left}}catch(r){n={top:0,left:0}}if(!t)if(window.pageYOffset==null){var i=document.documentElement||document.body.parentNode;i.scrollTop==null&&(i=document.body),n.top+=i.scrollTop,n.left+=i.scrollLeft}else n.top+=window.pageYOffset,n.left+=window.pageXOffset;return n}function tt(e){return e.textContent||e.innerText||e.nodeValue||""}function nt(e){t?(e.selectionStart=0,e.selectionEnd=e.value.length):e.select()}function rt(e,t){return e.line==t.line&&e.ch==t.ch}function it(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function st(e){return{line:e.line,ch:e.ch}}function ot(e,t,n,r){var i=document.createElement(e);n&&(i.className=n),r&&(i.style.cssText=r);if(typeof t=="string")ft(i,t);else if(t)for(var s=0;s<t.length;++s)i.appendChild(t[s]);return i}function ut(e){return e.innerHTML="",e}function at(e,t){ut(e).appendChild(t)}function ft(e,t){v?(e.innerHTML="",e.appendChild(document.createTextNode(t))):e.textContent=t}function lt(e,t){if(!t)return 0;if(!e)return t.length;for(var n=e.length,r=t.length;n>=0&&r>=0;--n,--r)if(e.charAt(n)!=t.charAt(r))break;return r+1}function ct(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;++n)if(e[n]==t)return n;return-1}function ht(e){return/\w/.test(e)||e.toUpperCase()!=e.toLowerCase()}e.defaults={value:"",mode:null,theme:"default",indentUnit:2,indentWithTabs:!1,smartIndent:!0,tabSize:4,keyMap:"default",extraKeys:null,electricChars:!0,autoClearEmptyLines:!1,onKeyEvent:null,onDragEvent:null,lineWrapping:!1,lineNumbers:!1,gutter:!1,fixedGutter:!1,firstLineNumber:1,readOnly:!1,dragDrop:!0,onChange:null,onCursorActivity:null,onGutterClick:null,onHighlightComplete:null,onUpdate:null,onFocus:null,onBlur:null,onScroll:null,matchBrackets:!1,workTime:100,workDelay:200,pollInterval:100,undoDepth:40,tabindex:null,autofocus:null,lineNumberFormatter:function(e){return e}};var t=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),n=t||/Mac/.test(navigator.platform),r=/Win/.test(navigator.platform),i=e.modes={},s=e.mimeModes={};e.defineMode=function(t,n){!e.defaults.mode&&t!="null"&&(e.defaults.mode=t);if(arguments.length>2){n.dependencies=[];for(var r=2;r<arguments.length;++r)n.dependencies.push(arguments[r])}i[t]=n},e.defineMIME=function(e,t){s[e]=t},e.resolveMode=function(t){if(typeof t=="string"&&s.hasOwnProperty(t))t=s[t];else if(typeof t=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return typeof t=="string"?{name:t}:t||{name:"null"}},e.getMode=function(t,n){var n=e.resolveMode(n),r=i[n.name];return r?r(t,n):e.getMode(t,"text/plain")},e.listModes=function(){var e=[];for(var t in i)i.propertyIsEnumerable(t)&&e.push(t);return e},e.listMIMEs=function(){var e=[];for(var t in s)s.propertyIsEnumerable(t)&&e.push({mime:t,mode:s[t]});return e};var o=e.extensions={};e.defineExtension=function(e,t){o[e]=t};var u=e.commands={selectAll:function(e){e.setSelection({line:0,ch:0},{line:e.lineCount()-1})},killLine:function(e){var t=e.getCursor(!0),n=e.getCursor(!1),r=!rt(t,n);!r&&e.getLine(t.line).length==t.ch?e.replaceRange("",t,{line:t.line+1,ch:0}):e.replaceRange("",t,r?n:{line:t.line})},deleteLine:function(e){var t=e.getCursor().line;e.replaceRange("",{line:t,ch:0},{line:t})},undo:function(e){e.undo()},redo:function(e){e.redo()},goDocStart:function(e){e.setCursor(0,0,!0)},goDocEnd:function(e){e.setSelection({line:e.lineCount()-1},null,!0)},goLineStart:function(e){e.setCursor(e.getCursor().line,0,!0)},goLineStartSmart:function(e){var t=e.getCursor(),n=e.getLine(t.line),r=Math.max(0,n.search(/\S/));e.setCursor(t.line,t.ch<=r&&t.ch?0:r,!0)},goLineEnd:function(e){e.setSelection({line:e.getCursor().line},null,!0)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goWordRight:function(e){e.moveH(1,"word")},delCharLeft:function(e){e.deleteH(-1,"char")},delCharRight:function(e){e.deleteH(1,"char")},delWordLeft:function(e){e.deleteH(-1,"word")},delWordRight:function(e){e.deleteH(1,"word")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ","end")},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.replaceSelection(" ","end")},transposeChars:function(e){var t=e.getCursor(),n=e.getLine(t.line);t.ch>0&&t.ch<n.length-1&&e.replaceRange(n.charAt(t.ch)+n.charAt(t.ch-1),{line:t.line,ch:t.ch-1},{line:t.line,ch:t.ch+1})},newlineAndIndent:function(e){e.replaceSelection("\n","end"),e.indentLine(e.getCursor().line)},toggleOverwrite:function(e){e.toggleOverwrite()}},a=e.keyMap={};a.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharRight",Backspace:"delCharLeft",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite"},a.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goWordLeft","Ctrl-Right":"goWordRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delWordLeft","Ctrl-Delete":"delWordRight","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",fallthrough:"basic"},a.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goWordLeft","Alt-Right":"goWordRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delWordLeft","Ctrl-Alt-Backspace":"delWordRight","Alt-Delete":"delWordRight","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",fallthrough:["basic","emacsy"]},a["default"]=n?a.macDefault:a.pcDefault,a.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":"goPageUp","Shift-Ctrl-V":"goPageDown","Ctrl-D":"delCharRight","Ctrl-H":"delCharLeft","Alt-D":"delWordRight","Alt-Backspace":"delWordLeft","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},e.fromTextArea=function(t,n){function r(){t.value=o.getValue()}n||(n={}),n.value=t.value,!n.tabindex&&t.tabindex&&(n.tabindex=t.tabindex),n.autofocus==null&&t.getAttribute("autofocus")!=null&&(n.autofocus=!0);if(t.form){var i=V(t.form,"submit",r,!0);if(typeof t.form.submit=="function"){var s=t.form.submit;t.form.submit=function u(){r(),t.form.submit=s,t.form.submit(),t.form.submit=u}}}t.style.display="none";var o=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},n);return o.save=r,o.getTextArea=function(){return t},o.toTextArea=function(){r(),t.parentNode.removeChild(o.getWrapperElement()),t.style.display="",t.form&&(i(),typeof t.form.submit=="function"&&(t.form.submit=s))},o};var h=/gecko\/\d{7}/i.test(navigator.userAgent),p=/MSIE \d/.test(navigator.userAgent),d=/MSIE [1-7]\b/.test(navigator.userAgent),v=/MSIE [1-8]\b/.test(navigator.userAgent),m=p&&document.documentMode==5,g=/WebKit\//.test(navigator.userAgent),y=/Chrome\//.test(navigator.userAgent),b=/Opera\//.test(navigator.userAgent),w=/Apple Computer/.test(navigator.vendor),E=/KHTML\//.test(navigator.userAgent),S=/Mac OS X 10\D([7-9]|\d\d)\D/.test(navigator.userAgent);e.copyState=x,e.startState=T,N.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(e){var t=this.string.charAt(this.pos);if(typeof e=="string")var n=t==e;else var n=t&&(e.test?e.test(t):e(t));if(n)return++this.pos,t},eatWhile:function(e){var t=this.pos;while(this.eat(e));return this.pos>t},eatSpace:function(){var e=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){return Y(this.string,this.start,this.tabSize)},indentation:function(){return Y(this.string,null,this.tabSize)},match:function(e,t,n){if(typeof e!="string"){var i=this.string.slice(this.pos).match(e);return i&&t!==!1&&(this.pos+=i[0].length),i}var r=function(e){return n?e.toLowerCase():e};if(r(this.string).indexOf(r(e),this.pos)==this.pos)return t!==!1&&(this.pos+=e.length),!0},current:function(){return this.string.slice(this.start,this.pos)}},e.StringStream=N,C.prototype={attach:function(e){this.marker.set.push(e)},detach:function(e){var t=ct(this.marker.set,e);t>-1&&this.marker.set.splice(t,1)},split:function(e,t){if(this.to<=e&&this.to!=null)return null;var n=this.from<e||this.from==null?null:this.from-e+t,r=this.to==null?null:this.to-e+t;return new C(n,r,this.style,this.marker)},dup:function(){return new C(null,null,this.style,this.marker)},clipTo:function(e,t,n,r,i){e&&r>this.from&&(r<this.to||this.to==null)?this.from=null:this.from!=null&&this.from>=t&&(this.from=Math.max(r,this.from)+i),n&&(t<this.to||this.to==null)&&(t>this.from||this.from==null)?this.to=null:this.to!=null&&this.to>t&&(this.to=r<this.to?this.to+i:t)},isDead:function(){return this.from!=null&&this.to!=null&&this.from>=this.to},sameSet:function(e){return this.marker==e.marker}},k.prototype={attach:function(e){this.line=e},detach:function(e){this.line==e&&(this.line=null)},split:function(e,t){if(e<this.from)return this.from=this.to=this.from-e+t,this},isDead:function(){return this.from>this.to},clipTo:function(e,t,n,r,i){(e||t<this.from)&&(n||r>this.to)?(this.from=0,this.to=-1):this.from>t&&(this.from=this.to=Math.max(r,this.from)+i)},sameSet:function(e){return!1},find:function(){return!this.line||!this.line.parent?null:{line:P(this.line),ch:this.from}},clear:function(){if(this.line){var e=ct(this.line.marked,this);e!=-1&&this.line.marked.splice(e,1),this.line=null}}};var L=" ";h||p&&!d?L="\u200b":b&&(L=""),A.inheritMarks=function(e,t){var n=new A(e),r=t&&t.marked;if(r)for(var i=0;i<r.length;++i)if(r[i].to==null&&r[i].style){var s=n.marked||(n.marked=[]),o=r[i],u=o.dup();s.push(u),u.attach(n)}return n},A.prototype={replace:function(e,t,n){var r=[],i=this.marked,s=t==null?this.text.length:t;O(0,e,this.styles,r),n&&r.push(n,null),O(s,this.text.length,this.styles,r),this.styles=r,this.text=this.text.slice(0,e)+n+this.text.slice(s),this.stateAfter=null;if(i){var o=n.length-(s-e);for(var u=0;u<i.length;++u){var a=i[u];a.clipTo(e==null,e||0,t==null,s,o),a.isDead()&&(a.detach(this),i.splice(u--,1))}}},split:function(e,t){var n=[t,null],r=this.marked;O(e,this.text.length,this.styles,n);var i=new A(t+this.text.slice(e),n);if(r)for(var s=0;s<r.length;++s){var o=r[s],u=o.split(e,t.length);u&&(i.marked||(i.marked=[]),i.marked.push(u),u.attach(i),u==o&&r.splice(s--,1))}return i},append:function(e){var t=this.text.length,n=e.marked,r=this.marked;this.text+=e.text,O(0,e.text.length,e.styles,this.styles);if(r)for(var i=0;i<r.length;++i)r[i].to==null&&(r[i].to=t);if(n&&n.length){r||(this.marked=r=[]);e:for(var i=0;i<n.length;++i){var s=n[i];if(!s.from)for(var o=0;o<r.length;++o){var u=r[o];if(u.to==t&&u.sameSet(s)){u.to=s.to==null?null:s.to+t,u.isDead()&&(u.detach(this),n.splice(i--,1));continue e}}r.push(s),s.attach(this),s.from+=t,s.to!=null&&(s.to+=t)}}},fixMarkEnds:function(e){var t=this.marked,n=e.marked;if(!t)return;e:for(var r=0;r<t.length;++r){var i=t[r],s=i.to==null;if(s&&n)for(var o=0;o<n.length;++o){var u=n[o];if(!u.sameSet(i)||u.from!=null)continue;if(i.from==this.text.length&&u.to==0){n.splice(o,1),t.splice(r--,1);continue e}s=!1;break}s&&(i.to=this.text.length)}},fixMarkStarts:function(){var e=this.marked;if(!e)return;for(var t=0;t<e.length;++t)e[t].from==null&&(e[t].from=0)},addMark:function(e){e.attach(this),this.marked==null&&(this.marked=[]),this.marked.push(e),this.marked.sort(function(e,t){return(e.from||0)-(t.from||0)})},highlight:function(e,t,n){var r=new N(this.text,n),i=this.styles,s=0,o=!1,u=i[0],a;this.text==""&&e.blankLine&&e.blankLine(t);while(!r.eol()){var f=e.token(r,t),l=this.text.slice(r.start,r.pos);r.start=r.pos,s&&i[s-1]==f?i[s-2]+=l:l&&(!o&&(i[s+1]!=f||s&&i[s-2]!=a)&&(o=!0),i[s++]=l,i[s++]=f,a=u,u=i[s]);if(r.pos>5e3){i[s++]=this.text.slice(r.pos),i[s++]=null;break}}return i.length!=s&&(i.length=s,o=!0),s&&i[s-2]!=a&&(o=!0),o||(i.length<5&&this.text.length<10?null:!1)},getTokenAt:function(e,t,n){var r=this.text,i=new N(r);while(i.pos<n&&!i.eol()){i.start=i.pos;var s=e.token(i,t)}return{start:i.start,end:i.pos,string:i.current(),className:s||null,state:t}},indentation:function(e){return Y(this.text,null,e)},getElement:function(e,t,n){function u(t,n,o){if(!n)return;r&&p&&n.charAt(0)==" "&&(n="\u00a0"+n.slice(1)),r=!1;if(!s.test(n)){i+=n.length;var u=document.createTextNode(n)}else{var u=document.createDocumentFragment(),a=0;for(;;){s.lastIndex=a;var f=s.exec(n),l=f?f.index-a:n.length-a;l&&(u.appendChild(document.createTextNode(n.slice(a,a+l))),i+=l);if(!f)break;a+=l+1;if(f[0]==" "){var c=e(i);u.appendChild(c.element.cloneNode(!0)),i+=c.width}else{var h=ot("span","\u2022","cm-invalidchar");h.title="\\u"+f[0].charCodeAt(0).toString(16),u.appendChild(h),i+=1}}}o?t.appendChild(ot("span",[u],o)):t.appendChild(u)}function m(e){return e?"cm-"+e.replace(/ +/g," cm-"):null}var r=!0,i=0,s=/[\t\u0000-\u0019\u200b\u2028\u2029\uFEFF]/g,o=ot("pre"),a=u;if(t!=null){var f=0,l=o.anchor=ot("span");a=function(e,r,i){var s=r.length;if(t>=f&&t<f+s){t>f&&(u(e,r.slice(0,t-f),i),n&&e.appendChild(ot("wbr"))),e.appendChild(l);var o=t-f;u(l,b?r.slice(o,o+1):r.slice(o),i),b&&u(e,r.slice(o+1),i),t--,f+=s}else f+=s,u(e,r,i),f==t&&f==v?(ft(l,L),e.appendChild(l)):f>t+10&&/\s/.test(r)&&(a=function(){})}}var c=this.styles,h=this.text,d=this.marked,v=h.length;if(!h&&t==null)a(o," ");else if(!d||!d.length)for(var g=0,y=0;y<v;g+=2){var w=c[g],E=c[g+1],S=w.length;y+S>v&&(w=w.slice(0,v-y)),y+=S,a(o,w,m(E))}else{var x=0,g=0,T="",E,N=0,C=d[0].from||0,k=[],A=0,O=function(){var e;while(A<d.length&&((e=d[A]).from==x||e.from==null))e.style!=null&&k.push(e),++A;C=A<d.length?d[A].from:Infinity;for(var t=0;t<k.length;++t){var n=k[t].to;n==null&&(n=Infinity),n==x?k.splice(t--,1):C=Math.min(n,C)}},M=0;while(x<v){C==x&&O();var _=Math.min(v,C);for(;;){if(T){var D=x+T.length,P=E;for(var H=0;H<k.length;++H)P=(P?P+" ":"")+k[H].style;a(o,D>_?T.slice(0,_-x):T,P);if(D>=_){T=T.slice(_-x),x=_;break}x=D}T=c[g++],E=m(c[g++])}}}return o},cleanUp:function(){this.parent=null;if(this.marked)for(var e=0,t=this.marked.length;e<t;++e)this.marked[e].detach(this)}},M.prototype={chunkSize:function(){return this.lines.length},remove:function(e,t,n){for(var r=e,i=e+t;r<i;++r){var s=this.lines[r];this.height-=s.height,s.cleanUp();if(s.handlers)for(var o=0;o<s.handlers.length;++o)n.push(s.handlers[o])}this.lines.splice(e,t)},collapse:function(e){e.splice.apply(e,[e.length,0].concat(this.lines))},insertHeight:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0,i=t.length;r<i;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}},_.prototype={chunkSize:function(){return this.size},remove:function(e,t,n){this.size-=t;for(var r=0;r<this.children.length;++r){var i=this.children[r],s=i.chunkSize();if(e<s){var o=Math.min(t,s-e),u=i.height;i.remove(e,o,n),this.height-=u-i.height,s==o&&(this.children.splice(r--,1),i.parent=null);if((t-=o)==0)break;e=0}else e-=s}if(this.size-t<25){var a=[];this.collapse(a),this.children=[new M(a)],this.children[0].parent=this}},collapse:function(e){for(var t=0,n=this.children.length;t<n;++t)this.children[t].collapse(e)},insert:function(e,t){var n=0;for(var r=0,i=t.length;r<i;++r)n+=t[r].height;this.insertHeight(e,t,n)},insertHeight:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0,i=this.children.length;r<i;++r){var s=this.children[r],o=s.chunkSize();if(e<=o){s.insertHeight(e,t,n);if(s.lines&&s.lines.length>50){while(s.lines.length>50){var u=s.lines.splice(s.lines.length-25,25),a=new M(u);s.height-=a.height,this.children.splice(r+1,0,a),a.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new _(t);if(!e.parent){var r=new _(e.children);r.parent=e,e.children=[r,n],e=r}else{e.size-=n.size,e.height-=n.height;var i=ct(e.parent.children,e);e.parent.children.splice(i+1,0,n)}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iter:function(e,t,n){this.iterN(e,t-e,n)},iterN:function(e,t,n){for(var r=0,i=this.children.length;r<i;++r){var s=this.children[r],o=s.chunkSize();if(e<o){var u=Math.min(t,o-e);if(s.iterN(e,u,n))return!0;if((t-=u)==0)break;e=0}else e-=o}}},j.prototype={addChange:function(e,t,n){this.undone.length=0;var r=+(new Date),i=this.done[this.done.length-1],s=i&&i[i.length-1],o=r-this.time;if(this.compound&&i&&!this.closed)i.push({start:e,added:t,old:n});else if(o>400||!s||this.closed||s.start>e+n.length||s.start+s.added<e)this.done.push([{start:e,added:t,old:n}]),this.closed=!1;else{var u=Math.max(0,s.start-e),a=Math.max(0,e+n.length-(s.start+s.added));for(var f=u;f>0;--f)s.old.unshift(n[f-1]);for(var f=a;f>0;--f)s.old.push(n[n.length-f]);u&&(s.start=e),s.added+=t-(n.length-u-a)}this.time=r},startCompound:function(){this.compound++||(this.closed=!0)},endCompound:function(){--this.compound||(this.closed=!0)}},e.e_stop=U,e.e_preventDefault=q,e.e_stopPropagation=R,e.connect=V,$.prototype={set:function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)}};var J=e.Pass={toString:function(){return"CodeMirror.Pass"}},K=function(){if(v)return!1;var e=ot("div");return"draggable"in e||"dragDrop"in e}(),Q=function(){var e=ot("textarea");return e.value="foo\nbar",e.value.indexOf("\r")>-1?"\r\n":"\n"}(),G=/^$/;h?G=/$'/:w?G=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/:y&&(G=/\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/),e.setTextContent=ft;var pt="\n\nb".split(/\n/).length!=3?function(e){var t=0,n=[],r=e.length;while(t<=r){var i=e.indexOf("\n",t);i==-1&&(i=e.length);var s=e.slice(t,e.charAt(i-1)=="\r"?i-1:i),o=s.indexOf("\r");o!=-1?(n.push(s.slice(0,o)),t+=o+1):(n.push(s),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)};e.splitLines=pt;var dt=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0};e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var vt={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};return e.keyNames=vt,function(){for(var e=0;e<10;e++)vt[e+48]=String(e);for(var e=65;e<=90;e++)vt[e]=String.fromCharCode(e);for(var e=1;e<=12;e++)vt[e+111]=vt[e+63235]="F"+e}(),e}();CodeMirror.defineMode("properties",function(){return{token:function(e,t){var n=e.sol()||t.afterSection,r=e.eol();t.afterSection=!1,n&&(t.nextMultiline?(t.inMultiline=!0,t.nextMultiline=!1):t.position="def"),r&&!t.nextMultiline&&(t.inMultiline=!1,t.position="def");if(n)while(e.eatSpace());var i=e.next();return!n||i!=="#"&&i!=="!"&&i!==";"?n&&i==="["?(t.afterSection=!0,e.skipTo("]"),e.eat("]"),"header"):i==="="||i===":"?(t.position="quote",null):(i==="\\"&&t.position==="quote"&&e.next()!=="u"&&(t.nextMultiline=!0),t.position):(t.position="comment",e.skipToEnd(),"comment")},startState:function(){return{position:"def",nextMultiline:!1,inMultiline:!1,afterSection:!1}}}}),CodeMirror.defineMIME("text/x-properties","properties"),CodeMirror.defineMIME("text/x-ini","properties")