From 15e7bf756fe55cb8b2bafae7b5d2cc57a3682e12 Mon Sep 17 00:00:00 2001 From: w8tcha Date: Thu, 25 Apr 2019 09:56:55 +0200 Subject: [PATCH] Upgraded to 5.46.0 --- codemirror/js/addon/edit/closebrackets.js | 6 +- codemirror/js/addon/edit/closetag.js | 8 + codemirror/js/addon/edit/continuelist.js | 2 +- codemirror/js/addon/edit/matchbrackets.js | 2 +- codemirror/js/addon/hint/sql-hint.js | 41 +- codemirror/js/addon/hint/xml-hint.js | 20 +- .../js/addon/search/matchesonscrollbar.js | 2 +- codemirror/js/codemirror.addons.min.js | 4 +- codemirror/js/codemirror.js | 3221 +++++++++-------- codemirror/js/codemirror.min.js | 2 +- codemirror/js/codemirror.mode.php.min.js | 2 +- codemirror/js/mode/clike/clike.js | 2 +- codemirror/theme/panda-syntax.css | 2 +- codemirror/theme/yonce.css | 59 + 14 files changed, 1737 insertions(+), 1636 deletions(-) create mode 100644 codemirror/theme/yonce.css diff --git a/codemirror/js/addon/edit/closebrackets.js b/codemirror/js/addon/edit/closebrackets.js index ce1a4ac6..4415c393 100644 --- a/codemirror/js/addon/edit/closebrackets.js +++ b/codemirror/js/addon/edit/closebrackets.js @@ -11,6 +11,7 @@ })(function(CodeMirror) { var defaults = { pairs: "()[]{}''\"\"", + closeBefore: ")]}'\":;>", triples: "", explode: "[]{}" }; @@ -109,6 +110,9 @@ var pairs = getOption(conf, "pairs"); var pos = pairs.indexOf(ch); if (pos == -1) return CodeMirror.Pass; + + var closeBefore = getOption(conf,"closeBefore"); + var triples = getOption(conf, "triples"); var identical = pairs.charAt(pos + 1) == ch; @@ -136,7 +140,7 @@ var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur) if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both"; else return CodeMirror.Pass; - } else if (opening) { + } else if (opening && (next.length === 0 || /\s/.test(next) || closeBefore.indexOf(next) > -1)) { curType = "both"; } else { return CodeMirror.Pass; diff --git a/codemirror/js/addon/edit/closetag.js b/codemirror/js/addon/edit/closetag.js index 25e62d54..e5e83bcd 100644 --- a/codemirror/js/addon/edit/closetag.js +++ b/codemirror/js/addon/edit/closetag.js @@ -21,6 +21,8 @@ * An array of tag names that should, when opened, cause a * blank line to be added inside the tag, and the blank line and * closing line to be indented. + * `emptyTags` (default is none) + * An array of XML tag names that should be autoclosed with '/>'. * * See demos/closetag.html for a usage example. */ @@ -76,6 +78,12 @@ closingTagExists(cm, tagName, pos, state, true)) return CodeMirror.Pass; + var emptyTags = typeof opt == "object" && opt.emptyTags; + if (emptyTags && indexOf(emptyTags, tagName) > -1) { + replacements[i] = { text: "/>", newPos: CodeMirror.Pos(pos.line, pos.ch + 2) }; + continue; + } + var indent = indentTags && indexOf(indentTags, lowerTagName) > -1; replacements[i] = {indent: indent, text: ">" + (indent ? "\n\n" : "") + "", diff --git a/codemirror/js/addon/edit/continuelist.js b/codemirror/js/addon/edit/continuelist.js index 65096fb5..fb5f0373 100644 --- a/codemirror/js/addon/edit/continuelist.js +++ b/codemirror/js/addon/edit/continuelist.js @@ -23,7 +23,7 @@ // If we're not in Markdown mode, fall back to normal newlineAndIndent var eolState = cm.getStateAfter(pos.line); - var inner = cm.getMode().innerMode(eolState); + var inner = CodeMirror.innerMode(cm.getMode(), eolState); if (inner.mode.name !== "markdown") { cm.execCommand("newlineAndIndent"); return; diff --git a/codemirror/js/addon/edit/matchbrackets.js b/codemirror/js/addon/edit/matchbrackets.js index 2dd48888..2a147282 100644 --- a/codemirror/js/addon/edit/matchbrackets.js +++ b/codemirror/js/addon/edit/matchbrackets.js @@ -69,7 +69,7 @@ var ch = line.charAt(pos); if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { var match = matching[ch]; - if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch); + if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch); else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; else stack.pop(); } diff --git a/codemirror/js/addon/hint/sql-hint.js b/codemirror/js/addon/hint/sql-hint.js index 9759b91e..444eba8b 100644 --- a/codemirror/js/addon/hint/sql-hint.js +++ b/codemirror/js/addon/hint/sql-hint.js @@ -275,24 +275,29 @@ if (search.charAt(0) == "." || search.charAt(0) == identifierQuote) { start = nameCompletion(cur, token, result, editor); } else { - addMatches(result, search, defaultTable, function(w) {return {text:w, className: "CodeMirror-hint-table CodeMirror-hint-default-table"};}); - addMatches( - result, - search, - tables, - function(w) { - if (typeof w === 'object') { - w.className = "CodeMirror-hint-table"; - } else { - w = {text: w, className: "CodeMirror-hint-table"}; - } - - return w; - } - ); - if (!disableKeywords) - addMatches(result, search, keywords, function(w) {return {text: w.toUpperCase(), className: "CodeMirror-hint-keyword"};}); - } + var objectOrClass = function(w, className) { + if (typeof w === "object") { + w.className = className; + } else { + w = { text: w, className: className }; + } + return w; + }; + addMatches(result, search, defaultTable, function(w) { + return objectOrClass(w, "CodeMirror-hint-table CodeMirror-hint-default-table"); + }); + addMatches( + result, + search, + tables, function(w) { + return objectOrClass(w, "CodeMirror-hint-table"); + } + ); + if (!disableKeywords) + addMatches(result, search, keywords, function(w) { + return objectOrClass(w.toUpperCase(), "CodeMirror-hint-keyword"); + }); + } return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)}; }); diff --git a/codemirror/js/addon/hint/xml-hint.js b/codemirror/js/addon/hint/xml-hint.js index e575fc43..106ba4f3 100644 --- a/codemirror/js/addon/hint/xml-hint.js +++ b/codemirror/js/addon/hint/xml-hint.js @@ -13,9 +13,15 @@ var Pos = CodeMirror.Pos; + function matches(hint, typed, matchInMiddle) { + if (matchInMiddle) return hint.indexOf(typed) >= 0; + else return hint.lastIndexOf(typed, 0) == 0; + } + function getHints(cm, options) { var tags = options && options.schemaInfo; var quote = (options && options.quoteChar) || '"'; + var matchInMiddle = options && options.matchInMiddle; if (!tags) return; var cur = cm.getCursor(), token = cm.getTokenAt(cur); if (token.end > cur.ch) { @@ -45,14 +51,14 @@ var cx = inner.state.context, curTag = cx && tags[cx.tagName]; var childList = cx ? curTag && curTag.children : tags["!top"]; if (childList && tagType != "close") { - for (var i = 0; i < childList.length; ++i) if (!prefix || childList[i].lastIndexOf(prefix, 0) == 0) + for (var i = 0; i < childList.length; ++i) if (!prefix || matches(childList[i], prefix, matchInMiddle)) result.push("<" + childList[i]); } else if (tagType != "close") { for (var name in tags) - if (tags.hasOwnProperty(name) && name != "!top" && name != "!attrs" && (!prefix || name.lastIndexOf(prefix, 0) == 0)) + if (tags.hasOwnProperty(name) && name != "!top" && name != "!attrs" && (!prefix || matches(name, prefix, matchInMiddle))) result.push("<" + name); } - if (cx && (!prefix || tagType == "close" && cx.tagName.lastIndexOf(prefix, 0) == 0)) + if (cx && (!prefix || tagType == "close" && matches(cx.tagName, prefix, matchInMiddle))) result.push(""); } else { // Attribute completion @@ -86,16 +92,20 @@ quote = token.string.charAt(len - 1); prefix = token.string.substr(n, len - 2); } + if (n) { // an opening quote + var line = cm.getLine(cur.line); + if (line.length > token.end && line.charAt(token.end) == quote) token.end++; // include a closing quote + } replaceToken = true; } - for (var i = 0; i < atValues.length; ++i) if (!prefix || atValues[i].lastIndexOf(prefix, 0) == 0) + for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle)) result.push(quote + atValues[i] + quote); } else { // An attribute name if (token.type == "attribute") { prefix = token.string; replaceToken = true; } - for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || attr.lastIndexOf(prefix, 0) == 0)) + for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || matches(attr, prefix, matchInMiddle))) result.push(attr); } } diff --git a/codemirror/js/addon/search/matchesonscrollbar.js b/codemirror/js/addon/search/matchesonscrollbar.js index 4645f5eb..8a4a8275 100644 --- a/codemirror/js/addon/search/matchesonscrollbar.js +++ b/codemirror/js/addon/search/matchesonscrollbar.js @@ -46,7 +46,7 @@ if (match.from.line >= this.gap.to) break; if (match.to.line >= this.gap.from) this.matches.splice(i--, 1); } - var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), this.caseFold); + var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), {caseFold: this.caseFold, multiline: this.options.multiline}); var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES; while (cursor.findNext()) { var match = {from: cursor.from(), to: cursor.to()}; diff --git a/codemirror/js/codemirror.addons.min.js b/codemirror/js/codemirror.addons.min.js index b13fd4fa..ea8da579 100644 --- a/codemirror/js/codemirror.addons.min.js +++ b/codemirror/js/codemirror.addons.min.js @@ -1,2 +1,2 @@ -!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/comment/continuecomment.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(t){if(t.getOption("disableInput"))return e.Pass;for(var i,r=t.listSelections(),o=[],a=0;a-1&&f>d){if(c=u.slice(0,f),/\S/.test(c)){c="";for(var h=0;h-1&&!/\S/.test(u.slice(0,f))&&(c=u.slice(0,f));null!=c&&(c+=i.blockCommentContinue)}if(null==c&&i.lineComment&&n(t)){var u=t.getLine(l.line),f=u.indexOf(i.lineComment);f>-1&&(c=u.slice(0,f),/\S/.test(c)?c=null:c+=i.lineComment+u.slice(f+i.lineComment.length).match(/^\s*/)[0])}if(null==c)return e.Pass;o[a]="\n"+c}t.operation(function(){for(var e=r.length-1;e>=0;e--)t.replaceRange(o[e],r[e].from(),r[e].to(),"+insert")})}function n(e){var t=e.getOption("continueComments");return!t||"object"!=typeof t||!1!==t.continueLineComment}e.defineOption("continueComments",null,function(n,i,r){if(r&&r!=e.Init&&n.removeKeyMap("continueComment"),i){var o="Enter";"string"==typeof i?o=i:"object"==typeof i&&i.key&&(o=i.key);var a={name:"continueComment"};a[o]=t,n.addKeyMap(a)}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/edit/closebrackets.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t){return"pairs"==t&&"string"==typeof e?e:"object"==typeof e&&null!=e[t]?e[t]:u[t]}function n(e){for(var t=0;t=0;l--){var f=a[l].head;n.replaceRange("",d(f.line,f.ch-1),d(f.line,f.ch+1),"+delete")}}function a(n){var i=r(n),o=i&&t(i,"explode");if(!o||n.getOption("disableInput"))return e.Pass;for(var a=n.listSelections(),l=0;l0;return{anchor:new d(t.anchor.line,t.anchor.ch+(n?-1:1)),head:new d(t.head.line,t.head.ch+(n?1:-1))}}function s(n,i){var o=r(n);if(!o||n.getOption("disableInput"))return e.Pass;var a=t(o,"pairs"),s=a.indexOf(i);if(-1==s)return e.Pass;for(var c,u=t(o,"triples"),h=a.charAt(s+1)==i,m=n.listSelections(),g=s%2==0,p=0;p1&&u.indexOf(i)>=0&&n.getRange(d(x.line,x.ch-2),x)==i+i){if(x.ch>2&&/\bstring/.test(n.getTokenTypeAt(d(x.line,x.ch-2))))return e.Pass;v="addFour"}else if(h){var C=0==x.ch?" ":n.getRange(d(x.line,x.ch-1),x);if(e.isWordChar(y)||C==i||e.isWordChar(C))return e.Pass;v="both"}else{if(!g)return e.Pass;v="both"}else v=h&&f(n,x)?"both":u.indexOf(i)>=0&&n.getRange(x,d(x.line,x.ch+3))==i+i+i?"skipThree":"skip";if(c){if(c!=v)return e.Pass}else c=v}var k=s%2?a.charAt(s-1):i,L=s%2?i:a.charAt(s+1);n.operation(function(){if("skip"==c)n.execCommand("goCharRight");else if("skipThree"==c)for(var e=0;e<3;e++)n.execCommand("goCharRight");else if("surround"==c){for(var t=n.getSelections(),e=0;e=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function o(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function a(e){for(;;){var t=e.text.indexOf(">",e.ch);if(-1==t){if(r(e))continue;return}{if(i(e,t+1)){var n=e.text.lastIndexOf("/",t),o=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,o?"selfClose":"regular"}e.ch=t+1}}}function l(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==t){if(o(e))continue;return}if(i(e,t+1)){m.lastIndex=t,e.ch=t;var n=m.exec(e.text);if(n&&n.index==t)return n}else e.ch=t}}function s(e){for(;;){m.lastIndex=e.ch;var t=m.exec(e.text);if(!t){if(r(e))continue;return}{if(i(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}}function c(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==t){if(o(e))continue;return}{if(i(e,t+1)){var n=e.text.lastIndexOf("/",t),r=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,r?"selfClose":"regular"}e.ch=t}}}function f(e,t){for(var n=[];;){var i,r=s(e),o=e.line,l=e.ch-(r?r[0].length:0);if(!r||!(i=a(e)))return;if("selfClose"!=i)if(r[1]){for(var c=n.length-1;c>=0;--c)if(n[c]==r[2]){n.length=c;break}if(c<0&&(!t||t==r[2]))return{tag:r[2],from:d(o,l),to:d(e.line,e.ch)}}else n.push(r[2])}}function u(e,t){for(var n=[];;){var i=c(e);if(!i)return;if("selfClose"!=i){var r=e.line,o=e.ch,a=l(e);if(!a)return;if(a[1])n.push(a[2]);else{for(var s=n.length-1;s>=0;--s)if(n[s]==a[2]){n.length=s;break}if(s<0&&(!t||t==a[2]))return{tag:a[2],from:d(e.line,e.ch),to:d(r,o)}}}else l(e)}}var d=e.Pos,h="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",m=new RegExp("<(/?)(["+h+"][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-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");e.registerHelper("fold","xml",function(e,i){for(var r=new n(e,i.line,0);;){var o=s(r);if(!o||r.line!=i.line)return;var l=a(r);if(!l)return;if(!o[1]&&"selfClose"!=l){var c=d(r.line,r.ch),u=f(r,o[2]);return u&&t(u.from,c)>0?{from:c,to:u.from}:null}}}),e.findMatchingTag=function(e,i,r){var o=new n(e,i.line,i.ch,r);if(-1!=o.text.indexOf(">")||-1!=o.text.indexOf("<")){var s=a(o),c=s&&d(o.line,o.ch),h=s&&l(o);if(s&&h&&!(t(o,i)>0)){var m={from:d(o.line,o.ch),to:c,tag:h[2]};return"selfClose"==s?{open:m,close:null,at:"open"}:h[1]?{open:u(o,h[2]),close:m,at:"close"}:(o=new n(e,c.line,c.ch,r),{open:m,close:f(o,h[2]),at:"open"})}}},e.findEnclosingTag=function(e,t,i,r){for(var o=new n(e,t.line,t.ch,i);;){var a=u(o,r);if(!a)break;var l=new n(e,t.line,t.ch,i),s=f(l,a.tag);if(s)return{open:a,close:s}}},e.scanForClosingTag=function(e,t,i,r){return f(new n(e,t.line,t.ch,r?{from:0,to:r}:null),i)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define("addon/edit/closetag.js",["../../lib/codemirror","../fold/xml-fold"],e):e(CodeMirror)}(function(e){function t(t){if(t.getOption("disableInput"))return e.Pass;for(var n=t.listSelections(),i=[],s=t.getOption("autoCloseTags"),c=0;cf.ch&&(v=v.slice(0,v.length-u.end+f.ch));var b=v.toLowerCase();if(!v||"string"==u.type&&(u.end!=f.ch||!/[\"\']/.test(u.string.charAt(u.string.length-1))||1==u.string.length)||"tag"==u.type&&"closeTag"==h.type||u.string.indexOf("/")==u.string.length-1||g&&r(g,b)>-1||o(t,v,f,h,!0))return e.Pass;var x=p&&r(p,b)>-1;i[c]={indent:x,text:">"+(x?"\n\n":"")+"",newPos:x?e.Pos(f.line+1,0):e.Pos(f.line,f.ch+1)}}for(var y="object"==typeof s&&s.dontIndentOnAutoClose,c=n.length-1;c>=0;c--){var C=i[c];t.replaceRange(C.text,n[c].head,n[c].anchor,"+insert");var k=t.listSelections().slice(0);k[c]={head:C.newPos,anchor:C.newPos},t.setSelections(k),!y&&C.indent&&(t.indentLine(C.newPos.line,null,!0),t.indentLine(C.newPos.line+1,null,!0))}}function n(t,n){for(var i=t.listSelections(),r=[],a=n?"/":""!=t.getLine(f.line).charAt(u.end)&&(m+=">"),r[c]=m}if(t.replaceSelections(r),i=t.listSelections(),!s)for(var c=0;c'"]=function(e){return t(e)}),n.addKeyMap(a)}});var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],l=["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"];e.commands.closeTag=function(e){return n(e)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/edit/matchbrackets.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e){return e&&e.bracketRegex||/[(){}[\]]/}function n(e,n,r){var o=e.getLineHandle(n.line),a=n.ch-1,c=r&&r.afterCursor;null==c&&(c=/(^| )cm-fat-cursor($| )/.test(e.getWrapperElement().className));var f=t(r),u=!c&&a>=0&&f.test(o.text.charAt(a))&&s[o.text.charAt(a)]||f.test(o.text.charAt(a+1))&&s[o.text.charAt(++a)];if(!u)return null;var d=">"==u.charAt(1)?1:-1;if(r&&r.strict&&d>0!=(a==n.ch))return null;var h=e.getTokenTypeAt(l(n.line,a+1)),m=i(e,l(n.line,a+(d>0?1:0)),d,h||null,r);return null==m?null:{from:l(n.line,a),to:m&&m.pos,match:m&&m.ch==u.charAt(0),forward:d>0}}function i(e,n,i,r,o){for(var a=o&&o.maxScanLineLength||1e4,c=o&&o.maxScanLines||1e3,f=[],u=t(o),d=i>0?Math.min(n.line+c,e.lastLine()+1):Math.max(e.firstLine()-1,n.line-c),h=n.line;h!=d;h+=i){var m=e.getLine(h);if(m){var g=i>0?0:m.length-1,p=i>0?m.length:-1;if(!(m.length>a))for(h==n.line&&(g=n.ch-(i<0?1:0));g!=p;g+=i){var v=m.charAt(g);if(u.test(v)&&(void 0===r||e.getTokenTypeAt(l(h,g+1))==r)){var b=s[v];if(">"==b.charAt(1)==i>0)f.push(v);else{if(!f.length)return{pos:l(h,g),ch:v};f.pop()}}}}}return h-i!=(i>0?e.lastLine():e.firstLine())&&null}function r(e,t,i){for(var r=e.state.matchBrackets.maxHighlightLineLength||1e3,o=[],s=e.listSelections(),c=0;c",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};e.defineOption("matchBrackets",!1,function(t,n,i){i&&i!=e.Init&&(t.off("cursorActivity",o),t.state.matchBrackets&&t.state.matchBrackets.currentlyHighlighted&&(t.state.matchBrackets.currentlyHighlighted(),t.state.matchBrackets.currentlyHighlighted=null)),n&&(t.state.matchBrackets="object"==typeof n?n:{},t.on("cursorActivity",o))}),e.defineExtension("matchBrackets",function(){r(this,!0)}),e.defineExtension("findMatchingBracket",function(e,t,i){return(i||"boolean"==typeof t)&&(i?(i.strict=t,t=i):t=t?{strict:!0}:null),n(this,e,t)}),e.defineExtension("scanForBracket",function(e,t,n,r){return i(this,e,t,n,r)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define("addon/edit/matchtags.js",["../../lib/codemirror","../fold/xml-fold"],e):e(CodeMirror)}(function(e){"use strict";function t(e){e.state.tagHit&&e.state.tagHit.clear(),e.state.tagOther&&e.state.tagOther.clear(),e.state.tagHit=e.state.tagOther=null}function n(n){n.state.failedTagMatch=!1,n.operation(function(){if(t(n),!n.somethingSelected()){var i=n.getCursor(),r=n.getViewport();r.from=Math.min(r.from,i.line),r.to=Math.max(i.line+1,r.to);var o=e.findMatchingTag(n,i,r);if(o){if(n.state.matchBothTags){var a="open"==o.at?o.open:o.close;a&&(n.state.tagHit=n.markText(a.from,a.to,{className:"CodeMirror-matchingtag"}))}var l="close"==o.at?o.open:o.close;l?n.state.tagOther=n.markText(l.from,l.to,{className:"CodeMirror-matchingtag"}):n.state.failedTagMatch=!0}}})}function i(e){e.state.failedTagMatch&&n(e)}e.defineOption("matchTags",!1,function(r,o,a){a&&a!=e.Init&&(r.off("cursorActivity",n),r.off("viewportChange",i),t(r)),o&&(r.state.matchBothTags="object"==typeof o&&o.bothTags,r.on("cursorActivity",n),r.on("viewportChange",i),n(r))}),e.commands.toMatchingTag=function(t){var n=e.findMatchingTag(t,t.getCursor());if(n){var i="close"==n.at?n.open:n.close;i&&t.extendSelection(i.to,i.from)}}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/edit/trailingspace.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineOption("showTrailingSpace",!1,function(t,n,i){i==e.Init&&(i=!1),i&&!n?t.removeOverlay("trailingspace"):!i&&n&&t.addOverlay({token:function(e){for(var t=e.string.length,n=t;n&&/\s/.test(e.string.charAt(n-1));--n);return n>e.pos?(e.pos=n,null):(e.pos=t,"trailingspace")},name:"trailingspace"})})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/foldcode",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(t,r,o,a){function l(e){var n=s(t,r);if(!n||n.to.line-n.from.linet.firstLine();)r=e.Pos(r.line-1,0),f=l(!1);if(f&&!f.cleared&&"unfold"!==a){var u=n(t,o);e.on(u,"mousedown",function(t){d.clear(),e.e_preventDefault(t)});var d=t.markText(f.from,f.to,{replacedWith:u,clearOnEnter:i(t,o,"clearOnEnter"),__isFold:!0});d.on("clear",function(n,i){e.signal(t,"unfold",t,n,i)}),e.signal(t,"fold",t,f.from,f.to)}}function n(e,t){var n=i(e,t,"widget");if("string"==typeof n){var r=document.createTextNode(n);n=document.createElement("span"),n.appendChild(r),n.className="CodeMirror-foldmarker"}else n&&(n=n.cloneNode(!0));return n}function i(e,t,n){if(t&&void 0!==t[n])return t[n];var i=e.options.foldOptions;return i&&void 0!==i[n]?i[n]:r[n]}e.newFoldFunction=function(e,n){return function(i,r){t(i,r,{rangeFinder:e,widget:n})}},e.defineExtension("foldCode",function(e,n,i){t(this,e,n,i)}),e.defineExtension("isFolded",function(e){for(var t=this.findMarksAt(e),n=0;n=l&&(n=r(o.indicatorOpen))}e.setGutterMarker(t,o.gutter,n),++a})}function a(e){var t=e.getViewport(),n=e.state.foldGutter;n&&(e.operation(function(){o(e,t.from,t.to)}),n.from=t.from,n.to=t.to)}function l(e,t,n){var r=e.state.foldGutter;if(r){var o=r.options;if(n==o.gutter){var a=i(e,t);a?a.clear():e.foldCode(u(t,0),o.rangeFinder)}}}function s(e){var t=e.state.foldGutter;if(t){var n=t.options;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){a(e)},n.foldOnChangeTimeSpan||600)}}function c(e){var t=e.state.foldGutter;if(t){var n=t.options;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){var n=e.getViewport();t.from==t.to||n.from-t.to>20||t.from-n.to>20?a(e):e.operation(function(){n.fromt.to&&(o(e,t.to,n.to),t.to=n.to)})},n.updateViewportTimeSpan||400)}}function f(e,t){var n=e.state.foldGutter;if(n){var i=t.line;i>=n.from&&it.lastLine())return null;var i=t.getTokenAt(e.Pos(n,1));if(/\S/.test(i.string)||(i=t.getTokenAt(e.Pos(n,i.end+1))),"keyword"!=i.type||"import"!=i.string)return null;for(var r=n,o=Math.min(t.lastLine(),n+10);r<=o;++r){var a=t.getLine(r),l=a.indexOf(";");if(-1!=l)return{startCh:i.end,end:e.Pos(r,l)}}}var r,o=n.line,a=i(o);if(!a||i(o-1)||(r=i(o-2))&&r.end.line==o-1)return null;for(var l=a.end;;){var s=i(l.line+1);if(null==s)break;l=s.end}return{from:t.clipPos(e.Pos(o,a.startCh+1)),to:l}}),e.registerHelper("fold","include",function(t,n){function i(n){if(nt.lastLine())return null;var i=t.getTokenAt(e.Pos(n,1));return/\S/.test(i.string)||(i=t.getTokenAt(e.Pos(n,i.end+1))),"meta"==i.type&&"#include"==i.string.slice(0,8)?i.start+8:void 0}var r=n.line,o=i(r);if(null==o||null!=i(r-1))return null;for(var a=r;;){if(null==i(a+1))break;++a}return{from:e.Pos(r,o+1),to:t.clipPos(e.Pos(a))}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/comment-fold.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerGlobalHelper("fold","comment",function(e){return e.blockCommentStart&&e.blockCommentEnd},function(t,n){var i=t.getModeAt(n),r=i.blockCommentStart,o=i.blockCommentEnd;if(r&&o){for(var a,l=n.line,s=t.getLine(l),c=n.ch,f=0;;){var u=c<=0?-1:s.lastIndexOf(r,c-1);if(-1!=u){if(1==f&&ur))break;o=a}}return o?{from:e.Pos(i.line,n.getLine(i.line).length),to:e.Pos(o,n.getLine(o).length)}:void 0}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/format/autoFormatAll.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineExtension("autoFormatAll",function(t,n){function i(){c+="\n",u=!0,++f}for(var r=this,o=r.getMode(),a=r.getRange(t,n).split("\n"),l=e.copyState(o,r.getTokenAt(t).state),s=r.getOption("tabSize"),c="",f=0,u=0==t.ch,d=0;dn&&(o+=i(e.substring(n,r[a].start)),n=r[a].start),r[a].start<=n&&r[a].end>=n&&(o+=e.substring(n,r[a].end),n=r[a].end);n")&&"open"==this.tagType){this.tagType="";var c=this.isXML?"[^<]*?":"";return RegExp("^"+c+"","i").test(n)?(this.noBreak=!1,this.isXML||(this.tagName=""),!1):(a=this.noBreak,this.noBreak=!1,!a)}if(0==t.indexOf("")&&"close"==this.tagType)return this.tagType="",0==n.indexOf("<")&&(l=n.match(/^<\/?\s*?([\w]+?)(\s|>)/i),s=null!=l?l[1].toLowerCase():"",-1==("|"+o+"|").indexOf("|"+s+"|"))?(this.noBreak=!1,!0):(a=this.noBreak,this.noBreak=!1,!a)}return 0==n.indexOf("<")&&(this.noBreak=!1,this.isXML&&""!=this.tagName?(this.tagName="",!1):(l=n.match(/^<\/?\s*?([\w]+?)(\s|>)/i),s=null!=l?l[1].toLowerCase():"",-1==("|"+o+"|").indexOf("|"+s+"|")))}}),e.defineExtension("commentRange",function(t,n,i){var r=this,o=e.innerMode(r.getMode(),r.getTokenAt(n).state).mode;r.operation(function(){if(t)r.replaceRange(o.commentEnd,i),r.replaceRange(o.commentStart,n),r.setSelection(n,{line:i.line,ch:i.ch+o.commentStart.length+o.commentEnd.length}),n.line==i.line&&n.ch==i.ch&&r.setCursor(n.line,n.ch+o.commentStart.length);else{var e=r.getRange(n,i),a=e.indexOf(o.commentStart),l=e.lastIndexOf(o.commentEnd);a>-1&&l>-1&&l>a&&(e=e.substr(0,a)+e.substring(a+o.commentStart.length,l)+e.substr(l+o.commentEnd.length)),r.replaceRange(e,n,i),r.setSelection(n,{line:i.line,ch:i.ch-o.commentStart.length-o.commentEnd.length})}})}),e.defineExtension("autoIndentRange",function(e,t){var n=this;this.operation(function(){for(var i=e.line;i<=t.line;i++)n.indentLine(i,"smart")})}),e.defineExtension("autoFormatRange",function(t,n){function i(){c+="\n",u=!0,++f}for(var r=this,o=r.getMode(),a=r.getRange(t,n).split("\n"),l=e.copyState(o,r.getTokenAt(t).state),s=r.getOption("tabSize"),c="",f=0,u=0==t.ch,d=0;dc);f++){var u=e.getLine(s++);a=null==a?u:a+"\n"+u}l*=2,t.lastIndex=o.ch;var d=t.exec(a);if(d){var h=a.slice(0,d.index).split("\n"),m=d[0].split("\n"),p=o.line+h.length-1,v=h[h.length-1].length;return{from:g(p,v),to:g(p+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:d}}}}function a(e,t){for(var n,i=0;;){t.lastIndex=i;var r=t.exec(e);if(!r)return n;if(n=r,(i=n.index+(n[0].length||1))==e.length)return n}}function l(e,t,i){t=n(t,"g");for(var r=i.line,o=i.ch,l=e.firstLine();r>=l;r--,o=-1){var s=e.getLine(r);o>-1&&(s=s.slice(0,o));var c=a(s,t);if(c)return{from:g(r,c.index),to:g(r,c.index+c[0].length),match:c}}}function s(e,t,i){t=n(t,"gm");for(var r,o=1,l=i.line,s=e.firstLine();l>=s;){for(var c=0;c>1,l=i(e.slice(0,a)).length;if(l==n)return a;l>n?o=a:r=a+1}}function f(e,t,n,i){if(!t.length)return null;var r=i?h:m,o=r(t).split(/\r|\n\r?/);e:for(var a=n.line,l=n.ch,s=e.lastLine()+1-o.length;a<=s;a++,l=0){var f=e.getLine(a).slice(l),u=r(f);if(1==o.length){var d=u.indexOf(o[0]);if(-1==d)continue e;var n=c(f,u,d,r)+l;return{from:g(a,c(f,u,d,r)+l),to:g(a,c(f,u,d+o[0].length,r)+l)}}var p=u.length-o[0].length;if(u.slice(p)==o[0]){for(var v=1;v=s;a--,l=-1){var f=e.getLine(a);l>-1&&(f=f.slice(0,l));var u=r(f);if(1==o.length){var d=u.lastIndexOf(o[0]);if(-1==d)continue e;return{from:g(a,c(f,u,d,r)),to:g(a,c(f,u,d+o[0].length,r))}}var p=o[o.length-1];if(u.slice(0,p.length)==p){for(var v=1,n=a-o.length+1;v0);)i.push({anchor:r.from(),head:r.to()});i.length&&this.setSelections(i,0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/scroll/annotatescrollbar",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){function n(e){clearTimeout(i.doRedraw),i.doRedraw=setTimeout(function(){i.redraw()},e)}this.cm=e,this.options=t,this.buttonHeight=t.scrollButtonHeight||e.getOption("scrollButtonHeight"),this.annotations=[],this.doRedraw=this.doUpdate=null,this.div=e.getWrapperElement().appendChild(document.createElement("div")),this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none",this.computeScale();var i=this;e.on("refresh",this.resizeHandler=function(){clearTimeout(i.doUpdate),i.doUpdate=setTimeout(function(){i.computeScale()&&n(20)},100)}),e.on("markerAdded",this.resizeHandler),e.on("markerCleared",this.resizeHandler),!1!==t.listenForChanges&&e.on("change",this.changeHandler=function(){n(250)})}e.defineExtension("annotateScrollbar",function(e){return"string"==typeof e&&(e={className:e}),new t(this,e)}),e.defineOption("scrollButtonHeight",0),t.prototype.computeScale=function(){var e=this.cm,t=(e.getWrapperElement().clientHeight-e.display.barHeight-2*this.buttonHeight)/e.getScrollerElement().scrollHeight;if(t!=this.hScale)return this.hScale=t,!0},t.prototype.update=function(e){this.annotations=e,this.redraw()},t.prototype.redraw=function(e){function t(e,t){return s!=e.line&&(s=e.line,c=n.getLineHandle(s)),c.widgets&&c.widgets.length||a&&c.height>l?n.charCoords(e,"local")[t?"top":"bottom"]:n.heightAtLine(c,"local")+(t?0:c.height)}!1!==e&&this.computeScale();var n=this.cm,i=this.hScale,r=document.createDocumentFragment(),o=this.annotations,a=n.getOption("lineWrapping"),l=a&&1.5*n.defaultTextHeight(),s=null,c=null,f=n.lastLine();if(n.display.barWidth)for(var u,d=0;df)){for(var m=u||t(h.from,!0)*i,g=t(h.to,!1)*i;df)&&!((u=t(o[d+1].from,!0)*i)>g+.9);)h=o[++d],g=t(h.to,!1)*i;if(g!=m){var p=Math.max(g-m,3),v=r.appendChild(document.createElement("div"));v.style.cssText="position: absolute; right: 0px; width: "+Math.max(n.display.barWidth-1,2)+"px; top: "+(m+this.buttonHeight)+"px; height: "+p+"px",v.className=this.options.className,h.id&&v.setAttribute("annotation-id",h.id)}}}this.div.textContent="",this.div.appendChild(r)},t.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler),this.cm.off("markerAdded",this.resizeHandler),this.cm.off("markerCleared",this.resizeHandler),this.changeHandler&&this.cm.off("change",this.changeHandler),this.div.parentNode.removeChild(this.div)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define("addon/search/matchesonscrollbar",["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,n,i){this.cm=e,this.options=i;var r={listenForChanges:!1};for(var o in i)r[o]=i[o];r.className||(r.className="CodeMirror-search-match"),this.annotation=e.annotateScrollbar(r),this.query=t,this.caseFold=n,this.gap={from:e.firstLine(),to:e.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var a=this;e.on("change",this.changeHandler=function(e,t){a.onChange(t)})}function n(e,t,n){return e<=t?e:Math.max(t,e+n)}e.defineExtension("showMatchesOnScrollbar",function(e,n,i){return"string"==typeof i&&(i={className:i}),i||(i={}),new t(this,e,n,i)});t.prototype.findMatches=function(){if(this.gap){for(var t=0;t=this.gap.to)break;n.to.line>=this.gap.from&&this.matches.splice(t--,1)}for(var i=this.cm.getSearchCursor(this.query,e.Pos(this.gap.from,0),this.caseFold),r=this.options&&this.options.maxMatches||1e3;i.findNext();){var n={from:i.from(),to:i.to()};if(n.from.line>=this.gap.to)break;if(this.matches.splice(t++,0,n),this.matches.length>r)break}this.gap=null}},t.prototype.onChange=function(t){var i=t.from.line,r=e.changeEnd(t).line,o=r-t.to.line;if(this.gap?(this.gap.from=Math.min(n(this.gap.from,i,o),t.from.line),this.gap.to=Math.max(n(this.gap.to,i,o),t.from.line)):this.gap={from:t.from.line,to:r+1},o)for(var a=0;a=t.options.minChars&&o(e,d,!1,t.options.style)}})}function s(e,t,n){if(null!==e.getRange(t,n).match(/^\w+$/)){if(t.ch>0){var i={line:t.line,ch:t.ch-1},r=e.getRange(i,t);if(null===r.match(/\W/))return!1}if(n.ch-1?r+t.length:r}var o=t.exec(n?e.slice(n):e);return o?o.index+n+(i?o[0].length:0):-1}var i=Array.prototype.slice.call(arguments,1);return{startState:function(){return{outer:e.startState(t),innerActive:null,inner:null}},copyState:function(n){return{outer:e.copyState(t,n.outer),innerActive:n.innerActive,inner:n.innerActive&&e.copyState(n.innerActive.mode,n.inner)}},token:function(r,o){if(o.innerActive){var a=o.innerActive,l=r.string;if(!a.close&&r.sol())return o.innerActive=o.inner=null,this.token(r,o);var s=a.close?n(l,a.close,r.pos,a.parseDelimiters):-1;if(s==r.pos&&!a.parseDelimiters)return r.match(a.close),o.innerActive=o.inner=null,a.delimStyle&&a.delimStyle+" "+a.delimStyle+"-close";s>-1&&(r.string=l.slice(0,s));var c=a.mode.token(r,o.inner);return s>-1&&(r.string=l),s==r.pos&&a.parseDelimiters&&(o.innerActive=o.inner=null),a.innerStyle&&(c=c?c+" "+a.innerStyle:a.innerStyle),c}for(var f=1/0,l=r.string,u=0;u-1&&f>d){if(c=u.slice(0,f),/\S/.test(c)){c="";for(var h=0;h-1&&!/\S/.test(u.slice(0,f))&&(c=u.slice(0,f));null!=c&&(c+=i.blockCommentContinue)}if(null==c&&i.lineComment&&n(t)){var u=t.getLine(l.line),f=u.indexOf(i.lineComment);f>-1&&(c=u.slice(0,f),/\S/.test(c)?c=null:c+=i.lineComment+u.slice(f+i.lineComment.length).match(/^\s*/)[0])}if(null==c)return e.Pass;o[a]="\n"+c}t.operation(function(){for(var e=r.length-1;e>=0;e--)t.replaceRange(o[e],r[e].from(),r[e].to(),"+insert")})}function n(e){var t=e.getOption("continueComments");return!t||"object"!=typeof t||!1!==t.continueLineComment}e.defineOption("continueComments",null,function(n,i,r){if(r&&r!=e.Init&&n.removeKeyMap("continueComment"),i){var o="Enter";"string"==typeof i?o=i:"object"==typeof i&&i.key&&(o=i.key);var a={name:"continueComment"};a[o]=t,n.addKeyMap(a)}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/edit/closebrackets.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t){return"pairs"==t&&"string"==typeof e?e:"object"==typeof e&&null!=e[t]?e[t]:u[t]}function n(e){for(var t=0;t=0;l--){var f=a[l].head;n.replaceRange("",d(f.line,f.ch-1),d(f.line,f.ch+1),"+delete")}}function a(n){var i=r(n),o=i&&t(i,"explode");if(!o||n.getOption("disableInput"))return e.Pass;for(var a=n.listSelections(),l=0;l0;return{anchor:new d(t.anchor.line,t.anchor.ch+(n?-1:1)),head:new d(t.head.line,t.head.ch+(n?1:-1))}}function s(n,i){var o=r(n);if(!o||n.getOption("disableInput"))return e.Pass;var a=t(o,"pairs"),s=a.indexOf(i);if(-1==s)return e.Pass;for(var c,u=t(o,"closeBefore"),h=t(o,"triples"),m=a.charAt(s+1)==i,g=n.listSelections(),p=s%2==0,v=0;v1&&h.indexOf(i)>=0&&n.getRange(d(y.line,y.ch-2),y)==i+i){if(y.ch>2&&/\bstring/.test(n.getTokenTypeAt(d(y.line,y.ch-2))))return e.Pass;b="addFour"}else if(m){var k=0==y.ch?" ":n.getRange(d(y.line,y.ch-1),y);if(e.isWordChar(C)||k==i||e.isWordChar(k))return e.Pass;b="both"}else{if(!p||!(0===C.length||/\s/.test(C)||u.indexOf(C)>-1))return e.Pass;b="both"}else b=m&&f(n,y)?"both":h.indexOf(i)>=0&&n.getRange(y,d(y.line,y.ch+3))==i+i+i?"skipThree":"skip";if(c){if(c!=b)return e.Pass}else c=b}var L=s%2?a.charAt(s-1):i,S=s%2?i:a.charAt(s+1);n.operation(function(){if("skip"==c)n.execCommand("goCharRight");else if("skipThree"==c)for(var e=0;e<3;e++)n.execCommand("goCharRight");else if("surround"==c){for(var t=n.getSelections(),e=0;e",triples:"",explode:"[]{}"},d=e.Pos;e.defineOption("autoCloseBrackets",!1,function(i,r,o){o&&o!=e.Init&&(i.removeKeyMap(h),i.state.closeBrackets=null),r&&(n(t(r,"pairs")),i.state.closeBrackets=r,i.addKeyMap(h))});var h={Backspace:o,Enter:a};n(u.pairs+"`")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/xml-fold",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){return e.line-t.line||e.ch-t.ch}function n(e,t,n,i){this.line=t,this.ch=n,this.cm=e,this.text=e.getLine(t),this.min=i?Math.max(i.from,e.firstLine()):e.firstLine(),this.max=i?Math.min(i.to-1,e.lastLine()):e.lastLine()}function i(e,t){var n=e.cm.getTokenTypeAt(d(e.line,t));return n&&/\btag\b/.test(n)}function r(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function o(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function a(e){for(;;){var t=e.text.indexOf(">",e.ch);if(-1==t){if(r(e))continue;return}{if(i(e,t+1)){var n=e.text.lastIndexOf("/",t),o=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,o?"selfClose":"regular"}e.ch=t+1}}}function l(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==t){if(o(e))continue;return}if(i(e,t+1)){m.lastIndex=t,e.ch=t;var n=m.exec(e.text);if(n&&n.index==t)return n}else e.ch=t}}function s(e){for(;;){m.lastIndex=e.ch;var t=m.exec(e.text);if(!t){if(r(e))continue;return}{if(i(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}}function c(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==t){if(o(e))continue;return}{if(i(e,t+1)){var n=e.text.lastIndexOf("/",t),r=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,r?"selfClose":"regular"}e.ch=t}}}function f(e,t){for(var n=[];;){var i,r=s(e),o=e.line,l=e.ch-(r?r[0].length:0);if(!r||!(i=a(e)))return;if("selfClose"!=i)if(r[1]){for(var c=n.length-1;c>=0;--c)if(n[c]==r[2]){n.length=c;break}if(c<0&&(!t||t==r[2]))return{tag:r[2],from:d(o,l),to:d(e.line,e.ch)}}else n.push(r[2])}}function u(e,t){for(var n=[];;){var i=c(e);if(!i)return;if("selfClose"!=i){var r=e.line,o=e.ch,a=l(e);if(!a)return;if(a[1])n.push(a[2]);else{for(var s=n.length-1;s>=0;--s)if(n[s]==a[2]){n.length=s;break}if(s<0&&(!t||t==a[2]))return{tag:a[2],from:d(e.line,e.ch),to:d(r,o)}}}else l(e)}}var d=e.Pos,h="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",m=new RegExp("<(/?)(["+h+"][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-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");e.registerHelper("fold","xml",function(e,i){for(var r=new n(e,i.line,0);;){var o=s(r);if(!o||r.line!=i.line)return;var l=a(r);if(!l)return;if(!o[1]&&"selfClose"!=l){var c=d(r.line,r.ch),u=f(r,o[2]);return u&&t(u.from,c)>0?{from:c,to:u.from}:null}}}),e.findMatchingTag=function(e,i,r){var o=new n(e,i.line,i.ch,r);if(-1!=o.text.indexOf(">")||-1!=o.text.indexOf("<")){var s=a(o),c=s&&d(o.line,o.ch),h=s&&l(o);if(s&&h&&!(t(o,i)>0)){var m={from:d(o.line,o.ch),to:c,tag:h[2]};return"selfClose"==s?{open:m,close:null,at:"open"}:h[1]?{open:u(o,h[2]),close:m,at:"close"}:(o=new n(e,c.line,c.ch,r),{open:m,close:f(o,h[2]),at:"open"})}}},e.findEnclosingTag=function(e,t,i,r){for(var o=new n(e,t.line,t.ch,i);;){var a=u(o,r);if(!a)break;var l=new n(e,t.line,t.ch,i),s=f(l,a.tag);if(s)return{open:a,close:s}}},e.scanForClosingTag=function(e,t,i,r){return f(new n(e,t.line,t.ch,r?{from:0,to:r}:null),i)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define("addon/edit/closetag.js",["../../lib/codemirror","../fold/xml-fold"],e):e(CodeMirror)}(function(e){function t(t){if(t.getOption("disableInput"))return e.Pass;for(var n=t.listSelections(),i=[],s=t.getOption("autoCloseTags"),c=0;cf.ch&&(v=v.slice(0,v.length-u.end+f.ch));var b=v.toLowerCase();if(!v||"string"==u.type&&(u.end!=f.ch||!/[\"\']/.test(u.string.charAt(u.string.length-1))||1==u.string.length)||"tag"==u.type&&"closeTag"==h.type||u.string.indexOf("/")==u.string.length-1||g&&r(g,b)>-1||o(t,v,f,h,!0))return e.Pass;var x="object"==typeof s&&s.emptyTags;if(x&&r(x,v)>-1)i[c]={text:"/>",newPos:e.Pos(f.line,f.ch+2)};else{var y=p&&r(p,b)>-1;i[c]={indent:y,text:">"+(y?"\n\n":"")+"",newPos:y?e.Pos(f.line+1,0):e.Pos(f.line,f.ch+1)}}}for(var C="object"==typeof s&&s.dontIndentOnAutoClose,c=n.length-1;c>=0;c--){var k=i[c];t.replaceRange(k.text,n[c].head,n[c].anchor,"+insert");var L=t.listSelections().slice(0);L[c]={head:k.newPos,anchor:k.newPos},t.setSelections(L),!C&&k.indent&&(t.indentLine(k.newPos.line,null,!0),t.indentLine(k.newPos.line+1,null,!0))}}function n(t,n){for(var i=t.listSelections(),r=[],a=n?"/":""!=t.getLine(f.line).charAt(u.end)&&(m+=">"),r[c]=m}if(t.replaceSelections(r),i=t.listSelections(),!s)for(var c=0;c'"]=function(e){return t(e)}),n.addKeyMap(a)}});var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],l=["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"];e.commands.closeTag=function(e){return n(e)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/edit/matchbrackets.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e){return e&&e.bracketRegex||/[(){}[\]]/}function n(e,n,r){var o=e.getLineHandle(n.line),a=n.ch-1,c=r&&r.afterCursor;null==c&&(c=/(^| )cm-fat-cursor($| )/.test(e.getWrapperElement().className));var f=t(r),u=!c&&a>=0&&f.test(o.text.charAt(a))&&s[o.text.charAt(a)]||f.test(o.text.charAt(a+1))&&s[o.text.charAt(++a)];if(!u)return null;var d=">"==u.charAt(1)?1:-1;if(r&&r.strict&&d>0!=(a==n.ch))return null;var h=e.getTokenTypeAt(l(n.line,a+1)),m=i(e,l(n.line,a+(d>0?1:0)),d,h||null,r);return null==m?null:{from:l(n.line,a),to:m&&m.pos,match:m&&m.ch==u.charAt(0),forward:d>0}}function i(e,n,i,r,o){for(var a=o&&o.maxScanLineLength||1e4,c=o&&o.maxScanLines||1e3,f=[],u=t(o),d=i>0?Math.min(n.line+c,e.lastLine()+1):Math.max(e.firstLine()-1,n.line-c),h=n.line;h!=d;h+=i){var m=e.getLine(h);if(m){var g=i>0?0:m.length-1,p=i>0?m.length:-1;if(!(m.length>a))for(h==n.line&&(g=n.ch-(i<0?1:0));g!=p;g+=i){var v=m.charAt(g);if(u.test(v)&&(void 0===r||e.getTokenTypeAt(l(h,g+1))==r)){var b=s[v];if(b&&">"==b.charAt(1)==i>0)f.push(v);else{if(!f.length)return{pos:l(h,g),ch:v};f.pop()}}}}}return h-i!=(i>0?e.lastLine():e.firstLine())&&null}function r(e,t,i){for(var r=e.state.matchBrackets.maxHighlightLineLength||1e3,o=[],s=e.listSelections(),c=0;c",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};e.defineOption("matchBrackets",!1,function(t,n,i){i&&i!=e.Init&&(t.off("cursorActivity",o),t.state.matchBrackets&&t.state.matchBrackets.currentlyHighlighted&&(t.state.matchBrackets.currentlyHighlighted(),t.state.matchBrackets.currentlyHighlighted=null)),n&&(t.state.matchBrackets="object"==typeof n?n:{},t.on("cursorActivity",o))}),e.defineExtension("matchBrackets",function(){r(this,!0)}),e.defineExtension("findMatchingBracket",function(e,t,i){return(i||"boolean"==typeof t)&&(i?(i.strict=t,t=i):t=t?{strict:!0}:null),n(this,e,t)}),e.defineExtension("scanForBracket",function(e,t,n,r){return i(this,e,t,n,r)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define("addon/edit/matchtags.js",["../../lib/codemirror","../fold/xml-fold"],e):e(CodeMirror)}(function(e){"use strict";function t(e){e.state.tagHit&&e.state.tagHit.clear(),e.state.tagOther&&e.state.tagOther.clear(),e.state.tagHit=e.state.tagOther=null}function n(n){n.state.failedTagMatch=!1,n.operation(function(){if(t(n),!n.somethingSelected()){var i=n.getCursor(),r=n.getViewport();r.from=Math.min(r.from,i.line),r.to=Math.max(i.line+1,r.to);var o=e.findMatchingTag(n,i,r);if(o){if(n.state.matchBothTags){var a="open"==o.at?o.open:o.close;a&&(n.state.tagHit=n.markText(a.from,a.to,{className:"CodeMirror-matchingtag"}))}var l="close"==o.at?o.open:o.close;l?n.state.tagOther=n.markText(l.from,l.to,{className:"CodeMirror-matchingtag"}):n.state.failedTagMatch=!0}}})}function i(e){e.state.failedTagMatch&&n(e)}e.defineOption("matchTags",!1,function(r,o,a){a&&a!=e.Init&&(r.off("cursorActivity",n),r.off("viewportChange",i),t(r)),o&&(r.state.matchBothTags="object"==typeof o&&o.bothTags,r.on("cursorActivity",n),r.on("viewportChange",i),n(r))}),e.commands.toMatchingTag=function(t){var n=e.findMatchingTag(t,t.getCursor());if(n){var i="close"==n.at?n.open:n.close;i&&t.extendSelection(i.to,i.from)}}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/edit/trailingspace.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineOption("showTrailingSpace",!1,function(t,n,i){i==e.Init&&(i=!1),i&&!n?t.removeOverlay("trailingspace"):!i&&n&&t.addOverlay({token:function(e){for(var t=e.string.length,n=t;n&&/\s/.test(e.string.charAt(n-1));--n);return n>e.pos?(e.pos=n,null):(e.pos=t,"trailingspace")},name:"trailingspace"})})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/foldcode",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(t,r,o,a){function l(e){var n=s(t,r);if(!n||n.to.line-n.from.linet.firstLine();)r=e.Pos(r.line-1,0),f=l(!1);if(f&&!f.cleared&&"unfold"!==a){var u=n(t,o);e.on(u,"mousedown",function(t){d.clear(),e.e_preventDefault(t)});var d=t.markText(f.from,f.to,{replacedWith:u,clearOnEnter:i(t,o,"clearOnEnter"),__isFold:!0});d.on("clear",function(n,i){e.signal(t,"unfold",t,n,i)}),e.signal(t,"fold",t,f.from,f.to)}}function n(e,t){var n=i(e,t,"widget");if("string"==typeof n){var r=document.createTextNode(n);n=document.createElement("span"),n.appendChild(r),n.className="CodeMirror-foldmarker"}else n&&(n=n.cloneNode(!0));return n}function i(e,t,n){if(t&&void 0!==t[n])return t[n];var i=e.options.foldOptions;return i&&void 0!==i[n]?i[n]:r[n]}e.newFoldFunction=function(e,n){return function(i,r){t(i,r,{rangeFinder:e,widget:n})}},e.defineExtension("foldCode",function(e,n,i){t(this,e,n,i)}),e.defineExtension("isFolded",function(e){for(var t=this.findMarksAt(e),n=0;n=l&&(n=r(o.indicatorOpen))}e.setGutterMarker(t,o.gutter,n),++a})}function a(e){var t=e.getViewport(),n=e.state.foldGutter;n&&(e.operation(function(){o(e,t.from,t.to)}),n.from=t.from,n.to=t.to)}function l(e,t,n){var r=e.state.foldGutter;if(r){var o=r.options;if(n==o.gutter){var a=i(e,t);a?a.clear():e.foldCode(u(t,0),o.rangeFinder)}}}function s(e){var t=e.state.foldGutter;if(t){var n=t.options;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){a(e)},n.foldOnChangeTimeSpan||600)}}function c(e){var t=e.state.foldGutter;if(t){var n=t.options;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){var n=e.getViewport();t.from==t.to||n.from-t.to>20||t.from-n.to>20?a(e):e.operation(function(){n.fromt.to&&(o(e,t.to,n.to),t.to=n.to)})},n.updateViewportTimeSpan||400)}}function f(e,t){var n=e.state.foldGutter;if(n){var i=t.line;i>=n.from&&it.lastLine())return null;var i=t.getTokenAt(e.Pos(n,1));if(/\S/.test(i.string)||(i=t.getTokenAt(e.Pos(n,i.end+1))),"keyword"!=i.type||"import"!=i.string)return null;for(var r=n,o=Math.min(t.lastLine(),n+10);r<=o;++r){var a=t.getLine(r),l=a.indexOf(";");if(-1!=l)return{startCh:i.end,end:e.Pos(r,l)}}}var r,o=n.line,a=i(o);if(!a||i(o-1)||(r=i(o-2))&&r.end.line==o-1)return null;for(var l=a.end;;){var s=i(l.line+1);if(null==s)break;l=s.end}return{from:t.clipPos(e.Pos(o,a.startCh+1)),to:l}}),e.registerHelper("fold","include",function(t,n){function i(n){if(nt.lastLine())return null;var i=t.getTokenAt(e.Pos(n,1));return/\S/.test(i.string)||(i=t.getTokenAt(e.Pos(n,i.end+1))),"meta"==i.type&&"#include"==i.string.slice(0,8)?i.start+8:void 0}var r=n.line,o=i(r);if(null==o||null!=i(r-1))return null;for(var a=r;;){if(null==i(a+1))break;++a}return{from:e.Pos(r,o+1),to:t.clipPos(e.Pos(a))}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/comment-fold.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerGlobalHelper("fold","comment",function(e){return e.blockCommentStart&&e.blockCommentEnd},function(t,n){var i=t.getModeAt(n),r=i.blockCommentStart,o=i.blockCommentEnd;if(r&&o){for(var a,l=n.line,s=t.getLine(l),c=n.ch,f=0;;){var u=c<=0?-1:s.lastIndexOf(r,c-1);if(-1!=u){if(1==f&&ur))break;o=a}}return o?{from:e.Pos(i.line,n.getLine(i.line).length),to:e.Pos(o,n.getLine(o).length)}:void 0}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/format/autoFormatAll.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineExtension("autoFormatAll",function(t,n){function i(){c+="\n",u=!0,++f}for(var r=this,o=r.getMode(),a=r.getRange(t,n).split("\n"),l=e.copyState(o,r.getTokenAt(t).state),s=r.getOption("tabSize"),c="",f=0,u=0==t.ch,d=0;dn&&(o+=i(e.substring(n,r[a].start)),n=r[a].start),r[a].start<=n&&r[a].end>=n&&(o+=e.substring(n,r[a].end),n=r[a].end);n")&&"open"==this.tagType){this.tagType="";var c=this.isXML?"[^<]*?":"";return RegExp("^"+c+"","i").test(n)?(this.noBreak=!1,this.isXML||(this.tagName=""),!1):(a=this.noBreak,this.noBreak=!1,!a)}if(0==t.indexOf("")&&"close"==this.tagType)return this.tagType="",0==n.indexOf("<")&&(l=n.match(/^<\/?\s*?([\w]+?)(\s|>)/i),s=null!=l?l[1].toLowerCase():"",-1==("|"+o+"|").indexOf("|"+s+"|"))?(this.noBreak=!1,!0):(a=this.noBreak,this.noBreak=!1,!a)}return 0==n.indexOf("<")&&(this.noBreak=!1,this.isXML&&""!=this.tagName?(this.tagName="",!1):(l=n.match(/^<\/?\s*?([\w]+?)(\s|>)/i),s=null!=l?l[1].toLowerCase():"",-1==("|"+o+"|").indexOf("|"+s+"|")))}}),e.defineExtension("commentRange",function(t,n,i){var r=this,o=e.innerMode(r.getMode(),r.getTokenAt(n).state).mode;r.operation(function(){if(t)r.replaceRange(o.commentEnd,i),r.replaceRange(o.commentStart,n),r.setSelection(n,{line:i.line,ch:i.ch+o.commentStart.length+o.commentEnd.length}),n.line==i.line&&n.ch==i.ch&&r.setCursor(n.line,n.ch+o.commentStart.length);else{var e=r.getRange(n,i),a=e.indexOf(o.commentStart),l=e.lastIndexOf(o.commentEnd);a>-1&&l>-1&&l>a&&(e=e.substr(0,a)+e.substring(a+o.commentStart.length,l)+e.substr(l+o.commentEnd.length)),r.replaceRange(e,n,i),r.setSelection(n,{line:i.line,ch:i.ch-o.commentStart.length-o.commentEnd.length})}})}),e.defineExtension("autoIndentRange",function(e,t){var n=this;this.operation(function(){for(var i=e.line;i<=t.line;i++)n.indentLine(i,"smart")})}),e.defineExtension("autoFormatRange",function(t,n){function i(){c+="\n",u=!0,++f}for(var r=this,o=r.getMode(),a=r.getRange(t,n).split("\n"),l=e.copyState(o,r.getTokenAt(t).state),s=r.getOption("tabSize"),c="",f=0,u=0==t.ch,d=0;dc);f++){var u=e.getLine(s++);a=null==a?u:a+"\n"+u}l*=2,t.lastIndex=o.ch;var d=t.exec(a);if(d){var h=a.slice(0,d.index).split("\n"),m=d[0].split("\n"),p=o.line+h.length-1,v=h[h.length-1].length;return{from:g(p,v),to:g(p+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:d}}}}function a(e,t){for(var n,i=0;;){t.lastIndex=i;var r=t.exec(e);if(!r)return n;if(n=r,(i=n.index+(n[0].length||1))==e.length)return n}}function l(e,t,i){t=n(t,"g");for(var r=i.line,o=i.ch,l=e.firstLine();r>=l;r--,o=-1){var s=e.getLine(r);o>-1&&(s=s.slice(0,o));var c=a(s,t);if(c)return{from:g(r,c.index),to:g(r,c.index+c[0].length),match:c}}}function s(e,t,i){t=n(t,"gm");for(var r,o=1,l=i.line,s=e.firstLine();l>=s;){for(var c=0;c>1,l=i(e.slice(0,a)).length;if(l==n)return a;l>n?o=a:r=a+1}}function f(e,t,n,i){if(!t.length)return null;var r=i?h:m,o=r(t).split(/\r|\n\r?/);e:for(var a=n.line,l=n.ch,s=e.lastLine()+1-o.length;a<=s;a++,l=0){var f=e.getLine(a).slice(l),u=r(f);if(1==o.length){var d=u.indexOf(o[0]);if(-1==d)continue e;var n=c(f,u,d,r)+l;return{from:g(a,c(f,u,d,r)+l),to:g(a,c(f,u,d+o[0].length,r)+l)}}var p=u.length-o[0].length;if(u.slice(p)==o[0]){for(var v=1;v=s;a--,l=-1){var f=e.getLine(a);l>-1&&(f=f.slice(0,l));var u=r(f);if(1==o.length){var d=u.lastIndexOf(o[0]);if(-1==d)continue e;return{from:g(a,c(f,u,d,r)),to:g(a,c(f,u,d+o[0].length,r))}}var p=o[o.length-1];if(u.slice(0,p.length)==p){for(var v=1,n=a-o.length+1;v0);)i.push({anchor:r.from(),head:r.to()});i.length&&this.setSelections(i,0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/scroll/annotatescrollbar",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){function n(e){clearTimeout(i.doRedraw),i.doRedraw=setTimeout(function(){i.redraw()},e)}this.cm=e,this.options=t,this.buttonHeight=t.scrollButtonHeight||e.getOption("scrollButtonHeight"),this.annotations=[],this.doRedraw=this.doUpdate=null,this.div=e.getWrapperElement().appendChild(document.createElement("div")),this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none",this.computeScale();var i=this;e.on("refresh",this.resizeHandler=function(){clearTimeout(i.doUpdate),i.doUpdate=setTimeout(function(){i.computeScale()&&n(20)},100)}),e.on("markerAdded",this.resizeHandler),e.on("markerCleared",this.resizeHandler),!1!==t.listenForChanges&&e.on("change",this.changeHandler=function(){n(250)})}e.defineExtension("annotateScrollbar",function(e){return"string"==typeof e&&(e={className:e}),new t(this,e)}),e.defineOption("scrollButtonHeight",0),t.prototype.computeScale=function(){var e=this.cm,t=(e.getWrapperElement().clientHeight-e.display.barHeight-2*this.buttonHeight)/e.getScrollerElement().scrollHeight;if(t!=this.hScale)return this.hScale=t,!0},t.prototype.update=function(e){this.annotations=e,this.redraw()},t.prototype.redraw=function(e){function t(e,t){return s!=e.line&&(s=e.line,c=n.getLineHandle(s)),c.widgets&&c.widgets.length||a&&c.height>l?n.charCoords(e,"local")[t?"top":"bottom"]:n.heightAtLine(c,"local")+(t?0:c.height)}!1!==e&&this.computeScale();var n=this.cm,i=this.hScale,r=document.createDocumentFragment(),o=this.annotations,a=n.getOption("lineWrapping"),l=a&&1.5*n.defaultTextHeight(),s=null,c=null,f=n.lastLine();if(n.display.barWidth)for(var u,d=0;df)){for(var m=u||t(h.from,!0)*i,g=t(h.to,!1)*i;df)&&!((u=t(o[d+1].from,!0)*i)>g+.9);)h=o[++d],g=t(h.to,!1)*i;if(g!=m){var p=Math.max(g-m,3),v=r.appendChild(document.createElement("div"));v.style.cssText="position: absolute; right: 0px; width: "+Math.max(n.display.barWidth-1,2)+"px; top: "+(m+this.buttonHeight)+"px; height: "+p+"px",v.className=this.options.className,h.id&&v.setAttribute("annotation-id",h.id)}}}this.div.textContent="",this.div.appendChild(r)},t.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler),this.cm.off("markerAdded",this.resizeHandler),this.cm.off("markerCleared",this.resizeHandler),this.changeHandler&&this.cm.off("change",this.changeHandler),this.div.parentNode.removeChild(this.div)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define("addon/search/matchesonscrollbar",["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,n,i){this.cm=e,this.options=i;var r={listenForChanges:!1};for(var o in i)r[o]=i[o];r.className||(r.className="CodeMirror-search-match"),this.annotation=e.annotateScrollbar(r),this.query=t,this.caseFold=n,this.gap={from:e.firstLine(),to:e.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var a=this;e.on("change",this.changeHandler=function(e,t){a.onChange(t)})}function n(e,t,n){return e<=t?e:Math.max(t,e+n)}e.defineExtension("showMatchesOnScrollbar",function(e,n,i){return"string"==typeof i&&(i={className:i}),i||(i={}),new t(this,e,n,i)});t.prototype.findMatches=function(){if(this.gap){for(var t=0;t=this.gap.to)break;n.to.line>=this.gap.from&&this.matches.splice(t--,1)}for(var i=this.cm.getSearchCursor(this.query,e.Pos(this.gap.from,0),{caseFold:this.caseFold,multiline:this.options.multiline}),r=this.options&&this.options.maxMatches||1e3;i.findNext();){var n={from:i.from(),to:i.to()};if(n.from.line>=this.gap.to)break;if(this.matches.splice(t++,0,n),this.matches.length>r)break}this.gap=null}},t.prototype.onChange=function(t){var i=t.from.line,r=e.changeEnd(t).line,o=r-t.to.line;if(this.gap?(this.gap.from=Math.min(n(this.gap.from,i,o),t.from.line),this.gap.to=Math.max(n(this.gap.to,i,o),t.from.line)):this.gap={from:t.from.line,to:r+1},o)for(var a=0;a=t.options.minChars&&o(e,d,!1,t.options.style)}})}function s(e,t,n){if(null!==e.getRange(t,n).match(/^\w+$/)){if(t.ch>0){var i={line:t.line,ch:t.ch-1},r=e.getRange(i,t);if(null===r.match(/\W/))return!1}if(n.ch-1?r+t.length:r}var o=t.exec(n?e.slice(n):e);return o?o.index+n+(i?o[0].length:0):-1}var i=Array.prototype.slice.call(arguments,1);return{startState:function(){return{outer:e.startState(t),innerActive:null,inner:null}},copyState:function(n){return{outer:e.copyState(t,n.outer),innerActive:n.innerActive,inner:n.innerActive&&e.copyState(n.innerActive.mode,n.inner)}},token:function(r,o){if(o.innerActive){var a=o.innerActive,l=r.string;if(!a.close&&r.sol())return o.innerActive=o.inner=null,this.token(r,o);var s=a.close?n(l,a.close,r.pos,a.parseDelimiters):-1;if(s==r.pos&&!a.parseDelimiters)return r.match(a.close),o.innerActive=o.inner=null,a.delimStyle&&a.delimStyle+" "+a.delimStyle+"-close";s>-1&&(r.string=l.slice(0,s));var c=a.mode.token(r,o.inner);return s>-1&&(r.string=l),s==r.pos&&a.parseDelimiters&&(o.innerActive=o.inner=null),a.innerStyle&&(c=c?c+" "+a.innerStyle:a.innerStyle),c}for(var f=1/0,l=r.string,u=0;u