Commits

Manuel Barkhau  committed 91a697c Draft

start loading libs earlier

  • Participants
  • Parent commits 1ea2d1d

Comments (0)

Files changed (4)

File backend/suggest.py

 
         query = "SELECT * FROM Script WHERE path >= :1 AND path < :2"
         if not self.request.get('nolimit'):
-            query += " LIMIT 15"
+            query += " LIMIT 30"
 
         scripts = db.GqlQuery(query, path, path + u"\ufffd")
 

File lib/codemirror.min.js

-var CodeMirror=function(){function e(r,i){function sn(e){return e>=0&&e<Ct.size}function un(e){return E(Ct,e)}function an(e,t){Wt=!0;var n=t-e.height;for(var r=e;r;r=r.parent)r.height+=n}function fn(e){var t={line:0,ch:0};Ln(t,{line:Ct.size-1,ch:un(Ct.size-1).text.length},lt(e),t,t),Ft=!0}function ln(){var e=[];return Ct.iter(0,Ct.size,function(t){e.push(t.text)}),e.join("\n")}function cn(e){if(Dt!=bt.scrollTop||Pt!=K.scrollLeft)Dt=bt.scrollTop,Pt=K.scrollLeft,er([]),s.fixedGutter&&(st.style.left=K.scrollLeft+"px"),s.onScroll&&s.onScroll(on)}function hn(e){function c(e){var t=Zr(e,!0);if(t&&!nt(t,o)){Lt||Tn(),o=t,or(r,t),Ft=!1;var n=Zn();if(t.line>=n.to||t.line<n.from)u=setTimeout(hi(function(){c(e)}),150)}}function h(e){clearTimeout(u);var t=Zr(e);t&&or(r,t),L(e),$n(),Ft=!0,p(),f()}sr(D(e,"shiftKey"));for(var t=M(e);t!=C;t=t.parentNode)if(t.parentNode==G&&t!=Y)return;for(var t=M(e);t!=C;t=t.parentNode)if(t.parentNode==ot)return s.onGutterClick&&s.onGutterClick(on,at(ot.childNodes,t)+$t,e),L(e);var r=Zr(e);switch(_(e)){case 3:j&&!n&&ei(e);return;case 2:r&&fr(r.line,r.ch,!0),setTimeout($n,20),L(e);return}if(!r){M(e)==K&&L(e);return}Lt||Tn();var i=+(new Date);if(_t&&_t.time>i-400&&nt(_t.pos,r))return L(e),setTimeout($n,20),yr(r.line);if(Mt&&Mt.time>i-400&&nt(Mt.pos,r))return _t={time:i,pos:r},L(e),gr(r);Mt={time:i,pos:r};var o=r,u;if(s.dragDrop&&J&&!s.readOnly&&!nt(At.from,At.to)&&!rt(r,At.from)&&!rt(At.to,r)){U&&(K.draggable=!0);function a(t){U&&(K.draggable=!1),Ht=!1,f(),l(),Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)<10&&(L(t),fr(r.line,r.ch,!0),$n())}var f=P(document,"mouseup",hi(a),!0),l=P(K,"drop",hi(a),!0);Ht=!0,K.dragDrop&&K.dragDrop();return}L(e),fr(r.line,r.ch,!0);var p=P(document,"mousemove",hi(function(e){clearTimeout(u),L(e),!F&&!_(e)?h(e):c(e)}),!0),f=P(document,"mouseup",hi(h),!0)}function pn(e){for(var t=M(e);t!=C;t=t.parentNode)if(t.parentNode==ot)return L(e);var n=Zr(e);if(!n)return;_t={time:+(new Date),pos:n},L(e),gr(n)}function dn(e){if(s.onDragEvent&&s.onDragEvent(on,k(e)))return;e.preventDefault();var t=Zr(e,!0),n=e.dataTransfer.files;if(!t||s.readOnly)return;if(n&&n.length&&window.FileReader&&window.File){function r(e,n){var r=new FileReader;r.onload=function(){o[n]=r.result,++u==i&&(t=cr(t),hi(function(){var e=Bn(o.join(""),t,t);or(t,e)})())},r.readAsText(e)}var i=n.length,o=Array(i),u=0;for(var a=0;a<i;++a)r(n[a],a)}else{if(Ht&&!rt(t,At.from)&&!rt(At.to,t))return;try{var o=e.dataTransfer.getData("Text");o&&pi(function(){var e=At.from,n=At.to;or(t,t),Ht&&Bn("",e,n),jn(o),$n()})}catch(e){}}}function vn(e){var t=qn();e.dataTransfer.setData("Text",t);if(j||z||W){var n=document.createElement("img");n.scr="data:image/gif;base64,R0lGODdhAgACAIAAAAAAAP///ywAAAAAAgACAAACAoRRADs=",e.dataTransfer.setDragImage(n,0,0)}}function mn(e,t){if(typeof e=="string"){e=u[e];if(!e)return!1}var n=Ot;try{s.readOnly&&(jt=!0),t&&(Ot=null),e(on)}catch(r){if(r!=B)throw r;return!1}finally{Ot=n,jt=!1}return!0}function gn(e){function u(){o=!0}var t=f(s.keyMap),n=t.auto;clearTimeout(wn),n&&!c(e)&&(wn=setTimeout(function(){f(s.keyMap)==t&&(s.keyMap=n.call?n.call(null,on):n)},50));var r=ht[D(e,"keyCode")],i=!1;if(r==null||e.altGraphKey)return!1;D(e,"altKey")&&(r="Alt-"+r),D(e,"ctrlKey")&&(r="Ctrl-"+r),D(e,"metaKey")&&(r="Cmd-"+r);var o=!1;return D(e,"shiftKey")?i=l("Shift-"+r,s.extraKeys,s.keyMap,function(e){return mn(e,!0)},u)||l(r,s.extraKeys,s.keyMap,function(e){if(typeof e=="string"&&/^go[A-Z]/.test(e))return mn(e)},u):i=l(r,s.extraKeys,s.keyMap,mn,u),o&&(i=!1),i&&(L(e),ti(),F&&(e.oldKeyCode=e.keyCode,e.keyCode=0)),i}function yn(e,t){var n=l("'"+t+"'",s.extraKeys,s.keyMap,function(e){return mn(e,!0)});return n&&(L(e),ti()),n}function En(e){Lt||Tn(),F&&e.keyCode==27&&(e.returnValue=!1),Rn&&Xn()&&(Rn=!1);if(s.onKeyEvent&&s.onKeyEvent(on,k(e)))return;var t=D(e,"keyCode");sr(t==16||D(e,"shiftKey"));var r=gn(e);W&&(bn=r?t:null,!r&&t==88&&D(e,n?"metaKey":"ctrlKey")&&jn(""))}function Sn(e){Rn&&Xn();if(s.onKeyEvent&&s.onKeyEvent(on,k(e)))return;var t=D(e,"keyCode"),n=D(e,"charCode");if(W&&t==bn){bn=null,L(e);return}if((W&&(!e.which||e.which<10)||V)&&gn(e))return;var r=String.fromCharCode(n==null?t:n);s.electricChars&&Nt.electricChars&&s.smartIndent&&!s.readOnly&&Nt.electricChars.indexOf(r)>-1&&setTimeout(hi(function(){wr(At.to.line,"smart")}),75);if(yn(e,r))return;zn()}function xn(e){if(s.onKeyEvent&&s.onKeyEvent(on,k(e)))return;D(e,"keyCode")==16&&(Ot=null)}function Tn(){if(s.readOnly=="nocursor")return;Lt||(s.onFocus&&s.onFocus(on),Lt=!0,K.className.search(/\bCodeMirror-focused\b/)==-1&&(K.className+=" CodeMirror-focused"),zt||Vn(!0)),Un(),ti()}function Nn(){Lt&&(s.onBlur&&s.onBlur(on),Lt=!1,Qt&&hi(function(){Qt&&(Qt(),Qt=null)})(),K.className=K.className.replace(" CodeMirror-focused","")),clearInterval(Tt),setTimeout(function(){Lt||(Ot=null)},150)}function Cn(e){return e>0&&e<1?1:e>-1&&e<0?-1:Math.round(e)}function kn(e){var t=0,n=0;if(e.type=="DOMMouseScroll"){var r=-e.detail*8;e.axis==e.HORIZONTAL_AXIS?t=r:e.axis==e.VERTICAL_AXIS&&(n=r)}else e.wheelDeltaX!==undefined&&e.wheelDeltaY!==undefined?(t=e.wheelDeltaX/3,n=e.wheelDeltaY/3):e.wheelDelta!==undefined&&(n=e.wheelDelta/3);var i=!1;t=Cn(t),n=Cn(n);if(t>0&&K.scrollLeft>0||t<0&&K.scrollLeft+K.clientWidth<K.scrollWidth)K.scrollLeft-=t,i=!0;if(n>0&&bt.scrollTop>0||n<0&&bt.scrollTop+bt.clientHeight<bt.scrollHeight)bt.scrollTop-=n,i=!0;i&&O(e)}function Ln(e,t,n,r,i){if(jt)return;if(tn){var o=[];Ct.iter(e.line,t.line+1,function(e){o.push(e.text)}),tn.addChange(e.line,n.length,o);while(tn.done.length>s.undoDepth)tn.done.shift()}_n(e,t,n,r,i)}function An(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;Ct.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:ut(o[o.length-1],s.old[s.old.length-1])};_n({line:s.start,ch:0},{line:u-1,ch:un(u-1).text.length},s.old,a,a)}Ft=!0,t.push(r)}function On(){An(tn.done,tn.undone)}function Mn(){An(tn.undone,tn.done)}function _n(e,t,n,r,i){function T(e){return e<=Math.min(t.line,t.line+y)?e:e+y}if(jt)return;var o=!1,u=Gt.length;s.lineWrapping||Ct.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)Wt=!0;var a=t.line-e.line,f=un(e.line),l=un(t.line);if(e.ch==0&&t.ch==0&&n[n.length-1]==""){var c=[],h=null;e.line?(h=un(e.line-1),h.fixMarkEnds(l)):l.fixMarkStarts();for(var p=0,d=n.length-1;p<d;++p)c.push(g.inheritMarks(n[p],h));a&&Ct.remove(e.line,a,Xt),c.length&&Ct.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(g.inheritMarks(n[p],f));c.push(l),Ct.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),Ct.remove(e.line+1,a,Xt);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(g.inheritMarks(n[p],f));a>1&&Ct.remove(e.line+1,a-1,Xt),Ct.insert(e.line+1,c)}if(s.lineWrapping){var v=Math.max(5,K.clientWidth/Qr()-3);Ct.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&&an(e,t)})}else Ct.iter(e.line,e.line+n.length,function(e){var t=e.text;!e.hidden&&t.length>u&&(Gt=t,u=t.length,Zt=!0,o=!1)}),o&&(Yt=!0);var m=[],y=n.length-a-1;for(var p=0,b=kt.length;p<b;++p){var w=kt[p];w<e.line?m.push(w):w>t.line&&m.push(w+y)}var E=e.line+Math.min(n.length,500);oi(e.line,E),m.push(E),kt=m,ai(100),qt.push({from:e.line,to:t.line+1,diff:y});var S={from:e,to:t,text:n};if(Rt){for(var x=Rt;x.next;x=x.next);x.next=S}else Rt=S;ur(cr(r),cr(i),T(At.from.line),T(At.to.line))}function Dn(e){var t=$r(),n=Math.floor(Ct.height*t+2*Gr()),r=K.clientHeight;bt.style.height=r+"px",K.clientHeight&&(wt.style.height=n+"px"),e!=null&&(bt.scrollTop=e),Y.style.top=Vt*t-bt.scrollTop+"px",bt.style.display=n>r?"block":"none"}function Pn(){var e=document.createElement("div"),t=document.createElement("div");e.className="CodeMirror-scrollbar",e.style.cssText="position: absolute; left: -9999px; height: 100px;",t.className="CodeMirror-scrollbar-inner",t.style.height="200px",e.appendChild(t),document.body.appendChild(e);var n=e.offsetWidth<=1;return document.body.removeChild(e),n}function Hn(){var e=0;Gt="",Zt=!0,Ct.iter(0,Ct.size,function(t){var n=t.text;!t.hidden&&n.length>e&&(e=n.length,Gt=n)}),Yt=!1}function Bn(e,t,n){function r(r){if(rt(r,t))return r;if(!rt(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=cr(t),n?n=cr(n):n=t,e=lt(e);var i;return Fn(e,t,n,function(e){return i=e,{from:r(At.from),to:r(At.to)}}),i}function jn(e,t){Fn(lt(e),At.from,At.to,function(e){return t=="end"?{from:e,to:e}:t=="start"?{from:At.from,to:At.from}:{from:At.from,to:e}})}function Fn(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});Ln(t,n,e,s.from,s.to)}function In(e,t){var n=e.line,r=t.line;if(n==r)return un(n).text.slice(e.ch,t.ch);var i=[un(n).text.slice(e.ch)];return Ct.iter(n+1,r,function(e){i.push(e.text)}),i.push(un(r).text.slice(0,t.ch)),i.join("\n")}function qn(){return In(At.from,At.to)}function Un(){if(Rn)return;St.set(s.pollInterval,function(){fi(),Xn(),Lt&&Un(),li()})}function zn(){function t(){fi();var n=Xn();!n&&!e?(e=!0,St.set(60,t)):(Rn=!1,Un()),li()}var e=!1;Rn=!0,St.set(20,t)}function Xn(){if(zt||!Lt||ct(X)||s.readOnly)return!1;var e=X.value;if(e==Wn)return!1;Ot=null;var t=0,n=Math.min(Wn.length,e.length);while(t<n&&Wn[t]==e[t])++t;return t<Wn.length?At.from={line:At.from.line,ch:At.from.ch-(Wn.length-t)}:Bt&&nt(At.from,At.to)&&(At.to={line:At.to.line,ch:Math.min(un(At.to.line).text.length,At.to.ch+(e.length-t))}),jn(e.slice(t),"end"),e.length>1e3?X.value=Wn="":Wn=e,!0}function Vn(e){nt(At.from,At.to)?e&&(Wn=X.value=""):(Wn="",X.value=qn(),tt(X))}function $n(){s.readOnly!="nocursor"&&X.focus()}function Jn(){if(!vt.getBoundingClientRect)return;var e=vt.getBoundingClientRect();if(F&&e.top==e.bottom)return;var t=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(e.top<0||e.bottom>t)&&Kn()}function Kn(){var e=Qn();return Gn(e.x,e.y,e.x,e.yBot)}function Qn(){var e=Rr(At.inverted?At.from:At.to),t=s.lineWrapping?Math.min(e.x,pt.offsetWidth):e.x;return{x:t,y:e.y,yBot:e.yBot}}function Gn(e,t,n,r){var i=Yn(e,t,n,r),o=!1;i.scrollLeft!=null&&(K.scrollLeft=i.scrollLeft,o=!0),i.scrollTop!=null&&(bt.scrollTop=i.scrollTop,o=!0),o&&s.onScroll&&s.onScroll(on)}function Yn(e,t,n,r){var i=Yr(),o=Gr();t+=o,r+=o,e+=i,n+=i;var u=K.clientHeight,a=bt.scrollTop,f={},l=t<Gr()+10;t<a?f.scrollTop=l?0:Math.max(0,t):r>a+u&&(f.scrollTop=r-u);var c=K.clientWidth,h=K.scrollLeft,p=s.fixedGutter?st.clientWidth:0,d=e<p+i+10;return e<h+p||d?(d&&(e=0),f.scrollLeft=Math.max(0,e-10-p)):n>c+h-3&&(f.scrollLeft=n+10-c),f}function Zn(e){var t=$r(),n=(e!=null?e:bt.scrollTop)-Gr(),r=Math.max(0,Math.floor(n/t)),i=Math.ceil((n+K.clientHeight)/t);return{from:x(Ct,r),to:x(Ct,i)}}function er(e,t,n){function d(){var e=yt.firstChild,t=!1;return Ct.iter($t,Jt,function(n){if(!n.hidden){var r=Math.round(e.offsetHeight/c)||1;n.height!=r&&(an(n,r),Wt=t=!0)}e=e.nextSibling}),t}if(!K.clientWidth){$t=Jt=Vt=0;return}var r=Zn(n);if(e!==!0&&e.length==0&&r.from>$t&&r.to<Jt){Dn(n);return}var i=Math.max(r.from-100,0),o=Math.min(Ct.size,r.to+100);$t<i&&i-$t<20&&(i=$t),Jt>o&&Jt-o<20&&(o=Math.min(Ct.size,Jt));var u=e===!0?[]:tr([{from:$t,to:Jt,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==$t&&o==Jt){Dn(n);return}u.sort(function(e,t){return e.domStart-t.domStart});var c=$r(),h=st.style.display;yt.style.display="none",nr(i,o,u),yt.style.display=st.style.display="";var p=i!=$t||o!=Jt||Kt!=K.clientHeight+c;p&&(Kt=K.clientHeight+c),$t=i,Jt=o,Vt=T(Ct,i);if(yt.childNodes.length!=Jt-$t)throw new Error("BAD PATCH! "+JSON.stringify(u)+" size="+(Jt-$t)+" nodes="+yt.childNodes.length);if(s.lineWrapping){var v=Math.floor(Ct.height*c+2*Gr()),m=K.clientHeight;v>m&&(bt.style.display="block"),d()}return st.style.display=h,(p||Wt)&&rr()&&s.lineWrapping&&d()&&rr(),ir(),Dn(n),!t&&s.onUpdate&&s.onUpdate(on),!0}function tr(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 nr(e,t,n){if(!n.length)yt.innerHTML="";else{function r(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var i=0,s=yt.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=yt.firstChild,f=e,h=document.createElement("div");Ct.iter(e,t,function(e){c&&c.to==f&&(c=n.shift());if(!c||c.from>f){if(e.hidden)var t=h.innerHTML="<pre></pre>";else{var t="<pre"+(e.className?' class="'+e.className+'"':"")+">"+e.getHTML(Tr)+"</pre>";e.bgClassName&&(t='<div style="position: relative"><pre class="'+e.bgClassName+'" style="position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2">&#160;</pre>'+t+"</div>")}h.innerHTML=t,yt.insertBefore(h.firstChild,s)}else s=s.nextSibling;++f})}function rr(){if(!s.gutter&&!s.lineNumbers)return;var e=Y.offsetHeight,t=K.clientHeight;st.style.height=(e-t<2?t:e)+"px";var n=[],r=$t,i;Ct.iter($t,Math.max(Jt,$t+1),function(e){if(e.hidden)n.push("<pre></pre>");else{var t=e.gutterMarker,o=s.lineNumbers?r+s.firstLineNumber:null;t&&t.text?o=t.text.replace("%N%",o!=null?o:""):o==null&&(o="\u00a0"),n.push(t&&t.style?'<pre class="'+t.style+'">':"<pre>",o);for(var u=1;u<e.height;++u)n.push("<br/>&#160;");n.push("</pre>"),t||(i=r)}++r}),st.style.display="none",ot.innerHTML=n.join("");if(i!=null&&s.lineNumbers){var o=ot.childNodes[i-$t],u=String(Ct.size).length,a=et(o.firstChild),f="";while(a.length+f.length<u)f+="\u00a0";f&&o.insertBefore(document.createTextNode(f),o.firstChild)}st.style.display="";var l=Math.abs((parseInt(pt.style.marginLeft)||0)-st.offsetWidth)>2;return pt.style.marginLeft=st.offsetWidth+"px",Wt=!1,l}function ir(){var e=nt(At.from,At.to),t=Rr(At.from,!0),n=e?t:Rr(At.to,!0),r=At.inverted?t:n,i=$r(),o=Z(C),u=Z(yt);A.style.top=Math.max(0,Math.min(K.offsetHeight,r.y+u.top-o.top))+"px",A.style.left=Math.max(0,Math.min(K.offsetWidth,r.x+u.left-o.left))+"px";if(e)vt.style.top=r.y+"px",vt.style.left=(s.lineWrapping?Math.min(r.x,pt.offsetWidth):r.x)+"px",vt.style.display="",gt.style.display="none";else{var a=t.y==n.y,f="",l=pt.clientWidth||pt.offsetWidth,c=pt.clientHeight||pt.offsetHeight;function h(e,t,n,r){var i=R?"width: "+(n?l-n-e:l)+"px":"right: "+n+"px";f+='<div class="CodeMirror-selected" style="position: absolute; left: '+e+"px; top: "+t+"px; "+i+"; height: "+r+'px"></div>'}if(At.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+(At.from.ch?i:0)),v=Math.min(n.y,c)-d;v>.2*i&&h(0,d,0,v),(!a||!At.from.ch)&&n.y<c-.5*i&&h(0,n.y,l-n.x,i),gt.innerHTML=f,vt.style.display="none",gt.style.display=""}}function sr(e){e?Ot=Ot||(At.inverted?At.to:At.from):Ot=null}function or(e,t){var n=Ot&&cr(Ot);n&&(rt(n,e)?e=n:rt(t,n)&&(t=n)),ur(e,t),It=!0}function ur(e,t,n,r){vr=null,n==null&&(n=At.from.line,r=At.to.line);if(nt(At.from,e)&&nt(At.to,t))return;if(rt(t,e)){var i=t;t=e,e=i}if(e.line!=n){var o=ar(e,n,At.from.ch);o?e=o:Hr(e.line,!1)}t.line!=r&&(t=ar(t,r,At.to.ch)),nt(e,t)?At.inverted=!1:nt(e,At.to)?At.inverted=!1:nt(t,At.from)&&(At.inverted=!0);if(s.autoClearEmptyLines&&nt(At.from,At.to)){var u=At.inverted?e:t;if(u.line!=At.from.line&&At.from.line<Ct.size){var a=un(At.from.line);/^\s+$/.test(a.text)&&setTimeout(hi(function(){if(a.parent&&/^\s+$/.test(a.text)){var e=S(a);Bn("",{line:e,ch:0},{line:e,ch:a.text.length})}},10))}}At.from=e,At.to=t,Ut=!0}function ar(e,t,n){function r(t){var r=e.line+t,i=t==1?Ct.size:-1;while(r!=i){var o=un(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=un(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 fr(e,t,n){var r=cr({line:e,ch:t||0});(n?or:ur)(r,r)}function lr(e){return Math.max(0,Math.min(e,Ct.size-1))}function cr(e){if(e.line<0)return{line:0,ch:0};if(e.line>=Ct.size)return{line:Ct.size-1,ch:un(Ct.size-1).text.length};var t=e.ch,n=un(e.line).text.length;return t==null||t>n?{line:e.line,ch:n}:t<0?{line:e.line,ch:0}:e}function hr(e,t){function o(){for(var t=r+e,n=e<0?-1:Ct.size;t!=n;t+=e){var i=un(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=At.inverted?At.from:At.to,r=n.line,i=n.ch,s=un(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(ft(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 pr(e,t){var n=e<0?At.from:At.to;if(Ot||nt(At.from,At.to))n=hr(e,t);fr(n.line,n.ch,!0)}function dr(e,t){nt(At.from,At.to)?e<0?Bn("",hr(e,t),At.to):Bn("",At.from,hr(e,t)):Bn("",At.from,At.to),It=!0}function mr(e,t){var n=0,r=Rr(At.inverted?At.from:At.to,!0);vr!=null&&(r.x=vr),t=="page"?n=Math.min(K.clientHeight,window.innerHeight||document.documentElement.clientHeight):t=="line"&&(n=$r());var i=Ur(r.x,r.y+n*e+2);t=="page"&&(bt.scrollTop+=Rr(i,!0).y-r.y),fr(i.line,i.ch,!0),vr=r.x}function gr(e){var t=un(e.line).text,n=e.ch,r=e.ch;while(n>0&&ft(t.charAt(n-1)))--n;while(r<t.length&&ft(t.charAt(r)))++r;or({line:e.line,ch:n},{line:e.line,ch:r})}function yr(e){or({line:e,ch:0},cr({line:e+1,ch:0}))}function br(e){if(nt(At.from,At.to))return wr(At.from.line,e);var t=At.to.line-(At.to.ch?0:1);for(var n=At.from.line;n<=t;++n)wr(n,e)}function wr(e,t){t||(t="add");if(t=="smart")if(!Nt.indent)t="prev";else var n=si(e);var r=un(e),i=r.indentation(s.tabSize),o=r.text.match(/^\s*/)[0],u;t=="smart"&&(u=Nt.indent(n,r.text.slice(o.length),r.text),u==B&&(t="prev")),t=="prev"?e?u=un(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;if(!a){if(At.from.line!=e&&At.to.line!=e)return;var f=o}else{var 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+=" "}Bn(f,{line:e,ch:0},{line:e,ch:o.length})}function Er(){Nt=e.getMode(s,s.mode),Ct.iter(0,Ct.size,function(e){e.stateAfter=null}),kt=[0],ai()}function Sr(){var e=s.gutter||s.lineNumbers;st.style.display=e?"":"none",e?Wt=!0:yt.parentNode.style.marginLeft=0}function xr(e,t){if(s.lineWrapping){C.className+=" CodeMirror-wrap";var n=K.clientWidth/Qr()-3;Ct.iter(0,Ct.size,function(e){if(e.hidden)return;var t=Math.ceil(e.text.length/n)||1;t!=1&&an(e,t)}),pt.style.width=G.style.width="",mt.style.left=""}else C.className=C.className.replace(" CodeMirror-wrap",""),Gt="",Zt=!0,Ct.iter(0,Ct.size,function(e){e.height!=1&&!e.hidden&&an(e,1),e.text.length>Gt.length&&(Gt=e.text)});qt.push({from:0,to:Ct.size})}function Tr(e){var t=s.tabSize-e%s.tabSize,n=en[t];if(n)return n;for(var r='<span class="cm-tab">',i=0;i<t;++i)r+=" ";return en[t]={html:r+"</span>",width:t}}function Nr(){K.className=K.className.replace(/\s*cm-s-\S+/g,"")+s.theme.replace(/(^|\s)\s*/g," cm-s-")}function Cr(){var e=a[s.keyMap].style;C.className=C.className.replace(/\s*cm-keymap-\S+/g,"")+(e?" cm-keymap-"+e:"")}function kr(){this.set=[]}function Lr(e,t,n){function i(e,t,n,i){un(e).addMark(new v(t,n,i,r))}e=cr(e),t=cr(t);var r=new kr;if(!rt(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 qt.push({from:e.line,to:t.line+1}),r}function Ar(e){e=cr(e);var t=new m(e.ch);return un(e.line).addMark(t),t}function Or(e){e=cr(e);var t=[],n=un(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 Mr(e,t,n){return typeof e=="number"&&(e=un(lr(e))),e.gutterMarker={text:t,style:n},Wt=!0,e}function _r(e){typeof e=="number"&&(e=un(lr(e))),e.gutterMarker=null,Wt=!0}function Dr(e,t){var n=e,r=e;return typeof e=="number"?r=un(lr(e)):n=S(e),n==null?null:t(r,n)?(qt.push({from:n,to:n+1}),r):null}function Pr(e,t,n){return Dr(e,function(e){if(e.className!=t||e.bgClassName!=n)return e.className=t,e.bgClassName=n,!0})}function Hr(e,t){return Dr(e,function(e,n){if(e.hidden!=t){e.hidden=t;if(!s.lineWrapping){var r=e.text;t&&r.length==Gt.length?Yt=!0:!t&&r.length>Gt.length&&(Gt=r,maxWidth=null,Yt=!1)}an(e,t?0:1);var i=At.from.line,o=At.to.line;if(t&&(i==n||o==n)){var u=i==n?ar({line:i,ch:0},i,0):At.from,a=o==n?ar({line:o,ch:0},o,0):At.to;if(!a)return;ur(u,a)}return Wt=!0}})}function Br(e){if(typeof e=="number"){if(!sn(e))return null;var t=e;e=un(e);if(!e)return null}else{var t=S(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 jr(e){return dt.innerHTML="<pre><span>x</span></pre>",dt.firstChild.firstChild.firstChild.nodeValue=e,dt.firstChild.firstChild.offsetWidth||10}function Fr(e,t){function i(e){return qr(n,e).left}if(t<=0)return 0;var n=un(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&&Q.test(e.text.slice(t-1,t+1));dt.innerHTML="<pre>"+e.getHTML(Tr,t,Ir,n)+"</pre>";var r=document.getElementById(Ir),i=r.offsetTop,o=r.offsetLeft;if(F&&i==0&&o==0){var u=document.createElement("span");u.innerHTML="x",r.parentNode.insertBefore(u,r.nextSibling),i=u.offsetTop}return{top:i,left:o}}function Rr(e,t){var n,r=$r(),i=r*(T(Ct,e.line)-(t?Vt:0));if(e.ch==0)n=0;else{var o=qr(un(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 c(e){var t=qr(u,e);if(f){var r=Math.round(t.top/n);return Math.max(0,t.left+(r-l)*K.clientWidth)}return t.left}t<0&&(t=0);var n=$r(),r=Qr(),i=Vt+Math.floor(t/n),o=x(Ct,i);if(o>=Ct.size)return{line:Ct.size-1,ch:un(Ct.size-1).text.length};var u=un(o),a=u.text,f=s.lineWrapping,l=f?i-T(Ct,o):0;if(e<=0&&l==0)return{line:o,ch:0};var h=0,p=0,d=a.length,v,m=Math.min(d,Math.ceil((e+l*K.clientWidth*.9)/r));for(;;){var g=c(m);if(!(g<=e&&m<d)){v=g,d=m;break}m=Math.min(d,Math.ceil(m*1.2))}if(e>v)return{line:o,ch:d};m=Math.floor(d*.8),g=c(m),g<e&&(h=m,p=g);for(;;){if(d-h<=1)return{line:o,ch:v-e>e-p?h:d};var y=Math.ceil((h+d)/2),b=c(y);b>e?(d=y,v=b):(h=y,p=b)}}function zr(e){var t=Rr(e,!0),n=Z(pt);return{x:n.left+t.x,y:n.top+t.y,yBot:n.top+t.yBot}}function $r(){if(Vr==null){Vr="<pre>";for(var e=0;e<49;++e)Vr+="x<br/>";Vr+="x</pre>"}var t=yt.clientHeight;return t==Xr?Wr:(Xr=t,dt.innerHTML=Vr,Wr=dt.firstChild.offsetHeight/50||1,dt.innerHTML="",Wr)}function Qr(){return K.clientWidth==Kr?Jr:(Kr=K.clientWidth,Jr=jr("x"))}function Gr(){return pt.offsetTop}function Yr(){return pt.offsetLeft}function Zr(e,t){var n=Z(K,!0),r,i;try{r=e.clientX,i=e.clientY}catch(e){return null}if(!t&&(r-n.left>K.clientWidth||i-n.top>K.clientHeight))return null;var s=Z(pt,!0);return Ur(r-s.left,i-s.top)}function ei(e){function o(){var e=lt(X.value).join("\n");e!=i&&!s.readOnly&&hi(jn)(e,"end"),A.style.position="relative",X.style.cssText=r,q&&(bt.scrollTop=n),zt=!1,Vn(!0),Un()}var t=Zr(e),n=bt.scrollTop;if(!t||W)return;(nt(At.from,At.to)||rt(t,At.from)||!rt(t,At.to))&&hi(fr)(t.line,t.ch);var r=X.style.cssText;A.style.position="absolute",X.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);",zt=!0;var i=X.value=qn();$n(),tt(X);if(j){O(e);var u=P(window,"mouseup",function(){u(),setTimeout(o,20)},!0)}else setTimeout(o,50)}function ti(){clearInterval(Tt);var e=!0;vt.style.visibility="",Tt=setInterval(function(){vt.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=At.inverted?At.from:At.to,n=un(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,Ct.size):Math.max(-1,l-100);l!=c;l+=u){var n=un(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=Lr({line:t.line,ch:r},{line:t.line,ch:r+1},h),b=g.pos!=null&&Lr({line:l,ch:g.pos},{line:l,ch:g.pos+1},h),w=hi(function(){y.clear(),b&&b.clear()});e?setTimeout(w,800):Qt=w}function ii(e){var t,n;for(var r=e,i=e-40;r>i;--r){if(r==0)return 0;var o=un(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&&un(t-1).stateAfter;return n?n=h(Nt,n):n=p(Nt),Ct.iter(t,e,function(e){e.highlight(Nt,n,s.tabSize),e.stateAfter=h(Nt,n)}),t<e&&qt.push({from:t,to:e}),e<Ct.size&&!un(e).stateAfter&&kt.push(e),n}function oi(e,t){var n=si(e);Ct.iter(e,t,function(e){e.highlight(Nt,n,s.tabSize),e.stateAfter=h(Nt,n)})}function ui(){var e=+(new Date)+s.workTime,t=kt.length;while(kt.length){if(!un($t).stateAfter)var n=$t;else var n=kt.pop();if(n>=Ct.size)continue;var r=ii(n),i=r&&un(r-1).stateAfter;i?i=h(Nt,i):i=p(Nt);var o=0,u=Nt.compareStates,a=!1,f=r,l=!1;Ct.iter(f,Ct.size,function(t){var r=t.stateAfter;if(+(new Date)>e)return kt.push(f),ai(s.workDelay),a&&qt.push({from:n,to:f+1}),l=!0;var c=t.highlight(Nt,i,s.tabSize);c&&(a=!0),t.stateAfter=h(Nt,i);var p=null;if(u){var d=r&&u(r,i);d!=B&&(p=!!d)}p==null&&(c!==!1||!r?o=0:++o>3&&(!Nt.indent||Nt.indent(r,"")==Nt.indent(i,""))&&(p=!0));if(p)return!0;++f});if(l)return;a&&qt.push({from:n,to:f+1})}t&&s.onHighlightComplete&&s.onHighlightComplete(on)}function ai(e){if(!kt.length)return;xt.set(e,hi(ui))}function fi(){Ft=It=Rt=null,qt=[],Ut=!1,Xt=[]}function li(){Yt&&Hn(),Zt&&!s.lineWrapping&&(mt.style.left=jr(Gt)+"px",Zt=!1);var e,t;if(Ut){var n=Qn();e=Yn(n.x,n.y,n.x,n.yBot)}qt.length?t=er(qt,!0,e?e.scrollTop:null):(Ut&&ir(),Wt&&rr()),e&&Kn(),Ut&&(Jn(),ti()),Lt&&!zt&&(Ft===!0||Ft!==!1&&Ut)&&Vn(It),Ut&&s.matchBrackets&&setTimeout(hi(function(){Qt&&(Qt(),Qt=null),nt(At.from,At.to)&&ri(!1)}),20);var r=Ut,i=Xt;Rt&&s.onChange&&on&&s.onChange(on,Rt),r&&s.onCursorActivity&&s.onCursorActivity(on);for(var o=0;o<i.length;++o)i[o](on);t&&s.onUpdate&&s.onUpdate(on)}function hi(e){return function(){ci++||fi();try{var t=e.apply(this,arguments)}finally{--ci||li()}return t}}function pi(e){tn.startCompound();try{return e()}finally{tn.endCompound()}}var s={},d=e.defaults;for(var y in d)d.hasOwnProperty(y)&&(s[y]=(i&&i.hasOwnProperty(y)?i:d)[y]);var C=document.createElement("div");C.className="CodeMirror"+(s.lineWrapping?" CodeMirror-wrap":""),C.innerHTML='<div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea style="position: absolute; padding: 0; width: 1px; height: 1em" wrap="off" autocorrect="off" autocapitalize="off"></textarea></div><div class="CodeMirror-scrollbar"><div class="CodeMirror-scrollbar-inner"></div></div><div class="CodeMirror-scroll" tabindex="-1"><div style="position: relative"><div style="position: relative"><div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div><div class="CodeMirror-lines"><div style="position: relative; z-index: 0"><div style="position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden;"></div><pre class="CodeMirror-cursor">&#160;</pre><pre class="CodeMirror-cursor" style="visibility: hidden">&#160;</pre><div style="position: relative; z-index: -1"></div><div></div></div></div></div></div></div>',r.appendChild?r.appendChild(C):r(C);var A=C.firstChild,X=A.firstChild,K=C.lastChild,G=K.firstChild,Y=G.firstChild,st=Y.firstChild,ot=st.firstChild,pt=st.nextSibling.firstChild,dt=pt.firstChild,vt=dt.nextSibling,mt=vt.nextSibling,gt=mt.nextSibling,yt=gt.nextSibling,bt=A.nextSibling,wt=bt.firstChild;Nr(),Cr(),t&&(X.style.width="0px"),U||(K.draggable=!0),pt.style.outline="none",s.tabindex!=null&&(X.tabIndex=s.tabindex),s.autofocus&&$n(),!s.gutter&&!s.lineNumbers&&(st.style.display="none"),V&&(A.style.height="1px",A.style.position="absolute"),$?bt.className+=Pn()?" cm-sb-overlap":" cm-sb-nonoverlap":I&&(bt.className+=" cm-sb-ie7");try{jr("x")}catch(Et){throw Et.message.match(/runtime/i)&&(Et=new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)")),Et}var St=new H,xt=new H,Tt,Nt,Ct=new w([new b([new g("")])]),kt,Lt;Er();var At={from:{line:0,ch:0},to:{line:0,ch:0},inverted:!1},Ot,Mt,_t,Dt=0,Pt=0,Ht,Bt=!1,jt=!1,Ft,It,qt,Rt,Ut,zt,Wt,Xt,Vt=0,$t=0,Jt=0,Kt=0,Qt,Gt="",Yt=!1,Zt=!0,en={};hi(function(){fn(s.value||""),Ft=!1})();var tn=new N;P(K,"mousedown",hi(hn)),P(K,"dblclick",hi(pn)),P(pt,"selectstart",L),j||P(K,"contextmenu",ei),P(K,"scroll",cn),P(bt,"scroll",cn),P(bt,"mousedown",function(){setTimeout($n,0)}),P(K,"mousewheel",kn),P(K,"DOMMouseScroll",kn),P(window,"resize",function(){er(!0)}),P(X,"keyup",hi(xn)),P(X,"input",zn),P(X,"keydown",hi(En)),P(X,"keypress",hi(Sn)),P(X,"focus",Tn),P(X,"blur",Nn);if(s.dragDrop){P(K,"dragstart",vn);function nn(e){if(s.onDragEvent&&s.onDragEvent(on,k(e)))return;O(e)}P(K,"dragenter",nn),P(K,"dragover",nn),P(K,"drop",hi(dn))}P(K,"paste",function(){$n(),zn()}),P(X,"paste",zn),P(X,"cut",hi(function(){s.readOnly||jn("")})),V&&P(G,"mouseup",function(){document.activeElement==X&&X.blur(),$n()});var rn;try{rn=document.activeElement==X}catch(Et){}rn||s.autofocus?setTimeout(Tn,20):Nn();var on=C.CodeMirror={getValue:ln,setValue:hi(fn),getSelection:qn,replaceSelection:hi(jn),focus:function(){window.focus(),$n(),Tn(),zn()},setOption:function(e,t){var n=s[e];s[e]=t,e=="mode"||e=="indentUnit"?Er():e=="readOnly"&&t=="nocursor"?(Nn(),X.blur()):e=="readOnly"&&!t?Vn(!0):e=="theme"?Nr():e=="lineWrapping"&&n!=t?hi(xr)():e=="tabSize"?er(!0):e=="keyMap"&&Cr();if(e=="lineNumbers"||e=="gutter"||e=="firstLineNumber"||e=="theme")Sr(),er(!0)},getOption:function(e){return s[e]},undo:hi(On),redo:hi(Mn),indentLine:hi(function(e,t){typeof t!="string"&&(t==null?t=s.smartIndent?"smart":"prev":t=t?"add":"subtract"),sn(e)&&wr(e,t)}),indentSelection:hi(br),historySize:function(){return{undo:tn.done.length,redo:tn.undone.length}},clearHistory:function(){tn=new N},matchBrackets:hi(function(){ri(!0)}),getTokenAt:hi(function(e){return e=cr(e),un(e.line).getTokenAt(Nt,si(e.line),e.ch)}),getStateAfter:function(e){return e=lr(e==null?Ct.size-1:e),si(e+1)},cursorCoords:function(e,t){return e==null&&(e=At.inverted),this.charCoords(e?At.from:At.to,t)},charCoords:function(e,t){return e=cr(e),t=="local"?Rr(e,!1):t=="div"?Rr(e,!0):zr(e)},coordsChar:function(e){var t=Z(pt);return Ur(e.x-t.left,e.y-t.top)},markText:hi(Lr),setBookmark:Ar,findMarksAt:Or,setMarker:hi(Mr),clearMarker:hi(_r),setLineClass:hi(Pr),hideLine:hi(function(e){return Hr(e,!0)}),showLine:hi(function(e){return Hr(e,!1)}),onDeleteLine:function(e,t){if(typeof e=="number"){if(!sn(e))return null;e=un(e)}return(e.handlers||(e.handlers=[])).push(t),e},lineInfo:Br,addWidget:function(e,t,n,r,i){e=Rr(cr(e));var s=e.yBot,o=e.x;t.style.position="absolute",G.appendChild(t);if(r=="over")s=e.y;else if(r=="near"){var u=Math.max(K.offsetHeight,Ct.height*$r()),a=Math.max(G.clientWidth,pt.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=G.clientWidth-t.offsetWidth,t.style.right="0px"):(i=="left"?o=0:i=="middle"&&(o=(G.clientWidth-t.offsetWidth)/2),t.style.left=o+Yr()+"px"),n&&Gn(o,s,o+t.offsetWidth,s+t.offsetHeight)},lineCount:function(){return Ct.size},clipPos:cr,getCursor:function(e){return e==null&&(e=At.inverted),it(e?At.from:At.to)},somethingSelected:function(){return!nt(At.from,At.to)},setCursor:hi(function(e,t,n){t==null&&typeof e.line=="number"?fr(e.line,e.ch,n):fr(e,t,n)}),setSelection:hi(function(e,t,n){(n?or:ur)(cr(e),cr(t||e))}),getLine:function(e){if(sn(e))return un(e).text},getLineHandle:function(e){if(sn(e))return un(e)},setLine:hi(function(e,t){sn(e)&&Bn(t,{line:e,ch:0},{line:e,ch:un(e).text.length})}),removeLine:hi(function(e){sn(e)&&Bn("",{line:e,ch:0},cr({line:e+1,ch:0}))}),replaceRange:hi(Bn),getRange:function(e,t){return In(cr(e),cr(t))},triggerOnKeyDown:hi(En),execCommand:function(e){return u[e](on)},moveH:hi(pr),deleteH:hi(dr),moveV:hi(mr),toggleOverwrite:function(){Bt?(Bt=!1,vt.className=vt.className.replace(" CodeMirror-overwrite","")):(Bt=!0,vt.className+=" CodeMirror-overwrite")},posFromIndex:function(e){var t=0,n;return Ct.iter(0,Ct.size,function(r){var i=r.text.length+1;if(i>e)return n=e,!0;e-=i,++t}),cr({line:t,ch:n})},indexFromPos:function(e){if(e.line<0||e.ch<0)return 0;var t=e.ch;return Ct.iter(0,e.line,function(e){t+=e.text.length+1}),t},scrollTo:function(e,t){e!=null&&(K.scrollLeft=e),t!=null&&(bt.scrollTop=t),er([])},getScrollInfo:function(){return{x:K.scrollLeft,y:bt.scrollTop,height:bt.scrollHeight,width:K.scrollWidth}},operation:function(e){return hi(e)()},compoundChange:function(e){return pi(e)},refresh:function(){er(!0),bt.scrollHeight>Dt&&(bt.scrollTop=Dt)},getInputField:function(){return X},getWrapperElement:function(){return C},getScrollerElement:function(){return K},getGutterElement:function(){return st}},bn=null,wn,Rn=!1,Wn="",vr=null;kr.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=S(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&&qt.push({from:e,to:t+1})}),kr.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=S(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 Ir="CodeMirror-temp-"+Math.floor(Math.random()*16777215).toString(16),Wr,Xr,Vr,Jr,Kr=0,ni={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},ci=0;for(var di in o)o.propertyIsEnumerable(di)&&!on.propertyIsEnumerable(di)&&(on[di]=o[di]);return on}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!=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=ht[D(e,"keyCode")];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function h(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 p(e,t,n){return e.startState?e.startState(t,n):!0}function d(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8}function v(e,t,n,r){this.from=e,this.to=t,this.style=n,this.marker=r}function m(e){this.from=e,this.to=e,this.line=null}function g(e,t){this.styles=t||[e,null],this.text=e,this.height=1,this.marked=this.gutterMarker=this.className=this.bgClassName=this.handlers=null,this.stateAfter=this.parent=this.hidden=null}function y(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 b(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 w(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 E(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 S(e){if(e.parent==null)return null;var t=e.parent,n=at(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 x(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 T(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 N(){this.time=0,this.done=[],this.undone=[],this.compound=0,this.closed=!1}function C(){O(this)}function k(e){return e.stop||(e.stop=C),e}function L(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function A(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function O(e){L(e),A(e)}function M(e){return e.target||e.srcElement}function _(e){if(e.which)return e.which;if(e.button&1)return 1;if(e.button&2)return 3;if(e.button&4)return 2}function D(e,t){var n=e.override&&e.override.hasOwnProperty(t);return n?e.override[t]:e[t]}function P(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 H(){this.id=null}function G(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 Y(e){return e.currentStyle?e.currentStyle:window.getComputedStyle(e,null)}function Z(e,t){var n=e.ownerDocument.body,r=0,i=0,s=!1;for(var o=e;o;o=o.offsetParent){var u=o.offsetLeft,a=o.offsetTop;o==n?(r+=Math.abs(u),i+=Math.abs(a)):(r+=u,i+=a),t&&Y(o).position=="fixed"&&(s=!0)}var f=t&&!s?null:n;for(var o=e.parentNode;o!=f;o=o.parentNode)o.scrollLeft!=null&&(r-=o.scrollLeft,i-=o.scrollTop);return{left:r,top:i}}function et(e){return e.textContent||e.innerText||e.nodeValue||""}function tt(e){t?(e.selectionStart=0,e.selectionEnd=e.value.length):e.select()}function nt(e,t){return e.line==t.line&&e.ch==t.ch}function rt(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function it(e){return{line:e.line,ch:e.ch}}function ot(e){return st.textContent=e,st.innerHTML}function ut(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 at(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 ft(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};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=!nt(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=u.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=P(t.form,"submit",r,!0);if(typeof t.form.submit=="function"){var s=t.form.submit;function o(){r(),t.form.submit=s,t.form.submit(),t.form.submit=o}t.form.submit=o}}t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},n);return u.save=r,u.getTextArea=function(){return t},u.toTextArea=function(){r(),t.parentNode.removeChild(u.getWrapperElement()),t.style.display="",t.form&&(i(),typeof t.form.submit=="function"&&(t.form.submit=s))},u},e.copyState=h,e.startState=p,d.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 G(this.string,this.start,this.tabSize)},indentation:function(){return G(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}function r(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=d,v.prototype={attach:function(e){this.marker.set.push(e)},detach:function(e){var t=at(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 v(n,r,this.style,this.marker)},dup:function(){return new v(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}},m.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:S(this.line),ch:this.from}},clear:function(){if(this.line){var e=at(this.line.marked,this);e!=-1&&this.line.marked.splice(e,1),this.line=null}}},g.inheritMarks=function(e,t){var n=new g(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},g.prototype={replace:function(e,t,n){var r=[],i=this.marked,s=t==null?this.text.length:t;y(0,e,this.styles,r),n&&r.push(n,null),y(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;y(e,this.text.length,this.styles,n);var i=new g(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,y(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;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)if(n[o].sameSet(i)){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 d(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 d(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 G(this.text,null,e)},getHTML:function(e,t,n,r){function u(t,n){if(!t)return;s&&F&&t.charAt(0)==" "&&(t="\u00a0"+t.slice(1)),s=!1;if(t.indexOf("	")==-1){o+=t.length;var r=ot(t)}else{var r="";for(var u=0;;){var a=t.indexOf("	",u);if(a==-1){r+=ot(t.slice(u)),o+=t.length-u;break}o+=a-u;var f=e(o);r+=ot(t.slice(u,a))+f.html,o+=f.width,u=a+1}}n?i.push('<span class="',n,'">',r,"</span>"):i.push(r)}function v(e){return e?"cm-"+e.replace(/ +/g," cm-"):null}var i=[],s=!0,o=0,a=u;if(t!=null){var f=0,l='<span id="'+n+'">';a=function(e,n){var s=e.length;if(t>=f&&t<f+s){t>f&&(u(e.slice(0,t-f),n),r&&i.push("<wbr>")),i.push(l);var o=t-f;u(W?e.slice(o,o+1):e.slice(o),n),i.push("</span>"),W&&u(e.slice(o+1),n),t--,f+=s}else f+=s,u(e,n),f==t&&f==d?i.push(l+" </span>"):f>t+10&&/\s/.test(e)&&(a=function(){})}}var c=this.styles,h=this.text,p=this.marked,d=h.length;if(!h&&t==null)a(" ");else if(!p||!p.length)for(var m=0,g=0;g<d;m+=2){var y=c[m],b=c[m+1],w=y.length;g+w>d&&(y=y.slice(0,d-g)),g+=w,a(y,v(b))}else{var E=0,m=0,S="",b,x=0,T=p[0].from||0,N=[],C=0;function k(){var e;while(C<p.length&&((e=p[C]).from==E||e.from==null))e.style!=null&&N.push(e),++C;T=C<p.length?p[C].from:Infinity;for(var t=0;t<N.length;++t){var n=N[t].to||Infinity;n==E?N.splice(t--,1):T=Math.min(n,T)}}var L=0;while(E<d){T==E&&k();var A=Math.min(d,T);for(;;){if(S){var O=E+S.length,M=b;for(var _=0;_<N.length;++_)M=(M?M+" ":"")+N[_].style;a(O>A?S.slice(0,A-E):S,M);if(O>=A){S=S.slice(A-E),E=A;break}E=O}S=c[m++],b=v(c[m++])}}}return i.join("")},cleanUp:function(){this.parent=null;if(this.marked)for(var e=0,t=this.marked.length;e<t;++e)this.marked[e].detach(this)}},b.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}},w.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 b(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 b(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 w(t);if(!e.parent){var r=new w(e.children);r.parent=e,e.children=[r,n],e=r}else{e.size-=n.size,e.height-=n.height;var i=at(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}}},N.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=O,e.e_preventDefault=L,e.e_stopPropagation=A,e.connect=P,H.prototype={set:function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)}};var B=e.Pass={toString:function(){return"CodeMirror.Pass"}},j=/gecko\/\d{7}/i.test(navigator.userAgent),F=/MSIE \d/.test(navigator.userAgent),I=/MSIE [1-7]\b/.test(navigator.userAgent),q=/MSIE [1-8]\b/.test(navigator.userAgent),R=F&&document.documentMode==5,U=/WebKit\//.test(navigator.userAgent),z=/Chrome\//.test(navigator.userAgent),W=/Opera\//.test(navigator.userAgent),X=/Apple Computer/.test(navigator.vendor),V=/KHTML\//.test(navigator.userAgent),$=/Mac OS X 10\D([7-9]|\d\d)\D/.test(navigator.userAgent),J=function(){if(q)return!1;var e=document.createElement("div");return"draggable"in e||"dragDrop"in e}(),K=function(){var e=document.createElement("textarea");return e.value="foo\nbar",e.value.indexOf("\r")>-1?"\r\n":"\n"}(),Q=/^$/;j?Q=/$'/:X?Q=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/:z&&(Q=/\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/),document.documentElement.getBoundingClientRect!=null&&(Z=function(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});var st=document.createElement("pre");ot("a")=="\na"?ot=function(e){return st.textContent=e,st.innerHTML.slice(1)}:ot("	")!="	"&&(ot=function(e){return st.innerHTML="",st.appendChild(document.createTextNode(e)),st.innerHTML}),e.htmlEscape=ot;var lt="\n\nb".split(/\n/).length!=3?function(e){var t=0,n,r=[];while((n=e.indexOf("\n",t))>-1)r.push(e.slice(t,e.charAt(n-1)=="\r"?n-1:n)),t=n+1;return r.push(e.slice(t)),r}:function(e){return e.split(/\r?\n/)};e.splitLines=lt;var ct=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 ht={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=ht,function(){for(var e=0;e<10;e++)ht[e+48]=String(e);for(var e=65;e<=90;e++)ht[e]=String.fromCharCode(e);for(var e=1;e<=12;e++)ht[e+111]=ht[e+63235]="F"+e}(),e}();CodeMirror.defineMode("coffeescript",function(e){function n(e){return new RegExp("^(("+e.join(")|(")+"))\\b")}function g(e,n){if(e.sol()){var l=n.scopes[0].offset;if(e.eatSpace()){var c=e.indentation();return c>l?"indent":c<l?"dedent":null}l>0&&E(e,n)}if(e.eatSpace())return null;var v=e.peek();if(e.match("####"))return e.skipToEnd(),"comment";if(e.match("###"))return n.tokenize=b,n.tokenize(e,n);if(v==="#")return e.skipToEnd(),"comment";if(e.match(/^-?[0-9\.]/,!1)){var g=!1;e.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)&&(g=!0),e.match(/^-?\d+\.\d*/)&&(g=!0),e.match(/^-?\.\d+/)&&(g=!0);if(g)return e.peek()=="."&&e.backUp(1),"number";var w=!1;e.match(/^-?0x[0-9a-f]+/i)&&(w=!0),e.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)&&(w=!0),e.match(/^-?0(?![\dx])/i)&&(w=!0);if(w)return"number"}if(e.match(p))return n.tokenize=y(e.current(),"string"),n.tokenize(e,n);if(e.match(d)){if(e.current()!="/"||e.match(/^.*\//,!1))return n.tokenize=y(e.current(),"string-2"),n.tokenize(e,n);e.backUp(1)}return e.match(u)||e.match(o)?"punctuation":e.match(s)||e.match(r)||e.match(f)?"operator":e.match(i)?"punctuation":e.match(m)?"atom":e.match(h)?"keyword":e.match(a)?"variable":(e.next(),t)}function y(n,r){var i=n.length==1;return function(o,u){while(!o.eol()){o.eatWhile(/[^'"\/\\]/);if(o.eat("\\")){o.next();if(i&&o.eol())return r}else{if(o.match(n))return u.tokenize=g,r;o.eat(/['"\/]/)}}return i&&(e.mode.singleLineStringErrors?r=t:u.tokenize=g),r}}function b(e,t){while(!e.eol()){e.eatWhile(/[^#]/);if(e.match("###")){t.tokenize=g;break}e.eatWhile("#")}return"comment"}function w(t,n,r){r=r||"coffee";var i=0;if(r==="coffee"){for(var s=0;s<n.scopes.length;s++)if(n.scopes[s].type==="coffee"){i=n.scopes[s].offset+e.indentUnit;break}}else i=t.column()+t.current().length;n.scopes.unshift({offset:i,type:r})}function E(e,t){if(t.scopes.length==1)return;if(t.scopes[0].type==="coffee"){var n=e.indentation(),r=-1;for(var i=0;i<t.scopes.length;++i)if(n===t.scopes[i].offset){r=i;break}if(r===-1)return!0;while(t.scopes[0].offset!==n)t.scopes.shift();return!1}return t.scopes.shift(),!1}function S(e,n){var r=n.tokenize(e,n),i=e.current();if(i===".")return r=n.tokenize(e,n),i=e.current(),r==="variable"?"variable":t;if(i==="@")return e.eat("@"),"keyword";i==="return"&&(n.dedent+=1),((i==="->"||i==="=>")&&!n.lambda&&n.scopes[0].type=="coffee"&&e.peek()===""||r==="indent")&&w(e,n);var s="[({".indexOf(i);return s!==-1&&w(e,n,"])}".slice(s,s+1)),l.exec(i)&&w(e,n),i=="then"&&E(e,n),r==="dedent"&&E(e,n)?t:(s="])}".indexOf(i),s!==-1&&E(e,n)?t:(n.dedent>0&&e.eol()&&n.scopes[0].type=="coffee"&&(n.scopes.length>1&&n.scopes.shift(),n.dedent-=1),r))}var t="error",r=new RegExp("^[\\+\\-\\*/%&|\\^~<>!?]"),i=new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]"),s=new RegExp("^((->)|(=>)|(\\+\\+)|(\\+\\=)|(\\-\\-)|(\\-\\=)|(\\*\\*)|(\\*\\=)|(\\/\\/)|(\\/\\=)|(==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//))"),o=new RegExp("^((\\.\\.)|(\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"),u=new RegExp("^((\\.\\.\\.)|(//=)|(>>=)|(<<=)|(\\*\\*=))"),a=new RegExp("^[_A-Za-z$][_A-Za-z$0-9]*"),f=n(["and","or","not","is","isnt","in","instanceof","typeof"]),l=["for","while","loop","if","unless","else","switch","try","catch","finally","class"],c=["break","by","continue","debugger","delete","do","in","of","new","return","then","this","throw","when","until"],h=n(l.concat(c));l=n(l);var p=new RegExp("^('{3}|\"{3}|['\"])"),d=new RegExp("^(/{3}|/)"),v=["Infinity","NaN","undefined","null","true","false","on","off","yes","no"],m=n(v),x={startState:function(e){return{tokenize:g,scopes:[{offset:e||0,type:"coffee"}],lastToken:null,lambda:!1,dedent:0}},token:function(e,t){var n=S(e,t);return t.lastToken={style:n,content:e.current()},e.eol()&&e.lambda&&(t.lambda=!1),n},indent:function(e,t){return e.tokenize!=g?0:e.scopes[0].offset}};return x}),CodeMirror.defineMIME("text/x-coffeescript","coffeescript")
+var CodeMirror=function(){function e(r,i){function sn(e){return e>=0&&e<Ct.size}function un(e){return E(Ct,e)}function an(e,t){Wt=!0;var n=t-e.height;for(var r=e;r;r=r.parent)r.height+=n}function fn(e){var t={line:0,ch:0};Ln(t,{line:Ct.size-1,ch:un(Ct.size-1).text.length},lt(e),t,t),Ft=!0}function ln(e){var t=[];return Ct.iter(0,Ct.size,function(e){t.push(e.text)}),t.join(e||"\n")}function cn(e){K.scrollTop&&(bt.scrollTop+=K.scrollTop,K.scrollTop=0);if(Dt!=bt.scrollTop||Pt!=K.scrollLeft)Dt=bt.scrollTop,Pt=K.scrollLeft,tr([]),s.fixedGutter&&(st.style.left=K.scrollLeft+"px"),s.onScroll&&s.onScroll(on)}function hn(e){function d(e){if(i=="single")ur(n,e);else if(i=="double"){var t=yr(e);rt(e,h)?ur(t.from,p):ur(h,t.to)}else i=="triple"&&(rt(e,h)?ur(p,hr({line:e.line,ch:0})):ur(h,hr({line:e.line+1,ch:0})))}function v(e){var t=ei(e,!0);if(t&&!nt(t,u)){Lt||Tn(),u=t,d(t),Ft=!1;var n=er();if(t.line>=n.to||t.line<n.from)a=setTimeout(pi(function(){v(e)}),150)}}function m(e){clearTimeout(a);var t=ei(e);t&&d(t),L(e),Jn(),Ft=!0,g(),l()}or(D(e,"shiftKey"));for(var t=M(e);t!=C;t=t.parentNode)if(t.parentNode==G&&t!=Y)return;for(var t=M(e);t!=C;t=t.parentNode)if(t.parentNode==ot)return s.onGutterClick&&s.onGutterClick(on,at(ot.childNodes,t)+$t,e),L(e);var n=ei(e);switch(_(e)){case 3:j&&ti(e);return;case 2:n&&lr(n.line,n.ch,!0),setTimeout(Jn,20),L(e);return}if(!n){M(e)==K&&L(e);return}Lt||Tn();var r=+(new Date),i="single";if(_t&&_t.time>r-400&&nt(_t.pos,n))i="triple",L(e),setTimeout(Jn,20),br(n.line);else if(Mt&&Mt.time>r-400&&nt(Mt.pos,n)){i="double",_t={time:r,pos:n},L(e);var o=yr(n);ur(o.from,o.to)}else Mt={time:r,pos:n};var u=n,a;if(s.dragDrop&&J&&!s.readOnly&&!nt(At.from,At.to)&&!rt(n,At.from)&&!rt(At.to,n)&&i=="single"){U&&(K.draggable=!0);function f(t){U&&(K.draggable=!1),Ht=!1,l(),c(),Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)<10&&(L(t),lr(n.line,n.ch,!0),Jn())}var l=P(document,"mouseup",pi(f),!0),c=P(K,"drop",pi(f),!0);Ht=!0,K.dragDrop&&K.dragDrop();return}L(e),i=="single"&&lr(n.line,n.ch,!0);var h=At.from,p=At.to,g=P(document,"mousemove",pi(function(e){clearTimeout(a),L(e),!F&&!_(e)?m(e):v(e)}),!0),l=P(document,"mouseup",pi(m),!0)}function pn(e){for(var t=M(e);t!=C;t=t.parentNode)if(t.parentNode==ot)return L(e);L(e)}function dn(e){if(s.onDragEvent&&s.onDragEvent(on,k(e)))return;e.preventDefault();var t=ei(e,!0),n=e.dataTransfer.files;if(!t||s.readOnly)return;if(n&&n.length&&window.FileReader&&window.File){function r(e,n){var r=new FileReader;r.onload=function(){o[n]=r.result,++u==i&&(t=hr(t),pi(function(){var e=jn(o.join(""),t,t);ur(t,e)})())},r.readAsText(e)}var i=n.length,o=Array(i),u=0;for(var a=0;a<i;++a)r(n[a],a)}else{if(Ht&&!rt(t,At.from)&&!rt(At.to,t))return;try{var o=e.dataTransfer.getData("Text");o&&di(function(){var e=At.from,n=At.to;ur(t,t),Ht&&jn("",e,n),Fn(o),Jn()})}catch(e){}}}function vn(e){var t=Rn();e.dataTransfer.setData("Text",t);if(j||z||W){var n=document.createElement("img");n.scr="data:image/gif;base64,R0lGODdhAgACAIAAAAAAAP///ywAAAAAAgACAAACAoRRADs=",e.dataTransfer.setDragImage(n,0,0)}}function mn(e,t){if(typeof e=="string"){e=u[e];if(!e)return!1}var n=Ot;try{s.readOnly&&(jt=!0),t&&(Ot=null),e(on)}catch(r){if(r!=B)throw r;return!1}finally{Ot=n,jt=!1}return!0}function gn(e){function u(){o=!0}var t=f(s.keyMap),n=t.auto;clearTimeout(wn),n&&!c(e)&&(wn=setTimeout(function(){f(s.keyMap)==t&&(s.keyMap=n.call?n.call(null,on):n)},50));var r=ht[D(e,"keyCode")],i=!1;if(r==null||e.altGraphKey)return!1;D(e,"altKey")&&(r="Alt-"+r),D(e,"ctrlKey")&&(r="Ctrl-"+r),D(e,"metaKey")&&(r="Cmd-"+r);var o=!1;return D(e,"shiftKey")?i=l("Shift-"+r,s.extraKeys,s.keyMap,function(e){return mn(e,!0)},u)||l(r,s.extraKeys,s.keyMap,function(e){if(typeof e=="string"&&/^go[A-Z]/.test(e))return mn(e)},u):i=l(r,s.extraKeys,s.keyMap,mn,u),o&&(i=!1),i&&(L(e),ni(),F&&(e.oldKeyCode=e.keyCode,e.keyCode=0)),i}function yn(e,t){var n=l("'"+t+"'",s.extraKeys,s.keyMap,function(e){return mn(e,!0)});return n&&(L(e),ni()),n}function En(e){Lt||Tn(),F&&e.keyCode==27&&(e.returnValue=!1),Un&&Vn()&&(Un=!1);if(s.onKeyEvent&&s.onKeyEvent(on,k(e)))return;var t=D(e,"keyCode");or(t==16||D(e,"shiftKey"));var r=gn(e);W&&(bn=r?t:null,!r&&t==88&&D(e,n?"metaKey":"ctrlKey")&&Fn(""))}function Sn(e){Un&&Vn();if(s.onKeyEvent&&s.onKeyEvent(on,k(e)))return;var t=D(e,"keyCode"),n=D(e,"charCode");if(W&&t==bn){bn=null,L(e);return}if((W&&(!e.which||e.which<10)||V)&&gn(e))return;var r=String.fromCharCode(n==null?t:n);s.electricChars&&Nt.electricChars&&s.smartIndent&&!s.readOnly&&Nt.electricChars.indexOf(r)>-1&&setTimeout(pi(function(){Er(At.to.line,"smart")}),75);if(yn(e,r))return;Wn()}function xn(e){if(s.onKeyEvent&&s.onKeyEvent(on,k(e)))return;D(e,"keyCode")==16&&(Ot=null)}function Tn(){if(s.readOnly=="nocursor")return;Lt||(s.onFocus&&s.onFocus(on),Lt=!0,K.className.search(/\bCodeMirror-focused\b/)==-1&&(K.className+=" CodeMirror-focused"),zt||$n(!0)),zn(),ni()}function Nn(){Lt&&(s.onBlur&&s.onBlur(on),Lt=!1,Qt&&pi(function(){Qt&&(Qt(),Qt=null)})(),K.className=K.className.replace(" CodeMirror-focused","")),clearInterval(Tt),setTimeout(function(){Lt||(Ot=null)},150)}function Cn(e){return e>0&&e<1?1:e>-1&&e<0?-1:Math.round(e)}function kn(e){var t=0,n=0;if(e.type=="DOMMouseScroll"){var r=-e.detail*8;e.axis==e.HORIZONTAL_AXIS?t=r:e.axis==e.VERTICAL_AXIS&&(n=r)}else e.wheelDeltaX!==undefined&&e.wheelDeltaY!==undefined?(t=e.wheelDeltaX/3,n=e.wheelDeltaY/3):e.wheelDelta!==undefined&&(n=e.wheelDelta/3);var i=!1;t=Cn(t),n=Cn(n);if(t>0&&K.scrollLeft>0||t<0&&K.scrollLeft+K.clientWidth<K.scrollWidth)K.scrollLeft-=t,i=!0;if(n>0&&bt.scrollTop>0||n<0&&bt.scrollTop+bt.clientHeight<bt.scrollHeight)bt.scrollTop-=n,i=!0;i&&O(e)}function Ln(e,t,n,r,i){if(jt)return;if(tn){var o=[];Ct.iter(e.line,t.line+1,function(e){o.push(e.text)}),tn.addChange(e.line,n.length,o);while(tn.done.length>s.undoDepth)tn.done.shift()}_n(e,t,n,r,i)}function An(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;Ct.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:ut(o[o.length-1],s.old[s.old.length-1])};_n({line:s.start,ch:0},{line:u-1,ch:un(u-1).text.length},s.old,a,a)}Ft=!0,t.push(r)}function On(){An(tn.done,tn.undone)}function Mn(){An(tn.undone,tn.done)}function _n(e,t,n,r,i){function T(e){return e<=Math.min(t.line,t.line+y)?e:e+y}if(jt)return;var o=!1,u=Gt.length;s.lineWrapping||Ct.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)Wt=!0;var a=t.line-e.line,f=un(e.line),l=un(t.line);if(e.ch==0&&t.ch==0&&n[n.length-1]==""){var c=[],h=null;e.line?(h=un(e.line-1),h.fixMarkEnds(l)):l.fixMarkStarts();for(var p=0,d=n.length-1;p<d;++p)c.push(g.inheritMarks(n[p],h));a&&Ct.remove(e.line,a,Xt),c.length&&Ct.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(g.inheritMarks(n[p],f));c.push(l),Ct.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),Ct.remove(e.line+1,a,Xt);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(g.inheritMarks(n[p],f));a>1&&Ct.remove(e.line+1,a-1,Xt),Ct.insert(e.line+1,c)}if(s.lineWrapping){var v=Math.max(5,K.clientWidth/Gr()-3);Ct.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&&an(e,t)})}else Ct.iter(e.line,e.line+n.length,function(e){var t=e.text;!e.hidden&&t.length>u&&(Gt=t,u=t.length,Zt=!0,o=!1)}),o&&(Yt=!0);var m=[],y=n.length-a-1;for(var p=0,b=kt.length;p<b;++p){var w=kt[p];w<e.line?m.push(w):w>t.line&&m.push(w+y)}var E=e.line+Math.min(n.length,500);ui(e.line,E),m.push(E),kt=m,fi(100),qt.push({from:e.line,to:t.line+1,diff:y});var S={from:e,to:t,text:n};if(Rt){for(var x=Rt;x.next;x=x.next);x.next=S}else Rt=S;ar(hr(r),hr(i),T(At.from.line),T(At.to.line))}function Dn(){var e=Ct.height*Jr()+2*Yr();return e-1>K.offsetHeight?e:!1}function Pn(e){var t=Dn();bt.style.display=t?"block":"none",t&&(wt.style.height=t+"px",bt.style.height=K.offsetHeight+"px",e!=null&&(bt.scrollTop=e)),Y.style.top=Vt*Jr()-bt.scrollTop+"px"}function Hn(){var e=document.createElement("div"),t=document.createElement("div");e.className="CodeMirror-scrollbar",e.style.cssText="position: absolute; left: -9999px; height: 100px;",t.className="CodeMirror-scrollbar-inner",t.style.height="200px",e.appendChild(t),document.body.appendChild(e);var n=e.offsetWidth<=1;return document.body.removeChild(e),n}function Bn(){var e=0;Gt="",Zt=!0,Ct.iter(0,Ct.size,function(t){var n=t.text;!t.hidden&&n.length>e&&(e=n.length,Gt=n)}),Yt=!1}function jn(e,t,n){function r(r){if(rt(r,t))return r;if(!rt(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=hr(t),n?n=hr(n):n=t,e=lt(e);var i;return In(e,t,n,function(e){return i=e,{from:r(At.from),to:r(At.to)}}),i}function Fn(e,t){In(lt(e),At.from,At.to,function(e){return t=="end"?{from:e,to:e}:t=="start"?{from:At.from,to:At.from}:{from:At.from,to:e}})}function In(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});Ln(t,n,e,s.from,s.to)}function qn(e,t,n){var r=e.line,i=t.line;if(r==i)return un(r).text.slice(e.ch,t.ch);var s=[un(r).text.slice(e.ch)];return Ct.iter(r+1,i,function(e){s.push(e.text)}),s.push(un(i).text.slice(0,t.ch)),s.join(n||"\n")}function Rn(e){return qn(At.from,At.to,e)}function zn(){if(Un)return;St.set(s.pollInterval,function(){li(),Vn(),Lt&&zn(),ci()})}function Wn(){function t(){li();var n=Vn();!n&&!e?(e=!0,St.set(60,t)):(Un=!1,zn()),ci()}var e=!1;Un=!0,St.set(20,t)}function Vn(){if(zt||!Lt||ct(X)||s.readOnly)return!1;var e=X.value;if(e==Xn)return!1;Ot=null;var t=0,n=Math.min(Xn.length,e.length);while(t<n&&Xn[t]==e[t])++t;return t<Xn.length?At.from={line:At.from.line,ch:At.from.ch-(Xn.length-t)}:Bt&&nt(At.from,At.to)&&(At.to={line:At.to.line,ch:Math.min(un(At.to.line).text.length,At.to.ch+(e.length-t))}),Fn(e.slice(t),"end"),e.length>1e3?X.value=Xn="":Xn=e,!0}function $n(e){nt(At.from,At.to)?e&&(Xn=X.value=""):(Xn="",X.value=Rn(),tt(X))}function Jn(){s.readOnly!="nocursor"&&X.focus()}function Kn(){var e=vt.getBoundingClientRect();if(F&&e.top==e.bottom)return;var t=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(e.top<0||e.bottom>t)&&Qn()}function Qn(){var e=Gn();return Yn(e.x,e.y,e.x,e.yBot)}function Gn(){var e=Ur(At.inverted?At.from:At.to),t=s.lineWrapping?Math.min(e.x,pt.offsetWidth):e.x;return{x:t,y:e.y,yBot:e.yBot}}function Yn(e,t,n,r){var i=Zn(e,t,n,r),o=!1;i.scrollLeft!=null&&(K.scrollLeft=i.scrollLeft,o=!0),i.scrollTop!=null&&(bt.scrollTop=i.scrollTop,o=!0),o&&s.onScroll&&s.onScroll(on)}function Zn(e,t,n,r){var i=Zr(),o=Yr();t+=o,r+=o,e+=i,n+=i;var u=K.clientHeight,a=bt.scrollTop,f={},l=K.scrollHeight,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=K.clientWidth,d=K.scrollLeft,v=s.fixedGutter?st.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 er(e){var t=Jr(),n=(e!=null?e:bt.scrollTop)-Yr(),r=Math.max(0,Math.floor(n/t)),i=Math.ceil((n+K.clientHeight)/t);return{from:x(Ct,r),to:x(Ct,i)}}function tr(e,t,n){function d(){var e=yt.firstChild,t=!1;return Ct.iter($t,Jt,function(n){if(!n.hidden){var r=Math.round(e.offsetHeight/c)||1;n.height!=r&&(an(n,r),Wt=t=!0)}e=e.nextSibling}),t}if(!K.clientWidth){$t=Jt=Vt=0;return}var r=er(n);if(e!==!0&&e.length==0&&r.from>$t&&r.to<Jt){Pn(n);return}var i=Math.max(r.from-100,0),o=Math.min(Ct.size,r.to+100);$t<i&&i-$t<20&&(i=$t),Jt>o&&Jt-o<20&&(o=Math.min(Ct.size,Jt));var u=e===!0?[]:nr([{from:$t,to:Jt,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==$t&&o==Jt){Pn(n);return}u.sort(function(e,t){return e.domStart-t.domStart});var c=Jr(),h=st.style.display;yt.style.display="none",rr(i,o,u),yt.style.display=st.style.display="";var p=i!=$t||o!=Jt||Kt!=K.clientHeight+c;p&&(Kt=K.clientHeight+c),$t=i,Jt=o,Vt=T(Ct,i);if(yt.childNodes.length!=Jt-$t)throw new Error("BAD PATCH! "+JSON.stringify(u)+" size="+(Jt-$t)+" nodes="+yt.childNodes.length);if(s.lineWrapping){d();var v=Dn(),m=v?"block":"none";bt.style.display!=m&&(bt.style.display=m,wt.style.height=v+"px",d())}return st.style.display=h,(p||Wt)&&ir()&&s.lineWrapping&&d()&&ir(),Pn(n),sr(),!t&&s.onUpdate&&s.onUpdate(on),!0}function nr(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 rr(e,t,n){if(!n.length)yt.innerHTML="";else{function r(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var i=0,s=yt.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=yt.firstChild,f=e,h=document.createElement("div");Ct.iter(e,t,function(e){c&&c.to==f&&(c=n.shift());if(!c||c.from>f){if(e.hidden)var t=h.innerHTML="<pre></pre>";else{var t="<pre"+(e.className?' class="'+e.className+'"':"")+">"+e.getHTML(Nr)+"</pre>";e.bgClassName&&(t='<div style="position: relative"><pre class="'+e.bgClassName+'" style="position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2">&#160;</pre>'+t+"</div>")}h.innerHTML=t,yt.insertBefore(h.firstChild,s)}else s=s.nextSibling;++f})}function ir(){if(!s.gutter&&!s.lineNumbers)return;var e=Y.offsetHeight,t=K.clientHeight;st.style.height=(e-t<2?t:e)+"px";var n=[],r=$t,i;Ct.iter($t,Math.max(Jt,$t+1),function(e){if(e.hidden)n.push("<pre></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"),n.push(t&&t.style?'<pre class="'+t.style+'">':"<pre>",o);for(var u=1;u<e.height;++u)n.push("<br/>&#160;");n.push("</pre>"),t||(i=r)}++r}),st.style.display="none",ot.innerHTML=n.join("");if(i!=null&&s.lineNumbers){var o=ot.childNodes[i-$t],u=String(Ct.size).length,a=et(o.firstChild),f="";while(a.length+f.length<u)f+="\u00a0";f&&o.insertBefore(document.createTextNode(f),o.firstChild)}st.style.display="";var l=Math.abs((parseInt(pt.style.marginLeft)||0)-st.offsetWidth)>2;return pt.style.marginLeft=st.offsetWidth+"px",Wt=!1,l}function sr(){var e=nt(At.from,At.to),t=Ur(At.from,!0),n=e?t:Ur(At.to,!0),r=At.inverted?t:n,i=Jr(),o=Z(C),u=Z(yt);A.style.top=Math.max(0,Math.min(K.offsetHeight,r.y+u.top-o.top))+"px",A.style.left=Math.max(0,Math.min(K.offsetWidth,r.x+u.left-o.left))+"px";if(e)vt.style.top=r.y+"px",vt.style.left=(s.lineWrapping?Math.min(r.x,pt.offsetWidth):r.x)+"px",vt.style.display="",gt.style.display="none";else{var a=t.y==n.y,f="",l=pt.clientWidth||pt.offsetWidth,c=pt.clientHeight||pt.offsetHeight;function h(e,t,n,r){var i=R?"width: "+(n?l-n-e:l)+"px":"right: "+n+"px";f+='<div class="CodeMirror-selected" style="position: absolute; left: '+e+"px; top: "+t+"px; "+i+"; height: "+r+'px"></div>'}if(At.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+(At.from.ch?i:0)),v=Math.min(n.y,c)-d;v>.2*i&&h(0,d,0,v),(!a||!At.from.ch)&&n.y<c-.5*i&&h(0,n.y,l-n.x,i),gt.innerHTML=f,vt.style.display="none",gt.style.display=""}}function or(e){e?Ot=Ot||(At.inverted?At.to:At.from):Ot=null}function ur(e,t){var n=Ot&&hr(Ot);n&&(rt(n,e)?e=n:rt(t,n)&&(t=n)),ar(e,t),It=!0}function ar(e,t,n,r){mr=null,n==null&&(n=At.from.line,r=At.to.line);if(nt(At.from,e)&&nt(At.to,t))return;if(rt(t,e)){var i=t;t=e,e=i}if(e.line!=n){var o=fr(e,n,At.from.ch);o?e=o:Br(e.line,!1)}t.line!=r&&(t=fr(t,r,At.to.ch)),nt(e,t)?At.inverted=!1:nt(e,At.to)?At.inverted=!1:nt(t,At.from)&&(At.inverted=!0);if(s.autoClearEmptyLines&&nt(At.from,At.to)){var u=At.inverted?e:t;if(u.line!=At.from.line&&At.from.line<Ct.size){var a=un(At.from.line);/^\s+$/.test(a.text)&&setTimeout(pi(function(){if(a.parent&&/^\s+$/.test(a.text)){var e=S(a);jn("",{line:e,ch:0},{line:e,ch:a.text.length})}},10))}}At.from=e,At.to=t,Ut=!0}function fr(e,t,n){function r(t){var r=e.line+t,i=t==1?Ct.size:-1;while(r!=i){var o=un(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=un(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 lr(e,t,n){var r=hr({line:e,ch:t||0});(n?ur:ar)(r,r)}function cr(e){return Math.max(0,Math.min(e,Ct.size-1))}function hr(e){if(e.line<0)return{line:0,ch:0};if(e.line>=Ct.size)return{line:Ct.size-1,ch:un(Ct.size-1).text.length};var t=e.ch,n=un(e.line).text.length;return t==null||t>n?{line:e.line,ch:n}:t<0?{line:e.line,ch:0}:e}function pr(e,t){function o(){for(var t=r+e,n=e<0?-1:Ct.size;t!=n;t+=e){var i=un(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=At.inverted?At.from:At.to,r=n.line,i=n.ch,s=un(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(ft(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 dr(e,t){var n=e<0?At.from:At.to;if(Ot||nt(At.from,At.to))n=pr(e,t);lr(n.line,n.ch,!0)}function vr(e,t){nt(At.from,At.to)?e<0?jn("",pr(e,t),At.to):jn("",At.from,pr(e,t)):jn("",At.from,At.to),It=!0}function gr(e,t){var n=0,r=Ur(At.inverted?At.from:At.to,!0);mr!=null&&(r.x=mr),t=="page"?n=Math.min(K.clientHeight,window.innerHeight||document.documentElement.clientHeight):t=="line"&&(n=Jr());var i=zr(r.x,r.y+n*e+2);t=="page"&&(bt.scrollTop+=Ur(i,!0).y-r.y),lr(i.line,i.ch,!0),mr=r.x}function yr(e){var t=un(e.line).text,n=e.ch,r=e.ch,i=ft(t.charAt(n<t.length?n:n-1))?ft:function(e){return!ft(e)};while(n>0&&i(t.charAt(n-1)))--n;while(r<t.length&&i(t.charAt(r)))++r;return{from:{line:e.line,ch:n},to:{line:e.line,ch:r}}}function br(e){ur({line:e,ch:0},hr({line:e+1,ch:0}))}function wr(e){if(nt(At.from,At.to))return Er(At.from.line,e);var t=At.to.line-(At.to.ch?0:1);for(var n=At.from.line;n<=t;++n)Er(n,e)}function Er(e,t){t||(t="add");if(t=="smart")if(!Nt.indent)t="prev";else var n=oi(e);var r=un(e),i=r.indentation(s.tabSize),o=r.text.match(/^\s*/)[0],u;t=="smart"&&(u=Nt.indent(n,r.text.slice(o.length),r.text),u==B&&(t="prev")),t=="prev"?e?u=un(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+=" ";jn(f,{line:e,ch:0},{line:e,ch:o.length})}function Sr(){Nt=e.getMode(s,s.mode),Ct.iter(0,Ct.size,function(e){e.stateAfter=null}),kt=[0],fi()}function xr(){var e=s.gutter||s.lineNumbers;st.style.display=e?"":"none",e?Wt=!0:yt.parentNode.style.marginLeft=0}function Tr(e,t){if(s.lineWrapping){C.className+=" CodeMirror-wrap";var n=K.clientWidth/Gr()-3;Ct.iter(0,Ct.size,function(e){if(e.hidden)return;var t=Math.ceil(e.text.length/n)||1;t!=1&&an(e,t)}),pt.style.width=G.style.width="",mt.style.left=""}else C.className=C.className.replace(" CodeMirror-wrap",""),Gt="",Zt=!0,Ct.iter(0,Ct.size,function(e){e.height!=1&&!e.hidden&&an(e,1),e.text.length>Gt.length&&(Gt=e.text)});qt.push({from:0,to:Ct.size})}function Nr(e){var t=s.tabSize-e%s.tabSize,n=en[t];if(n)return n;for(var r='<span class="cm-tab">',i=0;i<t;++i)r+=" ";return en[t]={html:r+"</span>",width:t}}function Cr(){K.className=K.className.replace(/\s*cm-s-\S+/g,"")+s.theme.replace(/(^|\s)\s*/g," cm-s-")}function kr(){var e=a[s.keyMap].style;C.className=C.className.replace(/\s*cm-keymap-\S+/g,"")+(e?" cm-keymap-"+e:"")}function Lr(){this.set=[]}function Ar(e,t,n){function i(e,t,n,i){un(e).addMark(new v(t,n,i,r))}e=hr(e),t=hr(t);var r=new Lr;if(!rt(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 qt.push({from:e.line,to:t.line+1}),r}function Or(e){e=hr(e);var t=new m(e.ch);return un(e.line).addMark(t),t}function Mr(e){e=hr(e);var t=[],n=un(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 _r(e,t,n){return typeof e=="number"&&(e=un(cr(e))),e.gutterMarker={text:t,style:n},Wt=!0,e}function Dr(e){typeof e=="number"&&(e=un(cr(e))),e.gutterMarker=null,Wt=!0}function Pr(e,t){var n=e,r=e;return typeof e=="number"?r=un(cr(e)):n=S(e),n==null?null:t(r,n)?(qt.push({from:n,to:n+1}),r):null}function Hr(e,t,n){return Pr(e,function(e){if(e.className!=t||e.bgClassName!=n)return e.className=t,e.bgClassName=n,!0})}function Br(e,t){return Pr(e,function(e,n){if(e.hidden!=t){e.hidden=t;if(!s.lineWrapping){var r=e.text;t&&r.length==Gt.length?Yt=!0:!t&&r.length>Gt.length&&(Gt=r,Yt=!1)}an(e,t?0:1);var i=At.from.line,o=At.to.line;if(t&&(i==n||o==n)){var u=i==n?fr({line:i,ch:0},i,0):At.from,a=o==n?fr({line:o,ch:0},o,0):At.to;if(!a)return;ar(u,a)}return Wt=!0}})}function jr(e){if(typeof e=="number"){if(!sn(e))return null;var t=e;e=un(e);if(!e)return null}else{var t=S(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 Fr(e){return dt.innerHTML="<pre><span>x</span></pre>",dt.firstChild.firstChild.firstChild.nodeValue=e,dt.firstChild.firstChild.offsetWidth||10}function Ir(e,t){function i(e){return Rr(n,e).left}if(t<=0)return 0;var n=un(e),r=n.text,s=0,o=0,u=r.length,a,f=Math.min(u,Math.ceil(t/Gr()));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 Rr(e,t){if(t==0)return{top:0,left:0};var n=s.lineWrapping&&t<e.text.length&&Q.test(e.text.slice(t-1,t+1));dt.innerHTML="<pre>"+e.getHTML(Nr,t,qr,n)+"</pre>";var r=document.getElementById(qr),i=r.offsetTop,o=r.offsetLeft;if(F&&i==0&&o==0){var u=document.createElement("span");u.innerHTML="x",r.parentNode.insertBefore(u,r.nextSibling),i=u.offsetTop}return{top:i,left:o}}function Ur(e,t){var n,r=Jr(),i=r*(T(Ct,e.line)-(t?Vt:0));if(e.ch==0)n=0;else{var o=Rr(un(e.line),e.ch);n=o.left,s.lineWrapping&&(i+=Math.max(0,o.top))}return{x:n,y:i,yBot:i+r}}function zr(e,t){function c(e){var t=Rr(u,e);if(f){var r=Math.round(t.top/n);return Math.max(0,t.left+(r-l)*K.clientWidth)}return t.left}t<0&&(t=0);var n=Jr(),r=Gr(),i=Vt+Math.floor(t/n),o=x(Ct,i);if(o>=Ct.size)return{line:Ct.size-1,ch:un(Ct.size-1).text.length};var u=un(o),a=u.text,f=s.lineWrapping,l=f?i-T(Ct,o):0;if(e<=0&&l==0)return{line:o,ch:0};var h=0,p=0,d=a.length,v,m=Math.min(d,Math.ceil((e+l*K.clientWidth*.9)/r));for(;;){var g=c(m);if(!(g<=e&&m<d)){v=g,d=m;break}m=Math.min(d,Math.ceil(m*1.2))}if(e>v)return{line:o,ch:d};m=Math.floor(d*.8),g=c(m),g<e&&(h=m,p=g);for(;;){if(d-h<=1)return{line:o,ch:v-e>e-p?h:d};var y=Math.ceil((h+d)/2),b=c(y);b>e?(d=y,v=b):(h=y,p=b)}}function Wr(e){var t=Ur(e,!0),n=Z(pt);return{x:n.left+t.x,y:n.top+t.y,yBot:n.top+t.yBot}}function Jr(){if($r==null){$r="<pre>";for(var e=0;e<49;++e)$r+="x<br/>";$r+="x</pre>"}var t=yt.clientHeight;return t==Vr?Xr:(Vr=t,dt.innerHTML=$r,Xr=dt.firstChild.offsetHeight/50||1,dt.innerHTML="",Xr)}function Gr(){return K.clientWidth==Qr?Kr:(Qr=K.clientWidth,Kr=Fr("x"))}function Yr(){return pt.offsetTop}function Zr(){return pt.offsetLeft}function ei(e,t){var n=Z(K,!0),r,i;try{r=e.clientX,i=e.clientY}catch(e){return null}if(!t&&(r-n.left>K.clientWidth||i-n.top>K.clientHeight))return null;var s=Z(pt,!0);return zr(r-s.left,i-s.top)}function ti(e){function o(){var e=lt(X.value).join("\n");e!=i&&!s.readOnly&&pi(Fn)(e,"end"),A.style.position="relative",X.style.cssText=r,q&&(bt.scrollTop=n),zt=!1,$n(!0),zn()}var t=ei(e),n=bt.scrollTop;if(!t||W)return;(nt(At.from,At.to)||rt(t,At.from)||!rt(t,At.to))&&pi(lr)(t.line,t.ch);var r=X.style.cssText;A.style.position="absolute",X.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);",zt=!0;var i=X.value=Rn();Jn(),tt(X);if(j){O(e);var u=P(window,"mouseup",function(){u(),setTimeout(o,20)},!0)}else setTimeout(o,50)}function ni(){clearInterval(Tt);var e=!0;vt.style.visibility="",Tt=setInterval(function(){vt.style.visibility=(e=!e)?"":"hidden"},650)}function ii(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=ri[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=At.inverted?At.from:At.to,n=un(t.line),r=t.ch-1,i=r>=0&&ri[n.text.charAt(r)]||ri[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,Ct.size):Math.max(-1,l-100);l!=c;l+=u){var n=un(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=Ar({line:t.line,ch:r},{line:t.line,ch:r+1},h),b=g.pos!=null&&Ar({line:l,ch:g.pos},{line:l,ch:g.pos+1},h),w=pi(function(){y.clear(),b&&b.clear()});e?setTimeout(w,800):Qt=w}function si(e){var t,n;for(var r=e,i=e-40;r>i;--r){if(r==0)return 0;var o=un(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 oi(e){var t=si(e),n=t&&un(t-1).stateAfter;return n?n=h(Nt,n):n=p(Nt),Ct.iter(t,e,function(e){e.highlight(Nt,n,s.tabSize),e.stateAfter=h(Nt,n)}),t<e&&qt.push({from:t,to:e}),e<Ct.size&&!un(e).stateAfter&&kt.push(e),n}function ui(e,t){var n=oi(e);Ct.iter(e,t,function(e){e.highlight(Nt,n,s.tabSize),e.stateAfter=h(Nt,n)})}function ai(){var e=+(new Date)+s.workTime,t=kt.length;while(kt.length){if(!un($t).stateAfter)var n=$t;else var n=kt.pop();if(n>=Ct.size)continue;var r=si(n),i=r&&un(r-1).stateAfter;i?i=h(Nt,i):i=p(Nt);var o=0,u=Nt.compareStates,a=!1,f=r,l=!1;Ct.iter(f,Ct.size,function(t){var r=t.stateAfter;if(+(new Date)>e)return kt.push(f),fi(s.workDelay),a&&qt.push({from:n,to:f+1}),l=!0;var c=t.highlight(Nt,i,s.tabSize);c&&(a=!0),t.stateAfter=h(Nt,i);var p=null;if(u){var d=r&&u(r,i);d!=B&&(p=!!d)}p==null&&(c!==!1||!r?o=0:++o>3&&(!Nt.indent||Nt.indent(r,"")==Nt.indent(i,""))&&(p=!0));if(p)return!0;++f});if(l)return;a&&qt.push({from:n,to:f+1})}t&&s.onHighlightComplete&&s.onHighlightComplete(on)}function fi(e){if(!kt.length)return;xt.set(e,pi(ai))}function li(){Ft=It=Rt=null,qt=[],Ut=!1,Xt=[]}function ci(){Yt&&Bn();if(Zt&&!s.lineWrapping){var e=mt.offsetWidth,t=Fr(Gt);mt.style.left=t+"px",pt.style.minWidth=t+e+"px",Zt=!1}var n,r;if(Ut){var i=Gn();n=Zn(i.x,i.y,i.x,i.yBot)}qt.length?r=tr(qt,!0,n?n.scrollTop:null):(Ut&&sr(),Wt&&ir()),n&&Qn(),Ut&&(Kn(),ni()),Lt&&!zt&&(Ft===!0||Ft!==!1&&Ut)&&$n(It),Ut&&s.matchBrackets&&setTimeout(pi(function(){Qt&&(Qt(),Qt=null),nt(At.from,At.to)&&ii(!1)}),20);var o=Ut,u=Xt;Rt&&s.onChange&&on&&s.onChange(on,Rt),o&&s.onCursorActivity&&s.onCursorActivity(on);for(var a=0;a<u.length;++a)u[a](on);r&&s.onUpdate&&s.onUpdate(on)}function pi(e){return function(){hi++||li();try{var t=e.apply(this,arguments)}finally{--hi||ci()}return t}}function di(e){tn.startCompound();try{return e()}finally{tn.endCompound()}}var s={},d=e.defaults;for(var y in d)d.hasOwnProperty(y)&&(s[y]=(i&&i.hasOwnProperty(y)?i:d)[y]);var C=document.createElement("div");C.className="CodeMirror"+(s.lineWrapping?" CodeMirror-wrap":""),C.innerHTML='<div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea style="position: absolute; padding: 0; width: 1px; height: 1em" wrap="off" autocorrect="off" autocapitalize="off"></textarea></div><div class="CodeMirror-scrollbar"><div class="CodeMirror-scrollbar-inner"></div></div><div class="CodeMirror-scroll" tabindex="-1"><div style="position: relative"><div style="position: relative"><div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div><div class="CodeMirror-lines"><div style="position: relative; z-index: 0"><div style="position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden;"></div><pre class="CodeMirror-cursor">&#160;</pre><pre class="CodeMirror-cursor" style="visibility: hidden">&#160;</pre><div style="position: relative; z-index: -1"></div><div></div></div></div></div></div></div>',r.appendChild?r.appendChild(C):r(C);var A=C.firstChild,X=A.firstChild,K=C.lastChild,G=K.firstChild,Y=G.firstChild,st=Y.firstChild,ot=st.firstChild,pt=st.nextSibling.firstChild,dt=pt.firstChild,vt=dt.nextSibling,mt=vt.nextSibling,gt=mt.nextSibling,yt=gt.nextSibling,bt=A.nextSibling,wt=bt.firstChild;Cr(),kr(),t&&(X.style.width="0px"),U||(K.draggable=!0),pt.style.outline="none",s.tabindex!=null&&(X.tabIndex=s.tabindex),s.autofocus&&Jn(),!s.gutter&&!s.lineNumbers&&(st.style.display="none"),V&&(A.style.height="1px",A.style.position="absolute"),$?bt.className+=Hn()?" cm-sb-overlap":" cm-sb-nonoverlap":I&&(bt.className+=" cm-sb-ie7");try{Fr("x")}catch(Et){throw Et.message.match(/runtime/i)&&(Et=new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)")),Et}var St=new H,xt=new H,Tt,Nt,Ct=new w([new b([new g("")])]),kt,Lt;Sr();var At={from:{line:0,ch:0},to:{line:0,ch:0},inverted:!1},Ot,Mt,_t,Dt=0,Pt=0,Ht,Bt=!1,jt=!1,Ft,It,qt,Rt,Ut,zt,Wt,Xt,Vt=0,$t=0,Jt=0,Kt=0,Qt,Gt="",Yt=!1,Zt=!0,en={};pi(function(){fn(s.value||""),Ft=!1})();var tn=new N;P(K,"mousedown",pi(hn)),P(K,"dblclick",pi(pn)),P(pt,"selectstart",L),j||P(K,"contextmenu",ti),P(K,"scroll",cn),P(bt,"scroll",cn),P(bt,"mousedown",function(){Lt&&setTimeout(Jn,0)}),P(K,"mousewheel",kn),P(K,"DOMMouseScroll",kn),P(window,"resize",function(){tr(!0)}),P(X,"keyup",pi(xn)),P(X,"input",Wn),P(X,"keydown",pi(En)),P(X,"keypress",pi(Sn)),P(X,"focus",Tn),P(X,"blur",Nn);if(s.dragDrop){P(K,"dragstart",vn);function nn(e){if(s.onDragEvent&&s.onDragEvent(on,k(e)))return;O(e)}P(K,"dragenter",nn),P(K,"dragover",nn),P(K,"drop",pi(dn))}P(K,"paste",function(){Jn(),Wn()}),P(X,"paste",Wn),P(X,"cut",pi(function(){s.readOnly||Fn("")})),V&&P(G,"mouseup",function(){document.activeElement==X&&X.blur(),Jn()});var rn;try{rn=document.activeElement==X}catch(Et){}rn||s.autofocus?setTimeout(Tn,20):Nn();var on=C.CodeMirror={getValue:ln,setValue:pi(fn),getSelection:Rn,replaceSelection:pi(Fn),focus:function(){window.focus(),Jn(),Tn(),Wn()},setOption:function(e,t){var n=s[e];s[e]=t,e=="mode"||e=="indentUnit"?Sr():e=="readOnly"&&t=="nocursor"?(Nn(),X.blur()):e=="readOnly"&&!t?$n(!0):e=="theme"?Cr():e=="lineWrapping"&&n!=t?pi(Tr)():e=="tabSize"?tr(!0):e=="keyMap"&&kr();if(e=="lineNumbers"||e=="gutter"||e=="firstLineNumber"||e=="theme")xr(),tr(!0)},getOption:function(e){return s[e]},undo:pi(On),redo:pi(Mn),indentLine:pi(function(e,t){typeof t!="string"&&(t==null?t=s.smartIndent?"smart":"prev":t=t?"add":"subtract"),sn(e)&&Er(e,t)}),indentSelection:pi(wr),historySize:function(){return{undo:tn.done.length,redo:tn.undone.length}},clearHistory:function(){tn=new N},setHistory:function(e){tn=new N,tn.done=e.done,tn.undone=e.undone},getHistory:function(){return tn.time=0,{done:tn.done.concat([]),undone:tn.undone.concat([])}},matchBrackets:pi(function(){ii(!0)}),getTokenAt:pi(function(e){return e=hr(e),un(e.line).getTokenAt(Nt,oi(e.line),e.ch)}),getStateAfter:function(e){return e=cr(e==null?Ct.size-1:e),oi(e+1)},cursorCoords:function(e,t){return e==null&&(e=At.inverted),this.charCoords(e?At.from:At.to,t)},charCoords:function(e,t){return e=hr(e),t=="local"?Ur(e,!1):t=="div"?Ur(e,!0):Wr(e)},coordsChar:function(e){var t=Z(pt);return zr(e.x-t.left,e.y-t.top)},markText:pi(Ar),setBookmark:Or,findMarksAt:Mr,setMarker:pi(_r),clearMarker:pi(Dr),setLineClass:pi(Hr),hideLine:pi(function(e){return Br(e,!0)}),showLine:pi(function(e){return Br(e,!1)}),onDeleteLine:function(e,t){if(typeof e=="number"){if(!sn(e))return null;e=un(e)}return(e.handlers||(e.handlers=[])).push(t),e},lineInfo:jr,addWidget:function(e,t,n,r,i){e=Ur(hr(e));var s=e.yBot,o=e.x;t.style.position="absolute",G.appendChild(t);if(r=="over")s=e.y;else if(r=="near"){var u=Math.max(K.offsetHeight,Ct.height*Jr()),a=Math.max(G.clientWidth,pt.clientWidth)-Zr();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+Yr()+"px",t.style.left=t.style.right="",i=="right"?(o=G.clientWidth-t.offsetWidth,t.style.right="0px"):(i=="left"?o=0:i=="middle"&&(o=(G.clientWidth-t.offsetWidth)/2),t.style.left=o+Zr()+"px"),n&&Yn(o,s,o+t.offsetWidth,s+t.offsetHeight)},lineCount:function(){return Ct.size},clipPos:hr,getCursor:function(e){return e==null&&(e=At.inverted),it(e?At.from:At.to)},somethingSelected:function(){return!nt(At.from,At.to)},setCursor:pi(function(e,t,n){t==null&&typeof e.line=="number"?lr(e.line,e.ch,n):lr(e,t,n)}),setSelection:pi(function(e,t,n){(n?ur:ar)(hr(e),hr(t||e))}),getLine:function(e){if(sn(e))return un(e).text},getLineHandle:function(e){if(sn(e))return un(e)},setLine:pi(function(e,t){sn(e)&&jn(t,{line:e,ch:0},{line:e,ch:un(e).text.length})}),removeLine:pi(function(e){sn(e)&&jn("",{line:e,ch:0},hr({line:e+1,ch:0}))}),replaceRange:pi(jn),getRange:function(e,t,n){return qn(hr(e),hr(t),n)},triggerOnKeyDown:pi(En),execCommand:function(e){return u[e](on)},moveH:pi(dr),deleteH:pi(vr),moveV:pi(gr),toggleOverwrite:function(){Bt?(Bt=!1,vt.className=vt.className.replace(" CodeMirror-overwrite","")):(Bt=!0,vt.className+=" CodeMirror-overwrite")},posFromIndex:function(e){var t=0,n;return Ct.iter(0,Ct.size,function(r){var i=r.text.length+1;if(i>e)return n=e,!0;e-=i,++t}),hr({line:t,ch:n})},indexFromPos:function(e){if(e.line<0||e.ch<0)return 0;var t=e.ch;return Ct.iter(0,e.line,function(e){t+=e.text.length+1}),t},scrollTo:function(e,t){e!=null&&(K.scrollLeft=e),t!=null&&(bt.scrollTop=t),tr([])},getScrollInfo:function(){return{x:K.scrollLeft,y:bt.scrollTop,height:bt.scrollHeight,width:K.scrollWidth}},setSize:function(e,t){function n(e){return e=String(e),/^\d+$/.test(e)?e+"px":e}e!=null&&(C.style.width=n(e)),t!=null&&(K.style.height=n(t))},operation:function(e){return pi(e)()},compoundChange:function(e){return di(e)},refresh:function(){tr(!0,null,Dt),bt.scrollHeight>Dt&&(bt.scrollTop=Dt)},getInputField:function(){return X},getWrapperElement:function(){return C},getScrollerElement:function(){return K},getGutterElement:function(){return st}},bn=null,wn,Un=!1,Xn="",mr=null;Lr.prototype.clear=pi(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=S(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&&qt.push({from:e,to:t+1})}),Lr.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=S(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 qr="CodeMirror-temp-"+Math.floor(Math.random()*16777215).toString(16),Xr,Vr,$r,Kr,Qr=0,ri={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},hi=0;for(var vi in o)o.propertyIsEnumerable(vi)&&!on.propertyIsEnumerable(vi)&&(on[vi]=o[vi]);return on}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!=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=ht[D(e,"keyCode")];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function h(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 p(e,t,n){return e.startState?e.startState(t,n):!0}function d(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8}function v(e,t,n,r){this.from=e,this.to=t,this.style=n,this.marker=r}function m(e){this.from=e,this.to=e,this.line=null}function g(e,t){this.styles=t||[e,null],this.text=e,this.height=1,this.marked=this.gutterMarker=this.className=this.bgClassName=this.handlers=null,this.stateAfter=this.parent=this.hidden=null}function y(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 b(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 w(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 E(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 S(e){if(e.parent==null)return null;var t=e.parent,n=at(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 x(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 T(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 N(){this.time=0,this.done=[],this.undone=[],this.compound=0,this.closed=!1}function C(){O(this)}function k(e){return e.stop||(e.stop=C),e}function L(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function A(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function O(e){L(e),A(e)}function M(e){return e.target||e.srcElement}function _(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 D(e,t){var n=e.override&&e.override.hasOwnProperty(t);return n?e.override[t]:e[t]}function P(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 H(){this.id=null}function G(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 Y(e){return e.currentStyle?e.currentStyle:window.getComputedStyle(e,null)}function Z(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 et(e){return e.textContent||e.innerText||e.nodeValue||""}function tt(e){t?(e.selectionStart=0,e.selectionEnd=e.value.length):e.select()}function nt(e,t){return e.line==t.line&&e.ch==t.ch}function rt(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function it(e){return{line:e.line,ch:e.ch}}function ot(e){return st.textContent=e,st.innerHTML}function ut(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 at(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 ft(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=!nt(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=u.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=P(t.form,"submit",r,!0);if(typeof t.form.submit=="function"){var s=t.form.submit;function o(){r(),t.form.submit=s,t.form.submit(),t.form.submit=o}t.form.submit=o}}t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},n);return u.save=r,u.getTextArea=function(){return t},u.toTextArea=function(){r(),t.parentNode.removeChild(u.getWrapperElement()),t.style.display="",t.form&&(i(),typeof t.form.submit=="function"&&(t.form.submit=s))},u},e.copyState=h,e.startState=p,d.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 G(this.string,this.start,this.tabSize)},indentation:function(){return G(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}function r(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=d,v.prototype={attach:function(e){this.marker.set.push(e)},detach:function(e){var t=at(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 v(n,r,this.style,this.marker)},dup:function(){return new v(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}},m.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:S(this.line),ch:this.from}},clear:function(){if(this.line){var e=at(this.line.marked,this);e!=-1&&this.line.marked.splice(e,1),this.line=null}}},g.inheritMarks=function(e,t){var n=new g(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},g.prototype={replace:function(e,t,n){var r=[],i=this.marked,s=t==null?this.text.length:t;y(0,e,this.styles,r),n&&r.push(n,null),y(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;y(e,this.text.length,this.styles,n);var i=new g(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,y(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 d(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 d(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 G(this.text,null,e)},getHTML:function(e,t,n,r){function u(t,n){if(!t)return;s&&F&&t.charAt(0)==" "&&(t="\u00a0"+t.slice(1)),s=!1;if(t.indexOf("	")==-1){o+=t.length;var r=ot(t)}else{var r="";for(var u=0;;){var a=t.indexOf("	",u);if(a==-1){r+=ot(t.slice(u)),o+=t.length-u;break}o+=a-u;var f=e(o);r+=ot(t.slice(u,a))+f.html,o+=f.width,u=a+1}}n?i.push('<span class="',n,'">',r,"</span>"):i.push(r)}function v(e){return e?"cm-"+e.replace(/ +/g," cm-"):null}var i=[],s=!0,o=0,a=u;if(t!=null){var f=0,l='<span id="'+n+'">';a=function(e,n){var s=e.length;if(t>=f&&t<f+s){t>f&&(u(e.slice(0,t-f),n),r&&i.push("<wbr>")),i.push(l);var o=t-f;u(W?e.slice(o,o+1):e.slice(o),n),i.push("</span>"),W&&u(e.slice(o+1),n),t--,f+=s}else f+=s,u(e,n),f==t&&f==d?i.push(l+(j?"&#x200b;":" ")+"</span>"):f>t+10&&/\s/.test(e)&&(a=function(){})}}var c=this.styles,h=this.text,p=this.marked,d=h.length;if(!h&&t==null)a(" ");else if(!p||!p.length)for(var m=0,g=0;g<d;m+=2){var y=c[m],b=c[m+1],w=y.length;g+w>d&&(y=y.slice(0,d-g)),g+=w,a(y,v(b))}else{var E=0,m=0,S="",b,x=0,T=p[0].from||0,N=[],C=0;function k(){var e;while(C<p.length&&((e=p[C]).from==E||e.from==null))e.style!=null&&N.push(e),++C;T=C<p.length?p[C].from:Infinity;for(var t=0;t<N.length;++t){var n=N[t].to;n==null&&(n=Infinity),n==E?N.splice(t--,1):T=Math.min(n,T)}}var L=0;while(E<d){T==E&&k();var A=Math.min(d,T);for(;;){if(S){var O=E+S.length,M=b;for(var _=0;_<N.length;++_)M=(M?M+" ":"")+N[_].style;a(O>A?S.slice(0,A-E):S,M);if(O>=A){S=S.slice(A-E),E=A;break}E=O}S=c[m++],b=v(c[m++])}}}return i.join("")},cleanUp:function(){this.parent=null;if(this.marked)for(var e=0,t=this.marked.length;e<t;++e)this.marked[e].detach(this)}},b.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}},w.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 b(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 b(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 w(t);if(!e.parent){var r=new w(e.children);r.parent=e,e.children=[r,n],e=r}else{e.size-=n.size,e.height-=n.height;var i=at(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}}},N.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=O,e.e_preventDefault=L,e.e_stopPropagation=A,e.connect=P,H.prototype={set:function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)}};var B=e.Pass={toString:function(){return"CodeMirror.Pass"}},j=/gecko\/\d{7}/i.test(navigator.userAgent),F=/MSIE \d/.test(navigator.userAgent),I=/MSIE [1-7]\b/.test(navigator.userAgent),q=/MSIE [1-8]\b/.test(navigator.userAgent),R=F&&document.documentMode==5,U=/WebKit\//.test(navigator.userAgent),z=/Chrome\//.test(navigator.userAgent),W=/Opera\//.test(navigator.userAgent),X=/Apple Computer/.test(navigator.vendor),V=/KHTML\//.test(navigator.userAgent),$=/Mac OS X 10\D([7-9]|\d\d)\D/.test(navigator.userAgent),J=function(){if(q)return!1;var e=document.createElement("div");return"draggable"in e||"dragDrop"in e}(),K=function(){var e=document.createElement("textarea");return e.value="foo\nbar",e.value.indexOf("\r")>-1?"\r\n":"\n"}(),Q=/^$/;j?Q=/$'/:X?Q=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/:z&&(Q=/\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/);var st=document.createElement("pre");ot("a")=="\na"?ot=function(e){return st.textContent=e,st.innerHTML.slice(1)}:ot("	")!="	"&&(ot=function(e){return st.innerHTML="",st.appendChild(document.createTextNode(e)),st.innerHTML}),e.htmlEscape=ot;var lt="\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=lt;var ct=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 ht={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=ht,function(){for(var e=0;e<10;e++)ht[e+48]=String(e);for(var e=65;e<=90;e++)ht[e]=String.fromCharCode(e);for(var e=1;e<=12;e++)ht[e+111]=ht[e+63235]="F"+e}(),e}();CodeMirror.defineMode("coffeescript",function(e){function n(e){return new RegExp("^(("+e.join(")|(")+"))\\b")}function y(e,n){if(e.sol()){var c=n.scopes[0].offset;if(e.eatSpace()){var h=e.indentation();return h>c?"indent":h<c?"dedent":null}c>0&&S(e,n)}if(e.eatSpace())return null;var m=e.peek();if(e.match("####"))return e.skipToEnd(),"comment";if(e.match("###"))return n.tokenize=w,n.tokenize(e,n);if(m==="#")return e.skipToEnd(),"comment";if(e.match(/^-?[0-9\.]/,!1)){var y=!1;e.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)&&(y=!0),e.match(/^-?\d+\.\d*/)&&(y=!0),e.match(/^-?\.\d+/)&&(y=!0);if(y)return e.peek()=="."&&e.backUp(1),"number";var E=!1;e.match(/^-?0x[0-9a-f]+/i)&&(E=!0),e.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)&&(E=!0),e.match(/^-?0(?![\dx])/i)&&(E=!0);if(E)return"number"}if(e.match(d))return n.tokenize=b(e.current(),"string"),n.tokenize(e,n);if(e.match(v)){if(e.current()!="/"||e.match(/^.*\//,!1))return n.tokenize=b(e.current(),"string-2"),n.tokenize(e,n);e.backUp(1)}return e.match(u)||e.match(o)?"punctuation":e.match(s)||e.match(r)||e.match(l)?"operator":e.match(i)?"punctuation":e.match(g)?"atom":e.match(p)?"keyword":e.match(a)?"variable":e.match(f)?"property":(e.next(),t)}function b(n,r){var i=n.length==1;return function(o,u){while(!o.eol()){o.eatWhile(/[^'"\/\\]/);if(o.eat("\\")){o.next();if(i&&o.eol())return r}else{if(o.match(n))return u.tokenize=y,r;o.eat(/['"\/]/)}}return i&&(e.mode.singleLineStringErrors?r=t:u.tokenize=y),r}}function w(e,t){while(!e.eol()){e.eatWhile(/[^#]/);if(e.match("###")){t.tokenize=y;break}e.eatWhile("#")}return"comment"}function E(t,n,r){r=r||"coffee";var i=0;if(r==="coffee"){for(var s=0;s<n.scopes.length;s++)if(n.scopes[s].type==="coffee"){i=n.scopes[s].offset+e.indentUnit;break}}else i=t.column()+t.current().length;n.scopes.unshift({offset:i,type:r})}function S(e,t){if(t.scopes.length==1)return;if(t.scopes[0].type==="coffee"){var n=e.indentation(),r=-1;for(var i=0;i<t.scopes.length;++i)if(n===t.scopes[i].offset){r=i;break}if(r===-1)return!0;while(t.scopes[0].offset!==n)t.scopes.shift();return!1}return t.scopes.shift(),!1}function x(e,n){var r=n.tokenize(e,n),i=e.current();if(i===".")return r=n.tokenize(e,n),i=e.current(),r==="variable"?"variable":t;i==="return"&&(n.dedent+=1),((i==="->"||i==="=>")&&!n.lambda&&n.scopes[0].type=="coffee"&&e.peek()===""||r==="indent")&&E(e,n);var s="[({".indexOf(i);return s!==-1&&E(e,n,"])}".slice(s,s+1)),c.exec(i)&&E(e,n),i=="then"&&S(e,n),r==="dedent"&&S(e,n)?t:(s="])}".indexOf(i),s!==-1&&S(e,n)?t:(n.dedent>0&&e.eol()&&n.scopes[0].type=="coffee"&&(n.scopes.length>1&&n.scopes.shift(),n.dedent-=1),r))}var t="error",r=new RegExp("^[\\+\\-\\*/%&|\\^~<>!?]"),i=new RegExp("^[\\(\\)\\[\\]\\{\\},:`=;\\.]"),s=new RegExp("^((->)|(=>)|(\\+\\+)|(\\+\\=)|(\\-\\-)|(\\-\\=)|(\\*\\*)|(\\*\\=)|(\\/\\/)|(\\/\\=)|(==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//))"),o=new RegExp("^((\\.\\.)|(\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"),u=new RegExp("^((\\.\\.\\.)|(//=)|(>>=)|(<<=)|(\\*\\*=))"),a=new RegExp("^[_A-Za-z$][_A-Za-z$0-9]*"),f=new RegExp("^(@|this.)[_A-Za-z$][_A-Za-z$0-9]*"),l=n(["and","or","not","is","isnt","in","instanceof","typeof"]),c=["for","while","loop","if","unless","else","switch","try","catch","finally","class"],h=["break","by","continue","debugger","delete","do","in","of","new","return","then","this","throw","when","until"],p=n(c.concat(h));c=n(c);var d=new RegExp("^('{3}|\"{3}|['\"])"),v=new RegExp("^(/{3}|/)"),m=["Infinity","NaN","undefined","null","true","false","on","off","yes","no"],g=n(m),T={startState:function(e){return{tokenize:y,scopes:[{offset:e||0,type:"coffee"}],lastToken:null,lambda:!1,dedent:0}},token:function(e,t){var n=x(e,t);return t.lastToken={style:n,content:e.current()},e.eol()&&e.lambda&&(t.lambda=!1),n},indent:function(e,t){return e.tokenize!=y?0:e.scopes[0].offset}};return T}),CodeMirror.defineMIME("text/x-coffeescript","coffeescript")

File scripts/view.coffee

 
     setTimeout(resize, 250)
 
-load_lib = (editor) ->
-    libs = [
-        "/lib/processing.min.js",
-        "/lib/coffee-script.min.js"
-    ]
-    if editor
-        libs.push("/lib/codemirror.min.js")
-    ender.script(libs)
-
 ###
 hides all panels but the specified one
 ###
 
     
 view_editor = ->
-    load_lib(true)
-
     script = cur_script()
     console.log "edit script try ", script
     if not script
         #timeout until lib is ready
         return setTimeout(view_editor, 20)
 
-    console.log "edit script success ", script
+    #console.log "edit script success ", script
     btn = if pcs.username and pcs.username == script.creator
         ['run', 'undo', 'redo', 'save', 'rename', 'copy', 'new']
     else if pcs.username
-        ['run', 'undo', 'redo', 'save', 'copy', 'new']
+        ['run', 'undo', 'redo', 'save', 'new']
     else
         (['run', 'undo', 'redo'])
 
     editor_load()
 
 view_script = ->
-    load_lib()
-
     script = cur_script()
     if not script
         return load_script(cur_path(), view_script)

File static/index.html

 <link rel="search" type="application/opensearch+xml" href="/static/opensearch.xml"/>
 -->
 
+<script async="true" src="/lib/processing.min.js"></script>
+<script async="true" src="/lib/coffee-script.min.js"></script>
+<script async="true" src="/lib/codemirror.min.js"></script>
 <script src="/lib/ender.min.js"></script>
 <script src="/lib/pcs.js"></script>