(function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)})(function(n){function r(n,t){return t=="pairs"&&typeof n=="string"?n:typeof n=="object"&&n[t]!=null?n[t]:o[t]}function h(n){return function(t){return a(t,n)}}function e(n){var t=n.state.closeBrackets,i;return t?(i=n.getModeAt(n.getCursor()),i.closeBrackets||t):null}function c(i){var c=e(i),l,f,h,u,o;if(!c||i.getOption("disableInput"))return n.Pass;for(l=r(c,"pairs"),f=i.listSelections(),u=0;u<f.length;u++)if(!f[u].empty()||(h=s(i,f[u].head),!h||l.indexOf(h)%2!=0))return n.Pass;for(u=f.length-1;u>=0;u--)o=f[u].head,i.replaceRange("",t(o.line,o.ch-1),t(o.line,o.ch+1))}function l(t){var o=e(t),h=o&&r(o,"explode"),i,u,f;if(!h||t.getOption("disableInput"))return n.Pass;for(i=t.listSelections(),u=0;u<i.length;u++)if(!i[u].empty()||(f=s(t,i[u].head),!f||h.indexOf(f)%2!=0))return n.Pass;t.operation(function(){var n,r;for(t.replaceSelection("\n\n",null),t.execCommand("goCharLeft"),i=t.listSelections(),n=0;n<i.length;n++)r=i[n].head.line,t.indentLine(r,null,!0),t.indentLine(r+1,null,!0)})}function a(i,u){var b=e(i),l,o,p,h,w;if(!b||i.getOption("disableInput")||(l=r(b,"pairs"),o=l.indexOf(u),o==-1))return n.Pass;var g=r(b,"triples"),k=l.charAt(o+1)==u,nt=i.listSelections(),d=o%2==0,s,a;for(p=0;p<nt.length;p++){var tt=nt[p],f=tt.head,c,a=i.getRange(f,t(f.line,f.ch+1));if(d&&!tt.empty())c="surround";else if((k||!d)&&a==u)c=g.indexOf(u)>=0&&i.getRange(f,t(f.line,f.ch+3))==u+u+u?"skipThree":"skip";else if(k&&f.ch>1&&g.indexOf(u)>=0&&i.getRange(t(f.line,f.ch-2),f)==u+u&&(f.ch<=2||i.getRange(t(f.line,f.ch-3),t(f.line,f.ch-2))!=u))c="addFour";else if(k)if(!n.isWordChar(a)&&y(i,f,u))c="both";else return n.Pass;else if(d&&(i.getLine(f.line).length==f.ch||v(a,l)||/\s/.test(a)))c="both";else return n.Pass;if(s){if(s!=c)return n.Pass}else s=c}h=o%2?l.charAt(o-1):u;w=o%2?u:l.charAt(o+1);i.operation(function(){var t,n;if(s=="skip")i.execCommand("goCharRight");else if(s=="skipThree")for(n=0;n<3;n++)i.execCommand("goCharRight");else if(s=="surround"){for(t=i.getSelections(),n=0;n<t.length;n++)t[n]=h+t[n]+w;i.replaceSelections(t,"around")}else s=="both"?(i.replaceSelection(h+w,null),i.triggerElectric(h+w),i.execCommand("goCharLeft")):s=="addFour"&&(i.replaceSelection(h+h+h+h,"before"),i.execCommand("goCharRight"))})}function v(n,t){var i=t.lastIndexOf(n);return i>-1&&i%2==1}function s(n,i){var r=n.getRange(t(i.line,i.ch-1),t(i.line,i.ch+1));return r.length==2?r:null}function y(t,i,r){var e=t.getLine(i.line),f=t.getTokenAt(i),u,o;if(/\bstring2?\b/.test(f.type))return!1;for(u=new n.StringStream(e.slice(0,i.ch)+r+e.slice(i.ch),4),u.pos=u.start=f.start;;){if(o=t.getMode().token(u,f.state),u.pos>=i.ch+1)return/\bstring2?\b/.test(o);u.start=u.pos}}var o={pairs:"()[]{}''\"\"",triples:"",explode:"[]{}"},t=n.Pos,u,f,i;for(n.defineOption("autoCloseBrackets",!1,function(t,i,r){r&&r!=n.Init&&(t.removeKeyMap(f),t.state.closeBrackets=null);i&&(t.state.closeBrackets=i,t.addKeyMap(f))}),u=o.pairs+"`",f={Backspace:c,Enter:l},i=0;i<u.length;i++)f["'"+u.charAt(i)+"'"]=h(u.charAt(i))}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror"),require("../fold/xml-fold")):typeof define=="function"&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],n):n(CodeMirror)}(function(n){function e(t){var h,p,b,y,e,l,k;if(t.getOption("disableInput"))return n.Pass;for(h=t.listSelections(),p=[],e=0;e<h.length;e++){if(!h[e].empty())return n.Pass;var s=h[e].head,o=t.getTokenAt(s),w=n.innerMode(t.getMode(),o.state),a=w.state;if(w.mode.name!="xml"||!a.tagName)return n.Pass;var v=t.getOption("autoCloseTags"),d=w.mode.configuration=="html",g=typeof v=="object"&&v.dontCloseTags||d&&u,nt=typeof v=="object"&&v.indentTags||d&&f,c=a.tagName;if(o.end>s.ch&&(c=c.slice(0,c.length-o.end+s.ch)),b=c.toLowerCase(),!c||o.type=="string"&&(o.end!=s.ch||!/[\"\']/.test(o.string.charAt(o.string.length-1))||o.string.length==1)||o.type=="tag"&&a.type=="closeTag"||o.string.indexOf("/")==o.string.length-1||g&&i(g,b)>-1||r(t,c,s,a,!0))return n.Pass;y=nt&&i(nt,b)>-1;p[e]={indent:y,text:">"+(y?"\n\n":"")+"<\/"+c+">",newPos:y?n.Pos(s.line+1,0):n.Pos(s.line,s.ch+1)}}for(e=h.length-1;e>=0;e--)l=p[e],t.replaceRange(l.text,h[e].head,h[e].anchor,"+insert"),k=t.listSelections().slice(0),k[e]={head:l.newPos,anchor:l.newPos},t.setSelections(k),l.indent&&(t.indentLine(l.newPos.line,null,!0),t.indentLine(l.newPos.line+1,null,!0))}function t(t,i){for(var f=t.listSelections(),o=[],c=i?"/":"<\/",u=0;u<f.length;u++){if(!f[u].empty())return n.Pass;var l=f[u].head,s=t.getTokenAt(l),h=n.innerMode(t.getMode(),s.state),e=h.state;if(i&&(s.type=="string"||s.string.charAt(0)!="<"||s.start!=l.ch-1))return n.Pass;if(h.mode.name!="xml")if(t.getMode().name=="htmlmixed"&&h.mode.name=="javascript")o[u]=c+"script>";else if(t.getMode().name=="htmlmixed"&&h.mode.name=="css")o[u]=c+"style>";else return n.Pass;else{if(!e.context||!e.context.tagName||r(t,e.context.tagName,l,e))return n.Pass;o[u]=c+e.context.tagName+">"}}for(t.replaceSelections(o),f=t.listSelections(),u=0;u<f.length;u++)(u==f.length-1||f[u].head.line<f[u+1].head.line)&&t.indentLine(f[u].head.line)}function o(i){return i.getOption("disableInput")?n.Pass:t(i,!0)}function i(n,t){if(n.indexOf)return n.indexOf(t);for(var i=0,r=n.length;i<r;++i)if(n[i]==t)return i;return-1}function r(t,i,r,u,f){var h,o,e,c,l,s;if(!n.scanForClosingTag||(h=Math.min(t.lastLine()+1,r.line+500),o=n.scanForClosingTag(t,r,null,h),!o||o.tag!=i))return!1;for(e=u.context,c=f?1:0;e&&e.tagName==i;e=e.prev)++c;for(r=o.to,l=1;l<c;l++){if(s=n.scanForClosingTag(t,r,null,h),!s||s.tag!=i)return!1;r=s.to}return!0}n.defineOption("autoCloseTags",!1,function(t,i,r){if(r!=n.Init&&r&&t.removeKeyMap("autoCloseTags"),i){var u={name:"autoCloseTags"};(typeof i!="object"||i.whenClosing)&&(u["'/'"]=function(n){return o(n)});(typeof i!="object"||i.whenOpening)&&(u["'>'"]=function(n){return e(n)});t.addKeyMap(u)}});var u=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],f=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];n.commands.closeTag=function(n){return t(n)}}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){function r(t){var o,i,v,h,s,f,y,r,l,c,p,a,e;if(t.getOption("disableInput"))return n.Pass;for(o=t.listSelections(),v=[],h=0;h<o.length;h++){if(s=o[h].head,f=t.getTokenAt(s),f.type!="comment")return n.Pass;if(y=n.innerMode(t.getMode(),f.state).mode,i){if(i!=y)return n.Pass}else i=y;if(r=null,i.blockCommentStart&&i.blockCommentContinue){if(l=f.string.indexOf(i.blockCommentEnd),c=t.getRange(n.Pos(s.line,0),n.Pos(s.line,f.end)),l==-1||l!=f.string.length-i.blockCommentEnd.length||!(s.ch>=l))if(f.string.indexOf(i.blockCommentStart)==0){if(r=c.slice(0,f.start),!/^\s*$/.test(r))for(r="",p=0;p<f.start;++p)r+=" "}else(e=c.indexOf(i.blockCommentContinue))!=-1&&e+i.blockCommentContinue.length>f.start&&/^\s*$/.test(c.slice(0,e))&&(r=c.slice(0,e));r!=null&&(r+=i.blockCommentContinue)}if(r==null&&i.lineComment&&u(t)&&(a=t.getLine(s.line),e=a.indexOf(i.lineComment),e>-1&&(r=a.slice(0,e),/\S/.test(r)?r=null:r+=i.lineComment+a.slice(e+i.lineComment.length).match(/^\s*/)[0])),r==null)return n.Pass;v[h]="\n"+r}t.operation(function(){for(var n=o.length-1;n>=0;n--)t.replaceRange(v[n],o[n].from(),o[n].to(),"+insert")})}function u(n){var t=n.getOption("continueComments");return t&&typeof t=="object"?t.continueLineComment!==!1:!0}for(var i=["clike","css","javascript"],t=0;t<i.length;++t)n.extendMode(i[t],{blockCommentContinue:" * "});n.defineOption("continueComments",null,function(t,i,u){var f,e;u&&u!=n.Init&&t.removeKeyMap("continueComment");i&&(f="Enter",typeof i=="string"?f=i:typeof i=="object"&&i.key&&(f=i.key),e={name:"continueComment"},e[f]=r,t.addKeyMap(e))})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){function u(n,i,u,e){var l=n.getLineHandle(i.line),o=i.ch-1,c=o>=0&&r[l.text.charAt(o)]||r[l.text.charAt(++o)],h,a,s;return c?(h=c.charAt(1)==">"?1:-1,u&&h>0!=(o==i.ch))?null:(a=n.getTokenTypeAt(t(i.line,o+1)),s=f(n,t(i.line,o+(h>0?1:0)),h,a||null,e),s==null)?null:{from:t(i.line,o),to:s&&s.pos,match:s&&s.ch==c.charAt(0),forward:h>0}:null}function f(n,i,u,f,e){for(var h,s,v,c,y,p=e&&e.maxScanLineLength||1e4,a=e&&e.maxScanLines||1e3,l=[],w=e&&e.bracketRegex?e.bracketRegex:/[(){}[\]]/,b=u>0?Math.min(i.line+a,n.lastLine()+1):Math.max(n.firstLine()-1,i.line-a),o=i.line;o!=b;o+=u)if((h=n.getLine(o),h)&&(s=u>0?0:h.length-1,v=u>0?h.length:-1,!(h.length>p)))for(o==i.line&&(s=i.ch-(u<0?1:0));s!=v;s+=u)if(c=h.charAt(s),w.test(c)&&(f===undefined||n.getTokenTypeAt(t(o,s+1))==f))if(y=r[c],y.charAt(1)==">"==u>0)l.push(c);else if(l.length)l.pop();else return{pos:t(o,s),ch:c};return o-u==(u>0?n.lastLine():n.firstLine())?!1:null}function e(n,i,r){for(var f,c,l,a=n.state.matchBrackets.maxHighlightLineLength||1e3,e=[],h=n.listSelections(),o=0;o<h.length;o++)f=h[o].empty()&&u(n,h[o].head,!1,r),f&&n.getLine(f.from.line).length<=a&&(c=f.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket",e.push(n.markText(f.from,t(f.from.line,f.from.ch+1),{className:c})),f.to&&n.getLine(f.to.line).length<=a&&e.push(n.markText(f.to,t(f.to.line,f.to.ch+1),{className:c})));if(e.length)if(s&&n.state.focused&&n.focus(),l=function(){n.operation(function(){for(var n=0;n<e.length;n++)e[n].clear()})},i)setTimeout(l,800);else return l}function o(n){n.operation(function(){i&&(i(),i=null);i=e(n,!1,n.state.matchBrackets)})}var s=/MSIE \d/.test(navigator.userAgent)&&(document.documentMode==null||document.documentMode<8),t=n.Pos,r={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},i=null;n.defineOption("matchBrackets",!1,function(t,i,r){if(r&&r!=n.Init&&t.off("cursorActivity",o),i){t.state.matchBrackets=typeof i=="object"?i:{};t.on("cursorActivity",o)}});n.defineExtension("matchBrackets",function(){e(this,!0)});n.defineExtension("findMatchingBracket",function(n,t,i){return u(this,n,t,i)});n.defineExtension("scanForBracket",function(n,t,i,r){return f(this,n,t,i,r)})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror"),require("../fold/xml-fold")):typeof define=="function"&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],n):n(CodeMirror)}(function(n){"use strict";function i(n){n.state.tagHit&&n.state.tagHit.clear();n.state.tagOther&&n.state.tagOther.clear();n.state.tagHit=n.state.tagOther=null}function t(t){t.state.failedTagMatch=!1;t.operation(function(){var f,u,r,e,o;(i(t),t.somethingSelected())||(f=t.getCursor(),u=t.getViewport(),u.from=Math.min(u.from,f.line),u.to=Math.max(f.line+1,u.to),r=n.findMatchingTag(t,f,u),r)&&(t.state.matchBothTags&&(e=r.at=="open"?r.open:r.close,e&&(t.state.tagHit=t.markText(e.from,e.to,{className:"CodeMirror-matchingtag"}))),o=r.at=="close"?r.open:r.close,o?t.state.tagOther=t.markText(o.from,o.to,{className:"CodeMirror-matchingtag"}):t.state.failedTagMatch=!0)})}function r(n){n.state.failedTagMatch&&t(n)}n.defineOption("matchTags",!1,function(u,f,e){if(e&&e!=n.Init&&(u.off("cursorActivity",t),u.off("viewportChange",r),i(u)),f){u.state.matchBothTags=typeof f=="object"&&f.bothTags;u.on("cursorActivity",t);u.on("viewportChange",r);t(u)}});n.commands.toMatchingTag=function(t){var i=n.findMatchingTag(t,t.getCursor()),r;i&&(r=i.at=="close"?i.open:i.close,r&&t.extendSelection(r.to,r.from))}}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){n.defineOption("showTrailingSpace",!1,function(t,i,r){r==n.Init&&(r=!1);r&&!i?t.removeOverlay("trailingspace"):!r&&i&&t.addOverlay({token:function(n){for(var i=n.string.length,t=i;t&&/\s/.test(n.string.charAt(t-1));--t);return t>n.pos?(n.pos=t,null):(n.pos=i,"trailingspace")},name:"trailingspace"})})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";function i(i,u,f,e){function a(n){var t=s(i,u),f,r;if(!t||t.to.line-t.from.line<l)return null;for(f=i.findMarksAt(t.from),r=0;r<f.length;++r)if(f[r].__isFold&&e!=="fold"){if(!n)return null;t.cleared=!0;f[r].clear()}return t}var s,l,o,h,c;if(f&&f.call?(s=f,f=null):s=t(i,f,"rangeFinder"),typeof u=="number"&&(u=n.Pos(u,0)),l=t(i,f,"minFoldSize"),o=a(!0),t(i,f,"scanUp"))while(!o&&u.line>i.firstLine())u=n.Pos(u.line-1,0),o=a(!1);if(o&&!o.cleared&&e!=="unfold"){h=r(i,f);n.on(h,"mousedown",function(t){c.clear();n.e_preventDefault(t)});c=i.markText(o.from,o.to,{replacedWith:h,clearOnEnter:!0,__isFold:!0});c.on("clear",function(t,r){n.signal(i,"unfold",i,t,r)});n.signal(i,"fold",i,o.from,o.to)}}function r(n,i){var r=t(n,i,"widget"),u;return typeof r=="string"&&(u=document.createTextNode(r),r=document.createElement("span"),r.appendChild(u),r.className="CodeMirror-foldmarker"),r}function t(n,t,i){if(t&&t[i]!==undefined)return t[i];var r=n.options.foldOptions;return r&&r[i]!==undefined?r[i]:u[i]}n.newFoldFunction=function(n,t){return function(r,u){i(r,u,{rangeFinder:n,widget:t})}};n.defineExtension("foldCode",function(n,t,r){i(this,n,t,r)});n.defineExtension("isFolded",function(n){for(var i=this.findMarksAt(n),t=0;t<i.length;++t)if(i[t].__isFold)return!0});n.commands.toggleFold=function(n){n.foldCode(n.getCursor())};n.commands.fold=function(n){n.foldCode(n.getCursor(),null,"fold")};n.commands.unfold=function(n){n.foldCode(n.getCursor(),null,"unfold")};n.commands.foldAll=function(t){t.operation(function(){for(var i=t.firstLine(),r=t.lastLine();i<=r;i++)t.foldCode(n.Pos(i,0),null,"fold")})};n.commands.unfoldAll=function(t){t.operation(function(){for(var i=t.firstLine(),r=t.lastLine();i<=r;i++)t.foldCode(n.Pos(i,0),null,"unfold")})};n.registerHelper("fold","combine",function(){var n=Array.prototype.slice.call(arguments,0);return function(t,i){for(var u,r=0;r<n.length;++r)if(u=n[r](t,i),u)return u}});n.registerHelper("fold","auto",function(n,t){for(var r,u=n.getHelpers(t,"fold"),i=0;i<u.length;i++)if(r=u[i](n,t),r)return r});var u={rangeFinder:n.fold.auto,widget:"↔",minFoldSize:0,scanUp:!1};n.defineOption("foldOptions",null);n.defineExtension("foldOption",function(n,i){return t(this,n,i)})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror"),require("./foldcode")):typeof define=="function"&&define.amd?define(["../../lib/codemirror","./foldcode"],n):n(CodeMirror)}(function(n){"use strict";function c(n){this.options=n;this.from=this.to=0}function l(n){return n===!0&&(n={}),n.gutter==null&&(n.gutter="CodeMirror-foldgutter"),n.indicatorOpen==null&&(n.indicatorOpen="CodeMirror-foldgutter-open"),n.indicatorFolded==null&&(n.indicatorFolded="CodeMirror-foldgutter-folded"),n}function f(n,t){for(var r=n.findMarksAt(u(t)),i=0;i<r.length;++i)if(r[i].__isFold&&r[i].find().from.line==t)return r[i]}function e(n){if(typeof n=="string"){var t=document.createElement("div");return t.className=n+" CodeMirror-guttermarker-subtle",t}return n.cloneNode(!0)}function i(n,t,i){var r=n.state.foldGutter.options,o=t,h=n.foldOption(r,"minFoldSize"),s=n.foldOption(r,"rangeFinder");n.eachLine(t,i,function(t){var c=null,l,i;f(n,o)?c=e(r.indicatorFolded):(l=u(o,0),i=s&&s(n,l),i&&i.to.line-i.from.line>=h&&(c=e(r.indicatorOpen)));n.setGutterMarker(t,r.gutter,c);++o})}function t(n){var t=n.getViewport(),r=n.state.foldGutter;r&&(n.operation(function(){i(n,t.from,t.to)}),r.from=t.from,r.to=t.to)}function o(n,t,i){var o=n.state.foldGutter,r,e;o&&(r=o.options,i==r.gutter)&&(e=f(n,t),e?e.clear():n.foldCode(u(t,0),r.rangeFinder))}function s(n){var i=n.state.foldGutter,r;i&&(r=i.options,i.from=i.to=0,clearTimeout(i.changeUpdate),i.changeUpdate=setTimeout(function(){t(n)},r.foldOnChangeTimeSpan||600))}function h(n){var r=n.state.foldGutter,u;r&&(u=r.options,clearTimeout(r.changeUpdate),r.changeUpdate=setTimeout(function(){var u=n.getViewport();r.from==r.to||u.from-r.to>20||r.from-u.to>20?t(n):n.operation(function(){u.from<r.from&&(i(n,u.from,r.from),r.from=u.from);u.to>r.to&&(i(n,r.to,u.to),r.to=u.to)})},u.updateViewportTimeSpan||400))}function r(n,t){var u=n.state.foldGutter,r;u&&(r=t.line,r>=u.from&&r<u.to&&i(n,r,r+1))}n.defineOption("foldGutter",!1,function(i,u,f){if(f&&f!=n.Init&&(i.clearGutter(i.state.foldGutter.options.gutter),i.state.foldGutter=null,i.off("gutterClick",o),i.off("change",s),i.off("viewportChange",h),i.off("fold",r),i.off("unfold",r),i.off("swapDoc",t)),u){i.state.foldGutter=new c(l(u));t(i);i.on("gutterClick",o);i.on("change",s);i.on("viewportChange",h);i.on("fold",r);i.on("unfold",r);i.on("swapDoc",t)}});var u=n.Pos}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";n.registerHelper("fold","brace",function(t,i){function p(r){for(var u,e=i.ch,o=0;;){if(u=e<=0?-1:y.lastIndexOf(r,e-1),u==-1){if(o==1)break;o=1;e=y.length;continue}if(o==1&&u<i.ch)break;if(l=t.getTokenTypeAt(n.Pos(f,u+1)),!/^(comment|string)/.test(l))return u+1;e=u-1}}var f=i.line,y=t.getLine(f),l,w="{",b="}",e=p("{"),a,k,h,v,u,o,r,s,c;if(e==null&&(w="[",b="]",e=p("[")),e!=null){a=1;k=t.lastLine();n:for(u=f;u<=k;++u)for(o=t.getLine(u),r=u==f?e:0;;){if(s=o.indexOf(w,r),c=o.indexOf(b,r),s<0&&(s=o.length),c<0&&(c=o.length),r=Math.min(s,c),r==o.length)break;if(t.getTokenTypeAt(n.Pos(u,r+1))==l)if(r==s)++a;else if(!--a){h=u;v=r;break n}++r}if(h!=null&&(f!=h||v!=e))return{from:n.Pos(f,e),to:n.Pos(h,v)}}});n.registerHelper("fold","import",function(t,i){function r(i){var r,u,e,o,f;if(i<t.firstLine()||i>t.lastLine()||(r=t.getTokenAt(n.Pos(i,1)),/\S/.test(r.string)||(r=t.getTokenAt(n.Pos(i,r.end+1))),r.type!="keyword"||r.string!="import"))return null;for(u=i,e=Math.min(t.lastLine(),i+10);u<=e;++u)if(o=t.getLine(u),f=o.indexOf(";"),f!=-1)return{startCh:r.end,end:n.Pos(u,f)}}var i=i.line,f=r(i),o,u,e;if(!f||r(i-1)||(o=r(i-2))&&o.end.line==i-1)return null;for(u=f.end;;){if(e=r(u.line+1),e==null)break;u=e.end}return{from:t.clipPos(n.Pos(i,f.startCh+1)),to:u}});n.registerHelper("fold","include",function(t,i){function u(i){if(i<t.firstLine()||i>t.lastLine())return null;var r=t.getTokenAt(n.Pos(i,1));return/\S/.test(r.string)||(r=t.getTokenAt(n.Pos(i,r.end+1))),r.type=="meta"&&r.string.slice(0,8)=="#include"?r.start+8:void 0}var i=i.line,f=u(i),r,e;if(f==null||u(i-1)!=null)return null;for(r=i;;){if(e=u(r+1),e==null)break;++r}return{from:n.Pos(i,f+1),to:t.clipPos(n.Pos(r))}})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";n.registerGlobalHelper("fold","comment",function(n){return n.blockCommentStart&&n.blockCommentEnd},function(t,i){var k=t.getModeAt(i),c=k.blockCommentStart,d=k.blockCommentEnd,u,p,l,s,a,f,w,g,v,b,e,o,r,h,y;if(c&&d){for(u=i.line,p=t.getLine(u),s=i.ch,a=0;;){if(f=s<=0?-1:p.lastIndexOf(c,s-1),f==-1){if(a==1)return;a=1;s=p.length;continue}if(a==1&&f<i.ch)return;if(/comment/.test(t.getTokenTypeAt(n.Pos(u,f+1)))){l=f+c.length;break}s=f-1}w=1;g=t.lastLine();n:for(e=u;e<=g;++e)for(o=t.getLine(e),r=e==u?l:0;;){if(h=o.indexOf(c,r),y=o.indexOf(d,r),h<0&&(h=o.length),y<0&&(y=o.length),r=Math.min(h,y),r==o.length)break;if(r==h)++w;else if(!--w){v=e;b=r;break n}++r}if(v!=null&&(u!=v||b!=l))return{from:n.Pos(u,l),to:n.Pos(v,b)}}})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";n.registerHelper("fold","indent",function(t,i){var c=t.getOption("tabSize"),f=t.getLine(i.line),r,s,e,h;if(/\S/.test(f)){var o=function(t){return n.countColumn(t,null,c)},l=o(f),u=null;for(r=i.line+1,s=t.lastLine();r<=s;++r)if(e=t.getLine(r),h=o(e),h>l)u=r;else if(/\S/.test(e))break;if(u)return{from:n.Pos(i.line,f.length),to:n.Pos(u,t.getLine(u).length)}}})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";function v(n,t){return n.line-t.line||n.ch-t.ch}function i(n,t,i,r){this.line=t;this.ch=i;this.cm=n;this.text=n.getLine(t);this.min=r?r.from:n.firstLine();this.max=r?r.to-1:n.lastLine()}function u(n,i){var r=n.cm.getTokenTypeAt(t(n.line,i));return r&&/\btag\b/.test(r)}function h(n){if(!(n.line>=n.max))return n.ch=0,n.text=n.cm.getLine(++n.line),!0}function c(n){if(!(n.line<=n.min))return n.text=n.cm.getLine(--n.line),n.ch=n.text.length,!0}function e(n){for(var t,i,r;;){if(t=n.text.indexOf(">",n.ch),t==-1)if(h(n))continue;else return;if(!u(n,t+1)){n.ch=t+1;continue}return i=n.text.lastIndexOf("/",t),r=i>-1&&!/\S/.test(n.text.slice(i+1,t)),n.ch=t+1,r?"selfClose":"regular"}}function o(n){for(var t,i;;){if(t=n.ch?n.text.lastIndexOf("<",n.ch-1):-1,t==-1)if(c(n))continue;else return;if(!u(n,t+1)){n.ch=t;continue}if(r.lastIndex=t,n.ch=t,i=r.exec(n.text),i&&i.index==t)return i}}function l(n){for(;;){r.lastIndex=n.ch;var t=r.exec(n.text);if(!t)if(h(n))continue;else return;if(!u(n,t.index+1)){n.ch=t.index+1;continue}return n.ch=t.index+t[0].length,t}}function p(n){for(var t,i,r;;){if(t=n.ch?n.text.lastIndexOf(">",n.ch-1):-1,t==-1)if(c(n))continue;else return;if(!u(n,t+1)){n.ch=t;continue}return i=n.text.lastIndexOf("/",t),r=i>-1&&!/\S/.test(n.text.slice(i+1,t)),n.ch=t+1,r?"selfClose":"regular"}}function f(n,i){for(var f=[],u;;){var r=l(n),o,s=n.line,h=n.ch-(r?r[0].length:0);if(!r||!(o=e(n)))return;if(o!="selfClose")if(r[1]){for(u=f.length-1;u>=0;--u)if(f[u]==r[2]){f.length=u;break}if(u<0&&(!i||i==r[2]))return{tag:r[2],from:t(s,h),to:t(n.line,n.ch)}}else f.push(r[2])}}function a(n,i){for(var f=[],e,u;;){if(e=p(n),!e)return;if(e=="selfClose"){o(n);continue}var s=n.line,h=n.ch,r=o(n);if(!r)return;if(r[1])f.push(r[2]);else{for(u=f.length-1;u>=0;--u)if(f[u]==r[2]){f.length=u;break}if(u<0&&(!i||i==r[2]))return{tag:r[2],from:t(n.line,n.ch),to:t(s,h)}}}}var t=n.Pos,s="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",y=s+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",r=new RegExp("<(/?)(["+s+"]["+y+"]*)","g");n.registerHelper("fold","xml",function(n,r){for(var u=new i(n,r.line,0),o,h,r,s;;){if(o=l(u),!o||u.line!=r.line||!(h=e(u)))return;if(!o[1]&&h!="selfClose")return r=t(u.line,u.ch),s=f(u,o[2]),s&&{from:r,to:s.from}}});n.findMatchingTag=function(n,r,u){var s=new i(n,r.line,r.ch,u),l;if(s.text.indexOf(">")!=-1||s.text.indexOf("<")!=-1){var c=e(s),y=c&&t(s.line,s.ch),h=c&&o(s);if(c&&h&&!(v(s,r)>0))return(l={from:t(s.line,s.ch),to:y,tag:h[2]},c=="selfClose")?{open:l,close:null,at:"open"}:h[1]?{open:a(s,h[2]),close:l,at:"close"}:(s=new i(n,y.line,y.ch,u),{open:l,close:f(s,h[2]),at:"open"})}};n.findEnclosingTag=function(n,t,r){for(var s=new i(n,t.line,t.ch,r),u,o,e;;){if(u=a(s),!u)break;if(o=new i(n,t.line,t.ch,r),e=f(o,u.tag),e)return{open:u,close:e}}};n.scanForClosingTag=function(n,t,r,u){var e=new i(n,t.line,t.ch,u?{from:0,to:u}:null);return f(e,r)}}),function(){CodeMirror.defineExtension("autoFormatAll",function(n,t){function v(){h+="\n";f=!0;++a}for(var i,r=this,u=r.getMode(),o=r.getRange(n,t).split("\n"),s=CodeMirror.copyState(u,r.getTokenAt(n).state),y=r.getOption("tabSize"),h="",a=0,f=n.ch==0,e=0;e<o.length;++e){for(i=new CodeMirror.StringStream(o[e],y);!i.eol();){var c=CodeMirror.innerMode(u,s),p=u.token(i,s),l=i.current();i.start=i.pos;(!f||/\S/.test(l))&&(h+=l,f=!1);!f&&c.mode.newlineAfterToken&&c.mode.newlineAfterToken(p,l,i.string.slice(i.pos)||o[e+1]||"",c.state)&&v()}!i.pos&&u.blankLine&&u.blankLine(s);!f&&e<o.length-1&&v()}r.operation(function(){r.replaceRange(h,n,t);for(var i=n.line+1,u=n.line+a;i<=u;++i)r.indentLine(i,"smart");r.setCursor({line:0,ch:0})})})}(),function(){function n(n){for(var i,t,f=[/for\s*?\((.*?)\)/g,/&#?[a-z0-9]+;[\s\S]/g,/\"(.*?)((\")|$)/g,/\/\*(.*?)(\*\/|$)/g,/^\/\/.*/g],r=[],u=0;u<f.length;u++)for(i=0;i<n.length;)if(t=n.substr(i).match(f[u]),t!=null)r.push({start:i+t.index,end:i+t.index+t[0].length}),i+=t.index+Math.max(1,t[0].length);else break;return r.sort(function(n,t){return n.start-t.start}),r}CodeMirror.extendMode("css",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(n,t){return/^[;{}]$/.test(t)}});CodeMirror.extendMode("javascript",{commentStart:"/*",commentEnd:"*/",wordWrapChars:[";","\\{","\\}"],autoFormatLineBreaks:function(t){var r=0,e=this.jsonMode?function(n){return n.replace(/([,{])/g,"$1\n").replace(/}/g,"\n}")}:function(n){return n.replace(/(;|\{|\})([^\r\n;])/g,"$1\n$2")},u=n(t),f="",i;if(u!=null){for(i=0;i<u.length;i++)u[i].start>r&&(f+=e(t.substring(r,u[i].start)),r=u[i].start),u[i].start<=r&&u[i].end>=r&&(f+=t.substring(r,u[i].end),r=u[i].end);r<t.length&&(f+=e(t.substr(r)))}else f=e(t);return f.replace(/^\n*|\n*$/,"")}});CodeMirror.extendMode("xml",{commentStart:"<!--",commentEnd:"-->",noBreak:!1,noBreakEmpty:null,tagType:"",tagName:"",isXML:!1,newlineAfterToken:function(n,t,i){var o="a|b|bdi|bdo|big|center|cite|del|em|font|i|img|ins|s|small|span|strike|strong|sub|sup|u",e="label|li|option|textarea|title|"+o,f=!1,r=null,u="",s;if(this.isXML=this.configuration=="xml"?!0:!1,n=="comment"||/<!--/.test(i))return!1;if(n=="tag"){if(t.indexOf("<")==0&&!t.indexOf("<\/")==0&&(this.tagType="open",r=t.match(/^<\s*?([\w]+?)$/i),this.tagName=r!=null?r[1]:"",u=this.tagName.toLowerCase(),("|"+e+"|").indexOf("|"+u+"|")!=-1&&(this.noBreak=!0)),t.indexOf(">")==0&&this.tagType=="open")return(this.tagType="",s=this.isXML?"[^<]*?":"",RegExp("^"+s+"<\/s*?"+this.tagName+"s*?>","i").test(i))?(this.noBreak=!1,this.isXML||(this.tagName=""),!1):(f=this.noBreak,this.noBreak=!1,f?!1:!0);if(t.indexOf("<\/")==0&&(this.tagType="close",r=t.match(/^<\/\s*?([\w]+?)$/i),r!=null&&(u=r[1].toLowerCase()),("|"+o+"|").indexOf("|"+u+"|")!=-1&&(this.noBreak=!0)),t.indexOf(">")==0&&this.tagType=="close")return(this.tagType="",i.indexOf("<")==0&&(r=i.match(/^<\/?\s*?([\w]+?)(\s|>)/i),u=r!=null?r[1].toLowerCase():"",("|"+e+"|").indexOf("|"+u+"|")==-1))?(this.noBreak=!1,!0):(f=this.noBreak,this.noBreak=!1,f?!1:!0)}return i.indexOf("<")==0?(this.noBreak=!1,this.isXML&&this.tagName!="")?(this.tagName="",!1):(r=i.match(/^<\/?\s*?([\w]+?)(\s|>)/i),u=r!=null?r[1].toLowerCase():"",("|"+e+"|").indexOf("|"+u+"|")!=-1?!1:!0):!1}});CodeMirror.defineExtension("commentRange",function(n,t,i){var r=this,u=CodeMirror.innerMode(r.getMode(),r.getTokenAt(t).state).mode;r.operation(function(){if(n)r.replaceRange(u.commentEnd,i),r.replaceRange(u.commentStart,t),t.line==i.line&&t.ch==i.ch&&r.setCursor(t.line,t.ch+u.commentStart.length);else{var f=r.getRange(t,i),e=f.indexOf(u.commentStart),o=f.lastIndexOf(u.commentEnd);e>-1&&o>-1&&o>e&&(f=f.substr(0,e)+f.substring(e+u.commentStart.length,o)+f.substr(o+u.commentEnd.length));r.replaceRange(f,t,i)}})});CodeMirror.defineExtension("autoIndentRange",function(n,t){var i=this;this.operation(function(){for(var r=n.line;r<=t.line;r++)i.indentLine(r,"smart")})});CodeMirror.defineExtension("autoFormatRange",function(n,t){function v(){h+="\n";f=!0;++a}for(var r,i=this,u=i.getMode(),o=i.getRange(n,t).split("\n"),s=CodeMirror.copyState(u,i.getTokenAt(n).state),y=i.getOption("tabSize"),h="",a=0,f=n.ch==0,e=0;e<o.length;++e){for(r=new CodeMirror.StringStream(o[e],y);!r.eol();){var c=CodeMirror.innerMode(u,s),p=u.token(r,s),l=r.current();r.start=r.pos;(!f||/\S/.test(l))&&(h+=l,f=!1);!f&&c.mode.newlineAfterToken&&c.mode.newlineAfterToken(p,l,r.string.slice(r.pos)||o[e+1]||"",c.state)&&v()}!r.pos&&u.blankLine&&u.blankLine(s);!f&&e<o.length-1&&v()}i.operation(function(){i.replaceRange(h,n,t);for(var r=n.line+1,u=n.line+a;r<=u;++r)i.indentLine(r,"smart");i.setSelection(n,i.getCursor(!1))})})}(),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";function r(n){for(var r=0;r<n.state.activeLines.length;r++)n.removeLineClass(n.state.activeLines[r],"wrap",t),n.removeLineClass(n.state.activeLines[r],"background",i)}function e(n,t){if(n.length!=t.length)return!1;for(var i=0;i<n.length;i++)if(n[i]!=t[i])return!1;return!0}function u(n,u){for(var s,h,f=[],o=0;o<u.length;o++)(s=u[o],s.empty())&&(h=n.getLineHandleVisualStart(s.head.line),f[f.length-1]!=h&&f.push(h));e(n.state.activeLines,f)||n.operation(function(){r(n);for(var u=0;u<f.length;u++)n.addLineClass(f[u],"wrap",t),n.addLineClass(f[u],"background",i);n.state.activeLines=f})}function f(n,t){u(n,t.ranges)}var t="CodeMirror-activeline",i="CodeMirror-activeline-background";n.defineOption("styleActiveLine",!1,function(t,i,e){var o=e&&e!=n.Init;if(i&&!o){t.state.activeLines=[];u(t,t.listSelections());t.on("beforeSelectionChange",f)}else!i&&o&&(t.off("beforeSelectionChange",f),r(t),delete t.state.activeLines)})}),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";function s(n){typeof n=="object"&&(this.minChars=n.minChars,this.style=n.style,this.showToken=n.showToken,this.delay=n.delay,this.wordsOnly=n.wordsOnly);this.style==null&&(this.style=f);this.minChars==null&&(this.minChars=u);this.delay==null&&(this.delay=e);this.wordsOnly==null&&(this.wordsOnly=o);this.overlay=this.timeout=null}function t(n){var t=n.state.matchHighlighter;clearTimeout(t.timeout);t.timeout=setTimeout(function(){i(n)},t.delay)}function i(n){n.operation(function(){var t=n.state.matchHighlighter,e,o,c;if(t.overlay&&(n.removeOverlay(t.overlay),t.overlay=null),!n.somethingSelected()&&t.showToken){for(var s=t.showToken===!0?/[\w$]/:t.showToken,l=n.getCursor(),f=n.getLine(l.line),i=l.ch,u=i;i&&s.test(f.charAt(i-1));)--i;while(u<f.length&&s.test(f.charAt(u)))++u;i<u&&n.addOverlay(t.overlay=r(f.slice(i,u),s,t.style));return}(e=n.getCursor("from"),o=n.getCursor("to"),e.line==o.line)&&(!t.wordsOnly||h(n,e,o))&&(c=n.getRange(e,o).replace(/^\s+|\s+$/g,""),c.length>=t.minChars&&n.addOverlay(t.overlay=r(c,!1,t.style)))})}function h(n,t,i){var f=n.getRange(t,i),r,u;return f.match(/^\w+$/)!==null?t.ch>0&&(r={line:t.line,ch:t.ch-1},u=n.getRange(r,t),u.match(/\W/)===null)?!1:i.ch<n.getLine(t.line).length&&(r={line:i.line,ch:i.ch+1},u=n.getRange(i,r),u.match(/\W/)===null)?!1:!0:!1}function c(n,t){return(!n.start||!t.test(n.string.charAt(n.start-1)))&&(n.pos==n.string.length||!t.test(n.string.charAt(n.pos)))}function r(n,t,i){return{token:function(r){if(r.match(n)&&(!t||c(r,t)))return i;r.next();r.skipTo(n.charAt(0))||r.skipToEnd()}}}var u=2,f="matchhighlight",e=100,o=!1;n.defineOption("highlightSelectionMatches",!1,function(r,u,f){if(f&&f!=n.Init){var e=r.state.matchHighlighter.overlay;e&&r.removeOverlay(e);clearTimeout(r.state.matchHighlighter.timeout);r.state.matchHighlighter=null;r.off("cursorActivity",t)}if(u){r.state.matchHighlighter=new s(u);i(r);r.on("cursorActivity",t)}})})