diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index 551302b209340..c6fac8df2b7c5 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -1427,6 +1427,9 @@ public function deleteUnexistingFiles() '/administrator/templates/isis/js/bootstrap.min.js', '/media/system/js/permissions.min.js', '/libraries/platform.php', + // Joomla! 3.6.3 + '/media/editors/codemirror/mode/jade/jade.js', + '/media/editors/codemirror/mode/jade/jade.min.js', ); // TODO There is an issue while deleting folders using the ftp mode @@ -1523,6 +1526,8 @@ public function deleteUnexistingFiles() // Joomla 3.6 '/libraries/simplepie/idn', '/libraries/simplepie', + // Joomla! 3.6.3 + '/media/editors/codemirror/mode/jade', ); jimport('joomla.filesystem.file'); diff --git a/media/editors/codemirror/addon/comment/comment.js b/media/editors/codemirror/addon/comment/comment.js index 2c4f975d08f59..2f2f071df974d 100644 --- a/media/editors/codemirror/addon/comment/comment.js +++ b/media/editors/codemirror/addon/comment/comment.js @@ -140,7 +140,7 @@ var line = self.getLine(i); var found = line.indexOf(lineString); if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1; - if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment; + if (found == -1 && nonWS.test(line)) break lineComment; if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment; lines.push(line); } diff --git a/media/editors/codemirror/addon/comment/comment.min.js b/media/editors/codemirror/addon/comment/comment.min.js index 30d5f86a9b6fa..8f1bffcddf91a 100644 --- a/media/editors/codemirror/addon/comment/comment.min.js +++ b/media/editors/codemirror/addon/comment/comment.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){var b=a.search(e);return-1==b?0:b}function c(a,b,c){return/\bstring\b/.test(a.getTokenTypeAt(f(b.line,0)))&&!/^[\'\"`]/.test(c)}var d={},e=/[^\s\u00a0]/,f=a.Pos;a.commands.toggleComment=function(a){a.toggleComment()},a.defineExtension("toggleComment",function(a){a||(a=d);for(var b=this,c=1/0,e=this.listSelections(),g=null,h=e.length-1;h>=0;h--){var i=e[h].from(),j=e[h].to();i.line>=c||(j.line>=c&&(j=f(c,0)),c=i.line,null==g?b.uncomment(i,j,a)?g="un":(b.lineComment(i,j,a),g="line"):"un"==g?b.uncomment(i,j,a):b.lineComment(i,j,a))}}),a.defineExtension("lineComment",function(a,g,h){h||(h=d);var i=this,j=i.getModeAt(a),k=i.getLine(a.line);if(null!=k&&!c(i,a,k)){var l=h.lineComment||j.lineComment;if(!l)return void((h.blockCommentStart||j.blockCommentStart)&&(h.fullLines=!0,i.blockComment(a,g,h)));var m=Math.min(0!=g.ch||g.line==a.line?g.line+1:g.line,i.lastLine()+1),n=null==h.padding?" ":h.padding,o=h.commentBlankLines||a.line==g.line;i.operation(function(){if(h.indent){for(var c=null,d=a.line;m>d;++d){var g=i.getLine(d),j=g.slice(0,b(g));(null==c||c.length>j.length)&&(c=j)}for(var d=a.line;m>d;++d){var g=i.getLine(d),k=c.length;(o||e.test(g))&&(g.slice(0,k)!=c&&(k=b(g)),i.replaceRange(c+l+n,f(d,0),f(d,k)))}}else for(var d=a.line;m>d;++d)(o||e.test(i.getLine(d)))&&i.replaceRange(l+n,f(d,0))})}}),a.defineExtension("blockComment",function(a,b,c){c||(c=d);var g=this,h=g.getModeAt(a),i=c.blockCommentStart||h.blockCommentStart,j=c.blockCommentEnd||h.blockCommentEnd;if(!i||!j)return void((c.lineComment||h.lineComment)&&0!=c.fullLines&&g.lineComment(a,b,c));var k=Math.min(b.line,g.lastLine());k!=a.line&&0==b.ch&&e.test(g.getLine(k))&&--k;var l=null==c.padding?" ":c.padding;a.line>k||g.operation(function(){if(0!=c.fullLines){var d=e.test(g.getLine(k));g.replaceRange(l+j,f(k)),g.replaceRange(i+l,f(a.line,0));var m=c.blockCommentLead||h.blockCommentLead;if(null!=m)for(var n=a.line+1;k>=n;++n)(n!=k||d)&&g.replaceRange(m+l,f(n,0))}else g.replaceRange(j,b),g.replaceRange(i,a)})}),a.defineExtension("uncomment",function(a,b,c){c||(c=d);var g,h=this,i=h.getModeAt(a),j=Math.min(0!=b.ch||b.line==a.line?b.line:b.line-1,h.lastLine()),k=Math.min(a.line,j),l=c.lineComment||i.lineComment,m=[],n=null==c.padding?" ":c.padding;a:if(l){for(var o=k;j>=o;++o){var p=h.getLine(o),q=p.indexOf(l);if(q>-1&&!/comment/.test(h.getTokenTypeAt(f(o,q+1)))&&(q=-1),-1==q&&(o!=j||o==k)&&e.test(p))break a;if(q>-1&&e.test(p.slice(0,q)))break a;m.push(p)}if(h.operation(function(){for(var a=k;j>=a;++a){var b=m[a-k],c=b.indexOf(l),d=c+l.length;0>c||(b.slice(d,d+n.length)==n&&(d+=n.length),g=!0,h.replaceRange("",f(a,c),f(a,d)))}}),g)return!0}var r=c.blockCommentStart||i.blockCommentStart,s=c.blockCommentEnd||i.blockCommentEnd;if(!r||!s)return!1;var t=c.blockCommentLead||i.blockCommentLead,u=h.getLine(k),v=j==k?u:h.getLine(j),w=u.indexOf(r),x=v.lastIndexOf(s);if(-1==x&&k!=j&&(v=h.getLine(--j),x=v.lastIndexOf(s)),-1==w||-1==x||!/comment/.test(h.getTokenTypeAt(f(k,w+1)))||!/comment/.test(h.getTokenTypeAt(f(j,x+1))))return!1;var y=u.lastIndexOf(r,a.ch),z=-1==y?-1:u.slice(0,a.ch).indexOf(s,y+r.length);if(-1!=y&&-1!=z&&z+s.length!=a.ch)return!1;z=v.indexOf(s,b.ch);var A=v.slice(b.ch).lastIndexOf(r,z-b.ch);return y=-1==z||-1==A?-1:b.ch+A,-1!=z&&-1!=y&&y!=b.ch?!1:(h.operation(function(){h.replaceRange("",f(j,x-(n&&v.slice(x-n.length,x)==n?n.length:0)),f(j,x+s.length));var a=w+r.length;if(n&&u.slice(a,a+n.length)==n&&(a+=n.length),h.replaceRange("",f(k,w),f(k,a)),t)for(var b=k+1;j>=b;++b){var c=h.getLine(b),d=c.indexOf(t);if(-1!=d&&!e.test(c.slice(0,d))){var g=d+t.length;n&&c.slice(g,g+n.length)==n&&(g+=n.length),h.replaceRange("",f(b,d),f(b,g))}}}),!0)})}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){var b=a.search(e);return-1==b?0:b}function c(a,b,c){return/\bstring\b/.test(a.getTokenTypeAt(f(b.line,0)))&&!/^[\'\"`]/.test(c)}var d={},e=/[^\s\u00a0]/,f=a.Pos;a.commands.toggleComment=function(a){a.toggleComment()},a.defineExtension("toggleComment",function(a){a||(a=d);for(var b=this,c=1/0,e=this.listSelections(),g=null,h=e.length-1;h>=0;h--){var i=e[h].from(),j=e[h].to();i.line>=c||(j.line>=c&&(j=f(c,0)),c=i.line,null==g?b.uncomment(i,j,a)?g="un":(b.lineComment(i,j,a),g="line"):"un"==g?b.uncomment(i,j,a):b.lineComment(i,j,a))}}),a.defineExtension("lineComment",function(a,g,h){h||(h=d);var i=this,j=i.getModeAt(a),k=i.getLine(a.line);if(null!=k&&!c(i,a,k)){var l=h.lineComment||j.lineComment;if(!l)return void((h.blockCommentStart||j.blockCommentStart)&&(h.fullLines=!0,i.blockComment(a,g,h)));var m=Math.min(0!=g.ch||g.line==a.line?g.line+1:g.line,i.lastLine()+1),n=null==h.padding?" ":h.padding,o=h.commentBlankLines||a.line==g.line;i.operation(function(){if(h.indent){for(var c=null,d=a.line;m>d;++d){var g=i.getLine(d),j=g.slice(0,b(g));(null==c||c.length>j.length)&&(c=j)}for(var d=a.line;m>d;++d){var g=i.getLine(d),k=c.length;(o||e.test(g))&&(g.slice(0,k)!=c&&(k=b(g)),i.replaceRange(c+l+n,f(d,0),f(d,k)))}}else for(var d=a.line;m>d;++d)(o||e.test(i.getLine(d)))&&i.replaceRange(l+n,f(d,0))})}}),a.defineExtension("blockComment",function(a,b,c){c||(c=d);var g=this,h=g.getModeAt(a),i=c.blockCommentStart||h.blockCommentStart,j=c.blockCommentEnd||h.blockCommentEnd;if(!i||!j)return void((c.lineComment||h.lineComment)&&0!=c.fullLines&&g.lineComment(a,b,c));var k=Math.min(b.line,g.lastLine());k!=a.line&&0==b.ch&&e.test(g.getLine(k))&&--k;var l=null==c.padding?" ":c.padding;a.line>k||g.operation(function(){if(0!=c.fullLines){var d=e.test(g.getLine(k));g.replaceRange(l+j,f(k)),g.replaceRange(i+l,f(a.line,0));var m=c.blockCommentLead||h.blockCommentLead;if(null!=m)for(var n=a.line+1;k>=n;++n)(n!=k||d)&&g.replaceRange(m+l,f(n,0))}else g.replaceRange(j,b),g.replaceRange(i,a)})}),a.defineExtension("uncomment",function(a,b,c){c||(c=d);var g,h=this,i=h.getModeAt(a),j=Math.min(0!=b.ch||b.line==a.line?b.line:b.line-1,h.lastLine()),k=Math.min(a.line,j),l=c.lineComment||i.lineComment,m=[],n=null==c.padding?" ":c.padding;a:if(l){for(var o=k;j>=o;++o){var p=h.getLine(o),q=p.indexOf(l);if(q>-1&&!/comment/.test(h.getTokenTypeAt(f(o,q+1)))&&(q=-1),-1==q&&e.test(p))break a;if(q>-1&&e.test(p.slice(0,q)))break a;m.push(p)}if(h.operation(function(){for(var a=k;j>=a;++a){var b=m[a-k],c=b.indexOf(l),d=c+l.length;0>c||(b.slice(d,d+n.length)==n&&(d+=n.length),g=!0,h.replaceRange("",f(a,c),f(a,d)))}}),g)return!0}var r=c.blockCommentStart||i.blockCommentStart,s=c.blockCommentEnd||i.blockCommentEnd;if(!r||!s)return!1;var t=c.blockCommentLead||i.blockCommentLead,u=h.getLine(k),v=j==k?u:h.getLine(j),w=u.indexOf(r),x=v.lastIndexOf(s);if(-1==x&&k!=j&&(v=h.getLine(--j),x=v.lastIndexOf(s)),-1==w||-1==x||!/comment/.test(h.getTokenTypeAt(f(k,w+1)))||!/comment/.test(h.getTokenTypeAt(f(j,x+1))))return!1;var y=u.lastIndexOf(r,a.ch),z=-1==y?-1:u.slice(0,a.ch).indexOf(s,y+r.length);if(-1!=y&&-1!=z&&z+s.length!=a.ch)return!1;z=v.indexOf(s,b.ch);var A=v.slice(b.ch).lastIndexOf(r,z-b.ch);return y=-1==z||-1==A?-1:b.ch+A,-1!=z&&-1!=y&&y!=b.ch?!1:(h.operation(function(){h.replaceRange("",f(j,x-(n&&v.slice(x-n.length,x)==n?n.length:0)),f(j,x+s.length));var a=w+r.length;if(n&&u.slice(a,a+n.length)==n&&(a+=n.length),h.replaceRange("",f(k,w),f(k,a)),t)for(var b=k+1;j>=b;++b){var c=h.getLine(b),d=c.indexOf(t);if(-1!=d&&!e.test(c.slice(0,d))){var g=d+t.length;n&&c.slice(g,g+n.length)==n&&(g+=n.length),h.replaceRange("",f(b,d),f(b,g))}}}),!0)})}); \ No newline at end of file diff --git a/media/editors/codemirror/addon/edit/matchbrackets.js b/media/editors/codemirror/addon/edit/matchbrackets.js index 70e1ae18c7481..76754ed557fe0 100644 --- a/media/editors/codemirror/addon/edit/matchbrackets.js +++ b/media/editors/codemirror/addon/edit/matchbrackets.js @@ -102,8 +102,10 @@ } CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { - if (old && old != CodeMirror.Init) + if (old && old != CodeMirror.Init) { cm.off("cursorActivity", doMatchBrackets); + if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;} + } if (val) { cm.state.matchBrackets = typeof val == "object" ? val : {}; cm.on("cursorActivity", doMatchBrackets); diff --git a/media/editors/codemirror/addon/edit/matchbrackets.min.js b/media/editors/codemirror/addon/edit/matchbrackets.min.js index 7a0e0c00c73b4..1b9421ea5d718 100644 --- a/media/editors/codemirror/addon/edit/matchbrackets.min.js +++ b/media/editors/codemirror/addon/edit/matchbrackets.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b,d,e){var f=a.getLineHandle(b.line),i=b.ch-1,j=i>=0&&h[f.text.charAt(i)]||h[f.text.charAt(++i)];if(!j)return null;var k=">"==j.charAt(1)?1:-1;if(d&&k>0!=(i==b.ch))return null;var l=a.getTokenTypeAt(g(b.line,i+1)),m=c(a,g(b.line,i+(k>0?1:0)),k,l||null,e);return null==m?null:{from:g(b.line,i),to:m&&m.pos,match:m&&m.ch==j.charAt(0),forward:k>0}}function c(a,b,c,d,e){for(var f=e&&e.maxScanLineLength||1e4,i=e&&e.maxScanLines||1e3,j=[],k=e&&e.bracketRegex?e.bracketRegex:/[(){}[\]]/,l=c>0?Math.min(b.line+i,a.lastLine()+1):Math.max(a.firstLine()-1,b.line-i),m=b.line;m!=l;m+=c){var n=a.getLine(m);if(n){var o=c>0?0:n.length-1,p=c>0?n.length:-1;if(!(n.length>f))for(m==b.line&&(o=b.ch-(0>c?1:0));o!=p;o+=c){var q=n.charAt(o);if(k.test(q)&&(void 0===d||a.getTokenTypeAt(g(m,o+1))==d)){var r=h[q];if(">"==r.charAt(1)==c>0)j.push(q);else{if(!j.length)return{pos:g(m,o),ch:q};j.pop()}}}}}return m-c==(c>0?a.lastLine():a.firstLine())?!1:null}function d(a,c,d){for(var e=a.state.matchBrackets.maxHighlightLineLength||1e3,h=[],i=a.listSelections(),j=0;j",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},i=null;a.defineOption("matchBrackets",!1,function(b,c,d){d&&d!=a.Init&&b.off("cursorActivity",e),c&&(b.state.matchBrackets="object"==typeof c?c:{},b.on("cursorActivity",e))}),a.defineExtension("matchBrackets",function(){d(this,!0)}),a.defineExtension("findMatchingBracket",function(a,c,d){return b(this,a,c,d)}),a.defineExtension("scanForBracket",function(a,b,d,e){return c(this,a,b,d,e)})}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b,d,e){var f=a.getLineHandle(b.line),i=b.ch-1,j=i>=0&&h[f.text.charAt(i)]||h[f.text.charAt(++i)];if(!j)return null;var k=">"==j.charAt(1)?1:-1;if(d&&k>0!=(i==b.ch))return null;var l=a.getTokenTypeAt(g(b.line,i+1)),m=c(a,g(b.line,i+(k>0?1:0)),k,l||null,e);return null==m?null:{from:g(b.line,i),to:m&&m.pos,match:m&&m.ch==j.charAt(0),forward:k>0}}function c(a,b,c,d,e){for(var f=e&&e.maxScanLineLength||1e4,i=e&&e.maxScanLines||1e3,j=[],k=e&&e.bracketRegex?e.bracketRegex:/[(){}[\]]/,l=c>0?Math.min(b.line+i,a.lastLine()+1):Math.max(a.firstLine()-1,b.line-i),m=b.line;m!=l;m+=c){var n=a.getLine(m);if(n){var o=c>0?0:n.length-1,p=c>0?n.length:-1;if(!(n.length>f))for(m==b.line&&(o=b.ch-(0>c?1:0));o!=p;o+=c){var q=n.charAt(o);if(k.test(q)&&(void 0===d||a.getTokenTypeAt(g(m,o+1))==d)){var r=h[q];if(">"==r.charAt(1)==c>0)j.push(q);else{if(!j.length)return{pos:g(m,o),ch:q};j.pop()}}}}}return m-c==(c>0?a.lastLine():a.firstLine())?!1:null}function d(a,c,d){for(var e=a.state.matchBrackets.maxHighlightLineLength||1e3,h=[],i=a.listSelections(),j=0;j",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},i=null;a.defineOption("matchBrackets",!1,function(b,c,d){d&&d!=a.Init&&(b.off("cursorActivity",e),i&&(i(),i=null)),c&&(b.state.matchBrackets="object"==typeof c?c:{},b.on("cursorActivity",e))}),a.defineExtension("matchBrackets",function(){d(this,!0)}),a.defineExtension("findMatchingBracket",function(a,c,d){return b(this,a,c,d)}),a.defineExtension("scanForBracket",function(a,b,d,e){return c(this,a,b,d,e)})}); \ No newline at end of file diff --git a/media/editors/codemirror/addon/hint/javascript-hint.js b/media/editors/codemirror/addon/hint/javascript-hint.js index 7bcbf4a057db2..d7088c191b160 100644 --- a/media/editors/codemirror/addon/hint/javascript-hint.js +++ b/media/editors/codemirror/addon/hint/javascript-hint.js @@ -97,6 +97,15 @@ var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " + "if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" "); + function forAllProps(obj, callback) { + if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) { + for (var name in obj) callback(name) + } else { + for (var o = obj; o; o = Object.getPrototypeOf(o)) + Object.getOwnPropertyNames(o).forEach(callback) + } + } + function getCompletions(token, context, keywords, options) { var found = [], start = token.string, global = options && options.globalScope || window; function maybeAdd(str) { @@ -106,7 +115,7 @@ if (typeof obj == "string") forEach(stringProps, maybeAdd); else if (obj instanceof Array) forEach(arrayProps, maybeAdd); else if (obj instanceof Function) forEach(funcProps, maybeAdd); - for (var name in obj) maybeAdd(name); + forAllProps(obj, maybeAdd) } if (context && context.length) { diff --git a/media/editors/codemirror/addon/hint/javascript-hint.min.js b/media/editors/codemirror/addon/hint/javascript-hint.min.js index ed3d656323785..0baf499f679ff 100644 --- a/media/editors/codemirror/addon/hint/javascript-hint.min.js +++ b/media/editors/codemirror/addon/hint/javascript-hint.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b){for(var c=0,d=a.length;d>c;++c)b(a[c])}function c(a,b){if(!Array.prototype.indexOf){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1}return-1!=a.indexOf(b)}function d(b,c,d,e){var f=b.getCursor(),g=d(b,f);if(!/\b(?:string|comment)\b/.test(g.type)){g.state=a.innerMode(b.getMode(),g.state).state,/^[\w$_]*$/.test(g.string)?g.end>f.ch&&(g.end=f.ch,g.string=g.string.slice(0,f.ch-g.start)):g={start:f.ch,end:f.ch,string:"",state:g.state,type:"."==g.string?"property":null};for(var j=g;"property"==j.type;){if(j=d(b,i(f.line,j.start)),"."!=j.string)return;if(j=d(b,i(f.line,j.start)),!k)var k=[];k.push(j)}return{list:h(g,k,c,e),from:i(f.line,g.start),to:i(f.line,g.end)}}}function e(a,b){return d(a,m,function(a,b){return a.getTokenAt(b)},b)}function f(a,b){var c=a.getTokenAt(b);return b.ch==c.start+1&&"."==c.string.charAt(0)?(c.end=c.start,c.string=".",c.type="property"):/^\.[\w$_]*$/.test(c.string)&&(c.type="property",c.start++,c.string=c.string.replace(/\./,"")),c}function g(a,b){return d(a,n,f,b)}function h(a,d,e,f){function g(a){0!=a.lastIndexOf(m,0)||c(i,a)||i.push(a)}function h(a){"string"==typeof a?b(j,g):a instanceof Array?b(k,g):a instanceof Function&&b(l,g);for(var c in a)g(c)}var i=[],m=a.string,n=f&&f.globalScope||window;if(d&&d.length){var o,p=d.pop();for(p.type&&0===p.type.indexOf("variable")?(f&&f.additionalContext&&(o=f.additionalContext[p.string]),f&&f.useGlobalScope===!1||(o=o||n[p.string])):"string"==p.type?o="":"atom"==p.type?o=1:"function"==p.type&&(null==n.jQuery||"$"!=p.string&&"jQuery"!=p.string||"function"!=typeof n.jQuery?null!=n._&&"_"==p.string&&"function"==typeof n._&&(o=n._()):o=n.jQuery());null!=o&&d.length;)o=o[d.pop().string];null!=o&&h(o)}else{for(var q=a.state.localVars;q;q=q.next)g(q.name);for(var q=a.state.globalVars;q;q=q.next)g(q.name);f&&f.useGlobalScope===!1||h(n),b(e,g)}return i}var i=a.Pos;a.registerHelper("hint","javascript",e),a.registerHelper("hint","coffeescript",g);var j="charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight toUpperCase toLowerCase split concat match replace search".split(" "),k="length concat join splice push pop shift unshift slice reverse sort indexOf lastIndexOf every some filter forEach map reduce reduceRight ".split(" "),l="prototype apply call bind".split(" "),m="break case catch continue debugger default delete do else false finally for function if in instanceof new null return switch throw true try typeof var void while with".split(" "),n="and break catch class continue delete do else extends false finally for if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes".split(" ")}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b){for(var c=0,d=a.length;d>c;++c)b(a[c])}function c(a,b){if(!Array.prototype.indexOf){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1}return-1!=a.indexOf(b)}function d(b,c,d,e){var f=b.getCursor(),g=d(b,f);if(!/\b(?:string|comment)\b/.test(g.type)){g.state=a.innerMode(b.getMode(),g.state).state,/^[\w$_]*$/.test(g.string)?g.end>f.ch&&(g.end=f.ch,g.string=g.string.slice(0,f.ch-g.start)):g={start:f.ch,end:f.ch,string:"",state:g.state,type:"."==g.string?"property":null};for(var h=g;"property"==h.type;){if(h=d(b,j(f.line,h.start)),"."!=h.string)return;if(h=d(b,j(f.line,h.start)),!k)var k=[];k.push(h)}return{list:i(g,k,c,e),from:j(f.line,g.start),to:j(f.line,g.end)}}}function e(a,b){return d(a,n,function(a,b){return a.getTokenAt(b)},b)}function f(a,b){var c=a.getTokenAt(b);return b.ch==c.start+1&&"."==c.string.charAt(0)?(c.end=c.start,c.string=".",c.type="property"):/^\.[\w$_]*$/.test(c.string)&&(c.type="property",c.start++,c.string=c.string.replace(/\./,"")),c}function g(a,b){return d(a,o,f,b)}function h(a,b){if(Object.getOwnPropertyNames&&Object.getPrototypeOf)for(var c=a;c;c=Object.getPrototypeOf(c))Object.getOwnPropertyNames(c).forEach(b);else for(var d in a)b(d)}function i(a,d,e,f){function g(a){0!=a.lastIndexOf(n,0)||c(j,a)||j.push(a)}function i(a){"string"==typeof a?b(k,g):a instanceof Array?b(l,g):a instanceof Function&&b(m,g),h(a,g)}var j=[],n=a.string,o=f&&f.globalScope||window;if(d&&d.length){var p,q=d.pop();for(q.type&&0===q.type.indexOf("variable")?(f&&f.additionalContext&&(p=f.additionalContext[q.string]),f&&f.useGlobalScope===!1||(p=p||o[q.string])):"string"==q.type?p="":"atom"==q.type?p=1:"function"==q.type&&(null==o.jQuery||"$"!=q.string&&"jQuery"!=q.string||"function"!=typeof o.jQuery?null!=o._&&"_"==q.string&&"function"==typeof o._&&(p=o._()):p=o.jQuery());null!=p&&d.length;)p=p[d.pop().string];null!=p&&i(p)}else{for(var r=a.state.localVars;r;r=r.next)g(r.name);for(var r=a.state.globalVars;r;r=r.next)g(r.name);f&&f.useGlobalScope===!1||i(o),b(e,g)}return j}var j=a.Pos;a.registerHelper("hint","javascript",e),a.registerHelper("hint","coffeescript",g);var k="charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight toUpperCase toLowerCase split concat match replace search".split(" "),l="length concat join splice push pop shift unshift slice reverse sort indexOf lastIndexOf every some filter forEach map reduce reduceRight ".split(" "),m="prototype apply call bind".split(" "),n="break case catch continue debugger default delete do else false finally for function if in instanceof new null return switch throw true try typeof var void while with".split(" "),o="and break catch class continue delete do else extends false finally for if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes".split(" ")}); \ No newline at end of file diff --git a/media/editors/codemirror/addon/search/match-highlighter.js b/media/editors/codemirror/addon/search/match-highlighter.js index 2121de417b61d..73ba0e0537090 100644 --- a/media/editors/codemirror/addon/search/match-highlighter.js +++ b/media/editors/codemirror/addon/search/match-highlighter.js @@ -45,6 +45,7 @@ this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name] this.overlay = this.timeout = null; this.matchesonscroll = null; + this.active = false; } CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) { @@ -53,16 +54,34 @@ clearTimeout(cm.state.matchHighlighter.timeout); cm.state.matchHighlighter = null; cm.off("cursorActivity", cursorActivity); + cm.off("focus", onFocus) } if (val) { - cm.state.matchHighlighter = new State(val); - highlightMatches(cm); + var state = cm.state.matchHighlighter = new State(val); + if (cm.hasFocus()) { + state.active = true + highlightMatches(cm) + } else { + cm.on("focus", onFocus) + } cm.on("cursorActivity", cursorActivity); } }); function cursorActivity(cm) { var state = cm.state.matchHighlighter; + if (state.active || cm.hasFocus()) scheduleHighlight(cm, state) + } + + function onFocus(cm) { + var state = cm.state.matchHighlighter + if (!state.active) { + state.active = true + scheduleHighlight(cm, state) + } + } + + function scheduleHighlight(cm, state) { clearTimeout(state.timeout); state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay); } diff --git a/media/editors/codemirror/addon/search/match-highlighter.min.js b/media/editors/codemirror/addon/search/match-highlighter.min.js index 3c04b8178fb5f..2af9bd3b26715 100644 --- a/media/editors/codemirror/addon/search/match-highlighter.min.js +++ b/media/editors/codemirror/addon/search/match-highlighter.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("./matchesonscrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./matchesonscrollbar"],a):a(CodeMirror)}(function(a){"use strict";function b(a){this.options={};for(var b in j)this.options[b]=(a&&a.hasOwnProperty(b)?a:j)[b];this.overlay=this.timeout=null,this.matchesonscroll=null}function c(a){var b=a.state.matchHighlighter;clearTimeout(b.timeout),b.timeout=setTimeout(function(){f(a)},b.options.delay)}function d(a,b,c,d){var e=a.state.matchHighlighter;if(a.addOverlay(e.overlay=i(b,c,d)),e.options.annotateScrollbar&&a.showMatchesOnScrollbar){var f=c?new RegExp("\\b"+b+"\\b"):b;e.matchesonscroll=a.showMatchesOnScrollbar(f,!1,{className:"CodeMirror-selection-highlight-scrollbar"})}}function e(a){var b=a.state.matchHighlighter;b.overlay&&(a.removeOverlay(b.overlay),b.overlay=null,b.matchesonscroll&&(b.matchesonscroll.clear(),b.matchesonscroll=null))}function f(a){a.operation(function(){var b=a.state.matchHighlighter;if(e(a),!a.somethingSelected()&&b.options.showToken){for(var c=b.options.showToken===!0?/[\w$]/:b.options.showToken,f=a.getCursor(),h=a.getLine(f.line),i=f.ch,j=i;i&&c.test(h.charAt(i-1));)--i;for(;ji&&d(a,h.slice(i,j),c,b.options.style))}var k=a.getCursor("from"),l=a.getCursor("to");if(k.line==l.line&&(!b.options.wordsOnly||g(a,k,l))){var m=a.getRange(k,l);b.options.trim&&(m=m.replace(/^\s+|\s+$/g,"")),m.length>=b.options.minChars&&d(a,m,!1,b.options.style)}})}function g(a,b,c){var d=a.getRange(b,c);if(null!==d.match(/^\w+$/)){if(b.ch>0){var e={line:b.line,ch:b.ch-1},f=a.getRange(e,b);if(null===f.match(/\W/))return!1}if(c.chh&&f(a,e.slice(h,j),c,b.options.style))}var k=a.getCursor("from"),l=a.getCursor("to");if(k.line==l.line&&(!b.options.wordsOnly||i(a,k,l))){var m=a.getRange(k,l);b.options.trim&&(m=m.replace(/^\s+|\s+$/g,"")),m.length>=b.options.minChars&&f(a,m,!1,b.options.style)}})}function i(a,b,c){var d=a.getRange(b,c);if(null!==d.match(/^\w+$/)){if(b.ch>0){var e={line:b.line,ch:b.ch-1},f=a.getRange(e,b);if(null===f.match(/\W/))return!1}if(c.chb.cursorCoords(c,"window").top&&((k=d).style.opacity=.4)}))};g(b,r,j,m,function(c,e){var f=a.keyMap[b.getOption("keyMap")][a.keyName(c)];"findNext"==f||"findPrev"==f?(a.e_stop(c),l(b,d(b),e),b.execCommand(f)):("find"==f||"findPersistent"==f)&&(a.e_stop(c),m(e,c))}),f&&(l(b,i,j),n(b,c))}else h(b,r,"Search for:",j,function(a){a&&!i.query&&b.operation(function(){l(b,i,a),i.posFrom=i.posTo=b.getCursor(),n(b,c)})})}function n(b,c,e){b.operation(function(){var g=d(b),h=f(b,g.query,c?g.posFrom:g.posTo);(h.find(c)||(h=f(b,g.query,c?a.Pos(b.lastLine()):a.Pos(b.firstLine(),0)),h.find(c)))&&(b.setSelection(h.from(),h.to()),b.scrollIntoView({from:h.from(),to:h.to()},20),g.posFrom=h.from(),g.posTo=h.to(),e&&e(h.from(),h.to()))})}function o(a){a.operation(function(){var b=d(a);b.lastQuery=b.query,b.query&&(b.query=b.queryText=null,a.removeOverlay(b.overlay),b.annotate&&(b.annotate.clear(),b.annotate=null))})}function p(a,b,c){a.operation(function(){for(var d=f(a,b);d.findNext();)if("string"!=typeof b){var e=a.getRange(d.from(),d.to()).match(b);d.replace(c.replace(/\$(\d)/g,function(a,b){return e[b]}))}else d.replace(c)})}function q(a,b){if(!a.getOption("readOnly")){var c=a.getSelection()||d(a).lastQuery,e=b?"Replace all:":"Replace:";h(a,e+s,e,c,function(c){c&&(c=k(c),h(a,t,"Replace with:","",function(d){if(d=j(d),b)p(a,c,d);else{o(a);var e=f(a,c,a.getCursor("from")),g=function(){var b,j=e.from();!(b=e.findNext())&&(e=f(a,c),!(b=e.findNext())||j&&e.from().line==j.line&&e.from().ch==j.ch)||(a.setSelection(e.from(),e.to()),a.scrollIntoView({from:e.from(),to:e.to()}),i(a,u,"Replace?",[function(){h(b)},g,function(){p(a,c,d)}]))},h=function(a){e.replace("string"==typeof c?d:d.replace(/\$(\d)/g,function(b,c){return a[c]})),g()};g()}}))})}}var r='Search: (Use /re/ syntax for regexp search)',s=' (Use /re/ syntax for regexp search)',t='With: ',u="Replace? ";a.commands.find=function(a){o(a),m(a)},a.commands.findPersistent=function(a){o(a),m(a,!1,!0)},a.commands.findPersistentNext=function(a){m(a,!1,!0,!0)},a.commands.findPersistentPrev=function(a){m(a,!0,!0,!0)},a.commands.findNext=m,a.commands.findPrev=function(a){m(a,!0)},a.commands.clearSearch=o,a.commands.replace=q,a.commands.replaceAll=function(a){q(a,!0)}}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b){return"string"==typeof a?a=new RegExp(a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),b?"gi":"g"):a.global||(a=new RegExp(a.source,a.ignoreCase?"gi":"g")),{token:function(b){a.lastIndex=b.pos;var c=a.exec(b.string);return c&&c.index==b.pos?(b.pos+=c[0].length||1,"searching"):void(c?b.pos=c.index:b.skipToEnd())}}}function c(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function d(a){return a.state.search||(a.state.search=new c)}function e(a){return"string"==typeof a&&a==a.toLowerCase()}function f(a,b,c){return a.getSearchCursor(b,c,e(b))}function g(a,b,c,d,e){a.openDialog(b,d,{value:c,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){o(a)},onKeyDown:e})}function h(a,b,c,d,e){a.openDialog?a.openDialog(b,e,{value:d,selectValueOnOpen:!0}):e(prompt(c,d))}function i(a,b,c,d){a.openConfirm?a.openConfirm(b,d):confirm(c)&&d[0]()}function j(a){return a.replace(/\\(.)/g,function(a,b){return"n"==b?"\n":"r"==b?"\r":b})}function k(a){var b=a.match(/^\/(.*)\/([a-z]*)$/);if(b)try{a=new RegExp(b[1],-1==b[2].indexOf("i")?"":"i")}catch(c){}else a=j(a);return("string"==typeof a?""==a:a.test(""))&&(a=/x^/),a}function l(a,c,d){c.queryText=d,c.query=k(d),a.removeOverlay(c.overlay,e(c.query)),c.overlay=b(c.query,e(c.query)),a.addOverlay(c.overlay),a.showMatchesOnScrollbar&&(c.annotate&&(c.annotate.clear(),c.annotate=null),c.annotate=a.showMatchesOnScrollbar(c.query,e(c.query)))}function m(b,c,e,f){var i=d(b);if(i.query)return n(b,c);var j=b.getSelection()||i.lastQuery;if(e&&b.openDialog){var k=null,m=function(c,d){a.e_stop(d),c&&(c!=i.queryText&&(l(b,i,c),i.posFrom=i.posTo=b.getCursor()),k&&(k.style.opacity=1),n(b,d.shiftKey,function(a,c){var d;c.line<3&&document.querySelector&&(d=b.display.wrapper.querySelector(".CodeMirror-dialog"))&&d.getBoundingClientRect().bottom-4>b.cursorCoords(c,"window").top&&((k=d).style.opacity=.4)}))};g(b,r,j,m,function(c,e){var f=a.keyName(c),g=a.keyMap[b.getOption("keyMap")][f];g||(g=b.getOption("extraKeys")[f]),"findNext"==g||"findPrev"==g||"findPersistentNext"==g||"findPersistentPrev"==g?(a.e_stop(c),l(b,d(b),e),b.execCommand(g)):("find"==g||"findPersistent"==g)&&(a.e_stop(c),m(e,c))}),f&&j&&(l(b,i,j),n(b,c))}else h(b,r,"Search for:",j,function(a){a&&!i.query&&b.operation(function(){l(b,i,a),i.posFrom=i.posTo=b.getCursor(),n(b,c)})})}function n(b,c,e){b.operation(function(){var g=d(b),h=f(b,g.query,c?g.posFrom:g.posTo);(h.find(c)||(h=f(b,g.query,c?a.Pos(b.lastLine()):a.Pos(b.firstLine(),0)),h.find(c)))&&(b.setSelection(h.from(),h.to()),b.scrollIntoView({from:h.from(),to:h.to()},20),g.posFrom=h.from(),g.posTo=h.to(),e&&e(h.from(),h.to()))})}function o(a){a.operation(function(){var b=d(a);b.lastQuery=b.query,b.query&&(b.query=b.queryText=null,a.removeOverlay(b.overlay),b.annotate&&(b.annotate.clear(),b.annotate=null))})}function p(a,b,c){a.operation(function(){for(var d=f(a,b);d.findNext();)if("string"!=typeof b){var e=a.getRange(d.from(),d.to()).match(b);d.replace(c.replace(/\$(\d)/g,function(a,b){return e[b]}))}else d.replace(c)})}function q(a,b){if(!a.getOption("readOnly")){var c=a.getSelection()||d(a).lastQuery,e=b?"Replace all:":"Replace:";h(a,e+s,e,c,function(c){c&&(c=k(c),h(a,t,"Replace with:","",function(d){if(d=j(d),b)p(a,c,d);else{o(a);var e=f(a,c,a.getCursor("from")),g=function(){var b,j=e.from();!(b=e.findNext())&&(e=f(a,c),!(b=e.findNext())||j&&e.from().line==j.line&&e.from().ch==j.ch)||(a.setSelection(e.from(),e.to()),a.scrollIntoView({from:e.from(),to:e.to()}),i(a,u,"Replace?",[function(){h(b)},g,function(){p(a,c,d)}]))},h=function(a){e.replace("string"==typeof c?d:d.replace(/\$(\d)/g,function(b,c){return a[c]})),g()};g()}}))})}}var r='Search: (Use /re/ syntax for regexp search)',s=' (Use /re/ syntax for regexp search)',t='With: ',u="Replace? ";a.commands.find=function(a){o(a),m(a)},a.commands.findPersistent=function(a){o(a),m(a,!1,!0)},a.commands.findPersistentNext=function(a){m(a,!1,!0,!0)},a.commands.findPersistentPrev=function(a){m(a,!0,!0,!0)},a.commands.findNext=m,a.commands.findPrev=function(a){m(a,!0)},a.commands.clearSearch=o,a.commands.replace=q,a.commands.replaceAll=function(a){q(a,!0)}}); \ No newline at end of file diff --git a/media/editors/codemirror/lib/addons.js b/media/editors/codemirror/lib/addons.js index d74d6996b26e5..2b8c888a353df 100644 --- a/media/editors/codemirror/lib/addons.js +++ b/media/editors/codemirror/lib/addons.js @@ -623,8 +623,10 @@ } CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { - if (old && old != CodeMirror.Init) + if (old && old != CodeMirror.Init) { cm.off("cursorActivity", doMatchBrackets); + if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;} + } if (val) { cm.state.matchBrackets = typeof val == "object" ? val : {}; cm.on("cursorActivity", doMatchBrackets); @@ -1900,6 +1902,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name] this.overlay = this.timeout = null; this.matchesonscroll = null; + this.active = false; } CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) { @@ -1908,16 +1911,34 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { clearTimeout(cm.state.matchHighlighter.timeout); cm.state.matchHighlighter = null; cm.off("cursorActivity", cursorActivity); + cm.off("focus", onFocus) } if (val) { - cm.state.matchHighlighter = new State(val); - highlightMatches(cm); + var state = cm.state.matchHighlighter = new State(val); + if (cm.hasFocus()) { + state.active = true + highlightMatches(cm) + } else { + cm.on("focus", onFocus) + } cm.on("cursorActivity", cursorActivity); } }); function cursorActivity(cm) { var state = cm.state.matchHighlighter; + if (state.active || cm.hasFocus()) scheduleHighlight(cm, state) + } + + function onFocus(cm) { + var state = cm.state.matchHighlighter + if (!state.active) { + state.active = true + scheduleHighlight(cm, state) + } + } + + function scheduleHighlight(cm, state) { clearTimeout(state.timeout); state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay); } diff --git a/media/editors/codemirror/lib/addons.min.js b/media/editors/codemirror/lib/addons.min.js index 6f209cd502244..bd6f86124dd4f 100644 --- a/media/editors/codemirror/lib/addons.min.js +++ b/media/editors/codemirror/lib/addons.min.js @@ -1,4 +1,4 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){var b=a.getWrapperElement();a.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:b.style.width,height:b.style.height},b.style.width="",b.style.height="auto",b.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",a.refresh()}function c(a){var b=a.getWrapperElement();b.className=b.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="";var c=a.state.fullScreenRestore;b.style.width=c.width,b.style.height=c.height,window.scrollTo(c.scrollLeft,c.scrollTop),a.refresh()}a.defineOption("fullScreen",!1,function(d,e,f){f==a.Init&&(f=!1),!f!=!e&&(e?b(d):c(d))})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b,c,d){this.cm=a,this.node=b,this.options=c,this.height=d,this.cleared=!1}function c(a){var b=a.getWrapperElement(),c=window.getComputedStyle?window.getComputedStyle(b):b.currentStyle,d=parseInt(c.height),e=a.state.panels={setHeight:b.style.height,heightLeft:d,panels:0,wrapper:document.createElement("div")};b.parentNode.insertBefore(e.wrapper,b);var f=a.hasFocus();e.wrapper.appendChild(b),f&&a.focus(),a._setSize=a.setSize,null!=d&&(a.setSize=function(b,c){if(null==c)return this._setSize(b,c);if(e.setHeight=c,"number"!=typeof c){var f=/^(\d+\.?\d*)px$/.exec(c);f?c=Number(f[1]):(e.wrapper.style.height=c,c=e.wrapper.offsetHeight,e.wrapper.style.height="")}a._setSize(b,e.heightLeft+=c-d),d=c})}function d(a){var b=a.state.panels;a.state.panels=null;var c=a.getWrapperElement();b.wrapper.parentNode.replaceChild(c,b.wrapper),c.style.height=b.setHeight,a.setSize=a._setSize,a.setSize()}a.defineExtension("addPanel",function(a,d){d=d||{},this.state.panels||c(this);var e=this.state.panels,f=e.wrapper,g=this.getWrapperElement();d.after instanceof b&&!d.after.cleared?f.insertBefore(a,d.before.node.nextSibling):d.before instanceof b&&!d.before.cleared?f.insertBefore(a,d.before.node):d.replace instanceof b&&!d.replace.cleared?(f.insertBefore(a,d.replace.node),d.replace.clear()):"bottom"==d.position?f.appendChild(a):"before-bottom"==d.position?f.insertBefore(a,g.nextSibling):"after-top"==d.position?f.insertBefore(a,g):f.insertBefore(a,f.firstChild);var h=d&&d.height||a.offsetHeight;return this._setSize(null,e.heightLeft-=h),e.panels++,new b(this,a,d,h)}),b.prototype.clear=function(){if(!this.cleared){this.cleared=!0;var a=this.cm.state.panels;this.cm._setSize(null,a.heightLeft+=this.height),a.wrapper.removeChild(this.node),0==--a.panels&&d(this.cm)}},b.prototype.changed=function(a){var b=null==a?this.node.offsetHeight:a,c=this.cm.state.panels;this.cm._setSize(null,c.height+=b-this.height),this.height=b}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b){return"pairs"==b&&"string"==typeof a?a:"object"==typeof a&&null!=a[b]?a[b]:l[b]}function c(a){return function(b){return h(b,a)}}function d(a){var b=a.state.closeBrackets;if(!b)return null;var c=a.getModeAt(a.getCursor());return c.closeBrackets||b}function e(c){var e=d(c);if(!e||c.getOption("disableInput"))return a.Pass;for(var f=b(e,"pairs"),g=c.listSelections(),h=0;h=0;h--){var k=g[h].head;c.replaceRange("",m(k.line,k.ch-1),m(k.line,k.ch+1),"+delete")}}function f(c){var e=d(c),f=e&&b(e,"explode");if(!f||c.getOption("disableInput"))return a.Pass;for(var g=c.listSelections(),h=0;h0;return{anchor:new m(b.anchor.line,b.anchor.ch+(c?-1:1)),head:new m(b.head.line,b.head.ch+(c?1:-1))}}function h(c,e){var f=d(c);if(!f||c.getOption("disableInput"))return a.Pass;var h=b(f,"pairs"),j=h.indexOf(e);if(-1==j)return a.Pass;for(var l,n=b(f,"triples"),o=h.charAt(j+1)==e,p=c.listSelections(),q=j%2==0,r=0;r1&&n.indexOf(e)>=0&&c.getRange(m(u.line,u.ch-2),u)==e+e&&(u.ch<=2||c.getRange(m(u.line,u.ch-3),m(u.line,u.ch-2))!=e))s="addFour";else if(o){if(a.isWordChar(v)||!k(c,u,e))return a.Pass;s="both"}else{if(!q||c.getLine(u.line).length!=u.ch&&!i(v,h)&&!/\s/.test(v))return a.Pass;s="both"}else s=n.indexOf(e)>=0&&c.getRange(u,m(u.line,u.ch+3))==e+e+e?"skipThree":"skip";if(l){if(l!=s)return a.Pass}else l=s}var w=j%2?h.charAt(j-1):e,x=j%2?e:h.charAt(j+1);c.operation(function(){if("skip"==l)c.execCommand("goCharRight");else if("skipThree"==l)for(var a=0;3>a;a++)c.execCommand("goCharRight");else if("surround"==l){for(var b=c.getSelections(),a=0;a-1&&c%2==1}function j(a,b){var c=a.getRange(m(b.line,b.ch-1),m(b.line,b.ch+1));return 2==c.length?c:null}function k(b,c,d){var e=b.getLine(c.line),f=b.getTokenAt(c);if(/\bstring2?\b/.test(f.type))return!1;var g=new a.StringStream(e.slice(0,c.ch)+d+e.slice(c.ch),4);for(g.pos=g.start=f.start;;){var h=b.getMode().token(g,f.state);if(g.pos>=c.ch+1)return/\bstring2?\b/.test(h);g.start=g.pos}}var l={pairs:"()[]{}''\"\"",triples:"",explode:"[]{}"},m=a.Pos;a.defineOption("autoCloseBrackets",!1,function(b,c,d){d&&d!=a.Init&&(b.removeKeyMap(o),b.state.closeBrackets=null),c&&(b.state.closeBrackets=c,b.addKeyMap(o))});for(var n=l.pairs+"`",o={Backspace:e,Enter:f},p=0;pj.ch&&(r=r.slice(0,r.length-k.end+j.ch));var s=r.toLowerCase();if(!r||"string"==k.type&&(k.end!=j.ch||!/[\"\']/.test(k.string.charAt(k.string.length-1))||1==k.string.length)||"tag"==k.type&&"closeTag"==m.type||k.string.indexOf("/")==k.string.length-1||p&&e(p,s)>-1||f(b,r,j,m,!0))return a.Pass;var t=q&&e(q,s)>-1;d[i]={indent:t,text:">"+(t?"\n\n":"")+"",newPos:t?a.Pos(j.line+1,0):a.Pos(j.line,j.ch+1)}}for(var i=c.length-1;i>=0;i--){var u=d[i];b.replaceRange(u.text,c[i].head,c[i].anchor,"+insert");var v=b.listSelections().slice(0);v[i]={head:u.newPos,anchor:u.newPos},b.setSelections(v),u.indent&&(b.indentLine(u.newPos.line,null,!0),b.indentLine(u.newPos.line+1,null,!0))}}function c(b,c){for(var d=b.listSelections(),e=[],g=c?"/":""!=b.getLine(i.line).charAt(j.end)&&(m+=">"),e[h]=m}b.replaceSelections(e),d=b.listSelections();for(var h=0;hc;++c)if(a[c]==b)return c;return-1}function f(b,c,d,e,f){if(!a.scanForClosingTag)return!1;var g=Math.min(b.lastLine()+1,d.line+500),h=a.scanForClosingTag(b,d,null,g);if(!h||h.tag!=c)return!1;for(var i=e.context,j=f?1:0;i&&i.tagName==c;i=i.prev)++j;d=h.to;for(var k=1;j>k;k++){var l=a.scanForClosingTag(b,d,null,g);if(!l||l.tag!=c)return!1;d=l.to}return!0}a.defineOption("autoCloseTags",!1,function(c,e,f){if(f!=a.Init&&f&&c.removeKeyMap("autoCloseTags"),e){var g={name:"autoCloseTags"};("object"!=typeof e||e.whenClosing)&&(g["'/'"]=function(a){return d(a)}),("object"!=typeof e||e.whenOpening)&&(g["'>'"]=function(a){return b(a)}),c.addKeyMap(g)}});var g=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],h=["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"];a.commands.closeTag=function(a){return c(a)}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b,d,e){var f=a.getLineHandle(b.line),i=b.ch-1,j=i>=0&&h[f.text.charAt(i)]||h[f.text.charAt(++i)];if(!j)return null;var k=">"==j.charAt(1)?1:-1;if(d&&k>0!=(i==b.ch))return null;var l=a.getTokenTypeAt(g(b.line,i+1)),m=c(a,g(b.line,i+(k>0?1:0)),k,l||null,e);return null==m?null:{from:g(b.line,i),to:m&&m.pos,match:m&&m.ch==j.charAt(0),forward:k>0}}function c(a,b,c,d,e){for(var f=e&&e.maxScanLineLength||1e4,i=e&&e.maxScanLines||1e3,j=[],k=e&&e.bracketRegex?e.bracketRegex:/[(){}[\]]/,l=c>0?Math.min(b.line+i,a.lastLine()+1):Math.max(a.firstLine()-1,b.line-i),m=b.line;m!=l;m+=c){var n=a.getLine(m);if(n){var o=c>0?0:n.length-1,p=c>0?n.length:-1;if(!(n.length>f))for(m==b.line&&(o=b.ch-(0>c?1:0));o!=p;o+=c){var q=n.charAt(o);if(k.test(q)&&(void 0===d||a.getTokenTypeAt(g(m,o+1))==d)){var r=h[q];if(">"==r.charAt(1)==c>0)j.push(q);else{if(!j.length)return{pos:g(m,o),ch:q};j.pop()}}}}}return m-c==(c>0?a.lastLine():a.firstLine())?!1:null}function d(a,c,d){for(var e=a.state.matchBrackets.maxHighlightLineLength||1e3,h=[],i=a.listSelections(),j=0;j",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},i=null;a.defineOption("matchBrackets",!1,function(b,c,d){d&&d!=a.Init&&b.off("cursorActivity",e),c&&(b.state.matchBrackets="object"==typeof c?c:{},b.on("cursorActivity",e))}),a.defineExtension("matchBrackets",function(){d(this,!0)}),a.defineExtension("findMatchingBracket",function(a,c,d){return b(this,a,c,d)}),a.defineExtension("scanForBracket",function(a,b,d,e){return c(this,a,b,d,e)})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],a):a(CodeMirror)}(function(a){"use strict";function b(a){a.state.tagHit&&a.state.tagHit.clear(),a.state.tagOther&&a.state.tagOther.clear(),a.state.tagHit=a.state.tagOther=null}function c(c){c.state.failedTagMatch=!1,c.operation(function(){if(b(c),!c.somethingSelected()){var d=c.getCursor(),e=c.getViewport();e.from=Math.min(e.from,d.line),e.to=Math.max(d.line+1,e.to);var f=a.findMatchingTag(c,d,e);if(f){if(c.state.matchBothTags){var g="open"==f.at?f.open:f.close;g&&(c.state.tagHit=c.markText(g.from,g.to,{className:"CodeMirror-matchingtag"}))}var h="close"==f.at?f.open:f.close;h?c.state.tagOther=c.markText(h.from,h.to,{className:"CodeMirror-matchingtag"}):c.state.failedTagMatch=!0}}})}function d(a){a.state.failedTagMatch&&c(a)}a.defineOption("matchTags",!1,function(e,f,g){g&&g!=a.Init&&(e.off("cursorActivity",c),e.off("viewportChange",d),b(e)),f&&(e.state.matchBothTags="object"==typeof f&&f.bothTags,e.on("cursorActivity",c),e.on("viewportChange",d),c(e))}),a.commands.toMatchingTag=function(b){var c=a.findMatchingTag(b,b.getCursor());if(c){var d="close"==c.at?c.open:c.close;d&&b.extendSelection(d.to,d.from)}}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.registerHelper("fold","brace",function(b,c){function d(d){for(var h=c.ch,i=0;;){var j=0>=h?-1:g.lastIndexOf(d,h-1);if(-1!=j){if(1==i&&j=o;++o)for(var p=b.getLine(o),q=o==f?j:0;;){var r=p.indexOf(h,q),s=p.indexOf(i,q);if(0>r&&(r=p.length),0>s&&(s=p.length),q=Math.min(r,s),q==p.length)break;if(b.getTokenTypeAt(a.Pos(o,q+1))==e)if(q==r)++m;else if(!--m){k=o,l=q;break a}++q}if(null!=k&&(f!=k||l!=j))return{from:a.Pos(f,j),to:a.Pos(k,l)}}}),a.registerHelper("fold","import",function(b,c){function d(c){if(cb.lastLine())return null;var d=b.getTokenAt(a.Pos(c,1));if(/\S/.test(d.string)||(d=b.getTokenAt(a.Pos(c,d.end+1))),"keyword"!=d.type||"import"!=d.string)return null;for(var e=c,f=Math.min(b.lastLine(),c+10);f>=e;++e){var g=b.getLine(e),h=g.indexOf(";");if(-1!=h)return{startCh:d.end,end:a.Pos(e,h)}}}var e,f=c.line,g=d(f);if(!g||d(f-1)||(e=d(f-2))&&e.end.line==f-1)return null;for(var h=g.end;;){var i=d(h.line+1);if(null==i)break;h=i.end}return{from:b.clipPos(a.Pos(f,g.startCh+1)),to:h}}),a.registerHelper("fold","include",function(b,c){function d(c){if(cb.lastLine())return null;var d=b.getTokenAt(a.Pos(c,1));return/\S/.test(d.string)||(d=b.getTokenAt(a.Pos(c,d.end+1))),"meta"==d.type&&"#include"==d.string.slice(0,8)?d.start+8:void 0}var e=c.line,f=d(e);if(null==f||null!=d(e-1))return null;for(var g=e;;){var h=d(g+1);if(null==h)break;++g}return{from:a.Pos(e,f+1),to:b.clipPos(a.Pos(g))}})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(b,e,f,g){function h(a){var c=i(b,e);if(!c||c.to.line-c.from.lineb.firstLine();)e=a.Pos(e.line-1,0),k=h(!1);if(k&&!k.cleared&&"unfold"!==g){var l=c(b,f);a.on(l,"mousedown",function(b){m.clear(),a.e_preventDefault(b)});var m=b.markText(k.from,k.to,{replacedWith:l,clearOnEnter:d(b,f,"clearOnEnter"),__isFold:!0});m.on("clear",function(c,d){a.signal(b,"unfold",b,c,d)}),a.signal(b,"fold",b,k.from,k.to)}}function c(a,b){var c=d(a,b,"widget");if("string"==typeof c){var e=document.createTextNode(c);c=document.createElement("span"),c.appendChild(e),c.className="CodeMirror-foldmarker"}return c}function d(a,b,c){if(b&&void 0!==b[c])return b[c];var d=a.options.foldOptions;return d&&void 0!==d[c]?d[c]:e[c]}a.newFoldFunction=function(a,c){return function(d,e){b(d,e,{rangeFinder:a,widget:c})}},a.defineExtension("foldCode",function(a,c,d){b(this,a,c,d)}),a.defineExtension("isFolded",function(a){for(var b=this.findMarksAt(a),c=0;c=c;c++)b.foldCode(a.Pos(c,0),null,"fold")})},a.commands.unfoldAll=function(b){b.operation(function(){for(var c=b.firstLine(),d=b.lastLine();d>=c;c++)b.foldCode(a.Pos(c,0),null,"unfold")})},a.registerHelper("fold","combine",function(){var a=Array.prototype.slice.call(arguments,0);return function(b,c){for(var d=0;d=h&&(c=e(f.indicatorOpen))}a.setGutterMarker(b,f.gutter,c),++g})}function g(a){var b=a.getViewport(),c=a.state.foldGutter;c&&(a.operation(function(){f(a,b.from,b.to)}),c.from=b.from,c.to=b.to)}function h(a,b,c){var e=a.state.foldGutter;if(e){var f=e.options;if(c==f.gutter){var g=d(a,b);g?g.clear():a.foldCode(l(b,0),f.rangeFinder)}}}function i(a){var b=a.state.foldGutter;if(b){var c=b.options;b.from=b.to=0,clearTimeout(b.changeUpdate),b.changeUpdate=setTimeout(function(){g(a)},c.foldOnChangeTimeSpan||600)}}function j(a){var b=a.state.foldGutter;if(b){var c=b.options;clearTimeout(b.changeUpdate),b.changeUpdate=setTimeout(function(){var c=a.getViewport();b.from==b.to||c.from-b.to>20||b.from-c.to>20?g(a):a.operation(function(){c.fromb.to&&(f(a,b.to,c.to),b.to=c.to)})},c.updateViewportTimeSpan||400)}}function k(a,b){var c=a.state.foldGutter;if(c){var d=b.line;d>=c.from&&d=a.max?void 0:(a.ch=0,a.text=a.cm.getLine(++a.line),!0)}function f(a){return a.line<=a.min?void 0:(a.text=a.cm.getLine(--a.line),a.ch=a.text.length,!0)}function g(a){for(;;){var b=a.text.indexOf(">",a.ch);if(-1==b){if(e(a))continue;return}{if(d(a,b+1)){var c=a.text.lastIndexOf("/",b),f=c>-1&&!/\S/.test(a.text.slice(c+1,b));return a.ch=b+1,f?"selfClose":"regular"}a.ch=b+1}}}function h(a){for(;;){var b=a.ch?a.text.lastIndexOf("<",a.ch-1):-1;if(-1==b){if(f(a))continue;return}if(d(a,b+1)){p.lastIndex=b,a.ch=b;var c=p.exec(a.text);if(c&&c.index==b)return c}else a.ch=b}}function i(a){for(;;){p.lastIndex=a.ch;var b=p.exec(a.text);if(!b){if(e(a))continue;return}{if(d(a,b.index+1))return a.ch=b.index+b[0].length,b;a.ch=b.index+1}}}function j(a){for(;;){var b=a.ch?a.text.lastIndexOf(">",a.ch-1):-1;if(-1==b){if(f(a))continue;return}{if(d(a,b+1)){var c=a.text.lastIndexOf("/",b),e=c>-1&&!/\S/.test(a.text.slice(c+1,b));return a.ch=b+1,e?"selfClose":"regular"}a.ch=b}}}function k(a,b){for(var c=[];;){var d,e=i(a),f=a.line,h=a.ch-(e?e[0].length:0);if(!e||!(d=g(a)))return;if("selfClose"!=d)if(e[1]){for(var j=c.length-1;j>=0;--j)if(c[j]==e[2]){c.length=j;break}if(0>j&&(!b||b==e[2]))return{tag:e[2],from:m(f,h),to:m(a.line,a.ch)}}else c.push(e[2])}}function l(a,b){for(var c=[];;){var d=j(a);if(!d)return;if("selfClose"!=d){var e=a.line,f=a.ch,g=h(a);if(!g)return;if(g[1])c.push(g[2]);else{for(var i=c.length-1;i>=0;--i)if(c[i]==g[2]){c.length=i;break}if(0>i&&(!b||b==g[2]))return{tag:g[2],from:m(a.line,a.ch),to:m(e,f)}}}else h(a)}}var m=a.Pos,n="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",o=n+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",p=new RegExp("<(/?)(["+n+"]["+o+"]*)","g");a.registerHelper("fold","xml",function(a,b){for(var d=new c(a,b.line,0);;){var e,f=i(d);if(!f||d.line!=b.line||!(e=g(d)))return;if(!f[1]&&"selfClose"!=e){var h=m(d.line,d.ch),j=k(d,f[2]);return j&&{from:h,to:j.from}}}}),a.findMatchingTag=function(a,d,e){var f=new c(a,d.line,d.ch,e);if(-1!=f.text.indexOf(">")||-1!=f.text.indexOf("<")){var i=g(f),j=i&&m(f.line,f.ch),n=i&&h(f);if(i&&n&&!(b(f,d)>0)){var o={from:m(f.line,f.ch),to:j,tag:n[2]};return"selfClose"==i?{open:o,close:null,at:"open"}:n[1]?{open:l(f,n[2]),close:o,at:"close"}:(f=new c(a,j.line,j.ch,e),{open:o,close:k(f,n[2]),at:"open"})}}},a.findEnclosingTag=function(a,b,d){for(var e=new c(a,b.line,b.ch,d);;){var f=l(e);if(!f)break;var g=new c(a,b.line,b.ch,d),h=k(g,f.tag);if(h)return{open:f,close:h}}},a.scanForClosingTag=function(a,b,d,e){var f=new c(a,b.line,b.ch,e?{from:0,to:e}:null);return k(f,d)}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),"cjs"):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],function(b){a(b,"amd")}):a(CodeMirror,"plain")}(function(a,b){function c(a,b){var c=b;return function(){0==--c&&a()}}function d(b,d){var e=a.modes[b].dependencies;if(!e)return d();for(var f=[],g=0;g-1?e+b.length:e}var f=b.exec(c?a.slice(c):a);return f?f.index+c+(d?f[0].length:0):-1}var d=Array.prototype.slice.call(arguments,1);return{startState:function(){return{outer:a.startState(b),innerActive:null,inner:null}},copyState:function(c){return{outer:a.copyState(b,c.outer),innerActive:c.innerActive,inner:c.innerActive&&a.copyState(c.innerActive.mode,c.inner)}},token:function(e,f){if(f.innerActive){var g=f.innerActive,h=e.string;if(!g.close&&e.sol())return f.innerActive=f.inner=null,this.token(e,f);var i=g.close?c(h,g.close,e.pos,g.parseDelimiters):-1;if(i==e.pos&&!g.parseDelimiters)return e.match(g.close),f.innerActive=f.inner=null,g.delimStyle&&g.delimStyle+" "+g.delimStyle+"-close";i>-1&&(e.string=h.slice(0,i));var j=g.mode.token(e,f.inner);return i>-1&&(e.string=h),i==e.pos&&g.parseDelimiters&&(f.innerActive=f.inner=null),g.innerStyle&&(j=j?j+" "+g.innerStyle:g.innerStyle),j}for(var k=1/0,h=e.string,l=0;li&&(k=i)}k!=1/0&&(e.string=h.slice(0,k));var n=b.token(e,f.outer);return k!=1/0&&(e.string=h),n},indent:function(c,d){var e=c.innerActive?c.innerActive.mode:b;return e.indent?e.indent(c.innerActive?c.inner:c.outer,d):a.Pass},blankLine:function(c){var e=c.innerActive?c.innerActive.mode:b;if(e.blankLine&&e.blankLine(c.innerActive?c.inner:c.outer),c.innerActive)"\n"===c.innerActive.close&&(c.innerActive=c.inner=null);else for(var f=0;fh)return c.charCoords(a,"local")[b?"top":"bottom"];var d=c.heightAtLine(j,"local");return d+(b?0:j.height)}a!==!1&&this.computeScale();var c=this.cm,d=this.hScale,e=document.createDocumentFragment(),f=this.annotations,g=c.getOption("lineWrapping"),h=g&&1.5*c.defaultTextHeight(),i=null,j=null;if(c.display.barWidth)for(var k,l=0;lo+.9));)m=f[++l],o=b(m.to,!1)*d;if(o!=n){var p=Math.max(o-n,3),q=e.appendChild(document.createElement("div"));q.style.cssText="position: absolute; right: 0px; width: "+Math.max(c.display.barWidth-1,2)+"px; top: "+(n+this.buttonHeight)+"px; height: "+p+"px",q.className=this.options.className,m.id&&q.setAttribute("annotation-id",m.id)}}this.div.textContent="",this.div.appendChild(e)},b.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(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(b,c,d){function e(b){var c=a.wheelEventPixels(b)["horizontal"==f.orientation?"x":"y"],d=f.pos;f.moveTo(f.pos+c),f.pos!=d&&a.e_preventDefault(b)}this.orientation=c,this.scroll=d,this.screen=this.total=this.size=1,this.pos=0,this.node=document.createElement("div"),this.node.className=b+"-"+c,this.inner=this.node.appendChild(document.createElement("div"));var f=this;a.on(this.inner,"mousedown",function(b){function c(){a.off(document,"mousemove",d),a.off(document,"mouseup",c)}function d(a){return 1!=a.which?c():void f.moveTo(h+(a[e]-g)*(f.total/f.size))}if(1==b.which){a.e_preventDefault(b);var e="horizontal"==f.orientation?"pageX":"pageY",g=b[e],h=f.pos;a.on(document,"mousemove",d),a.on(document,"mouseup",c)}}),a.on(this.node,"click",function(b){a.e_preventDefault(b);var c,d=f.inner.getBoundingClientRect();c="horizontal"==f.orientation?b.clientXd.right?1:0:b.clientYd.bottom?1:0,f.moveTo(f.pos+c*f.screen)}),a.on(this.node,"mousewheel",e),a.on(this.node,"DOMMouseScroll",e)}function c(a,c,d){this.addClass=a,this.horiz=new b(a,"horizontal",d),c(this.horiz.node),this.vert=new b(a,"vertical",d),c(this.vert.node),this.width=null}b.prototype.setPos=function(a,b){return 0>a&&(a=0),a>this.total-this.screen&&(a=this.total-this.screen),b||a!=this.pos?(this.pos=a,this.inner.style["horizontal"==this.orientation?"left":"top"]=a*(this.size/this.total)+"px",!0):!1},b.prototype.moveTo=function(a){this.setPos(a)&&this.scroll(a,this.orientation)};var d=10;b.prototype.update=function(a,b,c){var e=this.screen!=b||this.total!=a||this.size!=c;e&&(this.screen=b,this.total=a,this.size=c);var f=this.screen*(this.size/this.total);d>f&&(this.size-=d-f,f=d),this.inner.style["horizontal"==this.orientation?"width":"height"]=f+"px",this.setPos(this.pos,e)},c.prototype.update=function(a){if(null==this.width){var b=window.getComputedStyle?window.getComputedStyle(this.horiz.node):this.horiz.node.currentStyle;b&&(this.width=parseInt(b.height))}var c=this.width||0,d=a.scrollWidth>a.clientWidth+1,e=a.scrollHeight>a.clientHeight+1;return this.vert.node.style.display=e?"block":"none",this.horiz.node.style.display=d?"block":"none",e&&(this.vert.update(a.scrollHeight,a.clientHeight,a.viewHeight-(d?c:0)),this.vert.node.style.bottom=d?c+"px":"0"),d&&(this.horiz.update(a.scrollWidth,a.clientWidth,a.viewWidth-(e?c:0)-a.barLeft), -this.horiz.node.style.right=e?c+"px":"0",this.horiz.node.style.left=a.barLeft+"px"),{right:e?c:0,bottom:d?c:0}},c.prototype.setScrollTop=function(a){this.vert.setPos(a)},c.prototype.setScrollLeft=function(a){this.horiz.setPos(a)},c.prototype.clear=function(){var a=this.horiz.node.parentNode;a.removeChild(this.horiz.node),a.removeChild(this.vert.node)},a.scrollbarModel.simple=function(a,b){return new c("CodeMirror-simplescroll",a,b)},a.scrollbarModel.overlay=function(a,b){return new c("CodeMirror-overlayscroll",a,b)}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c,d){this.cm=a,this.options=d;var e={listenForChanges:!1};for(var f in d)e[f]=d[f];e.className||(e.className="CodeMirror-search-match"),this.annotation=a.annotateScrollbar(e),this.query=b,this.caseFold=c,this.gap={from:a.firstLine(),to:a.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var g=this;a.on("change",this.changeHandler=function(a,b){g.onChange(b)})}function c(a,b,c){return b>=a?a:Math.max(b,a+c)}a.defineExtension("showMatchesOnScrollbar",function(a,c,d){return"string"==typeof d&&(d={className:d}),d||(d={}),new b(this,a,c,d)});var d=1e3;b.prototype.findMatches=function(){if(this.gap){for(var b=0;b=this.gap.to)break;c.to.line>=this.gap.from&&this.matches.splice(b--,1)}for(var e=this.cm.getSearchCursor(this.query,a.Pos(this.gap.from,0),this.caseFold),f=this.options&&this.options.maxMatches||d;e.findNext();){var c={from:e.from(),to:e.to()};if(c.from.line>=this.gap.to)break;if(this.matches.splice(b++,0,c),this.matches.length>f)break}this.gap=null}},b.prototype.onChange=function(b){var d=b.from.line,e=a.changeEnd(b).line,f=e-b.to.line;if(this.gap?(this.gap.from=Math.min(c(this.gap.from,d,f),b.from.line),this.gap.to=Math.max(c(this.gap.to,d,f),b.from.line)):this.gap={from:b.from.line,to:e+1},f)for(var g=0;gi&&d(a,h.slice(i,j),c,b.options.style))}var k=a.getCursor("from"),l=a.getCursor("to");if(k.line==l.line&&(!b.options.wordsOnly||g(a,k,l))){var m=a.getRange(k,l);b.options.trim&&(m=m.replace(/^\s+|\s+$/g,"")),m.length>=b.options.minChars&&d(a,m,!1,b.options.style)}})}function g(a,b,c){var d=a.getRange(b,c);if(null!==d.match(/^\w+$/)){if(b.ch>0){var e={line:b.line,ch:b.ch-1},f=a.getRange(e,b);if(null===f.match(/\W/))return!1}if(c.ch-1)return k=c(i,j,k),{from:d(f.line,k),to:d(f.line,k+g.length)}}else{var i=a.getLine(f.line).slice(f.ch),j=h(i),k=j.indexOf(b);if(k>-1)return k=c(i,j,k)+f.ch,{from:d(f.line,k),to:d(f.line,k+g.length)}}}:this.matches=function(){};else{var j=g.split("\n");this.matches=function(b,c){var e=i.length-1;if(b){if(c.line-(i.length-1)=1;--k,--g)if(i[k]!=h(a.getLine(g)))return;var l=a.getLine(g),m=l.length-j[0].length;if(h(l.slice(m))!=i[0])return;return{from:d(g,m),to:f}}if(!(c.line+(i.length-1)>a.lastLine())){var l=a.getLine(c.line),m=l.length-j[0].length;if(h(l.slice(m))==i[0]){for(var n=d(c.line,m),g=c.line+1,k=1;e>k;++k,++g)if(i[k]!=h(a.getLine(g)))return;if(h(a.getLine(g).slice(0,j[e].length))==i[e])return{from:n,to:d(g,j[e].length)}}}}}}}function c(a,b,c){if(a.length==b.length)return c;for(var d=Math.min(c,a.length);;){var e=a.slice(0,d).toLowerCase().length;if(c>e)++d;else{if(!(e>c))return d;--d}}}var d=a.Pos;b.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(a){function b(a){var b=d(a,0);return c.pos={from:b,to:b},c.atOccurrence=!1,!1}for(var c=this,e=this.doc.clipPos(a?this.pos.from:this.pos.to);;){if(this.pos=this.matches(a,e))return this.atOccurrence=!0,this.pos.match||!0;if(a){if(!e.line)return b(0);e=d(e.line-1,this.doc.getLine(e.line-1).length)}else{var f=this.doc.lineCount();if(e.line==f-1)return b(f);e=d(e.line+1,0)}}},from:function(){return this.atOccurrence?this.pos.from:void 0},to:function(){return this.atOccurrence?this.pos.to:void 0},replace:function(b,c){if(this.atOccurrence){var e=a.splitLines(b);this.doc.replaceRange(e,this.pos.from,this.pos.to,c),this.pos.to=d(this.pos.from.line+e.length-1,e[e.length-1].length+(1==e.length?this.pos.from.ch:0))}}},a.defineExtension("getSearchCursor",function(a,c,d){return new b(this.doc,a,c,d)}),a.defineDocExtension("getSearchCursor",function(a,c,d){return new b(this,a,c,d)}),a.defineExtension("selectMatches",function(b,c){for(var d=[],e=this.getSearchCursor(b,this.getCursor("from"),c);e.findNext()&&!(a.cmpPos(e.to(),this.getCursor("to"))>0);)d.push({anchor:e.from(),head:e.to()});d.length&&this.setSelections(d,0)})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){for(var b=0;b",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"",type:"keyToKey",toKeys:"W"},{keys:"",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"",type:"keyToKey",toKeys:"w"},{keys:"",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"",type:"keyToKey",toKeys:"0"},{keys:"",type:"keyToKey",toKeys:"$"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r",type:"action",action:"replace",isEdit:!0},{keys:"@",type:"action",action:"replayMacro"},{keys:"q",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"",type:"action",action:"redo"},{keys:"m",type:"action",action:"setMark"},{keys:'"',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"a",type:"motion",motion:"textObjectManipulation"},{keys:"i",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],c=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"unmap"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"global",shortName:"g"}],d=a.Pos,e=function(){function e(b){b.setOption("disableInput",!0),b.setOption("showCursorWhenSelecting",!1),a.signal(b,"vim-mode-change",{mode:"normal"}),b.on("cursorActivity",ab),x(b),a.on(b.getInputField(),"paste",k(b))}function f(b){b.setOption("disableInput",!1),b.off("cursorActivity",ab),a.off(b.getInputField(),"paste",k(b)),b.state.vim=null}function g(b,c){this==a.keyMap.vim&&a.rmClass(b.getWrapperElement(),"cm-fat-cursor"),c&&c.attach==h||f(b,!1)}function h(b,c){this==a.keyMap.vim&&a.addClass(b.getWrapperElement(),"cm-fat-cursor"),c&&c.attach==h||e(b)}function i(b,c){if(!c)return void 0;if(this[b])return this[b];var d=j(b);if(!d)return!1;var e=a.Vim.findKey(c,d);return"function"==typeof e&&a.signal(c,"vim-keypress",d),e}function j(a){if("'"==a.charAt(0))return a.charAt(1);var b=a.split(/-(?!$)/),c=b[b.length-1];if(1==b.length&&1==b[0].length)return!1;if(2==b.length&&"Shift"==b[0]&&1==c.length)return!1;for(var d=!1,e=0;e"):!1}function k(a){var b=a.state.vim;return b.onPasteFn||(b.onPasteFn=function(){b.insertMode||(a.setCursor(L(a.getCursor(),0,1)),Ab.enterInsertMode(a,{},b))}),b.onPasteFn}function l(a,b){for(var c=[],d=a;a+b>d;d++)c.push(String.fromCharCode(d));return c}function m(a,b){return b>=a.firstLine()&&b<=a.lastLine()}function n(a){return/^[a-z]$/.test(a)}function o(a){return-1!="()[]{}".indexOf(a)}function p(a){return jb.test(a)}function q(a){return/^[A-Z]$/.test(a)}function r(a){return/^\s*$/.test(a)}function s(a,b){for(var c=0;cd;d++)c.push(a);return c}function H(a,b){zb[a]=b}function I(a,b){Ab[a]=b}function J(a,b,c){var e=Math.min(Math.max(a.firstLine(),b.line),a.lastLine()),f=X(a,e)-1;f=c?f+1:f;var g=Math.min(Math.max(0,b.ch),f);return d(e,g)}function K(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function L(a,b,c){return"object"==typeof b&&(c=b.ch,b=b.line),d(a.line+b,a.ch+c)}function M(a,b){return{line:b.line-a.line,ch:b.line-a.line}}function N(a,b,c,d){for(var e,f=[],g=[],h=0;h"==b.slice(-11)){var c=b.length-11,d=a.slice(0,c),e=b.slice(0,c);return d==e&&a.length>c?"full":0==e.indexOf(d)?"partial":!1}return a==b?"full":0==b.indexOf(a)?"partial":!1}function P(a){var b=/^.*(<[\w\-]+>)$/.exec(a),c=b?b[1]:a.slice(-1);if(c.length>1)switch(c){case"":c="\n";break;case"":c=" "}return c}function Q(a,b,c){return function(){for(var d=0;c>d;d++)b(a)}}function R(a){return d(a.line,a.ch)}function S(a,b){return a.ch==b.ch&&a.line==b.line}function T(a,b){return a.line2&&(b=U.apply(void 0,Array.prototype.slice.call(arguments,1))),T(a,b)?a:b}function V(a,b){return arguments.length>2&&(b=V.apply(void 0,Array.prototype.slice.call(arguments,1))),T(a,b)?b:a}function W(a,b,c){var d=T(a,b),e=T(b,c);return d&&e}function X(a,b){return a.getLine(b).length}function Y(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function Z(a){return a.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function $(a,b,c){var e=X(a,b),f=new Array(c-e+1).join(" ");a.setCursor(d(b,e)),a.replaceRange(f,a.getCursor())}function _(a,b){var c=[],e=a.listSelections(),f=R(a.clipPos(b)),g=!S(b,f),h=a.getCursor("head"),i=ba(e,h),j=S(e[i].head,e[i].anchor),k=e.length-1,l=k-i>i?k:0,m=e[l].anchor,n=Math.min(m.line,f.line),o=Math.max(m.line,f.line),p=m.ch,q=f.ch,r=e[l].head.ch-p,s=q-p;r>0&&0>=s?(p++,g||q--):0>r&&s>=0?(p--,j||q++):0>r&&-1==s&&(p--,q++);for(var t=n;o>=t;t++){var u={anchor:new d(t,p),head:new d(t,q)};c.push(u)}return i=f.line==o?c.length-1:0,a.setSelections(c),b.ch=q,m.ch=p,m}function aa(a,b,c){for(var d=[],e=0;c>e;e++){var f=L(b,e,0);d.push({anchor:f,head:f})}a.setSelections(d,0)}function ba(a,b,c){for(var d=0;dj&&(f.line=j),f.ch=X(a,f.line)}return{ranges:[{anchor:g,head:f}],primary:0}}if("block"==c){for(var k=Math.min(g.line,f.line),l=Math.min(g.ch,f.ch),m=Math.max(g.line,f.line),n=Math.max(g.ch,f.ch)+1,o=m-k+1,p=f.line==k?0:o-1,q=[],r=0;o>r;r++)q.push({anchor:d(k+r,l),head:d(k+r,n)});return{ranges:q,primary:p}}}function ha(a){var b=a.getCursor("head");return 1==a.getSelection().length&&(b=U(b,a.getCursor("anchor"))),b}function ia(b,c){var d=b.state.vim;c!==!1&&b.setCursor(J(b,d.sel.head)),da(b,d),d.visualMode=!1,d.visualLine=!1,d.visualBlock=!1,a.signal(b,"vim-mode-change",{mode:"normal"}),d.fakeCursor&&d.fakeCursor.clear()}function ja(a,b,c){var d=a.getRange(b,c);if(/\n\s*$/.test(d)){var e=d.split("\n");e.pop();for(var f,f=e.pop();e.length>0&&f&&r(f);f=e.pop())c.line--,c.ch=0;f?(c.line--,c.ch=X(a,c.line)):c.ch=0}}function ka(a,b,c){b.ch=0,c.ch=0,c.line++}function la(a){if(!a)return 0; -var b=a.search(/\S/);return-1==b?a.length:b}function ma(a,b,c,e,f){for(var g=ha(a),h=a.getLine(g.line),i=g.ch,j=f?kb[0]:lb[0];!j(h.charAt(i));)if(i++,i>=h.length)return null;e?j=lb[0]:(j=kb[0],j(h.charAt(i))||(j=kb[1]));for(var k=i,l=i;j(h.charAt(k))&&k=0;)l--;if(l++,b){for(var m=k;/\s/.test(h.charAt(k))&&k0;)l--;l||(l=n)}}return{start:d(g.line,l),end:d(g.line,k)}}function na(a,b,c){S(b,c)||ub.jumpList.add(a,b,c)}function oa(a,b){ub.lastCharacterSearch.increment=a,ub.lastCharacterSearch.forward=b.forward,ub.lastCharacterSearch.selectedCharacter=b.selectedCharacter}function pa(a,b,c,e){var f=R(a.getCursor()),g=c?1:-1,h=c?a.lineCount():-1,i=f.ch,j=f.line,k=a.getLine(j),l={lineText:k,nextCh:k.charAt(i),lastCh:null,index:i,symb:e,reverseSymb:(c?{")":"(","}":"{"}:{"(":")","{":"}"})[e],forward:c,depth:0,curMoveThrough:!1},m=Bb[e];if(!m)return f;var n=Cb[m].init,o=Cb[m].isComplete;for(n&&n(l);j!==h&&b;){if(l.index+=g,l.nextCh=l.lineText.charAt(l.index),!l.nextCh){if(j+=g,l.lineText=a.getLine(j)||"",g>0)l.index=0;else{var p=l.lineText.length;l.index=p>0?p-1:0}l.nextCh=l.lineText.charAt(l.index)}o(l)&&(f.line=j,f.ch=l.index,b--)}return l.nextCh||l.curMoveThrough?d(j,l.index):f}function qa(a,b,c,d,e){var f=b.line,g=b.ch,h=a.getLine(f),i=c?1:-1,j=d?lb:kb;if(e&&""==h){if(f+=i,h=a.getLine(f),!m(a,f))return null;g=c?0:h.length}for(;;){if(e&&""==h)return{from:0,to:0,line:f};for(var k=i>0?h.length:-1,l=k,n=k;g!=k;){for(var o=!1,p=0;p0?0:h.length}}function ra(a,b,c,e,f,g){var h=R(b),i=[];(e&&!f||!e&&f)&&c++;for(var j=!(e&&f),k=0;c>k;k++){var l=qa(a,b,e,g,j);if(!l){var m=X(a,a.lastLine());i.push(e?{line:a.lastLine(),from:m,to:m}:{line:0,from:0,to:0});break}i.push(l),b=d(l.line,e?l.to-1:l.from)}var n=i.length!=c,o=i[0],p=i.pop();return e&&!f?(n||o.from==h.ch&&o.line==h.line||(p=i.pop()),d(p.line,p.from)):e&&f?d(p.line,p.to-1):!e&&f?(n||o.to==h.ch&&o.line==h.line||(p=i.pop()),d(p.line,p.to)):d(p.line,p.from)}function sa(a,b,c,e){for(var f,g=a.getCursor(),h=g.ch,i=0;b>i;i++){var j=a.getLine(g.line);if(f=va(h,j,e,c,!0),-1==f)return null;h=f}return d(a.getCursor().line,f)}function ta(a,b){var c=a.getCursor().line;return J(a,d(c,b-1))}function ua(a,b,c,d){s(c,pb)&&(b.marks[c]&&b.marks[c].clear(),b.marks[c]=a.setBookmark(d))}function va(a,b,c,d,e){var f;return d?(f=b.indexOf(c,a+1),-1==f||e||(f-=1)):(f=b.lastIndexOf(c,a-1),-1==f||e||(f+=1)),f}function wa(a,b,c,e,f){function g(b){return!a.getLine(b)}function h(a,b,c){return c?g(a)!=g(a+b):!g(a)&&g(a+b)}var i,j,k=b.line,l=a.firstLine(),m=a.lastLine(),n=k;if(e){for(;n>=l&&m>=n&&c>0;)h(n,e)&&c--,n+=e;return new d(n,0)}var o=a.state.vim;if(o.visualLine&&h(k,1,!0)){var p=o.sel.anchor;h(p.line,-1,!0)&&(f&&p.line==k||(k+=1))}var q=g(k);for(n=k;m>=n&&c;n++)h(n,1,!0)&&(f&&g(n)==q||c--);for(j=new d(n,0),n>m&&!q?q=!0:f=!1,n=k;n>l&&(f&&g(n)!=q&&n!=k||!h(n,-1,!0));n--);return i=new d(n,0),{start:i,end:j}}function xa(a,b,c,e){var f,g,h=b,i={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[c],j={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[c],k=a.getLine(h.line).charAt(h.ch),l=k===j?1:0;if(f=a.scanForBracket(d(h.line,h.ch+l),-1,null,{bracketRegex:i}),g=a.scanForBracket(d(h.line,h.ch+l),1,null,{bracketRegex:i}),!f||!g)return{start:h,end:h};if(f=f.pos,g=g.pos,f.line==g.line&&f.ch>g.ch||f.line>g.line){var m=f;f=g,g=m}return e?g.ch+=1:f.ch+=1,{start:f,end:g}}function ya(a,b,c,e){var f,g,h,i,j=R(b),k=a.getLine(j.line),l=k.split(""),m=l.indexOf(c);if(j.ch-1&&!f;h--)l[h]==c&&(f=h+1);else f=j.ch+1;if(f&&!g)for(h=f,i=l.length;i>h&&!g;h++)l[h]==c&&(g=h);return f&&g?(e&&(--f,++g),{start:d(j.line,f),end:d(j.line,g)}):{start:j,end:j}}function za(){}function Aa(a){var b=a.state.vim;return b.searchState_||(b.searchState_=new za)}function Ba(a,b,c,d,e){a.openDialog?a.openDialog(b,d,{bottom:!0,value:e.value,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,selectValueOnOpen:!1}):d(prompt(c,""))}function Ca(a){var b=Da(a)||[];if(!b.length)return[];var c=[];if(0===b[0]){for(var d=0;d'+b+"",{bottom:!0,duration:5e3}):alert(b)}function Ja(a,b){var c=''+(a||"")+'';return b&&(c+=' '+b+""),c}function Ka(a,b){var c=(b.prefix||"")+" "+(b.desc||""),d=Ja(b.prefix,b.desc);Ba(a,d,c,b.onClose,b)}function La(a,b){if(a instanceof RegExp&&b instanceof RegExp){for(var c=["global","multiline","ignoreCase","source"],d=0;dh;h++){var i=g.find(b);if(0==h&&i&&S(g.from(),f)&&(i=g.find(b)),!i&&(g=a.getSearchCursor(c,b?d(a.lastLine()):d(a.firstLine(),0)),!g.find(b)))return}return g.from()})}function Qa(a){var b=Aa(a);a.removeOverlay(Aa(a).getOverlay()),b.setOverlay(null),b.getScrollbarAnnotate()&&(b.getScrollbarAnnotate().clear(),b.setScrollbarAnnotate(null))}function Ra(a,b,c){return"number"!=typeof a&&(a=a.line),b instanceof Array?s(a,b):c?a>=b&&c>=a:a==b}function Sa(a){var b=a.getScrollInfo(),c=6,d=10,e=a.coordsChar({left:0,top:c+b.top},"local"),f=b.clientHeight-d+b.top,g=a.coordsChar({left:0,top:f},"local");return{top:e.line,bottom:g.line}}function Ta(b,c,d,e,f,g,h,i,j){function k(){b.operation(function(){for(;!p;)l(),m();n()})}function l(){var a=b.getRange(g.from(),g.to()),c=a.replace(h,i);g.replace(c)}function m(){for(;g.findNext()&&Ra(g.from(),e,f);)if(d||!q||g.from().line!=q.line)return b.scrollIntoView(g.from(),30),b.setSelection(g.from(),g.to()),q=g.from(),void(p=!1);p=!0}function n(a){if(a&&a(),b.focus(),q){b.setCursor(q);var c=b.state.vim;c.exMode=!1,c.lastHPos=c.lastHSPos=q.ch}j&&j()}function o(c,d,e){a.e_stop(c);var f=a.keyName(c);switch(f){case"Y":l(),m();break;case"N":m();break;case"A":var g=j;j=void 0,b.operation(k),j=g;break;case"L":l();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":n(e)}return p&&n(e),!0}b.state.vim.exMode=!0;var p=!1,q=g.from();return m(),p?void Ia(b,"No matches for "+h.source):c?void Ka(b,{prefix:"replace with "+i+" (y/n/a/q/l)",onKeyDown:o}):(k(),void(j&&j()))}function Ua(b){var c=b.state.vim,d=ub.macroModeState,e=ub.registerController.getRegister("."),f=d.isPlaying,g=d.lastInsertModeChanges,h=[];if(!f){for(var i=g.inVisualBlock?c.lastSelection.visualBlock.height:1,j=g.changes,h=[],k=0;k1&&(fb(b,c,c.insertModeRepeat-1,!0),c.lastEditInputState.repeatOverride=c.insertModeRepeat),delete c.insertModeRepeat,c.insertMode=!1,b.setCursor(b.getCursor().line,b.getCursor().ch-1),b.setOption("keyMap","vim"),b.setOption("disableInput",!0),b.toggleOverwrite(!1),e.setText(g.changes.join("")),a.signal(b,"vim-mode-change",{mode:"normal"}),d.isRecording&&Za(d)}function Va(a){b.unshift(a)}function Wa(a,b,c,d,e){var f={keys:a,type:b};f[b]=c,f[b+"Args"]=d;for(var g in e)f[g]=e[g];Va(f)}function Xa(b,c,d,e){var f=ub.registerController.getRegister(e);if(":"==e)return f.keyBuffer[0]&&Ib.processCommand(b,f.keyBuffer[0]),void(d.isPlaying=!1);var g=f.keyBuffer,h=0;d.isPlaying=!0,d.replaySearchQueries=f.searchQueries.slice(0);for(var i=0;i|<\w+>|./.exec(l),k=j[0],l=l.substring(j.index+k.length),a.Vim.handleKey(b,k,"macro"),c.insertMode){var m=f.insertModeChanges[h++].changes;ub.macroModeState.lastInsertModeChanges.changes=m,gb(b,m,1),Ua(b)}d.isPlaying=!1}function Ya(a,b){if(!a.isPlaying){var c=a.latestRegister,d=ub.registerController.getRegister(c);d&&d.pushText(b)}}function Za(a){if(!a.isPlaying){var b=a.latestRegister,c=ub.registerController.getRegister(b);c&&c.pushInsertModeChanges&&c.pushInsertModeChanges(a.lastInsertModeChanges)}}function $a(a,b){if(!a.isPlaying){var c=a.latestRegister,d=ub.registerController.getRegister(c);d&&d.pushSearchQuery&&d.pushSearchQuery(b)}}function _a(a,b){var c=ub.macroModeState,d=c.lastInsertModeChanges;if(!c.isPlaying)for(;b;){if(d.expectCursorActivityForChange=!0,"+input"==b.origin||"paste"==b.origin||void 0===b.origin){var e=b.text.join("\n");d.changes.push(e)}b=b.next}}function ab(a){var b=a.state.vim;if(b.insertMode){var c=ub.macroModeState;if(c.isPlaying)return;var d=c.lastInsertModeChanges;d.expectCursorActivityForChange?d.expectCursorActivityForChange=!1:d.changes=[]}else a.curOp.isVimOp||cb(a,b);b.visualMode&&bb(a)}function bb(a){var b=a.state.vim,c=J(a,R(b.sel.head)),d=L(c,0,1);b.fakeCursor&&b.fakeCursor.clear(),b.fakeCursor=a.markText(c,d,{className:"cm-animate-fat-cursor"})}function cb(b,c){var d=b.getCursor("anchor"),e=b.getCursor("head");if(c.visualMode&&!b.somethingSelected()?ia(b,!1):c.visualMode||c.insertMode||!b.somethingSelected()||(c.visualMode=!0,c.visualLine=!1,a.signal(b,"vim-mode-change",{mode:"visual"})),c.visualMode){var f=T(e,d)?0:-1,g=T(e,d)?-1:0;e=L(e,0,f),d=L(d,0,g),c.sel={anchor:d,head:e},ua(b,c,"<",U(e,d)),ua(b,c,">",V(e,d))}else c.insertMode||(c.lastHPos=b.getCursor().ch)}function db(a){this.keyName=a}function eb(b){function c(){return e.changes.push(new db(f)),!0}var d=ub.macroModeState,e=d.lastInsertModeChanges,f=a.keyName(b);f&&(-1!=f.indexOf("Delete")||-1!=f.indexOf("Backspace"))&&a.lookupKey(f,"vim-insert",c)}function fb(a,b,c,d){function e(){h?xb.processAction(a,b,b.lastEditActionCommand):xb.evalInput(a,b)}function f(c){if(g.lastInsertModeChanges.changes.length>0){c=b.lastEditActionCommand?c:1;var d=g.lastInsertModeChanges;gb(a,d.changes,c)}}var g=ub.macroModeState;g.isPlaying=!0;var h=!!b.lastEditActionCommand,i=b.inputState;if(b.inputState=b.lastEditInputState,h&&b.lastEditActionCommand.interlaceInsertRepeat)for(var j=0;c>j;j++)e(),f(1);else d||e(),f(c);b.inputState=i,b.insertMode&&!d&&Ua(a),g.isPlaying=!1}function gb(b,c,d){function e(c){return"string"==typeof c?a.commands[c](b):c(b),!0}var f=b.getCursor("head"),g=ub.macroModeState.lastInsertModeChanges.inVisualBlock;if(g){var h=b.state.vim,i=h.lastSelection,j=M(i.anchor,i.head);aa(b,f,j.line+1),d=b.listSelections().length,b.setCursor(f)}for(var k=0;d>k;k++){g&&b.setCursor(L(f,k,0));for(var l=0;l"]),qb=[].concat(mb,nb,ob,["-",'"',".",":","/"]),rb={};t("filetype",void 0,"string",["ft"],function(a,b){if(void 0!==b){if(void 0===a){var c=b.getOption("mode");return"null"==c?"":c}var c=""==a?"null":a;b.setOption("mode",c)}});var sb=function(){function a(a,b,h){function i(b){var e=++d%c,f=g[e];f&&f.clear(),g[e]=a.setBookmark(b)}var j=d%c,k=g[j];if(k){var l=k.find();l&&!S(l,b)&&i(b)}else i(b);i(h),e=d,f=d-c+1,0>f&&(f=0)}function b(a,b){d+=b,d>e?d=e:f>d&&(d=f);var h=g[(c+d)%c];if(h&&!h.find()){var i,j=b>0?1:-1,k=a.getCursor();do if(d+=j,h=g[(c+d)%c],h&&(i=h.find())&&!S(k,i))break;while(e>d&&d>f)}return h}var c=100,d=-1,e=0,f=0,g=new Array(c);return{cachedCursor:void 0,add:a,move:b}},tb=function(a){return a?{changes:a.changes,expectCursorActivityForChange:a.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};w.prototype={exitMacroRecordMode:function(){var a=ub.macroModeState;a.onRecordingDone&&a.onRecordingDone(),a.onRecordingDone=void 0,a.isRecording=!1},enterMacroRecordMode:function(a,b){var c=ub.registerController.getRegister(b);c&&(c.clear(),this.latestRegister=b,a.openDialog&&(this.onRecordingDone=a.openDialog("(recording)["+b+"]",null,{bottom:!0})),this.isRecording=!0)}};var ub,vb,wb={buildKeyMap:function(){},getRegisterController:function(){return ub.registerController},resetVimGlobalState_:y,getVimGlobalState_:function(){return ub},maybeInitVimState_:x,suppressErrorLogging:!1,InsertModeKey:db,map:function(a,b,c){Ib.map(a,b,c)},unmap:function(a,b){Ib.unmap(a,b)},setOption:u,getOption:v,defineOption:t,defineEx:function(a,b,c){if(b){if(0!==a.indexOf(b))throw new Error('(Vim.defineEx) "'+b+'" is not a prefix of "'+a+'", command not registered')}else b=a;Hb[a]=c,Ib.commandMap_[b]={name:a,shortName:b,type:"api"}},handleKey:function(a,b,c){var d=this.findKey(a,b,c);return"function"==typeof d?d():void 0},findKey:function(c,d,e){function f(){var a=ub.macroModeState;if(a.isRecording){if("q"==d)return a.exitMacroRecordMode(),A(c),!0;"mapping"!=e&&Ya(a,d)}}function g(){return""==d?(A(c),l.visualMode?ia(c):l.insertMode&&Ua(c),!0):void 0}function h(b){for(var e;b;)e=/<\w+-.+?>|<\w+>|./.exec(b),d=e[0],b=b.substring(e.index+d.length),a.Vim.handleKey(c,d,"mapping")}function i(){if(g())return!0;for(var a=l.inputState.keyBuffer=l.inputState.keyBuffer+d,e=1==d.length,f=xb.matchCommand(a,b,l.inputState,"insert");a.length>1&&"full"!=f.type;){var a=l.inputState.keyBuffer=a.slice(1),h=xb.matchCommand(a,b,l.inputState,"insert");"none"!=h.type&&(f=h)}if("none"==f.type)return A(c),!1;if("partial"==f.type)return vb&&window.clearTimeout(vb),vb=window.setTimeout(function(){l.insertMode&&l.inputState.keyBuffer&&A(c)},v("insertModeEscKeysTimeout")),!e;if(vb&&window.clearTimeout(vb),e){var i=c.getCursor();c.replaceRange("",L(i,0,-(a.length-1)),i,"+input")}return A(c),f.command}function j(){if(f()||g())return!0;var a=l.inputState.keyBuffer=l.inputState.keyBuffer+d;if(/^[1-9]\d*$/.test(a))return!0;var e=/^(\d*)(.*)$/.exec(a);if(!e)return A(c),!1;var h=l.visualMode?"visual":"normal",i=xb.matchCommand(e[2]||e[1],b,l.inputState,h);if("none"==i.type)return A(c),!1;if("partial"==i.type)return!0;l.inputState.keyBuffer="";var e=/^(\d*)(.*)$/.exec(a);return e[1]&&"0"!=e[1]&&l.inputState.pushRepeatDigit(e[1]),i.command}var k,l=x(c);return k=l.insertMode?i():j(),k===!1?void 0:k===!0?function(){}:function(){return c.operation(function(){c.curOp.isVimOp=!0;try{"keyToKey"==k.type?h(k.toKeys):xb.processCommand(c,l,k)}catch(b){throw c.state.vim=void 0,x(c),a.Vim.suppressErrorLogging||console.log(b),b}return!0})}},handleEx:function(a,b){Ib.processCommand(a,b)},defineMotion:F,defineAction:I,defineOperator:H,mapCommand:Wa,_mapCommand:Va,defineRegister:C,exitVisualMode:ia,exitInsertMode:Ua};z.prototype.pushRepeatDigit=function(a){this.operator?this.motionRepeat=this.motionRepeat.concat(a):this.prefixRepeat=this.prefixRepeat.concat(a)},z.prototype.getRepeat=function(){var a=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(a=1,this.prefixRepeat.length>0&&(a*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(a*=parseInt(this.motionRepeat.join(""),10))),a},B.prototype={setText:function(a,b,c){this.keyBuffer=[a||""],this.linewise=!!b,this.blockwise=!!c},pushText:function(a,b){b&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0),this.keyBuffer.push(a)},pushInsertModeChanges:function(a){this.insertModeChanges.push(tb(a))},pushSearchQuery:function(a){this.searchQueries.push(a)},clear:function(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1},toString:function(){return this.keyBuffer.join("")}},D.prototype={pushText:function(a,b,c,d,e){d&&"\n"==c.charAt(0)&&(c=c.slice(1)+"\n"),d&&"\n"!==c.charAt(c.length-1)&&(c+="\n");var f=this.isValidRegister(a)?this.getRegister(a):null;if(!f){switch(b){case"yank":this.registers[0]=new B(c,d,e);break;case"delete":case"change":-1==c.indexOf("\n")?this.registers["-"]=new B(c,d):(this.shiftNumericRegisters_(),this.registers[1]=new B(c,d))}return void this.unnamedRegister.setText(c,d,e)}var g=q(a);g?f.pushText(c,d):f.setText(c,d,e),this.unnamedRegister.setText(f.toString(),d)},getRegister:function(a){return this.isValidRegister(a)?(a=a.toLowerCase(),this.registers[a]||(this.registers[a]=new B),this.registers[a]):this.unnamedRegister},isValidRegister:function(a){return a&&s(a,qb)},shiftNumericRegisters_:function(){for(var a=9;a>=2;a--)this.registers[a]=this.getRegister(""+(a-1))}},E.prototype={nextMatch:function(a,b){var c=this.historyBuffer,d=b?-1:1;null===this.initialPrefix&&(this.initialPrefix=a);for(var e=this.iterator+d;b?e>=0:e=c.length?(this.iterator=c.length,this.initialPrefix):0>e?a:void 0},pushInput:function(a){var b=this.historyBuffer.indexOf(a);b>-1&&this.historyBuffer.splice(b,1),a.length&&this.historyBuffer.push(a)},reset:function(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}};var xb={matchCommand:function(a,b,c,d){var e=N(a,b,d,c);if(!e.full&&!e.partial)return{type:"none"};if(!e.full&&e.partial)return{type:"partial"};for(var f,g=0;g"==f.keys.slice(-11)&&(c.selectedCharacter=P(a)),{type:"full",command:f}},processCommand:function(a,b,c){switch(b.inputState.repeatOverride=c.repeatOverride,c.type){case"motion":this.processMotion(a,b,c);break;case"operator":this.processOperator(a,b,c);break;case"operatorMotion":this.processOperatorMotion(a,b,c);break;case"action":this.processAction(a,b,c);break;case"search":this.processSearch(a,b,c);break;case"ex":case"keyToEx":this.processEx(a,b,c)}},processMotion:function(a,b,c){b.inputState.motion=c.motion,b.inputState.motionArgs=K(c.motionArgs),this.evalInput(a,b)},processOperator:function(a,b,c){var d=b.inputState;if(d.operator){if(d.operator==c.operator)return d.motion="expandToLine",d.motionArgs={linewise:!0},void this.evalInput(a,b);A(a)}d.operator=c.operator,d.operatorArgs=K(c.operatorArgs),b.visualMode&&this.evalInput(a,b)},processOperatorMotion:function(a,b,c){var d=b.visualMode,e=K(c.operatorMotionArgs);e&&d&&e.visualLine&&(b.visualLine=!0),this.processOperator(a,b,c),d||this.processMotion(a,b,c)},processAction:function(a,b,c){var d=b.inputState,e=d.getRepeat(),f=!!e,g=K(c.actionArgs)||{};d.selectedCharacter&&(g.selectedCharacter=d.selectedCharacter),c.operator&&this.processOperator(a,b,c),c.motion&&this.processMotion(a,b,c),(c.motion||c.operator)&&this.evalInput(a,b),g.repeat=e||1,g.repeatIsExplicit=f,g.registerName=d.registerName,A(a),b.lastMotion=null,c.isEdit&&this.recordLastEdit(b,d,c),Ab[c.action](a,g,b)},processSearch:function(b,c,d){function e(a,e,f){ub.searchHistoryController.pushInput(a),ub.searchHistoryController.reset();try{Ma(b,a,e,f)}catch(g){return Ia(b,"Invalid regex: "+a),void A(b)}xb.processMotion(b,c,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:d.searchArgs.toJumplist}})}function f(a){b.scrollTo(m.left,m.top),e(a,!0,!0);var c=ub.macroModeState;c.isRecording&&$a(c,a)}function g(c,d,e){var f,g=a.keyName(c);"Up"==g||"Down"==g?(f="Up"==g?!0:!1,d=ub.searchHistoryController.nextMatch(d,f)||"",e(d)):"Left"!=g&&"Right"!=g&&"Ctrl"!=g&&"Alt"!=g&&"Shift"!=g&&ub.searchHistoryController.reset();var h;try{h=Ma(b,d,!0,!0)}catch(c){}h?b.scrollIntoView(Pa(b,!i,h),30):(Qa(b),b.scrollTo(m.left,m.top))}function h(c,d,e){var f=a.keyName(c);"Esc"==f||"Ctrl-C"==f||"Ctrl-["==f||"Backspace"==f&&""==d?(ub.searchHistoryController.pushInput(d),ub.searchHistoryController.reset(),Ma(b,l),Qa(b),b.scrollTo(m.left,m.top),a.e_stop(c),A(b),e(),b.focus()):"Ctrl-U"==f&&(a.e_stop(c),e(""))}if(b.getSearchCursor){var i=d.searchArgs.forward,j=d.searchArgs.wholeWordOnly;Aa(b).setReversed(!i);var k=i?"/":"?",l=Aa(b).getQuery(),m=b.getScrollInfo();switch(d.searchArgs.querySrc){case"prompt":var n=ub.macroModeState;if(n.isPlaying){var o=n.replaySearchQueries.shift();e(o,!0,!1)}else Ka(b,{onClose:f,prefix:k,desc:Fb,onKeyUp:g,onKeyDown:h});break;case"wordUnderCursor":var p=ma(b,!1,!0,!1,!0),q=!0;if(p||(p=ma(b,!1,!0,!1,!1),q=!1),!p)return;var o=b.getLine(p.start.line).substring(p.start.ch,p.end.ch);o=q&&j?"\\b"+o+"\\b":Z(o),ub.jumpList.cachedCursor=b.getCursor(),b.setCursor(p.start),e(o,!0,!1)}}},processEx:function(b,c,d){function e(a){ub.exCommandHistoryController.pushInput(a),ub.exCommandHistoryController.reset(),Ib.processCommand(b,a)}function f(c,d,e){var f,g=a.keyName(c);("Esc"==g||"Ctrl-C"==g||"Ctrl-["==g||"Backspace"==g&&""==d)&&(ub.exCommandHistoryController.pushInput(d),ub.exCommandHistoryController.reset(),a.e_stop(c),A(b),e(),b.focus()),"Up"==g||"Down"==g?(f="Up"==g?!0:!1,d=ub.exCommandHistoryController.nextMatch(d,f)||"",e(d)):"Ctrl-U"==g?(a.e_stop(c),e("")):"Left"!=g&&"Right"!=g&&"Ctrl"!=g&&"Alt"!=g&&"Shift"!=g&&ub.exCommandHistoryController.reset()}"keyToEx"==d.type?Ib.processCommand(b,d.exArgs.input):c.visualMode?Ka(b,{onClose:e,prefix:":",value:"'<,'>",onKeyDown:f}):Ka(b,{onClose:e,prefix:":",onKeyDown:f})},evalInput:function(a,b){var c,e,f,g=b.inputState,h=g.motion,i=g.motionArgs||{},j=g.operator,k=g.operatorArgs||{},l=g.registerName,m=b.sel,n=R(b.visualMode?J(a,m.head):a.getCursor("head")),o=R(b.visualMode?J(a,m.anchor):a.getCursor("anchor")),p=R(n),q=R(o);if(j&&this.recordLastEdit(b,g),f=void 0!==g.repeatOverride?g.repeatOverride:g.getRepeat(),f>0&&i.explicitRepeat?i.repeatIsExplicit=!0:(i.noRepeat||!i.explicitRepeat&&0===f)&&(f=1,i.repeatIsExplicit=!1),g.selectedCharacter&&(i.selectedCharacter=k.selectedCharacter=g.selectedCharacter),i.repeat=f,A(a),h){var r=yb[h](a,n,i,b);if(b.lastMotion=yb[h],!r)return;if(i.toJumplist){var s=ub.jumpList,t=s.cachedCursor;t?(na(a,t,r),delete s.cachedCursor):na(a,n,r)}r instanceof Array?(e=r[0],c=r[1]):c=r,c||(c=R(n)),b.visualMode?(b.visualBlock&&c.ch===1/0||(c=J(a,c,b.visualBlock)),e&&(e=J(a,e,!0)),e=e||q,m.anchor=e,m.head=c,fa(a),ua(a,b,"<",T(e,c)?e:c),ua(a,b,">",T(e,c)?c:e)):j||(c=J(a,c),a.setCursor(c.line,c.ch))}if(j){if(k.lastSel){e=q;var u=k.lastSel,v=Math.abs(u.head.line-u.anchor.line),w=Math.abs(u.head.ch-u.anchor.ch);c=u.visualLine?d(q.line+v,q.ch):u.visualBlock?d(q.line+v,q.ch+w):u.head.line==u.anchor.line?d(q.line,q.ch+w):d(q.line+v,q.ch),b.visualMode=!0,b.visualLine=u.visualLine,b.visualBlock=u.visualBlock,m=b.sel={anchor:e,head:c},fa(a)}else b.visualMode&&(k.lastSel={anchor:R(m.anchor),head:R(m.head),visualBlock:b.visualBlock,visualLine:b.visualLine});var x,y,z,B,C;if(b.visualMode){if(x=U(m.head,m.anchor),y=V(m.head,m.anchor),z=b.visualLine||k.linewise,B=b.visualBlock?"block":z?"line":"char",C=ga(a,{anchor:x,head:y},B),z){var D=C.ranges;if("block"==B)for(var E=0;Ei&&f.line==j?this.moveToStartOfLine(a,b,c,e):i>k&&f.line==k?this.moveToEol(a,b,c,e):(c.toFirstChar&&(g=la(a.getLine(i)),e.lastHPos=g),e.lastHSPos=a.charCoords(d(i,g),"div").left,d(i,g))},moveByDisplayLines:function(a,b,c,e){var f=b;switch(e.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:e.lastHSPos=a.charCoords(f,"div").left}var g=c.repeat,h=a.findPosV(f,c.forward?g:-g,"line",e.lastHSPos);if(h.hitSide)if(c.forward)var i=a.charCoords(h,"div"),j={top:i.top+8,left:e.lastHSPos},h=a.coordsChar(j,"div");else{var k=a.charCoords(d(a.firstLine(),0),"div");k.left=e.lastHSPos,h=a.coordsChar(k,"div")}return e.lastHPos=h.ch,h},moveByPage:function(a,b,c){var d=b,e=c.repeat;return a.findPosV(d,c.forward?e:-e,"page")},moveByParagraph:function(a,b,c){var d=c.forward?1:-1;return wa(a,b,c.repeat,d)},moveByScroll:function(a,b,c,d){var e=a.getScrollInfo(),f=null,g=c.repeat;g||(g=e.clientHeight/(2*a.defaultTextHeight()));var h=a.charCoords(b,"local");c.repeat=g;var f=yb.moveByDisplayLines(a,b,c,d);if(!f)return null;var i=a.charCoords(f,"local");return a.scrollTo(null,e.top+i.top-h.top),f},moveByWords:function(a,b,c){return ra(a,b,c.repeat,!!c.forward,!!c.wordEnd,!!c.bigWord)},moveTillCharacter:function(a,b,c){var d=c.repeat,e=sa(a,d,c.forward,c.selectedCharacter),f=c.forward?-1:1;return oa(f,c),e?(e.ch+=f,e):null},moveToCharacter:function(a,b,c){var d=c.repeat;return oa(0,c),sa(a,d,c.forward,c.selectedCharacter)||b},moveToSymbol:function(a,b,c){var d=c.repeat;return pa(a,d,c.forward,c.selectedCharacter)||b},moveToColumn:function(a,b,c,d){var e=c.repeat;return d.lastHPos=e-1,d.lastHSPos=a.charCoords(b,"div").left,ta(a,e)},moveToEol:function(a,b,c,e){var f=b;e.lastHPos=1/0;var g=d(f.line+c.repeat-1,1/0),h=a.clipPos(g);return h.ch--,e.lastHSPos=a.charCoords(h,"div").left,g},moveToFirstNonWhiteSpaceCharacter:function(a,b){var c=b;return d(c.line,la(a.getLine(c.line)))},moveToMatchedSymbol:function(a,b){var c,e=b,f=e.line,g=e.ch,h=a.getLine(f);do if(c=h.charAt(g++),c&&o(c)){var i=a.getTokenTypeAt(d(f,g));if("string"!==i&&"comment"!==i)break}while(c);if(c){var j=a.findMatchingBracket(d(f,g));return j.to}return e},moveToStartOfLine:function(a,b){return d(b.line,0)},moveToLineOrEdgeOfDocument:function(a,b,c){var e=c.forward?a.lastLine():a.firstLine();return c.repeatIsExplicit&&(e=c.repeat-a.getOption("firstLineNumber")),d(e,la(a.getLine(e)))},textObjectManipulation:function(a,b,c,d){var e={"(":")",")":"(","{":"}","}":"{","[":"]","]":"["},f={"'":!0,'"':!0},g=c.selectedCharacter;"b"==g?g="(":"B"==g&&(g="{");var h,i=!c.textObjectInner;if(e[g])h=xa(a,b,g,i);else if(f[g])h=ya(a,b,g,i);else if("W"===g)h=ma(a,i,!0,!0);else if("w"===g)h=ma(a,i,!0,!1);else{if("p"!==g)return null;if(h=wa(a,b,c.repeat,0,i),c.linewise=!0,d.visualMode)d.visualLine||(d.visualLine=!0);else{var j=d.inputState.operatorArgs;j&&(j.linewise=!0),h.end.line--}}return a.state.vim.visualMode?ea(a,h.start,h.end):[h.start,h.end]},repeatLastCharacterSearch:function(a,b,c){var d=ub.lastCharacterSearch,e=c.repeat,f=c.forward===d.forward,g=(d.increment?1:0)*(f?-1:1);a.moveH(-g,"char"),c.inclusive=f?!0:!1;var h=sa(a,e,f,d.selectedCharacter);return h?(h.ch+=g,h):(a.moveH(g,"char"),b)}},zb={change:function(b,c,e){var f,g,h=b.state.vim;if(ub.macroModeState.lastInsertModeChanges.inVisualBlock=h.visualBlock,h.visualMode){g=b.getSelection();var i=G("",e.length);b.replaceSelections(i),f=U(e[0].head,e[0].anchor)}else{var j=e[0].anchor,k=e[0].head;g=b.getRange(j,k);var l=h.lastEditInputState||{};if("moveByWords"==l.motion&&!r(g)){var m=/\s+$/.exec(g);m&&l.motionArgs&&l.motionArgs.forward&&(k=L(k,0,-m[0].length),g=g.slice(0,-m[0].length))}var n=new d(j.line-1,Number.MAX_VALUE),o=b.firstLine()==b.lastLine();k.line>b.lastLine()&&c.linewise&&!o?b.replaceRange("",n,k):b.replaceRange("",j,k),c.linewise&&(o||(b.setCursor(n),a.commands.newlineAndIndent(b)),j.ch=Number.MAX_VALUE),f=j}ub.registerController.pushText(c.registerName,"change",g,c.linewise,e.length>1),Ab.enterInsertMode(b,{head:f},b.state.vim)},"delete":function(a,b,c){var e,f,g=a.state.vim;if(g.visualBlock){f=a.getSelection();var h=G("",c.length);a.replaceSelections(h),e=c[0].anchor}else{var i=c[0].anchor,j=c[0].head;b.linewise&&j.line!=a.firstLine()&&i.line==a.lastLine()&&i.line==j.line-1&&(i.line==a.firstLine()?i.ch=0:i=d(i.line-1,X(a,i.line-1))),f=a.getRange(i,j),a.replaceRange("",i,j),e=i,b.linewise&&(e=yb.moveToFirstNonWhiteSpaceCharacter(a,i))}return ub.registerController.pushText(b.registerName,"delete",f,b.linewise,g.visualBlock),J(a,e)},indent:function(a,b,c){var d=a.state.vim,e=c[0].anchor.line,f=d.visualBlock?c[c.length-1].anchor.line:c[0].head.line,g=d.visualMode?b.repeat:1;b.linewise&&f--;for(var h=e;f>=h;h++)for(var i=0;g>i;i++)a.indentLine(h,b.indentRight); -return yb.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},changeCase:function(a,b,c,d,e){for(var f=a.getSelections(),g=[],h=b.toLower,i=0;ij.top?(i.line+=(h-j.top)/e,i.line=Math.ceil(i.line),a.setCursor(i),j=a.charCoords(i,"local"),a.scrollTo(null,j.top)):a.scrollTo(null,h);else{var k=h+a.getScrollInfo().clientHeight;k=g.anchor.line?L(g.head,0,1):d(g.anchor.line,0);else if("inplace"==f&&e.visualMode)return;b.setOption("disableInput",!1),c&&c.replace?(b.toggleOverwrite(!0),b.setOption("keyMap","vim-replace"),a.signal(b,"vim-mode-change",{mode:"replace"})):(b.toggleOverwrite(!1),b.setOption("keyMap","vim-insert"),a.signal(b,"vim-mode-change",{mode:"insert"})),ub.macroModeState.isPlaying||(b.on("change",_a),a.on(b.getInputField(),"keydown",eb)),e.visualMode&&ia(b),aa(b,h,i)}},toggleVisualMode:function(b,c,e){var f,g=c.repeat,h=b.getCursor();e.visualMode?e.visualLine^c.linewise||e.visualBlock^c.blockwise?(e.visualLine=!!c.linewise,e.visualBlock=!!c.blockwise,a.signal(b,"vim-mode-change",{mode:"visual",subMode:e.visualLine?"linewise":e.visualBlock?"blockwise":""}),fa(b)):ia(b):(e.visualMode=!0,e.visualLine=!!c.linewise,e.visualBlock=!!c.blockwise,f=J(b,d(h.line,h.ch+g-1),!0),e.sel={anchor:h,head:f},a.signal(b,"vim-mode-change",{mode:"visual",subMode:e.visualLine?"linewise":e.visualBlock?"blockwise":""}),fa(b),ua(b,e,"<",U(h,f)),ua(b,e,">",V(h,f)))},reselectLastSelection:function(b,c,d){var e=d.lastSelection;if(d.visualMode&&da(b,d),e){var f=e.anchorMark.find(),g=e.headMark.find();if(!f||!g)return;d.sel={anchor:f,head:g},d.visualMode=!0,d.visualLine=e.visualLine,d.visualBlock=e.visualBlock,fa(b),ua(b,d,"<",U(f,g)),ua(b,d,">",V(f,g)),a.signal(b,"vim-mode-change",{mode:"visual",subMode:d.visualLine?"linewise":d.visualBlock?"blockwise":""})}},joinLines:function(a,b,c){var e,f;if(c.visualMode){if(e=a.getCursor("anchor"),f=a.getCursor("head"),T(f,e)){var g=f;f=e,e=g}f.ch=X(a,f.line)-1}else{var h=Math.max(b.repeat,2);e=a.getCursor(),f=J(a,d(e.line+h-1,1/0))}for(var i=0,j=e.line;jc)return"";if(a.getOption("indentWithTabs")){var d=Math.floor(c/h);return Array(d+1).join(" ")}return Array(c+1).join(" ")});g+=m?"\n":""}if(b.repeat>1)var g=Array(b.repeat+1).join(g);var o=f.linewise,p=f.blockwise;if(o)c.visualMode?g=c.visualLine?g.slice(0,-1):"\n"+g.slice(0,g.length-1)+"\n":b.after?(g="\n"+g.slice(0,g.length-1),e.ch=X(a,e.line)):e.ch=0;else{if(p){g=g.split("\n");for(var q=0;qa.lastLine()&&a.replaceRange("\n",d(A,0));var B=X(a,A);Bk.length&&(f=k.length),g=d(i.line,f)}if("\n"==h)e.visualMode||b.replaceRange("",i,g),(a.commands.newlineAndIndentContinueComment||a.commands.newlineAndIndent)(b);else{var l=b.getRange(i,g);if(l=l.replace(/[^\n]/g,h),e.visualBlock){var m=new Array(b.getOption("tabSize")+1).join(" ");l=b.getSelection(),l=l.replace(/\t/g,m).replace(/[^\n]/g,h).split("\n"),b.replaceSelections(l)}else b.replaceRange(l,i,g);e.visualMode?(i=T(j[0].anchor,j[0].head)?j[0].anchor:j[0].head,b.setCursor(i),ia(b,!1)):b.setCursor(L(g,0,-1))}},incrementNumberToken:function(a,b){for(var c,e,f,g,h,i=a.getCursor(),j=a.getLine(i.line),k=/-?\d+/g;null!==(c=k.exec(j))&&(h=c[0],e=c.index,f=e+h.length,!(i.ch=1)return!0}else a.nextCh===a.reverseSymb&&a.depth--;return!1}},section:{init:function(a){a.curMoveThrough=!0,a.symb=(a.forward?"]":"[")===a.symb?"{":"}"},isComplete:function(a){return 0===a.index&&a.nextCh===a.symb}},comment:{isComplete:function(a){var b="*"===a.lastCh&&"/"===a.nextCh;return a.lastCh=a.nextCh,b}},method:{init:function(a){a.symb="m"===a.symb?"{":"}",a.reverseSymb="{"===a.symb?"}":"{"},isComplete:function(a){return a.nextCh===a.symb?!0:!1}},preprocess:{init:function(a){a.index=0},isComplete:function(a){if("#"===a.nextCh){var b=a.lineText.match(/#(\w+)/)[1];if("endif"===b){if(a.forward&&0===a.depth)return!0;a.depth++}else if("if"===b){if(!a.forward&&0===a.depth)return!0;a.depth--}if("else"===b&&0===a.depth)return!0}return!1}}};t("pcre",!0,"boolean"),za.prototype={getQuery:function(){return ub.query},setQuery:function(a){ub.query=a},getOverlay:function(){return this.searchOverlay},setOverlay:function(a){this.searchOverlay=a},isReversed:function(){return ub.isReversed},setReversed:function(a){ub.isReversed=a},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(a){this.annotate=a}};var Db={"\\n":"\n","\\r":"\r","\\t":" "},Eb={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":" "},Fb="(Javascript regexp)",Gb=function(){this.buildCommandMap_()};Gb.prototype={processCommand:function(a,b,c){var d=this;a.operation(function(){a.curOp.isVimOp=!0,d._processCommand(a,b,c)})},_processCommand:function(b,c,d){var e=b.state.vim,f=ub.registerController.getRegister(":"),g=f.toString();e.visualMode&&ia(b);var h=new a.StringStream(c);f.setText(c);var i=d||{};i.input=c;try{this.parseInput_(b,h,i)}catch(j){throw Ia(b,j),j}var k,l;if(i.commandName){if(k=this.matchCommand_(i.commandName)){if(l=k.name,k.excludeFromCommandHistory&&f.setText(g),this.parseCommandArgs_(h,i,k),"exToKey"==k.type){for(var m=0;m0;b--){var c=a.substring(0,b);if(this.commandMap_[c]){var d=this.commandMap_[c];if(0===d.name.indexOf(a))return d}}return null},buildCommandMap_:function(){this.commandMap_={};for(var a=0;a
";if(c){var f;c=c.join("");for(var g=0;g"}}else for(var f in d){var i=d[f].toString();i.length&&(e+='"'+f+" "+i+"
")}Ia(a,e)},sort:function(b,c){function e(){if(c.argString){var b=new a.StringStream(c.argString);if(b.eat("!")&&(g=!0),b.eol())return;if(!b.eatSpace())return"Invalid arguments";var d=b.match(/[a-z]+/);if(d){d=d[0],h=-1!=d.indexOf("i"),i=-1!=d.indexOf("u");var e=-1!=d.indexOf("d")&&1,f=-1!=d.indexOf("x")&&1,k=-1!=d.indexOf("o")&&1;if(e+f+k>1)return"Invalid arguments";j=e&&"decimal"||f&&"hex"||k&&"octal"}if(b.match(/\/.*\//))return"patterns not supported"}}function f(a,b){if(g){var c;c=a,a=b,b=c}h&&(a=a.toLowerCase(),b=b.toLowerCase());var d=j&&q.exec(a),e=j&&q.exec(b);return d?(d=parseInt((d[1]+d[2]).toLowerCase(),r),e=parseInt((e[1]+e[2]).toLowerCase(),r),d-e):b>a?-1:1}var g,h,i,j,k=e();if(k)return void Ia(b,k+": "+c.argString);var l=c.line||b.firstLine(),m=c.lineEnd||c.line||b.lastLine();if(l!=m){var n=d(l,0),o=d(m,X(b,m)),p=b.getRange(n,o).split("\n"),q="decimal"==j?/(-?)([\d]+)/:"hex"==j?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==j?/([0-7]+)/:null,r="decimal"==j?10:"hex"==j?16:"octal"==j?8:null,s=[],t=[];if(j)for(var u=0;u=m;m++){var n=j.test(a.getLine(m));n&&(k.push(m+1),l+=a.getLine(m)+"
")}if(!d)return void Ia(a,l);var o=0,p=function(){if(o=k)return void Ia(b,"Invalid argument: "+c.argString.substring(f));for(var l=0;k-j>=l;l++){var m=String.fromCharCode(j+l);delete d.marks[m]}}else delete d.marks[g]}}},Ib=new Gb;return a.keyMap.vim={attach:h,detach:g,call:i},t("insertModeEscKeysTimeout",200,"number"),a.keyMap["vim-insert"]={fallthrough:["default"],attach:h,detach:g,call:i},a.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:h,detach:g,call:i},y(),wb};a.Vim=e()}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){var b=a.getWrapperElement();a.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:b.style.width,height:b.style.height},b.style.width="",b.style.height="auto",b.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",a.refresh()}function c(a){var b=a.getWrapperElement();b.className=b.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="";var c=a.state.fullScreenRestore;b.style.width=c.width,b.style.height=c.height,window.scrollTo(c.scrollLeft,c.scrollTop),a.refresh()}a.defineOption("fullScreen",!1,function(d,e,f){f==a.Init&&(f=!1),!f!=!e&&(e?b(d):c(d))})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b,c,d){this.cm=a,this.node=b,this.options=c,this.height=d,this.cleared=!1}function c(a){var b=a.getWrapperElement(),c=window.getComputedStyle?window.getComputedStyle(b):b.currentStyle,d=parseInt(c.height),e=a.state.panels={setHeight:b.style.height,heightLeft:d,panels:0,wrapper:document.createElement("div")};b.parentNode.insertBefore(e.wrapper,b);var f=a.hasFocus();e.wrapper.appendChild(b),f&&a.focus(),a._setSize=a.setSize,null!=d&&(a.setSize=function(b,c){if(null==c)return this._setSize(b,c);if(e.setHeight=c,"number"!=typeof c){var f=/^(\d+\.?\d*)px$/.exec(c);f?c=Number(f[1]):(e.wrapper.style.height=c,c=e.wrapper.offsetHeight,e.wrapper.style.height="")}a._setSize(b,e.heightLeft+=c-d),d=c})}function d(a){var b=a.state.panels;a.state.panels=null;var c=a.getWrapperElement();b.wrapper.parentNode.replaceChild(c,b.wrapper),c.style.height=b.setHeight,a.setSize=a._setSize,a.setSize()}a.defineExtension("addPanel",function(a,d){d=d||{},this.state.panels||c(this);var e=this.state.panels,f=e.wrapper,g=this.getWrapperElement();d.after instanceof b&&!d.after.cleared?f.insertBefore(a,d.before.node.nextSibling):d.before instanceof b&&!d.before.cleared?f.insertBefore(a,d.before.node):d.replace instanceof b&&!d.replace.cleared?(f.insertBefore(a,d.replace.node),d.replace.clear()):"bottom"==d.position?f.appendChild(a):"before-bottom"==d.position?f.insertBefore(a,g.nextSibling):"after-top"==d.position?f.insertBefore(a,g):f.insertBefore(a,f.firstChild);var h=d&&d.height||a.offsetHeight;return this._setSize(null,e.heightLeft-=h),e.panels++,new b(this,a,d,h)}),b.prototype.clear=function(){if(!this.cleared){this.cleared=!0;var a=this.cm.state.panels;this.cm._setSize(null,a.heightLeft+=this.height),a.wrapper.removeChild(this.node),0==--a.panels&&d(this.cm)}},b.prototype.changed=function(a){var b=null==a?this.node.offsetHeight:a,c=this.cm.state.panels;this.cm._setSize(null,c.height+=b-this.height),this.height=b}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b){return"pairs"==b&&"string"==typeof a?a:"object"==typeof a&&null!=a[b]?a[b]:l[b]}function c(a){return function(b){return h(b,a)}}function d(a){var b=a.state.closeBrackets;if(!b)return null;var c=a.getModeAt(a.getCursor());return c.closeBrackets||b}function e(c){var e=d(c);if(!e||c.getOption("disableInput"))return a.Pass;for(var f=b(e,"pairs"),g=c.listSelections(),h=0;h=0;h--){var k=g[h].head;c.replaceRange("",m(k.line,k.ch-1),m(k.line,k.ch+1),"+delete")}}function f(c){var e=d(c),f=e&&b(e,"explode");if(!f||c.getOption("disableInput"))return a.Pass;for(var g=c.listSelections(),h=0;h0;return{anchor:new m(b.anchor.line,b.anchor.ch+(c?-1:1)),head:new m(b.head.line,b.head.ch+(c?1:-1))}}function h(c,e){var f=d(c);if(!f||c.getOption("disableInput"))return a.Pass;var h=b(f,"pairs"),j=h.indexOf(e);if(-1==j)return a.Pass;for(var l,n=b(f,"triples"),o=h.charAt(j+1)==e,p=c.listSelections(),q=j%2==0,r=0;r1&&n.indexOf(e)>=0&&c.getRange(m(u.line,u.ch-2),u)==e+e&&(u.ch<=2||c.getRange(m(u.line,u.ch-3),m(u.line,u.ch-2))!=e))s="addFour";else if(o){if(a.isWordChar(v)||!k(c,u,e))return a.Pass;s="both"}else{if(!q||c.getLine(u.line).length!=u.ch&&!i(v,h)&&!/\s/.test(v))return a.Pass;s="both"}else s=n.indexOf(e)>=0&&c.getRange(u,m(u.line,u.ch+3))==e+e+e?"skipThree":"skip";if(l){if(l!=s)return a.Pass}else l=s}var w=j%2?h.charAt(j-1):e,x=j%2?e:h.charAt(j+1);c.operation(function(){if("skip"==l)c.execCommand("goCharRight");else if("skipThree"==l)for(var a=0;3>a;a++)c.execCommand("goCharRight");else if("surround"==l){for(var b=c.getSelections(),a=0;a-1&&c%2==1}function j(a,b){var c=a.getRange(m(b.line,b.ch-1),m(b.line,b.ch+1));return 2==c.length?c:null}function k(b,c,d){var e=b.getLine(c.line),f=b.getTokenAt(c);if(/\bstring2?\b/.test(f.type))return!1;var g=new a.StringStream(e.slice(0,c.ch)+d+e.slice(c.ch),4);for(g.pos=g.start=f.start;;){var h=b.getMode().token(g,f.state);if(g.pos>=c.ch+1)return/\bstring2?\b/.test(h);g.start=g.pos}}var l={pairs:"()[]{}''\"\"",triples:"",explode:"[]{}"},m=a.Pos;a.defineOption("autoCloseBrackets",!1,function(b,c,d){d&&d!=a.Init&&(b.removeKeyMap(o),b.state.closeBrackets=null),c&&(b.state.closeBrackets=c,b.addKeyMap(o))});for(var n=l.pairs+"`",o={Backspace:e,Enter:f},p=0;pj.ch&&(r=r.slice(0,r.length-k.end+j.ch));var s=r.toLowerCase();if(!r||"string"==k.type&&(k.end!=j.ch||!/[\"\']/.test(k.string.charAt(k.string.length-1))||1==k.string.length)||"tag"==k.type&&"closeTag"==m.type||k.string.indexOf("/")==k.string.length-1||p&&e(p,s)>-1||f(b,r,j,m,!0))return a.Pass;var t=q&&e(q,s)>-1;d[i]={indent:t,text:">"+(t?"\n\n":"")+"",newPos:t?a.Pos(j.line+1,0):a.Pos(j.line,j.ch+1)}}for(var i=c.length-1;i>=0;i--){var u=d[i];b.replaceRange(u.text,c[i].head,c[i].anchor,"+insert");var v=b.listSelections().slice(0);v[i]={head:u.newPos,anchor:u.newPos},b.setSelections(v),u.indent&&(b.indentLine(u.newPos.line,null,!0),b.indentLine(u.newPos.line+1,null,!0))}}function c(b,c){for(var d=b.listSelections(),e=[],g=c?"/":""!=b.getLine(i.line).charAt(j.end)&&(m+=">"),e[h]=m}b.replaceSelections(e),d=b.listSelections();for(var h=0;hc;++c)if(a[c]==b)return c;return-1}function f(b,c,d,e,f){if(!a.scanForClosingTag)return!1;var g=Math.min(b.lastLine()+1,d.line+500),h=a.scanForClosingTag(b,d,null,g);if(!h||h.tag!=c)return!1;for(var i=e.context,j=f?1:0;i&&i.tagName==c;i=i.prev)++j;d=h.to;for(var k=1;j>k;k++){var l=a.scanForClosingTag(b,d,null,g);if(!l||l.tag!=c)return!1;d=l.to}return!0}a.defineOption("autoCloseTags",!1,function(c,e,f){if(f!=a.Init&&f&&c.removeKeyMap("autoCloseTags"),e){var g={name:"autoCloseTags"};("object"!=typeof e||e.whenClosing)&&(g["'/'"]=function(a){return d(a)}),("object"!=typeof e||e.whenOpening)&&(g["'>'"]=function(a){return b(a)}),c.addKeyMap(g)}});var g=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],h=["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"];a.commands.closeTag=function(a){return c(a)}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function b(a,b,d,e){var f=a.getLineHandle(b.line),i=b.ch-1,j=i>=0&&h[f.text.charAt(i)]||h[f.text.charAt(++i)];if(!j)return null;var k=">"==j.charAt(1)?1:-1;if(d&&k>0!=(i==b.ch))return null;var l=a.getTokenTypeAt(g(b.line,i+1)),m=c(a,g(b.line,i+(k>0?1:0)),k,l||null,e);return null==m?null:{from:g(b.line,i),to:m&&m.pos,match:m&&m.ch==j.charAt(0),forward:k>0}}function c(a,b,c,d,e){for(var f=e&&e.maxScanLineLength||1e4,i=e&&e.maxScanLines||1e3,j=[],k=e&&e.bracketRegex?e.bracketRegex:/[(){}[\]]/,l=c>0?Math.min(b.line+i,a.lastLine()+1):Math.max(a.firstLine()-1,b.line-i),m=b.line;m!=l;m+=c){var n=a.getLine(m);if(n){var o=c>0?0:n.length-1,p=c>0?n.length:-1;if(!(n.length>f))for(m==b.line&&(o=b.ch-(0>c?1:0));o!=p;o+=c){var q=n.charAt(o);if(k.test(q)&&(void 0===d||a.getTokenTypeAt(g(m,o+1))==d)){var r=h[q];if(">"==r.charAt(1)==c>0)j.push(q);else{if(!j.length)return{pos:g(m,o),ch:q};j.pop()}}}}}return m-c==(c>0?a.lastLine():a.firstLine())?!1:null}function d(a,c,d){for(var e=a.state.matchBrackets.maxHighlightLineLength||1e3,h=[],i=a.listSelections(),j=0;j",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},i=null;a.defineOption("matchBrackets",!1,function(b,c,d){d&&d!=a.Init&&(b.off("cursorActivity",e),i&&(i(),i=null)),c&&(b.state.matchBrackets="object"==typeof c?c:{},b.on("cursorActivity",e))}),a.defineExtension("matchBrackets",function(){d(this,!0)}),a.defineExtension("findMatchingBracket",function(a,c,d){return b(this,a,c,d)}),a.defineExtension("scanForBracket",function(a,b,d,e){return c(this,a,b,d,e)})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],a):a(CodeMirror)}(function(a){"use strict";function b(a){a.state.tagHit&&a.state.tagHit.clear(),a.state.tagOther&&a.state.tagOther.clear(),a.state.tagHit=a.state.tagOther=null}function c(c){c.state.failedTagMatch=!1,c.operation(function(){if(b(c),!c.somethingSelected()){var d=c.getCursor(),e=c.getViewport();e.from=Math.min(e.from,d.line),e.to=Math.max(d.line+1,e.to);var f=a.findMatchingTag(c,d,e);if(f){if(c.state.matchBothTags){var g="open"==f.at?f.open:f.close;g&&(c.state.tagHit=c.markText(g.from,g.to,{className:"CodeMirror-matchingtag"}))}var h="close"==f.at?f.open:f.close;h?c.state.tagOther=c.markText(h.from,h.to,{className:"CodeMirror-matchingtag"}):c.state.failedTagMatch=!0}}})}function d(a){a.state.failedTagMatch&&c(a)}a.defineOption("matchTags",!1,function(e,f,g){g&&g!=a.Init&&(e.off("cursorActivity",c),e.off("viewportChange",d),b(e)),f&&(e.state.matchBothTags="object"==typeof f&&f.bothTags,e.on("cursorActivity",c),e.on("viewportChange",d),c(e))}),a.commands.toMatchingTag=function(b){var c=a.findMatchingTag(b,b.getCursor());if(c){var d="close"==c.at?c.open:c.close;d&&b.extendSelection(d.to,d.from)}}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.registerHelper("fold","brace",function(b,c){function d(d){for(var h=c.ch,i=0;;){var j=0>=h?-1:g.lastIndexOf(d,h-1);if(-1!=j){if(1==i&&j=o;++o)for(var p=b.getLine(o),q=o==f?j:0;;){var r=p.indexOf(h,q),s=p.indexOf(i,q);if(0>r&&(r=p.length),0>s&&(s=p.length),q=Math.min(r,s),q==p.length)break;if(b.getTokenTypeAt(a.Pos(o,q+1))==e)if(q==r)++m;else if(!--m){k=o,l=q;break a}++q}if(null!=k&&(f!=k||l!=j))return{from:a.Pos(f,j),to:a.Pos(k,l)}}}),a.registerHelper("fold","import",function(b,c){function d(c){if(cb.lastLine())return null;var d=b.getTokenAt(a.Pos(c,1));if(/\S/.test(d.string)||(d=b.getTokenAt(a.Pos(c,d.end+1))),"keyword"!=d.type||"import"!=d.string)return null;for(var e=c,f=Math.min(b.lastLine(),c+10);f>=e;++e){var g=b.getLine(e),h=g.indexOf(";");if(-1!=h)return{startCh:d.end,end:a.Pos(e,h)}}}var e,f=c.line,g=d(f);if(!g||d(f-1)||(e=d(f-2))&&e.end.line==f-1)return null;for(var h=g.end;;){var i=d(h.line+1);if(null==i)break;h=i.end}return{from:b.clipPos(a.Pos(f,g.startCh+1)),to:h}}),a.registerHelper("fold","include",function(b,c){function d(c){if(cb.lastLine())return null;var d=b.getTokenAt(a.Pos(c,1));return/\S/.test(d.string)||(d=b.getTokenAt(a.Pos(c,d.end+1))),"meta"==d.type&&"#include"==d.string.slice(0,8)?d.start+8:void 0}var e=c.line,f=d(e);if(null==f||null!=d(e-1))return null;for(var g=e;;){var h=d(g+1);if(null==h)break;++g}return{from:a.Pos(e,f+1),to:b.clipPos(a.Pos(g))}})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(b,e,f,g){function h(a){var c=i(b,e);if(!c||c.to.line-c.from.lineb.firstLine();)e=a.Pos(e.line-1,0),k=h(!1);if(k&&!k.cleared&&"unfold"!==g){var l=c(b,f);a.on(l,"mousedown",function(b){m.clear(),a.e_preventDefault(b)});var m=b.markText(k.from,k.to,{replacedWith:l,clearOnEnter:d(b,f,"clearOnEnter"),__isFold:!0});m.on("clear",function(c,d){a.signal(b,"unfold",b,c,d)}),a.signal(b,"fold",b,k.from,k.to)}}function c(a,b){var c=d(a,b,"widget");if("string"==typeof c){var e=document.createTextNode(c);c=document.createElement("span"),c.appendChild(e),c.className="CodeMirror-foldmarker"}return c}function d(a,b,c){if(b&&void 0!==b[c])return b[c];var d=a.options.foldOptions;return d&&void 0!==d[c]?d[c]:e[c]}a.newFoldFunction=function(a,c){return function(d,e){b(d,e,{rangeFinder:a,widget:c})}},a.defineExtension("foldCode",function(a,c,d){b(this,a,c,d)}),a.defineExtension("isFolded",function(a){for(var b=this.findMarksAt(a),c=0;c=c;c++)b.foldCode(a.Pos(c,0),null,"fold")})},a.commands.unfoldAll=function(b){b.operation(function(){for(var c=b.firstLine(),d=b.lastLine();d>=c;c++)b.foldCode(a.Pos(c,0),null,"unfold")})},a.registerHelper("fold","combine",function(){var a=Array.prototype.slice.call(arguments,0);return function(b,c){for(var d=0;d=h&&(c=e(f.indicatorOpen))}a.setGutterMarker(b,f.gutter,c),++g})}function g(a){var b=a.getViewport(),c=a.state.foldGutter;c&&(a.operation(function(){f(a,b.from,b.to)}),c.from=b.from,c.to=b.to)}function h(a,b,c){var e=a.state.foldGutter;if(e){var f=e.options;if(c==f.gutter){var g=d(a,b);g?g.clear():a.foldCode(l(b,0),f.rangeFinder)}}}function i(a){var b=a.state.foldGutter;if(b){var c=b.options;b.from=b.to=0,clearTimeout(b.changeUpdate),b.changeUpdate=setTimeout(function(){g(a)},c.foldOnChangeTimeSpan||600)}}function j(a){var b=a.state.foldGutter;if(b){var c=b.options;clearTimeout(b.changeUpdate),b.changeUpdate=setTimeout(function(){var c=a.getViewport();b.from==b.to||c.from-b.to>20||b.from-c.to>20?g(a):a.operation(function(){c.fromb.to&&(f(a,b.to,c.to),b.to=c.to)})},c.updateViewportTimeSpan||400)}}function k(a,b){var c=a.state.foldGutter;if(c){var d=b.line;d>=c.from&&d=a.max?void 0:(a.ch=0,a.text=a.cm.getLine(++a.line),!0)}function f(a){return a.line<=a.min?void 0:(a.text=a.cm.getLine(--a.line),a.ch=a.text.length,!0)}function g(a){for(;;){var b=a.text.indexOf(">",a.ch);if(-1==b){if(e(a))continue;return}{if(d(a,b+1)){var c=a.text.lastIndexOf("/",b),f=c>-1&&!/\S/.test(a.text.slice(c+1,b));return a.ch=b+1,f?"selfClose":"regular"}a.ch=b+1}}}function h(a){for(;;){var b=a.ch?a.text.lastIndexOf("<",a.ch-1):-1;if(-1==b){if(f(a))continue;return}if(d(a,b+1)){p.lastIndex=b,a.ch=b;var c=p.exec(a.text);if(c&&c.index==b)return c}else a.ch=b}}function i(a){for(;;){p.lastIndex=a.ch;var b=p.exec(a.text);if(!b){if(e(a))continue;return}{if(d(a,b.index+1))return a.ch=b.index+b[0].length,b;a.ch=b.index+1}}}function j(a){for(;;){var b=a.ch?a.text.lastIndexOf(">",a.ch-1):-1;if(-1==b){if(f(a))continue;return}{if(d(a,b+1)){var c=a.text.lastIndexOf("/",b),e=c>-1&&!/\S/.test(a.text.slice(c+1,b));return a.ch=b+1,e?"selfClose":"regular"}a.ch=b}}}function k(a,b){for(var c=[];;){var d,e=i(a),f=a.line,h=a.ch-(e?e[0].length:0);if(!e||!(d=g(a)))return;if("selfClose"!=d)if(e[1]){for(var j=c.length-1;j>=0;--j)if(c[j]==e[2]){c.length=j;break}if(0>j&&(!b||b==e[2]))return{tag:e[2],from:m(f,h),to:m(a.line,a.ch)}}else c.push(e[2])}}function l(a,b){for(var c=[];;){var d=j(a);if(!d)return;if("selfClose"!=d){var e=a.line,f=a.ch,g=h(a);if(!g)return;if(g[1])c.push(g[2]);else{for(var i=c.length-1;i>=0;--i)if(c[i]==g[2]){c.length=i;break}if(0>i&&(!b||b==g[2]))return{tag:g[2],from:m(a.line,a.ch),to:m(e,f)}}}else h(a)}}var m=a.Pos,n="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",o=n+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",p=new RegExp("<(/?)(["+n+"]["+o+"]*)","g");a.registerHelper("fold","xml",function(a,b){for(var d=new c(a,b.line,0);;){var e,f=i(d);if(!f||d.line!=b.line||!(e=g(d)))return;if(!f[1]&&"selfClose"!=e){var h=m(d.line,d.ch),j=k(d,f[2]);return j&&{from:h,to:j.from}}}}),a.findMatchingTag=function(a,d,e){var f=new c(a,d.line,d.ch,e);if(-1!=f.text.indexOf(">")||-1!=f.text.indexOf("<")){var i=g(f),j=i&&m(f.line,f.ch),n=i&&h(f);if(i&&n&&!(b(f,d)>0)){var o={from:m(f.line,f.ch),to:j,tag:n[2]};return"selfClose"==i?{open:o,close:null,at:"open"}:n[1]?{open:l(f,n[2]),close:o,at:"close"}:(f=new c(a,j.line,j.ch,e),{open:o,close:k(f,n[2]),at:"open"})}}},a.findEnclosingTag=function(a,b,d){for(var e=new c(a,b.line,b.ch,d);;){var f=l(e);if(!f)break;var g=new c(a,b.line,b.ch,d),h=k(g,f.tag);if(h)return{open:f,close:h}}},a.scanForClosingTag=function(a,b,d,e){var f=new c(a,b.line,b.ch,e?{from:0,to:e}:null);return k(f,d)}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),"cjs"):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],function(b){a(b,"amd")}):a(CodeMirror,"plain")}(function(a,b){function c(a,b){var c=b;return function(){0==--c&&a()}}function d(b,d){var e=a.modes[b].dependencies;if(!e)return d();for(var f=[],g=0;g-1?e+b.length:e}var f=b.exec(c?a.slice(c):a);return f?f.index+c+(d?f[0].length:0):-1}var d=Array.prototype.slice.call(arguments,1);return{startState:function(){return{outer:a.startState(b),innerActive:null,inner:null}},copyState:function(c){return{outer:a.copyState(b,c.outer),innerActive:c.innerActive,inner:c.innerActive&&a.copyState(c.innerActive.mode,c.inner)}},token:function(e,f){if(f.innerActive){var g=f.innerActive,h=e.string;if(!g.close&&e.sol())return f.innerActive=f.inner=null,this.token(e,f);var i=g.close?c(h,g.close,e.pos,g.parseDelimiters):-1;if(i==e.pos&&!g.parseDelimiters)return e.match(g.close),f.innerActive=f.inner=null,g.delimStyle&&g.delimStyle+" "+g.delimStyle+"-close";i>-1&&(e.string=h.slice(0,i));var j=g.mode.token(e,f.inner);return i>-1&&(e.string=h),i==e.pos&&g.parseDelimiters&&(f.innerActive=f.inner=null),g.innerStyle&&(j=j?j+" "+g.innerStyle:g.innerStyle),j}for(var k=1/0,h=e.string,l=0;li&&(k=i)}k!=1/0&&(e.string=h.slice(0,k));var n=b.token(e,f.outer);return k!=1/0&&(e.string=h),n},indent:function(c,d){var e=c.innerActive?c.innerActive.mode:b;return e.indent?e.indent(c.innerActive?c.inner:c.outer,d):a.Pass},blankLine:function(c){var e=c.innerActive?c.innerActive.mode:b;if(e.blankLine&&e.blankLine(c.innerActive?c.inner:c.outer),c.innerActive)"\n"===c.innerActive.close&&(c.innerActive=c.inner=null);else for(var f=0;fh)return c.charCoords(a,"local")[b?"top":"bottom"];var d=c.heightAtLine(j,"local");return d+(b?0:j.height)}a!==!1&&this.computeScale();var c=this.cm,d=this.hScale,e=document.createDocumentFragment(),f=this.annotations,g=c.getOption("lineWrapping"),h=g&&1.5*c.defaultTextHeight(),i=null,j=null;if(c.display.barWidth)for(var k,l=0;lo+.9));)m=f[++l],o=b(m.to,!1)*d;if(o!=n){var p=Math.max(o-n,3),q=e.appendChild(document.createElement("div"));q.style.cssText="position: absolute; right: 0px; width: "+Math.max(c.display.barWidth-1,2)+"px; top: "+(n+this.buttonHeight)+"px; height: "+p+"px",q.className=this.options.className,m.id&&q.setAttribute("annotation-id",m.id)}}this.div.textContent="",this.div.appendChild(e)},b.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(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(b,c,d){function e(b){var c=a.wheelEventPixels(b)["horizontal"==f.orientation?"x":"y"],d=f.pos;f.moveTo(f.pos+c),f.pos!=d&&a.e_preventDefault(b)}this.orientation=c,this.scroll=d,this.screen=this.total=this.size=1,this.pos=0,this.node=document.createElement("div"),this.node.className=b+"-"+c,this.inner=this.node.appendChild(document.createElement("div"));var f=this;a.on(this.inner,"mousedown",function(b){function c(){a.off(document,"mousemove",d),a.off(document,"mouseup",c)}function d(a){return 1!=a.which?c():void f.moveTo(h+(a[e]-g)*(f.total/f.size))}if(1==b.which){a.e_preventDefault(b);var e="horizontal"==f.orientation?"pageX":"pageY",g=b[e],h=f.pos;a.on(document,"mousemove",d),a.on(document,"mouseup",c)}}),a.on(this.node,"click",function(b){a.e_preventDefault(b);var c,d=f.inner.getBoundingClientRect();c="horizontal"==f.orientation?b.clientXd.right?1:0:b.clientYd.bottom?1:0,f.moveTo(f.pos+c*f.screen)}),a.on(this.node,"mousewheel",e),a.on(this.node,"DOMMouseScroll",e)}function c(a,c,d){this.addClass=a,this.horiz=new b(a,"horizontal",d),c(this.horiz.node),this.vert=new b(a,"vertical",d),c(this.vert.node),this.width=null}b.prototype.setPos=function(a,b){return 0>a&&(a=0),a>this.total-this.screen&&(a=this.total-this.screen),b||a!=this.pos?(this.pos=a,this.inner.style["horizontal"==this.orientation?"left":"top"]=a*(this.size/this.total)+"px",!0):!1},b.prototype.moveTo=function(a){this.setPos(a)&&this.scroll(a,this.orientation)};var d=10;b.prototype.update=function(a,b,c){var e=this.screen!=b||this.total!=a||this.size!=c;e&&(this.screen=b,this.total=a,this.size=c);var f=this.screen*(this.size/this.total);d>f&&(this.size-=d-f,f=d),this.inner.style["horizontal"==this.orientation?"width":"height"]=f+"px",this.setPos(this.pos,e)},c.prototype.update=function(a){if(null==this.width){var b=window.getComputedStyle?window.getComputedStyle(this.horiz.node):this.horiz.node.currentStyle;b&&(this.width=parseInt(b.height))}var c=this.width||0,d=a.scrollWidth>a.clientWidth+1,e=a.scrollHeight>a.clientHeight+1;return this.vert.node.style.display=e?"block":"none",this.horiz.node.style.display=d?"block":"none",e&&(this.vert.update(a.scrollHeight,a.clientHeight,a.viewHeight-(d?c:0)),this.vert.node.style.bottom=d?c+"px":"0"),d&&(this.horiz.update(a.scrollWidth,a.clientWidth,a.viewWidth-(e?c:0)-a.barLeft), +this.horiz.node.style.right=e?c+"px":"0",this.horiz.node.style.left=a.barLeft+"px"),{right:e?c:0,bottom:d?c:0}},c.prototype.setScrollTop=function(a){this.vert.setPos(a)},c.prototype.setScrollLeft=function(a){this.horiz.setPos(a)},c.prototype.clear=function(){var a=this.horiz.node.parentNode;a.removeChild(this.horiz.node),a.removeChild(this.vert.node)},a.scrollbarModel.simple=function(a,b){return new c("CodeMirror-simplescroll",a,b)},a.scrollbarModel.overlay=function(a,b){return new c("CodeMirror-overlayscroll",a,b)}}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c,d){this.cm=a,this.options=d;var e={listenForChanges:!1};for(var f in d)e[f]=d[f];e.className||(e.className="CodeMirror-search-match"),this.annotation=a.annotateScrollbar(e),this.query=b,this.caseFold=c,this.gap={from:a.firstLine(),to:a.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var g=this;a.on("change",this.changeHandler=function(a,b){g.onChange(b)})}function c(a,b,c){return b>=a?a:Math.max(b,a+c)}a.defineExtension("showMatchesOnScrollbar",function(a,c,d){return"string"==typeof d&&(d={className:d}),d||(d={}),new b(this,a,c,d)});var d=1e3;b.prototype.findMatches=function(){if(this.gap){for(var b=0;b=this.gap.to)break;c.to.line>=this.gap.from&&this.matches.splice(b--,1)}for(var e=this.cm.getSearchCursor(this.query,a.Pos(this.gap.from,0),this.caseFold),f=this.options&&this.options.maxMatches||d;e.findNext();){var c={from:e.from(),to:e.to()};if(c.from.line>=this.gap.to)break;if(this.matches.splice(b++,0,c),this.matches.length>f)break}this.gap=null}},b.prototype.onChange=function(b){var d=b.from.line,e=a.changeEnd(b).line,f=e-b.to.line;if(this.gap?(this.gap.from=Math.min(c(this.gap.from,d,f),b.from.line),this.gap.to=Math.max(c(this.gap.to,d,f),b.from.line)):this.gap={from:b.from.line,to:e+1},f)for(var g=0;gh&&f(a,e.slice(h,j),c,b.options.style))}var k=a.getCursor("from"),l=a.getCursor("to");if(k.line==l.line&&(!b.options.wordsOnly||i(a,k,l))){var m=a.getRange(k,l);b.options.trim&&(m=m.replace(/^\s+|\s+$/g,"")),m.length>=b.options.minChars&&f(a,m,!1,b.options.style)}})}function i(a,b,c){var d=a.getRange(b,c);if(null!==d.match(/^\w+$/)){if(b.ch>0){var e={line:b.line,ch:b.ch-1},f=a.getRange(e,b);if(null===f.match(/\W/))return!1}if(c.ch-1)return k=c(i,j,k),{from:d(f.line,k),to:d(f.line,k+g.length)}}else{var i=a.getLine(f.line).slice(f.ch),j=h(i),k=j.indexOf(b);if(k>-1)return k=c(i,j,k)+f.ch,{from:d(f.line,k),to:d(f.line,k+g.length)}}}:this.matches=function(){};else{var j=g.split("\n");this.matches=function(b,c){var e=i.length-1;if(b){if(c.line-(i.length-1)=1;--k,--g)if(i[k]!=h(a.getLine(g)))return;var l=a.getLine(g),m=l.length-j[0].length;if(h(l.slice(m))!=i[0])return;return{from:d(g,m),to:f}}if(!(c.line+(i.length-1)>a.lastLine())){var l=a.getLine(c.line),m=l.length-j[0].length;if(h(l.slice(m))==i[0]){for(var n=d(c.line,m),g=c.line+1,k=1;e>k;++k,++g)if(i[k]!=h(a.getLine(g)))return;if(h(a.getLine(g).slice(0,j[e].length))==i[e])return{from:n,to:d(g,j[e].length)}}}}}}}function c(a,b,c){if(a.length==b.length)return c;for(var d=Math.min(c,a.length);;){var e=a.slice(0,d).toLowerCase().length;if(c>e)++d;else{if(!(e>c))return d;--d}}}var d=a.Pos;b.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(a){function b(a){var b=d(a,0);return c.pos={from:b,to:b},c.atOccurrence=!1,!1}for(var c=this,e=this.doc.clipPos(a?this.pos.from:this.pos.to);;){if(this.pos=this.matches(a,e))return this.atOccurrence=!0,this.pos.match||!0;if(a){if(!e.line)return b(0);e=d(e.line-1,this.doc.getLine(e.line-1).length)}else{var f=this.doc.lineCount();if(e.line==f-1)return b(f);e=d(e.line+1,0)}}},from:function(){return this.atOccurrence?this.pos.from:void 0},to:function(){return this.atOccurrence?this.pos.to:void 0},replace:function(b,c){if(this.atOccurrence){var e=a.splitLines(b);this.doc.replaceRange(e,this.pos.from,this.pos.to,c),this.pos.to=d(this.pos.from.line+e.length-1,e[e.length-1].length+(1==e.length?this.pos.from.ch:0))}}},a.defineExtension("getSearchCursor",function(a,c,d){return new b(this.doc,a,c,d)}),a.defineDocExtension("getSearchCursor",function(a,c,d){return new b(this,a,c,d)}),a.defineExtension("selectMatches",function(b,c){for(var d=[],e=this.getSearchCursor(b,this.getCursor("from"),c);e.findNext()&&!(a.cmpPos(e.to(),this.getCursor("to"))>0);)d.push({anchor:e.from(),head:e.to()});d.length&&this.setSelections(d,0)})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){for(var b=0;b",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"",type:"keyToKey",toKeys:"W"},{keys:"",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"",type:"keyToKey",toKeys:"w"},{keys:"",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"",type:"keyToKey",toKeys:"0"},{keys:"",type:"keyToKey",toKeys:"$"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r",type:"action",action:"replace",isEdit:!0},{keys:"@",type:"action",action:"replayMacro"},{keys:"q",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"",type:"action",action:"redo"},{keys:"m",type:"action",action:"setMark"},{keys:'"',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"a",type:"motion",motion:"textObjectManipulation"},{keys:"i",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],c=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"unmap"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"global",shortName:"g"}],d=a.Pos,e=function(){function e(b){b.setOption("disableInput",!0),b.setOption("showCursorWhenSelecting",!1),a.signal(b,"vim-mode-change",{mode:"normal"}),b.on("cursorActivity",ab),x(b),a.on(b.getInputField(),"paste",k(b))}function f(b){b.setOption("disableInput",!1),b.off("cursorActivity",ab),a.off(b.getInputField(),"paste",k(b)),b.state.vim=null}function g(b,c){this==a.keyMap.vim&&a.rmClass(b.getWrapperElement(),"cm-fat-cursor"),c&&c.attach==h||f(b,!1)}function h(b,c){this==a.keyMap.vim&&a.addClass(b.getWrapperElement(),"cm-fat-cursor"),c&&c.attach==h||e(b)}function i(b,c){if(!c)return void 0;if(this[b])return this[b];var d=j(b);if(!d)return!1;var e=a.Vim.findKey(c,d);return"function"==typeof e&&a.signal(c,"vim-keypress",d),e}function j(a){if("'"==a.charAt(0))return a.charAt(1);var b=a.split(/-(?!$)/),c=b[b.length-1];if(1==b.length&&1==b[0].length)return!1;if(2==b.length&&"Shift"==b[0]&&1==c.length)return!1;for(var d=!1,e=0;e"):!1}function k(a){var b=a.state.vim;return b.onPasteFn||(b.onPasteFn=function(){b.insertMode||(a.setCursor(L(a.getCursor(),0,1)),Ab.enterInsertMode(a,{},b))}),b.onPasteFn}function l(a,b){for(var c=[],d=a;a+b>d;d++)c.push(String.fromCharCode(d));return c}function m(a,b){return b>=a.firstLine()&&b<=a.lastLine()}function n(a){return/^[a-z]$/.test(a)}function o(a){return-1!="()[]{}".indexOf(a)}function p(a){return jb.test(a)}function q(a){return/^[A-Z]$/.test(a)}function r(a){return/^\s*$/.test(a)}function s(a,b){for(var c=0;cd;d++)c.push(a);return c}function H(a,b){zb[a]=b}function I(a,b){Ab[a]=b}function J(a,b,c){var e=Math.min(Math.max(a.firstLine(),b.line),a.lastLine()),f=X(a,e)-1;f=c?f+1:f;var g=Math.min(Math.max(0,b.ch),f);return d(e,g)}function K(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function L(a,b,c){return"object"==typeof b&&(c=b.ch,b=b.line),d(a.line+b,a.ch+c)}function M(a,b){return{line:b.line-a.line,ch:b.line-a.line}}function N(a,b,c,d){for(var e,f=[],g=[],h=0;h"==b.slice(-11)){var c=b.length-11,d=a.slice(0,c),e=b.slice(0,c);return d==e&&a.length>c?"full":0==e.indexOf(d)?"partial":!1}return a==b?"full":0==b.indexOf(a)?"partial":!1}function P(a){var b=/^.*(<[\w\-]+>)$/.exec(a),c=b?b[1]:a.slice(-1);if(c.length>1)switch(c){case"":c="\n";break;case"":c=" "}return c}function Q(a,b,c){return function(){for(var d=0;c>d;d++)b(a)}}function R(a){return d(a.line,a.ch)}function S(a,b){return a.ch==b.ch&&a.line==b.line}function T(a,b){return a.line2&&(b=U.apply(void 0,Array.prototype.slice.call(arguments,1))),T(a,b)?a:b}function V(a,b){return arguments.length>2&&(b=V.apply(void 0,Array.prototype.slice.call(arguments,1))),T(a,b)?b:a}function W(a,b,c){var d=T(a,b),e=T(b,c);return d&&e}function X(a,b){return a.getLine(b).length}function Y(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function Z(a){return a.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function $(a,b,c){var e=X(a,b),f=new Array(c-e+1).join(" ");a.setCursor(d(b,e)),a.replaceRange(f,a.getCursor())}function _(a,b){var c=[],e=a.listSelections(),f=R(a.clipPos(b)),g=!S(b,f),h=a.getCursor("head"),i=ba(e,h),j=S(e[i].head,e[i].anchor),k=e.length-1,l=k-i>i?k:0,m=e[l].anchor,n=Math.min(m.line,f.line),o=Math.max(m.line,f.line),p=m.ch,q=f.ch,r=e[l].head.ch-p,s=q-p;r>0&&0>=s?(p++,g||q--):0>r&&s>=0?(p--,j||q++):0>r&&-1==s&&(p--,q++);for(var t=n;o>=t;t++){var u={anchor:new d(t,p),head:new d(t,q)};c.push(u)}return i=f.line==o?c.length-1:0,a.setSelections(c),b.ch=q,m.ch=p,m}function aa(a,b,c){for(var d=[],e=0;c>e;e++){var f=L(b,e,0);d.push({anchor:f,head:f})}a.setSelections(d,0)}function ba(a,b,c){for(var d=0;dj&&(f.line=j),f.ch=X(a,f.line)}return{ranges:[{anchor:g,head:f}],primary:0}}if("block"==c){for(var k=Math.min(g.line,f.line),l=Math.min(g.ch,f.ch),m=Math.max(g.line,f.line),n=Math.max(g.ch,f.ch)+1,o=m-k+1,p=f.line==k?0:o-1,q=[],r=0;o>r;r++)q.push({anchor:d(k+r,l),head:d(k+r,n)});return{ranges:q,primary:p}}}function ha(a){var b=a.getCursor("head");return 1==a.getSelection().length&&(b=U(b,a.getCursor("anchor"))),b}function ia(b,c){var d=b.state.vim;c!==!1&&b.setCursor(J(b,d.sel.head)),da(b,d),d.visualMode=!1,d.visualLine=!1,d.visualBlock=!1,a.signal(b,"vim-mode-change",{mode:"normal"}),d.fakeCursor&&d.fakeCursor.clear()}function ja(a,b,c){var d=a.getRange(b,c);if(/\n\s*$/.test(d)){ +var e=d.split("\n");e.pop();for(var f,f=e.pop();e.length>0&&f&&r(f);f=e.pop())c.line--,c.ch=0;f?(c.line--,c.ch=X(a,c.line)):c.ch=0}}function ka(a,b,c){b.ch=0,c.ch=0,c.line++}function la(a){if(!a)return 0;var b=a.search(/\S/);return-1==b?a.length:b}function ma(a,b,c,e,f){for(var g=ha(a),h=a.getLine(g.line),i=g.ch,j=f?kb[0]:lb[0];!j(h.charAt(i));)if(i++,i>=h.length)return null;e?j=lb[0]:(j=kb[0],j(h.charAt(i))||(j=kb[1]));for(var k=i,l=i;j(h.charAt(k))&&k=0;)l--;if(l++,b){for(var m=k;/\s/.test(h.charAt(k))&&k0;)l--;l||(l=n)}}return{start:d(g.line,l),end:d(g.line,k)}}function na(a,b,c){S(b,c)||ub.jumpList.add(a,b,c)}function oa(a,b){ub.lastCharacterSearch.increment=a,ub.lastCharacterSearch.forward=b.forward,ub.lastCharacterSearch.selectedCharacter=b.selectedCharacter}function pa(a,b,c,e){var f=R(a.getCursor()),g=c?1:-1,h=c?a.lineCount():-1,i=f.ch,j=f.line,k=a.getLine(j),l={lineText:k,nextCh:k.charAt(i),lastCh:null,index:i,symb:e,reverseSymb:(c?{")":"(","}":"{"}:{"(":")","{":"}"})[e],forward:c,depth:0,curMoveThrough:!1},m=Bb[e];if(!m)return f;var n=Cb[m].init,o=Cb[m].isComplete;for(n&&n(l);j!==h&&b;){if(l.index+=g,l.nextCh=l.lineText.charAt(l.index),!l.nextCh){if(j+=g,l.lineText=a.getLine(j)||"",g>0)l.index=0;else{var p=l.lineText.length;l.index=p>0?p-1:0}l.nextCh=l.lineText.charAt(l.index)}o(l)&&(f.line=j,f.ch=l.index,b--)}return l.nextCh||l.curMoveThrough?d(j,l.index):f}function qa(a,b,c,d,e){var f=b.line,g=b.ch,h=a.getLine(f),i=c?1:-1,j=d?lb:kb;if(e&&""==h){if(f+=i,h=a.getLine(f),!m(a,f))return null;g=c?0:h.length}for(;;){if(e&&""==h)return{from:0,to:0,line:f};for(var k=i>0?h.length:-1,l=k,n=k;g!=k;){for(var o=!1,p=0;p0?0:h.length}}function ra(a,b,c,e,f,g){var h=R(b),i=[];(e&&!f||!e&&f)&&c++;for(var j=!(e&&f),k=0;c>k;k++){var l=qa(a,b,e,g,j);if(!l){var m=X(a,a.lastLine());i.push(e?{line:a.lastLine(),from:m,to:m}:{line:0,from:0,to:0});break}i.push(l),b=d(l.line,e?l.to-1:l.from)}var n=i.length!=c,o=i[0],p=i.pop();return e&&!f?(n||o.from==h.ch&&o.line==h.line||(p=i.pop()),d(p.line,p.from)):e&&f?d(p.line,p.to-1):!e&&f?(n||o.to==h.ch&&o.line==h.line||(p=i.pop()),d(p.line,p.to)):d(p.line,p.from)}function sa(a,b,c,e){for(var f,g=a.getCursor(),h=g.ch,i=0;b>i;i++){var j=a.getLine(g.line);if(f=va(h,j,e,c,!0),-1==f)return null;h=f}return d(a.getCursor().line,f)}function ta(a,b){var c=a.getCursor().line;return J(a,d(c,b-1))}function ua(a,b,c,d){s(c,pb)&&(b.marks[c]&&b.marks[c].clear(),b.marks[c]=a.setBookmark(d))}function va(a,b,c,d,e){var f;return d?(f=b.indexOf(c,a+1),-1==f||e||(f-=1)):(f=b.lastIndexOf(c,a-1),-1==f||e||(f+=1)),f}function wa(a,b,c,e,f){function g(b){return!a.getLine(b)}function h(a,b,c){return c?g(a)!=g(a+b):!g(a)&&g(a+b)}var i,j,k=b.line,l=a.firstLine(),m=a.lastLine(),n=k;if(e){for(;n>=l&&m>=n&&c>0;)h(n,e)&&c--,n+=e;return new d(n,0)}var o=a.state.vim;if(o.visualLine&&h(k,1,!0)){var p=o.sel.anchor;h(p.line,-1,!0)&&(f&&p.line==k||(k+=1))}var q=g(k);for(n=k;m>=n&&c;n++)h(n,1,!0)&&(f&&g(n)==q||c--);for(j=new d(n,0),n>m&&!q?q=!0:f=!1,n=k;n>l&&(f&&g(n)!=q&&n!=k||!h(n,-1,!0));n--);return i=new d(n,0),{start:i,end:j}}function xa(a,b,c,e){var f,g,h=b,i={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[c],j={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[c],k=a.getLine(h.line).charAt(h.ch),l=k===j?1:0;if(f=a.scanForBracket(d(h.line,h.ch+l),-1,null,{bracketRegex:i}),g=a.scanForBracket(d(h.line,h.ch+l),1,null,{bracketRegex:i}),!f||!g)return{start:h,end:h};if(f=f.pos,g=g.pos,f.line==g.line&&f.ch>g.ch||f.line>g.line){var m=f;f=g,g=m}return e?g.ch+=1:f.ch+=1,{start:f,end:g}}function ya(a,b,c,e){var f,g,h,i,j=R(b),k=a.getLine(j.line),l=k.split(""),m=l.indexOf(c);if(j.ch-1&&!f;h--)l[h]==c&&(f=h+1);else f=j.ch+1;if(f&&!g)for(h=f,i=l.length;i>h&&!g;h++)l[h]==c&&(g=h);return f&&g?(e&&(--f,++g),{start:d(j.line,f),end:d(j.line,g)}):{start:j,end:j}}function za(){}function Aa(a){var b=a.state.vim;return b.searchState_||(b.searchState_=new za)}function Ba(a,b,c,d,e){a.openDialog?a.openDialog(b,d,{bottom:!0,value:e.value,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,selectValueOnOpen:!1}):d(prompt(c,""))}function Ca(a){var b=Da(a)||[];if(!b.length)return[];var c=[];if(0===b[0]){for(var d=0;d'+b+"",{bottom:!0,duration:5e3}):alert(b)}function Ja(a,b){var c=''+(a||"")+'';return b&&(c+=' '+b+""),c}function Ka(a,b){var c=(b.prefix||"")+" "+(b.desc||""),d=Ja(b.prefix,b.desc);Ba(a,d,c,b.onClose,b)}function La(a,b){if(a instanceof RegExp&&b instanceof RegExp){for(var c=["global","multiline","ignoreCase","source"],d=0;dh;h++){var i=g.find(b);if(0==h&&i&&S(g.from(),f)&&(i=g.find(b)),!i&&(g=a.getSearchCursor(c,b?d(a.lastLine()):d(a.firstLine(),0)),!g.find(b)))return}return g.from()})}function Qa(a){var b=Aa(a);a.removeOverlay(Aa(a).getOverlay()),b.setOverlay(null),b.getScrollbarAnnotate()&&(b.getScrollbarAnnotate().clear(),b.setScrollbarAnnotate(null))}function Ra(a,b,c){return"number"!=typeof a&&(a=a.line),b instanceof Array?s(a,b):c?a>=b&&c>=a:a==b}function Sa(a){var b=a.getScrollInfo(),c=6,d=10,e=a.coordsChar({left:0,top:c+b.top},"local"),f=b.clientHeight-d+b.top,g=a.coordsChar({left:0,top:f},"local");return{top:e.line,bottom:g.line}}function Ta(b,c,d,e,f,g,h,i,j){function k(){b.operation(function(){for(;!p;)l(),m();n()})}function l(){var a=b.getRange(g.from(),g.to()),c=a.replace(h,i);g.replace(c)}function m(){for(;g.findNext()&&Ra(g.from(),e,f);)if(d||!q||g.from().line!=q.line)return b.scrollIntoView(g.from(),30),b.setSelection(g.from(),g.to()),q=g.from(),void(p=!1);p=!0}function n(a){if(a&&a(),b.focus(),q){b.setCursor(q);var c=b.state.vim;c.exMode=!1,c.lastHPos=c.lastHSPos=q.ch}j&&j()}function o(c,d,e){a.e_stop(c);var f=a.keyName(c);switch(f){case"Y":l(),m();break;case"N":m();break;case"A":var g=j;j=void 0,b.operation(k),j=g;break;case"L":l();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":n(e)}return p&&n(e),!0}b.state.vim.exMode=!0;var p=!1,q=g.from();return m(),p?void Ia(b,"No matches for "+h.source):c?void Ka(b,{prefix:"replace with "+i+" (y/n/a/q/l)",onKeyDown:o}):(k(),void(j&&j()))}function Ua(b){var c=b.state.vim,d=ub.macroModeState,e=ub.registerController.getRegister("."),f=d.isPlaying,g=d.lastInsertModeChanges,h=[];if(!f){for(var i=g.inVisualBlock?c.lastSelection.visualBlock.height:1,j=g.changes,h=[],k=0;k1&&(fb(b,c,c.insertModeRepeat-1,!0),c.lastEditInputState.repeatOverride=c.insertModeRepeat),delete c.insertModeRepeat,c.insertMode=!1,b.setCursor(b.getCursor().line,b.getCursor().ch-1),b.setOption("keyMap","vim"),b.setOption("disableInput",!0),b.toggleOverwrite(!1),e.setText(g.changes.join("")),a.signal(b,"vim-mode-change",{mode:"normal"}),d.isRecording&&Za(d)}function Va(a){b.unshift(a)}function Wa(a,b,c,d,e){var f={keys:a,type:b};f[b]=c,f[b+"Args"]=d;for(var g in e)f[g]=e[g];Va(f)}function Xa(b,c,d,e){var f=ub.registerController.getRegister(e);if(":"==e)return f.keyBuffer[0]&&Ib.processCommand(b,f.keyBuffer[0]),void(d.isPlaying=!1);var g=f.keyBuffer,h=0;d.isPlaying=!0,d.replaySearchQueries=f.searchQueries.slice(0);for(var i=0;i|<\w+>|./.exec(l),k=j[0],l=l.substring(j.index+k.length),a.Vim.handleKey(b,k,"macro"),c.insertMode){var m=f.insertModeChanges[h++].changes;ub.macroModeState.lastInsertModeChanges.changes=m,gb(b,m,1),Ua(b)}d.isPlaying=!1}function Ya(a,b){if(!a.isPlaying){var c=a.latestRegister,d=ub.registerController.getRegister(c);d&&d.pushText(b)}}function Za(a){if(!a.isPlaying){var b=a.latestRegister,c=ub.registerController.getRegister(b);c&&c.pushInsertModeChanges&&c.pushInsertModeChanges(a.lastInsertModeChanges)}}function $a(a,b){if(!a.isPlaying){var c=a.latestRegister,d=ub.registerController.getRegister(c);d&&d.pushSearchQuery&&d.pushSearchQuery(b)}}function _a(a,b){var c=ub.macroModeState,d=c.lastInsertModeChanges;if(!c.isPlaying)for(;b;){if(d.expectCursorActivityForChange=!0,"+input"==b.origin||"paste"==b.origin||void 0===b.origin){var e=b.text.join("\n");d.changes.push(e)}b=b.next}}function ab(a){var b=a.state.vim;if(b.insertMode){var c=ub.macroModeState;if(c.isPlaying)return;var d=c.lastInsertModeChanges;d.expectCursorActivityForChange?d.expectCursorActivityForChange=!1:d.changes=[]}else a.curOp.isVimOp||cb(a,b);b.visualMode&&bb(a)}function bb(a){var b=a.state.vim,c=J(a,R(b.sel.head)),d=L(c,0,1);b.fakeCursor&&b.fakeCursor.clear(),b.fakeCursor=a.markText(c,d,{className:"cm-animate-fat-cursor"})}function cb(b,c){var d=b.getCursor("anchor"),e=b.getCursor("head");if(c.visualMode&&!b.somethingSelected()?ia(b,!1):c.visualMode||c.insertMode||!b.somethingSelected()||(c.visualMode=!0,c.visualLine=!1,a.signal(b,"vim-mode-change",{mode:"visual"})),c.visualMode){var f=T(e,d)?0:-1,g=T(e,d)?-1:0;e=L(e,0,f),d=L(d,0,g),c.sel={anchor:d,head:e},ua(b,c,"<",U(e,d)),ua(b,c,">",V(e,d))}else c.insertMode||(c.lastHPos=b.getCursor().ch)}function db(a){this.keyName=a}function eb(b){function c(){return e.changes.push(new db(f)),!0}var d=ub.macroModeState,e=d.lastInsertModeChanges,f=a.keyName(b);f&&(-1!=f.indexOf("Delete")||-1!=f.indexOf("Backspace"))&&a.lookupKey(f,"vim-insert",c)}function fb(a,b,c,d){function e(){h?xb.processAction(a,b,b.lastEditActionCommand):xb.evalInput(a,b)}function f(c){if(g.lastInsertModeChanges.changes.length>0){c=b.lastEditActionCommand?c:1;var d=g.lastInsertModeChanges;gb(a,d.changes,c)}}var g=ub.macroModeState;g.isPlaying=!0;var h=!!b.lastEditActionCommand,i=b.inputState;if(b.inputState=b.lastEditInputState,h&&b.lastEditActionCommand.interlaceInsertRepeat)for(var j=0;c>j;j++)e(),f(1);else d||e(),f(c);b.inputState=i,b.insertMode&&!d&&Ua(a),g.isPlaying=!1}function gb(b,c,d){function e(c){return"string"==typeof c?a.commands[c](b):c(b),!0}var f=b.getCursor("head"),g=ub.macroModeState.lastInsertModeChanges.inVisualBlock;if(g){var h=b.state.vim,i=h.lastSelection,j=M(i.anchor,i.head);aa(b,f,j.line+1),d=b.listSelections().length,b.setCursor(f)}for(var k=0;d>k;k++){g&&b.setCursor(L(f,k,0));for(var l=0;l"]),qb=[].concat(mb,nb,ob,["-",'"',".",":","/"]),rb={};t("filetype",void 0,"string",["ft"],function(a,b){if(void 0!==b){if(void 0===a){var c=b.getOption("mode");return"null"==c?"":c}var c=""==a?"null":a;b.setOption("mode",c)}});var sb=function(){function a(a,b,h){function i(b){var e=++d%c,f=g[e];f&&f.clear(),g[e]=a.setBookmark(b)}var j=d%c,k=g[j];if(k){var l=k.find();l&&!S(l,b)&&i(b)}else i(b);i(h),e=d,f=d-c+1,0>f&&(f=0)}function b(a,b){d+=b,d>e?d=e:f>d&&(d=f);var h=g[(c+d)%c];if(h&&!h.find()){var i,j=b>0?1:-1,k=a.getCursor();do if(d+=j,h=g[(c+d)%c],h&&(i=h.find())&&!S(k,i))break;while(e>d&&d>f)}return h}var c=100,d=-1,e=0,f=0,g=new Array(c);return{cachedCursor:void 0,add:a,move:b}},tb=function(a){return a?{changes:a.changes,expectCursorActivityForChange:a.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};w.prototype={exitMacroRecordMode:function(){var a=ub.macroModeState;a.onRecordingDone&&a.onRecordingDone(),a.onRecordingDone=void 0,a.isRecording=!1},enterMacroRecordMode:function(a,b){var c=ub.registerController.getRegister(b);c&&(c.clear(),this.latestRegister=b,a.openDialog&&(this.onRecordingDone=a.openDialog("(recording)["+b+"]",null,{bottom:!0})),this.isRecording=!0)}};var ub,vb,wb={buildKeyMap:function(){},getRegisterController:function(){return ub.registerController},resetVimGlobalState_:y,getVimGlobalState_:function(){return ub},maybeInitVimState_:x,suppressErrorLogging:!1,InsertModeKey:db,map:function(a,b,c){Ib.map(a,b,c)},unmap:function(a,b){Ib.unmap(a,b)},setOption:u,getOption:v,defineOption:t,defineEx:function(a,b,c){if(b){if(0!==a.indexOf(b))throw new Error('(Vim.defineEx) "'+b+'" is not a prefix of "'+a+'", command not registered')}else b=a;Hb[a]=c,Ib.commandMap_[b]={name:a,shortName:b,type:"api"}},handleKey:function(a,b,c){var d=this.findKey(a,b,c);return"function"==typeof d?d():void 0},findKey:function(c,d,e){function f(){var a=ub.macroModeState;if(a.isRecording){if("q"==d)return a.exitMacroRecordMode(),A(c),!0;"mapping"!=e&&Ya(a,d)}}function g(){return""==d?(A(c),l.visualMode?ia(c):l.insertMode&&Ua(c),!0):void 0}function h(b){for(var e;b;)e=/<\w+-.+?>|<\w+>|./.exec(b),d=e[0],b=b.substring(e.index+d.length),a.Vim.handleKey(c,d,"mapping")}function i(){if(g())return!0;for(var a=l.inputState.keyBuffer=l.inputState.keyBuffer+d,e=1==d.length,f=xb.matchCommand(a,b,l.inputState,"insert");a.length>1&&"full"!=f.type;){var a=l.inputState.keyBuffer=a.slice(1),h=xb.matchCommand(a,b,l.inputState,"insert");"none"!=h.type&&(f=h)}if("none"==f.type)return A(c),!1;if("partial"==f.type)return vb&&window.clearTimeout(vb),vb=window.setTimeout(function(){l.insertMode&&l.inputState.keyBuffer&&A(c)},v("insertModeEscKeysTimeout")),!e;if(vb&&window.clearTimeout(vb),e){var i=c.getCursor();c.replaceRange("",L(i,0,-(a.length-1)),i,"+input")}return A(c),f.command}function j(){if(f()||g())return!0;var a=l.inputState.keyBuffer=l.inputState.keyBuffer+d;if(/^[1-9]\d*$/.test(a))return!0;var e=/^(\d*)(.*)$/.exec(a);if(!e)return A(c),!1;var h=l.visualMode?"visual":"normal",i=xb.matchCommand(e[2]||e[1],b,l.inputState,h);if("none"==i.type)return A(c),!1;if("partial"==i.type)return!0;l.inputState.keyBuffer="";var e=/^(\d*)(.*)$/.exec(a);return e[1]&&"0"!=e[1]&&l.inputState.pushRepeatDigit(e[1]),i.command}var k,l=x(c);return k=l.insertMode?i():j(),k===!1?void 0:k===!0?function(){}:function(){return c.operation(function(){c.curOp.isVimOp=!0;try{"keyToKey"==k.type?h(k.toKeys):xb.processCommand(c,l,k)}catch(b){throw c.state.vim=void 0,x(c),a.Vim.suppressErrorLogging||console.log(b),b}return!0})}},handleEx:function(a,b){Ib.processCommand(a,b)},defineMotion:F,defineAction:I,defineOperator:H,mapCommand:Wa,_mapCommand:Va,defineRegister:C,exitVisualMode:ia,exitInsertMode:Ua};z.prototype.pushRepeatDigit=function(a){this.operator?this.motionRepeat=this.motionRepeat.concat(a):this.prefixRepeat=this.prefixRepeat.concat(a)},z.prototype.getRepeat=function(){var a=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(a=1,this.prefixRepeat.length>0&&(a*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(a*=parseInt(this.motionRepeat.join(""),10))),a},B.prototype={setText:function(a,b,c){this.keyBuffer=[a||""],this.linewise=!!b,this.blockwise=!!c},pushText:function(a,b){b&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0),this.keyBuffer.push(a)},pushInsertModeChanges:function(a){this.insertModeChanges.push(tb(a))},pushSearchQuery:function(a){this.searchQueries.push(a)},clear:function(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1},toString:function(){return this.keyBuffer.join("")}},D.prototype={pushText:function(a,b,c,d,e){d&&"\n"==c.charAt(0)&&(c=c.slice(1)+"\n"),d&&"\n"!==c.charAt(c.length-1)&&(c+="\n");var f=this.isValidRegister(a)?this.getRegister(a):null;if(!f){switch(b){case"yank":this.registers[0]=new B(c,d,e);break;case"delete":case"change":-1==c.indexOf("\n")?this.registers["-"]=new B(c,d):(this.shiftNumericRegisters_(),this.registers[1]=new B(c,d))}return void this.unnamedRegister.setText(c,d,e)}var g=q(a);g?f.pushText(c,d):f.setText(c,d,e),this.unnamedRegister.setText(f.toString(),d)},getRegister:function(a){return this.isValidRegister(a)?(a=a.toLowerCase(),this.registers[a]||(this.registers[a]=new B),this.registers[a]):this.unnamedRegister},isValidRegister:function(a){return a&&s(a,qb)},shiftNumericRegisters_:function(){for(var a=9;a>=2;a--)this.registers[a]=this.getRegister(""+(a-1))}},E.prototype={nextMatch:function(a,b){var c=this.historyBuffer,d=b?-1:1;null===this.initialPrefix&&(this.initialPrefix=a);for(var e=this.iterator+d;b?e>=0:e=c.length?(this.iterator=c.length,this.initialPrefix):0>e?a:void 0},pushInput:function(a){var b=this.historyBuffer.indexOf(a);b>-1&&this.historyBuffer.splice(b,1),a.length&&this.historyBuffer.push(a)},reset:function(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}};var xb={matchCommand:function(a,b,c,d){var e=N(a,b,d,c);if(!e.full&&!e.partial)return{type:"none"};if(!e.full&&e.partial)return{type:"partial"};for(var f,g=0;g"==f.keys.slice(-11)&&(c.selectedCharacter=P(a)),{type:"full",command:f}},processCommand:function(a,b,c){switch(b.inputState.repeatOverride=c.repeatOverride,c.type){case"motion":this.processMotion(a,b,c);break;case"operator":this.processOperator(a,b,c);break;case"operatorMotion":this.processOperatorMotion(a,b,c);break;case"action":this.processAction(a,b,c);break;case"search":this.processSearch(a,b,c);break;case"ex":case"keyToEx":this.processEx(a,b,c)}},processMotion:function(a,b,c){b.inputState.motion=c.motion,b.inputState.motionArgs=K(c.motionArgs),this.evalInput(a,b)},processOperator:function(a,b,c){var d=b.inputState;if(d.operator){if(d.operator==c.operator)return d.motion="expandToLine",d.motionArgs={linewise:!0},void this.evalInput(a,b);A(a)}d.operator=c.operator,d.operatorArgs=K(c.operatorArgs),b.visualMode&&this.evalInput(a,b)},processOperatorMotion:function(a,b,c){var d=b.visualMode,e=K(c.operatorMotionArgs);e&&d&&e.visualLine&&(b.visualLine=!0),this.processOperator(a,b,c),d||this.processMotion(a,b,c)},processAction:function(a,b,c){var d=b.inputState,e=d.getRepeat(),f=!!e,g=K(c.actionArgs)||{};d.selectedCharacter&&(g.selectedCharacter=d.selectedCharacter),c.operator&&this.processOperator(a,b,c),c.motion&&this.processMotion(a,b,c),(c.motion||c.operator)&&this.evalInput(a,b),g.repeat=e||1,g.repeatIsExplicit=f,g.registerName=d.registerName,A(a),b.lastMotion=null,c.isEdit&&this.recordLastEdit(b,d,c),Ab[c.action](a,g,b)},processSearch:function(b,c,d){function e(a,e,f){ub.searchHistoryController.pushInput(a),ub.searchHistoryController.reset();try{Ma(b,a,e,f)}catch(g){return Ia(b,"Invalid regex: "+a),void A(b)}xb.processMotion(b,c,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:d.searchArgs.toJumplist}})}function f(a){b.scrollTo(m.left,m.top),e(a,!0,!0);var c=ub.macroModeState;c.isRecording&&$a(c,a)}function g(c,d,e){var f,g=a.keyName(c);"Up"==g||"Down"==g?(f="Up"==g?!0:!1,d=ub.searchHistoryController.nextMatch(d,f)||"",e(d)):"Left"!=g&&"Right"!=g&&"Ctrl"!=g&&"Alt"!=g&&"Shift"!=g&&ub.searchHistoryController.reset();var h;try{h=Ma(b,d,!0,!0)}catch(c){}h?b.scrollIntoView(Pa(b,!i,h),30):(Qa(b),b.scrollTo(m.left,m.top))}function h(c,d,e){var f=a.keyName(c);"Esc"==f||"Ctrl-C"==f||"Ctrl-["==f||"Backspace"==f&&""==d?(ub.searchHistoryController.pushInput(d),ub.searchHistoryController.reset(),Ma(b,l),Qa(b),b.scrollTo(m.left,m.top),a.e_stop(c),A(b),e(),b.focus()):"Ctrl-U"==f&&(a.e_stop(c),e(""))}if(b.getSearchCursor){var i=d.searchArgs.forward,j=d.searchArgs.wholeWordOnly;Aa(b).setReversed(!i);var k=i?"/":"?",l=Aa(b).getQuery(),m=b.getScrollInfo();switch(d.searchArgs.querySrc){case"prompt":var n=ub.macroModeState;if(n.isPlaying){var o=n.replaySearchQueries.shift();e(o,!0,!1)}else Ka(b,{onClose:f,prefix:k,desc:Fb,onKeyUp:g,onKeyDown:h});break;case"wordUnderCursor":var p=ma(b,!1,!0,!1,!0),q=!0;if(p||(p=ma(b,!1,!0,!1,!1),q=!1),!p)return;var o=b.getLine(p.start.line).substring(p.start.ch,p.end.ch);o=q&&j?"\\b"+o+"\\b":Z(o),ub.jumpList.cachedCursor=b.getCursor(),b.setCursor(p.start),e(o,!0,!1)}}},processEx:function(b,c,d){function e(a){ub.exCommandHistoryController.pushInput(a),ub.exCommandHistoryController.reset(),Ib.processCommand(b,a)}function f(c,d,e){var f,g=a.keyName(c);("Esc"==g||"Ctrl-C"==g||"Ctrl-["==g||"Backspace"==g&&""==d)&&(ub.exCommandHistoryController.pushInput(d),ub.exCommandHistoryController.reset(),a.e_stop(c),A(b),e(),b.focus()),"Up"==g||"Down"==g?(f="Up"==g?!0:!1,d=ub.exCommandHistoryController.nextMatch(d,f)||"",e(d)):"Ctrl-U"==g?(a.e_stop(c),e("")):"Left"!=g&&"Right"!=g&&"Ctrl"!=g&&"Alt"!=g&&"Shift"!=g&&ub.exCommandHistoryController.reset()}"keyToEx"==d.type?Ib.processCommand(b,d.exArgs.input):c.visualMode?Ka(b,{onClose:e,prefix:":",value:"'<,'>",onKeyDown:f}):Ka(b,{onClose:e,prefix:":",onKeyDown:f})},evalInput:function(a,b){var c,e,f,g=b.inputState,h=g.motion,i=g.motionArgs||{},j=g.operator,k=g.operatorArgs||{},l=g.registerName,m=b.sel,n=R(b.visualMode?J(a,m.head):a.getCursor("head")),o=R(b.visualMode?J(a,m.anchor):a.getCursor("anchor")),p=R(n),q=R(o);if(j&&this.recordLastEdit(b,g),f=void 0!==g.repeatOverride?g.repeatOverride:g.getRepeat(),f>0&&i.explicitRepeat?i.repeatIsExplicit=!0:(i.noRepeat||!i.explicitRepeat&&0===f)&&(f=1,i.repeatIsExplicit=!1),g.selectedCharacter&&(i.selectedCharacter=k.selectedCharacter=g.selectedCharacter),i.repeat=f,A(a),h){var r=yb[h](a,n,i,b);if(b.lastMotion=yb[h],!r)return;if(i.toJumplist){var s=ub.jumpList,t=s.cachedCursor;t?(na(a,t,r),delete s.cachedCursor):na(a,n,r)}r instanceof Array?(e=r[0],c=r[1]):c=r,c||(c=R(n)),b.visualMode?(b.visualBlock&&c.ch===1/0||(c=J(a,c,b.visualBlock)),e&&(e=J(a,e,!0)),e=e||q,m.anchor=e,m.head=c,fa(a),ua(a,b,"<",T(e,c)?e:c),ua(a,b,">",T(e,c)?c:e)):j||(c=J(a,c),a.setCursor(c.line,c.ch))}if(j){if(k.lastSel){e=q;var u=k.lastSel,v=Math.abs(u.head.line-u.anchor.line),w=Math.abs(u.head.ch-u.anchor.ch);c=u.visualLine?d(q.line+v,q.ch):u.visualBlock?d(q.line+v,q.ch+w):u.head.line==u.anchor.line?d(q.line,q.ch+w):d(q.line+v,q.ch),b.visualMode=!0,b.visualLine=u.visualLine,b.visualBlock=u.visualBlock,m=b.sel={anchor:e,head:c},fa(a)}else b.visualMode&&(k.lastSel={anchor:R(m.anchor),head:R(m.head),visualBlock:b.visualBlock,visualLine:b.visualLine});var x,y,z,B,C;if(b.visualMode){if(x=U(m.head,m.anchor),y=V(m.head,m.anchor),z=b.visualLine||k.linewise,B=b.visualBlock?"block":z?"line":"char",C=ga(a,{anchor:x,head:y},B),z){var D=C.ranges;if("block"==B)for(var E=0;Ei&&f.line==j?this.moveToStartOfLine(a,b,c,e):i>k&&f.line==k?this.moveToEol(a,b,c,e):(c.toFirstChar&&(g=la(a.getLine(i)),e.lastHPos=g),e.lastHSPos=a.charCoords(d(i,g),"div").left,d(i,g))},moveByDisplayLines:function(a,b,c,e){var f=b;switch(e.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:e.lastHSPos=a.charCoords(f,"div").left}var g=c.repeat,h=a.findPosV(f,c.forward?g:-g,"line",e.lastHSPos);if(h.hitSide)if(c.forward)var i=a.charCoords(h,"div"),j={top:i.top+8,left:e.lastHSPos},h=a.coordsChar(j,"div");else{var k=a.charCoords(d(a.firstLine(),0),"div");k.left=e.lastHSPos,h=a.coordsChar(k,"div")}return e.lastHPos=h.ch,h},moveByPage:function(a,b,c){var d=b,e=c.repeat;return a.findPosV(d,c.forward?e:-e,"page")},moveByParagraph:function(a,b,c){var d=c.forward?1:-1;return wa(a,b,c.repeat,d)},moveByScroll:function(a,b,c,d){var e=a.getScrollInfo(),f=null,g=c.repeat;g||(g=e.clientHeight/(2*a.defaultTextHeight()));var h=a.charCoords(b,"local");c.repeat=g;var f=yb.moveByDisplayLines(a,b,c,d);if(!f)return null;var i=a.charCoords(f,"local");return a.scrollTo(null,e.top+i.top-h.top),f},moveByWords:function(a,b,c){return ra(a,b,c.repeat,!!c.forward,!!c.wordEnd,!!c.bigWord)},moveTillCharacter:function(a,b,c){var d=c.repeat,e=sa(a,d,c.forward,c.selectedCharacter),f=c.forward?-1:1;return oa(f,c),e?(e.ch+=f,e):null},moveToCharacter:function(a,b,c){var d=c.repeat;return oa(0,c),sa(a,d,c.forward,c.selectedCharacter)||b},moveToSymbol:function(a,b,c){var d=c.repeat;return pa(a,d,c.forward,c.selectedCharacter)||b},moveToColumn:function(a,b,c,d){var e=c.repeat;return d.lastHPos=e-1,d.lastHSPos=a.charCoords(b,"div").left,ta(a,e)},moveToEol:function(a,b,c,e){var f=b;e.lastHPos=1/0;var g=d(f.line+c.repeat-1,1/0),h=a.clipPos(g);return h.ch--,e.lastHSPos=a.charCoords(h,"div").left,g},moveToFirstNonWhiteSpaceCharacter:function(a,b){var c=b;return d(c.line,la(a.getLine(c.line)))},moveToMatchedSymbol:function(a,b){var c,e=b,f=e.line,g=e.ch,h=a.getLine(f);do if(c=h.charAt(g++),c&&o(c)){var i=a.getTokenTypeAt(d(f,g));if("string"!==i&&"comment"!==i)break}while(c);if(c){var j=a.findMatchingBracket(d(f,g));return j.to}return e},moveToStartOfLine:function(a,b){return d(b.line,0)},moveToLineOrEdgeOfDocument:function(a,b,c){var e=c.forward?a.lastLine():a.firstLine();return c.repeatIsExplicit&&(e=c.repeat-a.getOption("firstLineNumber")),d(e,la(a.getLine(e)))},textObjectManipulation:function(a,b,c,d){var e={"(":")",")":"(","{":"}","}":"{","[":"]","]":"["},f={"'":!0,'"':!0},g=c.selectedCharacter;"b"==g?g="(":"B"==g&&(g="{");var h,i=!c.textObjectInner;if(e[g])h=xa(a,b,g,i);else if(f[g])h=ya(a,b,g,i);else if("W"===g)h=ma(a,i,!0,!0);else if("w"===g)h=ma(a,i,!0,!1);else{if("p"!==g)return null;if(h=wa(a,b,c.repeat,0,i),c.linewise=!0,d.visualMode)d.visualLine||(d.visualLine=!0);else{var j=d.inputState.operatorArgs;j&&(j.linewise=!0),h.end.line--}}return a.state.vim.visualMode?ea(a,h.start,h.end):[h.start,h.end]},repeatLastCharacterSearch:function(a,b,c){var d=ub.lastCharacterSearch,e=c.repeat,f=c.forward===d.forward,g=(d.increment?1:0)*(f?-1:1);a.moveH(-g,"char"),c.inclusive=f?!0:!1;var h=sa(a,e,f,d.selectedCharacter);return h?(h.ch+=g,h):(a.moveH(g,"char"),b)}},zb={change:function(b,c,e){var f,g,h=b.state.vim;if(ub.macroModeState.lastInsertModeChanges.inVisualBlock=h.visualBlock,h.visualMode){g=b.getSelection();var i=G("",e.length);b.replaceSelections(i),f=U(e[0].head,e[0].anchor)}else{var j=e[0].anchor,k=e[0].head;g=b.getRange(j,k);var l=h.lastEditInputState||{};if("moveByWords"==l.motion&&!r(g)){var m=/\s+$/.exec(g);m&&l.motionArgs&&l.motionArgs.forward&&(k=L(k,0,-m[0].length),g=g.slice(0,-m[0].length))}var n=new d(j.line-1,Number.MAX_VALUE),o=b.firstLine()==b.lastLine();k.line>b.lastLine()&&c.linewise&&!o?b.replaceRange("",n,k):b.replaceRange("",j,k),c.linewise&&(o||(b.setCursor(n),a.commands.newlineAndIndent(b)),j.ch=Number.MAX_VALUE),f=j}ub.registerController.pushText(c.registerName,"change",g,c.linewise,e.length>1),Ab.enterInsertMode(b,{head:f},b.state.vim)},"delete":function(a,b,c){var e,f,g=a.state.vim;if(g.visualBlock){f=a.getSelection();var h=G("",c.length);a.replaceSelections(h),e=c[0].anchor}else{var i=c[0].anchor,j=c[0].head;b.linewise&&j.line!=a.firstLine()&&i.line==a.lastLine()&&i.line==j.line-1&&(i.line==a.firstLine()?i.ch=0:i=d(i.line-1,X(a,i.line-1))),f=a.getRange(i,j),a.replaceRange("",i,j),e=i,b.linewise&&(e=yb.moveToFirstNonWhiteSpaceCharacter(a,i))}return ub.registerController.pushText(b.registerName,"delete",f,b.linewise,g.visualBlock),J(a,e)},indent:function(a,b,c){ +var d=a.state.vim,e=c[0].anchor.line,f=d.visualBlock?c[c.length-1].anchor.line:c[0].head.line,g=d.visualMode?b.repeat:1;b.linewise&&f--;for(var h=e;f>=h;h++)for(var i=0;g>i;i++)a.indentLine(h,b.indentRight);return yb.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},changeCase:function(a,b,c,d,e){for(var f=a.getSelections(),g=[],h=b.toLower,i=0;ij.top?(i.line+=(h-j.top)/e,i.line=Math.ceil(i.line),a.setCursor(i),j=a.charCoords(i,"local"),a.scrollTo(null,j.top)):a.scrollTo(null,h);else{var k=h+a.getScrollInfo().clientHeight;k=g.anchor.line?L(g.head,0,1):d(g.anchor.line,0);else if("inplace"==f&&e.visualMode)return;b.setOption("disableInput",!1),c&&c.replace?(b.toggleOverwrite(!0),b.setOption("keyMap","vim-replace"),a.signal(b,"vim-mode-change",{mode:"replace"})):(b.toggleOverwrite(!1),b.setOption("keyMap","vim-insert"),a.signal(b,"vim-mode-change",{mode:"insert"})),ub.macroModeState.isPlaying||(b.on("change",_a),a.on(b.getInputField(),"keydown",eb)),e.visualMode&&ia(b),aa(b,h,i)}},toggleVisualMode:function(b,c,e){var f,g=c.repeat,h=b.getCursor();e.visualMode?e.visualLine^c.linewise||e.visualBlock^c.blockwise?(e.visualLine=!!c.linewise,e.visualBlock=!!c.blockwise,a.signal(b,"vim-mode-change",{mode:"visual",subMode:e.visualLine?"linewise":e.visualBlock?"blockwise":""}),fa(b)):ia(b):(e.visualMode=!0,e.visualLine=!!c.linewise,e.visualBlock=!!c.blockwise,f=J(b,d(h.line,h.ch+g-1),!0),e.sel={anchor:h,head:f},a.signal(b,"vim-mode-change",{mode:"visual",subMode:e.visualLine?"linewise":e.visualBlock?"blockwise":""}),fa(b),ua(b,e,"<",U(h,f)),ua(b,e,">",V(h,f)))},reselectLastSelection:function(b,c,d){var e=d.lastSelection;if(d.visualMode&&da(b,d),e){var f=e.anchorMark.find(),g=e.headMark.find();if(!f||!g)return;d.sel={anchor:f,head:g},d.visualMode=!0,d.visualLine=e.visualLine,d.visualBlock=e.visualBlock,fa(b),ua(b,d,"<",U(f,g)),ua(b,d,">",V(f,g)),a.signal(b,"vim-mode-change",{mode:"visual",subMode:d.visualLine?"linewise":d.visualBlock?"blockwise":""})}},joinLines:function(a,b,c){var e,f;if(c.visualMode){if(e=a.getCursor("anchor"),f=a.getCursor("head"),T(f,e)){var g=f;f=e,e=g}f.ch=X(a,f.line)-1}else{var h=Math.max(b.repeat,2);e=a.getCursor(),f=J(a,d(e.line+h-1,1/0))}for(var i=0,j=e.line;jc)return"";if(a.getOption("indentWithTabs")){var d=Math.floor(c/h);return Array(d+1).join(" ")}return Array(c+1).join(" ")});g+=m?"\n":""}if(b.repeat>1)var g=Array(b.repeat+1).join(g);var o=f.linewise,p=f.blockwise;if(o)c.visualMode?g=c.visualLine?g.slice(0,-1):"\n"+g.slice(0,g.length-1)+"\n":b.after?(g="\n"+g.slice(0,g.length-1),e.ch=X(a,e.line)):e.ch=0;else{if(p){g=g.split("\n");for(var q=0;qa.lastLine()&&a.replaceRange("\n",d(A,0));var B=X(a,A);Bk.length&&(f=k.length),g=d(i.line,f)}if("\n"==h)e.visualMode||b.replaceRange("",i,g),(a.commands.newlineAndIndentContinueComment||a.commands.newlineAndIndent)(b);else{var l=b.getRange(i,g);if(l=l.replace(/[^\n]/g,h),e.visualBlock){var m=new Array(b.getOption("tabSize")+1).join(" ");l=b.getSelection(),l=l.replace(/\t/g,m).replace(/[^\n]/g,h).split("\n"),b.replaceSelections(l)}else b.replaceRange(l,i,g);e.visualMode?(i=T(j[0].anchor,j[0].head)?j[0].anchor:j[0].head,b.setCursor(i),ia(b,!1)):b.setCursor(L(g,0,-1))}},incrementNumberToken:function(a,b){for(var c,e,f,g,h,i=a.getCursor(),j=a.getLine(i.line),k=/-?\d+/g;null!==(c=k.exec(j))&&(h=c[0],e=c.index,f=e+h.length,!(i.ch=1)return!0}else a.nextCh===a.reverseSymb&&a.depth--;return!1}},section:{init:function(a){a.curMoveThrough=!0,a.symb=(a.forward?"]":"[")===a.symb?"{":"}"},isComplete:function(a){return 0===a.index&&a.nextCh===a.symb}},comment:{isComplete:function(a){var b="*"===a.lastCh&&"/"===a.nextCh;return a.lastCh=a.nextCh,b}},method:{init:function(a){a.symb="m"===a.symb?"{":"}",a.reverseSymb="{"===a.symb?"}":"{"},isComplete:function(a){return a.nextCh===a.symb?!0:!1}},preprocess:{init:function(a){a.index=0},isComplete:function(a){if("#"===a.nextCh){var b=a.lineText.match(/#(\w+)/)[1];if("endif"===b){if(a.forward&&0===a.depth)return!0;a.depth++}else if("if"===b){if(!a.forward&&0===a.depth)return!0;a.depth--}if("else"===b&&0===a.depth)return!0}return!1}}};t("pcre",!0,"boolean"),za.prototype={getQuery:function(){return ub.query},setQuery:function(a){ub.query=a},getOverlay:function(){return this.searchOverlay},setOverlay:function(a){this.searchOverlay=a},isReversed:function(){return ub.isReversed},setReversed:function(a){ub.isReversed=a},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(a){this.annotate=a}};var Db={"\\n":"\n","\\r":"\r","\\t":" "},Eb={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":" "},Fb="(Javascript regexp)",Gb=function(){this.buildCommandMap_()};Gb.prototype={processCommand:function(a,b,c){var d=this;a.operation(function(){a.curOp.isVimOp=!0,d._processCommand(a,b,c)})},_processCommand:function(b,c,d){var e=b.state.vim,f=ub.registerController.getRegister(":"),g=f.toString();e.visualMode&&ia(b);var h=new a.StringStream(c);f.setText(c);var i=d||{};i.input=c;try{this.parseInput_(b,h,i)}catch(j){throw Ia(b,j),j}var k,l;if(i.commandName){if(k=this.matchCommand_(i.commandName)){if(l=k.name,k.excludeFromCommandHistory&&f.setText(g),this.parseCommandArgs_(h,i,k),"exToKey"==k.type){for(var m=0;m0;b--){var c=a.substring(0,b);if(this.commandMap_[c]){var d=this.commandMap_[c];if(0===d.name.indexOf(a))return d}}return null},buildCommandMap_:function(){this.commandMap_={};for(var a=0;a
";if(c){var f;c=c.join("");for(var g=0;g"}}else for(var f in d){var i=d[f].toString();i.length&&(e+='"'+f+" "+i+"
")}Ia(a,e)},sort:function(b,c){function e(){if(c.argString){var b=new a.StringStream(c.argString);if(b.eat("!")&&(g=!0),b.eol())return;if(!b.eatSpace())return"Invalid arguments";var d=b.match(/[a-z]+/);if(d){d=d[0],h=-1!=d.indexOf("i"),i=-1!=d.indexOf("u");var e=-1!=d.indexOf("d")&&1,f=-1!=d.indexOf("x")&&1,k=-1!=d.indexOf("o")&&1;if(e+f+k>1)return"Invalid arguments";j=e&&"decimal"||f&&"hex"||k&&"octal"}if(b.match(/\/.*\//))return"patterns not supported"}}function f(a,b){if(g){var c;c=a,a=b,b=c}h&&(a=a.toLowerCase(),b=b.toLowerCase());var d=j&&q.exec(a),e=j&&q.exec(b);return d?(d=parseInt((d[1]+d[2]).toLowerCase(),r),e=parseInt((e[1]+e[2]).toLowerCase(),r),d-e):b>a?-1:1}var g,h,i,j,k=e();if(k)return void Ia(b,k+": "+c.argString);var l=c.line||b.firstLine(),m=c.lineEnd||c.line||b.lastLine();if(l!=m){var n=d(l,0),o=d(m,X(b,m)),p=b.getRange(n,o).split("\n"),q="decimal"==j?/(-?)([\d]+)/:"hex"==j?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==j?/([0-7]+)/:null,r="decimal"==j?10:"hex"==j?16:"octal"==j?8:null,s=[],t=[];if(j)for(var u=0;u=m;m++){var n=j.test(a.getLine(m));n&&(k.push(m+1),l+=a.getLine(m)+"
")}if(!d)return void Ia(a,l);var o=0,p=function(){if(o=k)return void Ia(b,"Invalid argument: "+c.argString.substring(f));for(var l=0;k-j>=l;l++){var m=String.fromCharCode(j+l);delete d.marks[m]}}else delete d.marks[g]}}},Ib=new Gb;return a.keyMap.vim={attach:h,detach:g,call:i},t("insertModeEscKeysTimeout",200,"number"),a.keyMap["vim-insert"]={fallthrough:["default"],attach:h,detach:g,call:i},a.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:h,detach:g,call:i},y(),wb};a.Vim=e()}); \ No newline at end of file diff --git a/media/editors/codemirror/lib/codemirror.js b/media/editors/codemirror/lib/codemirror.js index 5009f836cbffe..68b4e953fa9e7 100644 --- a/media/editors/codemirror/lib/codemirror.js +++ b/media/editors/codemirror/lib/codemirror.js @@ -592,8 +592,12 @@ var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; var gutterW = display.gutters.offsetWidth, left = comp + "px"; for (var i = 0; i < view.length; i++) if (!view[i].hidden) { - if (cm.options.fixedGutter && view[i].gutter) - view[i].gutter.style.left = left; + if (cm.options.fixedGutter) { + if (view[i].gutter) + view[i].gutter.style.left = left; + if (view[i].gutterBackground) + view[i].gutterBackground.style.left = left; + } var align = view[i].alignable; if (align) for (var j = 0; j < align.length; j++) align[j].style.left = left; @@ -1149,7 +1153,7 @@ } function handlePaste(e, cm) { - var pasted = e.clipboardData && e.clipboardData.getData("text/plain"); + var pasted = e.clipboardData && e.clipboardData.getData("Text"); if (pasted) { e.preventDefault(); if (!cm.isReadOnly() && !cm.options.disableInput) @@ -1193,10 +1197,10 @@ return {text: text, ranges: ranges}; } - function disableBrowserMagic(field) { + function disableBrowserMagic(field, spellcheck) { field.setAttribute("autocorrect", "off"); field.setAttribute("autocapitalize", "off"); - field.setAttribute("spellcheck", "false"); + field.setAttribute("spellcheck", !!spellcheck); } // TEXTAREA INPUT STYLE @@ -1574,10 +1578,14 @@ init: function(display) { var input = this, cm = input.cm; var div = input.div = display.lineDiv; - disableBrowserMagic(div); + disableBrowserMagic(div, cm.options.spellcheck); on(div, "paste", function(e) { - if (!signalDOMEvent(cm, e)) handlePaste(e, cm); + if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return + // IE doesn't fire input events, so we schedule a read for the pasted content in this way + if (ie_version <= 11) setTimeout(operation(cm, function() { + if (!input.pollContent()) regChange(cm); + }), 20) }) on(div, "compositionstart", function(e) { @@ -1637,23 +1645,27 @@ }); } } - // iOS exposes the clipboard API, but seems to discard content inserted into it - if (e.clipboardData && !ios) { - e.preventDefault(); + if (e.clipboardData) { e.clipboardData.clearData(); - e.clipboardData.setData("text/plain", lastCopied.text.join("\n")); - } else { - // Old-fashioned briefly-focus-a-textarea hack - var kludge = hiddenTextarea(), te = kludge.firstChild; - cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); - te.value = lastCopied.text.join("\n"); - var hadFocus = document.activeElement; - selectInput(te); - setTimeout(function() { - cm.display.lineSpace.removeChild(kludge); - hadFocus.focus(); - }, 50); + var content = lastCopied.text.join("\n") + // iOS exposes the clipboard API, but seems to discard content inserted into it + e.clipboardData.setData("Text", content); + if (e.clipboardData.getData("Text") == content) { + e.preventDefault(); + return + } } + // Old-fashioned briefly-focus-a-textarea hack + var kludge = hiddenTextarea(), te = kludge.firstChild; + cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); + te.value = lastCopied.text.join("\n"); + var hadFocus = document.activeElement; + selectInput(te); + setTimeout(function() { + cm.display.lineSpace.removeChild(kludge); + hadFocus.focus(); + if (hadFocus == div) input.showPrimarySelection() + }, 50); } on(div, "copy", onCopyCut); on(div, "cut", onCopyCut); @@ -1961,7 +1973,7 @@ if (found) return badPos(Pos(found.line, found.ch + dist), bad); else - dist += after.textContent.length; + dist += before.textContent.length; } } @@ -4948,7 +4960,10 @@ addOverlay: methodOp(function(spec, options) { var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); if (mode.startState) throw new Error("Overlays may not be stateful."); - this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque}); + insertSorted(this.state.overlays, + {mode: mode, modeSpec: spec, opaque: options && options.opaque, + priority: (options && options.priority) || 0}, + function(overlay) { return overlay.priority }) this.state.modeGen++; regChange(this); }), @@ -5420,6 +5435,9 @@ option("inputStyle", mobile ? "contenteditable" : "textarea", function() { throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME }, true); + option("spellcheck", false, function(cm, val) { + cm.getInputField().spellcheck = val + }, true); option("rtlMoveVisually", !windows); option("wholeLineUpdateBefore", true); @@ -5529,6 +5547,8 @@ spec.name = found.name; } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { return CodeMirror.resolveMode("application/xml"); + } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) { + return CodeMirror.resolveMode("application/json"); } if (typeof spec == "string") return {name: spec}; else return spec || {name: "null"}; @@ -7958,7 +7978,7 @@ } // Register a change in the history. Merges changes that are within - // a single operation, ore are close together with an origin that + // a single operation, or are close together with an origin that // allows merging (starting with "+") into a single event. function addChangeToHistory(doc, change, selAfter, opId) { var hist = doc.history; @@ -8361,6 +8381,12 @@ return out; } + function insertSorted(array, value, score) { + var pos = 0, priority = score(value) + while (pos < array.length && score(array[pos]) <= priority) pos++ + array.splice(pos, 0, value) + } + function nothing() {} function createObj(base, props) { @@ -8929,7 +8955,7 @@ // THE END - CodeMirror.version = "5.17.0"; + CodeMirror.version = "5.18.0"; return CodeMirror; }); diff --git a/media/editors/codemirror/lib/codemirror.min.js b/media/editors/codemirror/lib/codemirror.min.js index a59442aee368f..34145c0dbf1eb 100644 --- a/media/editors/codemirror/lib/codemirror.min.js +++ b/media/editors/codemirror/lib/codemirror.min.js @@ -1,5 +1,5 @@ -!function(a){if("object"==typeof exports&&"object"==typeof module)module.exports=a();else{if("function"==typeof define&&define.amd)return define([],a);(this||window).CodeMirror=a()}}(function(){"use strict";function a(c,d){if(!(this instanceof a))return new a(c,d);this.options=d=d?Le(d):{},Le(ag,d,!1),n(d);var e=d.value;"string"==typeof e&&(e=new yg(e,d.mode,null,d.lineSeparator)),this.doc=e;var f=new a.inputStyles[d.inputStyle](this),g=this.display=new b(c,e,f);g.wrapper.CodeMirror=this,j(this),h(this),d.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),d.autofocus&&!Df&&g.input.focus(),r(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Ee,keySeq:null,specialChars:null};var i=this;tf&&11>uf&&setTimeout(function(){i.display.input.reset(!0)},20),Rb(this),Xe(),vb(this),this.curOp.forceUpdate=!0,Yd(this,e),d.autofocus&&!Df||i.hasFocus()?setTimeout(Me(rc,this),20):sc(this);for(var k in bg)bg.hasOwnProperty(k)&&bg[k](this,d[k],cg);w(this),d.finishInit&&d.finishInit(this);for(var l=0;luf&&(d.gutters.style.zIndex=-1,d.scroller.style.paddingRight=0),vf||qf&&Df||(d.scroller.draggable=!0),a&&(a.appendChild?a.appendChild(d.wrapper):a(d.wrapper)),d.viewFrom=d.viewTo=b.first,d.reportedViewFrom=d.reportedViewTo=b.first,d.view=[],d.renderedView=null,d.externalMeasured=null,d.viewOffset=0,d.lastWrapHeight=d.lastWrapWidth=0,d.updateLineNumbers=null,d.nativeBarWidth=d.barHeight=d.barWidth=0,d.scrollbarsClipped=!1,d.lineNumWidth=d.lineNumInnerWidth=d.lineNumChars=null,d.alignWidgets=!1,d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null,d.maxLine=null,d.maxLineLength=0,d.maxLineChanged=!1,d.wheelDX=d.wheelDY=d.wheelStartX=d.wheelStartY=null,d.shift=!1,d.selForContextMenu=null,d.activeTouch=null,c.init(d)}function c(b){b.doc.mode=a.getMode(b.options,b.doc.modeOption),d(b)}function d(a){a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null)}),a.doc.frontier=a.doc.first,Na(a,100),a.state.modeGen++,a.curOp&&Kb(a)}function e(a){a.options.lineWrapping?($g(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):(Zg(a.display.wrapper,"CodeMirror-wrap"),m(a)),g(a),Kb(a),ib(a),setTimeout(function(){s(a)},100)}function f(a){var b=tb(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/ub(a.display)-3);return function(e){if(wd(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;gb.maxLineLength&&(b.maxLineLength=c,b.maxLine=a)})}function n(a){var b=He(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):b>-1&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function o(a){var b=a.display,c=b.gutters.offsetWidth,d=Math.round(a.doc.height+Sa(a.display));return{clientHeight:b.scroller.clientHeight,viewHeight:b.wrapper.clientHeight,scrollWidth:b.scroller.scrollWidth,clientWidth:b.scroller.clientWidth,viewWidth:b.wrapper.clientWidth,barLeft:a.options.fixedGutter?c:0,docHeight:d,scrollHeight:d+Ua(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}function p(a,b,c){this.cm=c;var d=this.vert=Qe("div",[Qe("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),e=this.horiz=Qe("div",[Qe("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");a(d),a(e),Eg(d,"scroll",function(){d.clientHeight&&b(d.scrollTop,"vertical")}),Eg(e,"scroll",function(){e.clientWidth&&b(e.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,tf&&8>uf&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function q(){}function r(b){b.display.scrollbars&&(b.display.scrollbars.clear(),b.display.scrollbars.addClass&&Zg(b.display.wrapper,b.display.scrollbars.addClass)),b.display.scrollbars=new a.scrollbarModel[b.options.scrollbarStyle](function(a){b.display.wrapper.insertBefore(a,b.display.scrollbarFiller),Eg(a,"mousedown",function(){b.state.focused&&setTimeout(function(){b.display.input.focus()},0)}),a.setAttribute("cm-not-content","true")},function(a,c){"horizontal"==c?fc(b,a):ec(b,a)},b),b.display.scrollbars.addClass&&$g(b.display.wrapper,b.display.scrollbars.addClass)}function s(a,b){b||(b=o(a));var c=a.display.barWidth,d=a.display.barHeight;t(a,b);for(var e=0;4>e&&c!=a.display.barWidth||d!=a.display.barHeight;e++)c!=a.display.barWidth&&a.options.lineWrapping&&F(a),t(a,o(a)),c=a.display.barWidth,d=a.display.barHeight}function t(a,b){var c=a.display,d=c.scrollbars.update(b);c.sizer.style.paddingRight=(c.barWidth=d.right)+"px",c.sizer.style.paddingBottom=(c.barHeight=d.bottom)+"px",c.heightForcer.style.borderBottom=d.bottom+"px solid transparent",d.right&&d.bottom?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=d.bottom+"px",c.scrollbarFiller.style.width=d.right+"px"):c.scrollbarFiller.style.display="",d.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d.bottom+"px",c.gutterFiller.style.width=b.gutterWidth+"px"):c.gutterFiller.style.display=""}function u(a,b,c){var d=c&&null!=c.top?Math.max(0,c.top):a.scroller.scrollTop;d=Math.floor(d-Ra(a));var e=c&&null!=c.bottom?c.bottom:d+a.wrapper.clientHeight,f=ce(b,d),g=ce(b,e);if(c&&c.ensure){var h=c.ensure.from.line,i=c.ensure.to.line;f>h?(f=h,g=ce(b,de(Zd(b,h))+a.wrapper.clientHeight)):Math.min(i,b.lastLine())>=g&&(f=ce(b,de(Zd(b,i))-a.wrapper.clientHeight),g=i)}return{from:f,to:Math.max(g,f+1)}}function v(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=y(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g=c.viewFrom&&b.visible.to<=c.viewTo&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo)&&c.renderedView==c.view&&0==Qb(a))return!1;w(a)&&(Mb(a),b.dims=H(a));var e=d.first+d.size,f=Math.max(b.visible.from-a.options.viewportMargin,d.first),g=Math.min(e,b.visible.to+a.options.viewportMargin);c.viewFromg&&c.viewTo-g<20&&(g=Math.min(e,c.viewTo)),Lf&&(f=ud(a.doc,f),g=vd(a.doc,g));var h=f!=c.viewFrom||g!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;Pb(a,f,g),c.viewOffset=de(Zd(a.doc,c.viewFrom)),a.display.mover.style.top=c.viewOffset+"px";var i=Qb(a);if(!h&&0==i&&!b.force&&c.renderedView==c.view&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;var j=Te();return i>4&&(c.lineDiv.style.display="none"),I(a,c.updateLineNumbers,b.dims),i>4&&(c.lineDiv.style.display=""),c.renderedView=c.view,j&&Te()!=j&&j.offsetHeight&&j.focus(),Re(c.cursorDiv),Re(c.selectionDiv),c.gutters.style.height=c.sizer.style.minHeight=0,h&&(c.lastWrapHeight=b.wrapperHeight,c.lastWrapWidth=b.wrapperWidth,Na(a,400)),c.updateLineNumbers=null,!0}function C(a,b){for(var c=b.viewport,d=!0;(d&&a.options.lineWrapping&&b.oldDisplayWidth!=Va(a)||(c&&null!=c.top&&(c={top:Math.min(a.doc.height+Sa(a.display)-Wa(a),c.top)}),b.visible=u(a.display,a.doc,c),!(b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo)))&&B(a,b);d=!1){F(a);var e=o(a);Ia(a),s(a,e),E(a,e)}b.signal(a,"update",a),(a.display.viewFrom!=a.display.reportedViewFrom||a.display.viewTo!=a.display.reportedViewTo)&&(b.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo)}function D(a,b){var c=new z(a,b);if(B(a,c)){F(a),C(a,c);var d=o(a);Ia(a),s(a,d),E(a,d),c.finish()}}function E(a,b){a.display.sizer.style.minHeight=b.docHeight+"px",a.display.heightForcer.style.top=b.docHeight+"px",a.display.gutters.style.height=b.docHeight+a.display.barHeight+Ua(a)+"px"}function F(a){for(var b=a.display,c=b.lineDiv.offsetTop,d=0;duf){var g=f.node.offsetTop+f.node.offsetHeight;e=g-c,c=g}else{var h=f.node.getBoundingClientRect();e=h.bottom-h.top}var i=f.line.height-e;if(2>e&&(e=tb(b)),(i>.001||-.001>i)&&(ae(f.line,e),G(f.line),f.rest))for(var j=0;j=b&&l.lineNumber;l.changes&&(He(l.changes,"gutter")>-1&&(m=!1),J(a,l,j,c)),m&&(Re(l.lineNumber),l.lineNumber.appendChild(document.createTextNode(x(a.options,j)))),h=l.node.nextSibling}else{var n=R(a,l,j,c);g.insertBefore(n,h)}j+=l.size}for(;h;)h=d(h)}function J(a,b,c,d){for(var e=0;euf&&(a.node.style.zIndex=2)),a.node}function L(a){var b=a.bgClass?a.bgClass+" "+(a.line.bgClass||""):a.line.bgClass;if(b&&(b+=" CodeMirror-linebackground"),a.background)b?a.background.className=b:(a.background.parentNode.removeChild(a.background),a.background=null);else if(b){var c=K(a);a.background=c.insertBefore(Qe("div",null,b),c.firstChild)}}function M(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):Md(a,b)}function N(a,b){var c=b.text.className,d=M(a,b);b.text==b.node&&(b.node=d.pre),b.text.parentNode.replaceChild(d.pre,b.text),b.text=d.pre,d.bgClass!=b.bgClass||d.textClass!=b.textClass?(b.bgClass=d.bgClass,b.textClass=d.textClass,O(b)):c&&(b.text.className=c)}function O(a){L(a),a.line.wrapClass?K(a).className=a.line.wrapClass:a.node!=a.text&&(a.node.className="");var b=a.textClass?a.textClass+" "+(a.line.textClass||""):a.line.textClass;a.text.className=b||""}function P(a,b,c,d){if(b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null),b.gutterBackground&&(b.node.removeChild(b.gutterBackground),b.gutterBackground=null),b.line.gutterClass){var e=K(b);b.gutterBackground=Qe("div",null,"CodeMirror-gutter-background "+b.line.gutterClass,"left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px; width: "+d.gutterTotalWidth+"px"),e.insertBefore(b.gutterBackground,b.text)}var f=b.line.gutterMarkers;if(a.options.lineNumbers||f){var e=K(b),g=b.gutter=Qe("div",null,"CodeMirror-gutter-wrapper","left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px");if(a.display.input.setUneditable(g),e.insertBefore(g,b.text),b.line.gutterClass&&(g.className+=" "+b.line.gutterClass),!a.options.lineNumbers||f&&f["CodeMirror-linenumbers"]||(b.lineNumber=g.appendChild(Qe("div",x(a.options,c),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+d.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+a.display.lineNumInnerWidth+"px"))),f)for(var h=0;h1)if(Of&&Of.text.join("\n")==b){if(d.ranges.length%Of.text.length==0){i=[];for(var j=0;j=0;j--){var k=d.ranges[j],l=k.from(),m=k.to();k.empty()&&(c&&c>0?l=Mf(l.line,l.ch-c):a.state.overwrite&&!g?m=Mf(m.line,Math.min(Zd(f,m.line).text.length,m.ch+Ge(h).length)):Of&&Of.lineWise&&Of.text.join("\n")==b&&(l=m=Mf(l.line,0)));var n=a.curOp.updateInput,o={from:l,to:m,text:i?i[j%i.length]:h,origin:e||(g?"paste":a.state.cutIncoming?"cut":"+input")};Ac(a.doc,o),ye(a,"inputRead",a,o)}b&&!g&&_(a,b),Mc(a),a.curOp.updateInput=n,a.curOp.typing=!0,a.state.pasteIncoming=a.state.cutIncoming=!1}function $(a,b){var c=a.clipboardData&&a.clipboardData.getData("text/plain");return c?(a.preventDefault(),b.isReadOnly()||b.options.disableInput||Eb(b,function(){Z(b,c,0,null,"paste")}),!0):void 0}function _(a,b){if(a.options.electricChars&&a.options.smartIndent)for(var c=a.doc.sel,d=c.ranges.length-1;d>=0;d--){var e=c.ranges[d];if(!(e.head.ch>100||d&&c.ranges[d-1].head.line==e.head.line)){var f=a.getModeAt(e.head),g=!1;if(f.electricChars){for(var h=0;h-1){g=Oc(a,e.head.line,"smart");break}}else f.electricInput&&f.electricInput.test(Zd(a.doc,e.head.line).text.slice(0,e.head.ch))&&(g=Oc(a,e.head.line,"smart"));g&&ye(a,"electricInput",a,e.head.line)}}}function aa(a){for(var b=[],c=[],d=0;de?j.map:k[e],g=0;ge?a.line:a.rest[e]),l=f[g]+d;return(0>d||h!=b)&&(l=f[g+(d?1:0)]),Mf(i,l)}}}var e=a.text.firstChild,f=!1;if(!b||!Wg(e,b))return ga(Mf(be(a.line),0),!0);if(b==e&&(f=!0,b=e.childNodes[c],c=0,!b)){var g=a.rest?Ge(a.rest):a.line;return ga(Mf(be(g),g.text.length),f)}var h=3==b.nodeType?b:null,i=b;for(h||1!=b.childNodes.length||3!=b.firstChild.nodeType||(h=b.firstChild,c&&(c=h.nodeValue.length));i.parentNode!=e;)i=i.parentNode;var j=a.measure,k=j.maps,l=d(h,i,c);if(l)return ga(l,f);for(var m=i.nextSibling,n=h?h.nodeValue.length-c:0;m;m=m.nextSibling){if(l=d(m,m.firstChild,0))return ga(Mf(l.line,l.ch-n),f);n+=m.textContent.length}for(var o=i.previousSibling,n=c;o;o=o.previousSibling){if(l=d(o,o.firstChild,-1))return ga(Mf(l.line,l.ch+n),f);n+=m.textContent.length}}function ja(a,b,c,d,e){function f(a){return function(b){return b.id==a}}function g(b){if(1==b.nodeType){var c=b.getAttribute("cm-text");if(null!=c)return""==c&&(c=b.textContent.replace(/\u200b/g,"")),void(h+=c);var k,l=b.getAttribute("cm-marker");if(l){var m=a.findMarks(Mf(d,0),Mf(e+1,0),f(+l));return void(m.length&&(k=m[0].find())&&(h+=$d(a.doc,k.from,k.to).join(j)))}if("false"==b.getAttribute("contenteditable"))return;for(var n=0;n=0){var g=X(f.from(),e.from()),h=W(f.to(),e.to()),i=f.empty()?e.from()==e.head:f.from()==f.head;b>=d&&--b,a.splice(--d,2,new la(i?h:g,i?g:h))}}return new ka(a,b)}function na(a,b){return new ka([new la(a,b||a)],0)}function oa(a,b){return Math.max(a.first,Math.min(b,a.first+a.size-1))}function pa(a,b){if(b.linec?Mf(c,Zd(a,c).text.length):qa(b,Zd(a,b.line).text.length)}function qa(a,b){var c=a.ch;return null==c||c>b?Mf(a.line,b):0>c?Mf(a.line,0):a}function ra(a,b){return b>=a.first&&b=b.ch:h.to>b.ch))){if(e&&(Hg(i,"beforeCursorEnter"),i.explicitlyCleared)){if(f.markedSpans){--g;continue}break}if(!i.atomic)continue;if(c){var j,k=i.find(0>d?1:-1);if((0>d?i.inclusiveRight:i.inclusiveLeft)&&(k=Ha(a,k,-d,k&&k.line==b.line?f:null)),k&&k.line==b.line&&(j=Nf(k,c))&&(0>d?0>j:j>0))return Fa(a,k,b,d,e)}var l=i.find(0>d?-1:1);return(0>d?i.inclusiveLeft:i.inclusiveRight)&&(l=Ha(a,l,d,l.line==b.line?f:null)),l?Fa(a,l,b,d,e):null}}return b}function Ga(a,b,c,d,e){var f=d||1,g=Fa(a,b,c,f,e)||!e&&Fa(a,b,c,f,!0)||Fa(a,b,c,-f,e)||!e&&Fa(a,b,c,-f,!0);return g?g:(a.cantEdit=!0,Mf(a.first,0))}function Ha(a,b,c,d){return 0>c&&0==b.ch?b.line>a.first?pa(a,Mf(b.line-1)):null:c>0&&b.ch==(d||Zd(a,b.line)).text.length?b.line=a.display.viewTo||h.to().lineb&&(b=0),b=Math.round(b),d=Math.round(d),h.appendChild(Qe("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?k-a:c)+"px; height: "+(d-b)+"px"))}function e(b,c,e){function f(c,d){return nb(a,Mf(b,c),"div",l,d)}var h,i,l=Zd(g,b),m=l.text.length;return af(ee(l),c||0,null==e?m:e,function(a,b,g){var l,n,o,p=f(a,"left");if(a==b)l=p,n=o=p.left;else{if(l=f(b-1,"right"),"rtl"==g){var q=p;p=l,l=q}n=p.left,o=l.right}null==c&&0==a&&(n=j),l.top-p.top>3&&(d(n,p.top,null,p.bottom),n=j,p.bottomi.bottom||l.bottom==i.bottom&&l.right>i.right)&&(i=l),j+1>n&&(n=j),d(n,l.top,o-n,l.bottom)}),{start:h,end:i}}var f=a.display,g=a.doc,h=document.createDocumentFragment(),i=Ta(a.display),j=i.left,k=Math.max(f.sizerWidth,Va(a)-f.sizer.offsetLeft)-i.right,l=b.from(),m=b.to();if(l.line==m.line)e(l.line,l.ch,m.ch);else{var n=Zd(g,l.line),o=Zd(g,m.line),p=sd(n)==sd(o),q=e(l.line,l.ch,p?n.text.length+1:null).end,r=e(m.line,p?0:null,m.ch).start;p&&(q.top0?b.blinker=setInterval(function(){b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate):a.options.cursorBlinkRate<0&&(b.cursorDiv.style.visibility="hidden")}}function Na(a,b){a.doc.mode.startState&&a.doc.frontier=a.display.viewTo)){var c=+new Date+a.options.workTime,d=ig(b.mode,Qa(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(b.frontier>=a.display.viewFrom){var g=f.styles,h=f.text.length>a.options.maxHighlightLength,i=Id(a,f,h?ig(b.mode,d):d,!0);f.styles=i.styles;var j=f.styleClasses,k=i.classes;k?f.styleClasses=k:j&&(f.styleClasses=null);for(var l=!g||g.length!=f.styles.length||j!=k&&(!j||!k||j.bgClass!=k.bgClass||j.textClass!=k.textClass),m=0;!l&&mc?(Na(a,a.options.workDelay),!0):void 0}),e.length&&Eb(a,function(){for(var b=0;bg;--h){if(h<=f.first)return f.first;var i=Zd(f,h-1);if(i.stateAfter&&(!c||h<=f.frontier))return h;var j=Og(i.text,null,a.options.tabSize);(null==e||d>j)&&(e=h-1,d=j)}return e}function Qa(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0;var f=Pa(a,b,c),g=f>d.first&&Zd(d,f-1).stateAfter;return g=g?ig(d.mode,g):jg(d.mode),d.iter(f,b,function(c){Kd(a,c.text,g);var h=f==b-1||f%5==0||f>=e.viewFrom&&f2&&f.push((i.bottom+j.top)/2-c.top)}}f.push(c.bottom-c.top)}}function Ya(a,b,c){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};for(var d=0;dc)return{map:a.measure.maps[d],cache:a.measure.caches[d],before:!0}}function Za(a,b){b=sd(b);var c=be(b),d=a.display.externalMeasured=new Ib(a.doc,b,c);d.lineN=c;var e=d.built=Md(a,d);return d.text=e.pre,Se(a.display.lineMeasure,e.pre),d}function $a(a,b,c,d){return bb(a,ab(a,b),c,d)}function _a(a,b){if(b>=a.display.viewFrom&&b=c.lineN&&bb?(e=0,f=1,g="left"):j>b?(e=b-i, -f=e+1):(h==a.length-3||b==j&&a[h+3]>b)&&(f=j-i,e=f-1,b>=j&&(g="right")),null!=e){if(d=a[h+2],i==j&&c==(d.insertLeft?"left":"right")&&(g=c),"left"==c&&0==e)for(;h&&a[h-2]==a[h-3]&&a[h-1].insertLeft;)d=a[(h-=3)+2],g="left";if("right"==c&&e==j-i)for(;h=0&&(c=a[d]).left==c.right;d--);return c}function eb(a,b,c,d){var e,f=cb(b.map,c,d),g=f.node,h=f.start,i=f.end,j=f.collapse;if(3==g.nodeType){for(var k=0;4>k;k++){for(;h&&Pe(b.line.text.charAt(f.coverStart+h));)--h;for(;f.coverStart+iuf&&0==h&&i==f.coverEnd-f.coverStart?g.parentNode.getBoundingClientRect():db(Sg(g,h,i).getClientRects(),d),e.left||e.right||0==h)break;i=h,h-=1,j="right"}tf&&11>uf&&(e=fb(a.display.measure,e))}else{h>0&&(j=d="right");var l;e=a.options.lineWrapping&&(l=g.getClientRects()).length>1?l["right"==d?l.length-1:0]:g.getBoundingClientRect()}if(tf&&9>uf&&!h&&(!e||!e.left&&!e.right)){var m=g.parentNode.getClientRects()[0];e=m?{left:m.left,right:m.left+ub(a.display),top:m.top,bottom:m.bottom}:Sf}for(var n=e.top-b.rect.top,o=e.bottom-b.rect.top,p=(n+o)/2,q=b.view.measure.heights,k=0;kc.from?g(a-1):g(a,d)}d=d||Zd(a.doc,b.line),e||(e=ab(a,d));var i=ee(d),j=b.ch;if(!i)return g(j);var k=kf(i,j),l=h(j,k);return null!=gh&&(l.other=h(j,gh)),l}function pb(a,b){var c=0,b=pa(a.doc,b);a.options.lineWrapping||(c=ub(a.display)*b.ch);var d=Zd(a.doc,b.line),e=de(d)+Ra(a.display);return{left:c,right:c,top:e,bottom:e+d.height}}function qb(a,b,c,d){var e=Mf(a,b);return e.xRel=d,c&&(e.outside=!0),e}function rb(a,b,c){var d=a.doc;if(c+=a.display.viewOffset,0>c)return qb(d.first,0,!0,-1);var e=ce(d,c),f=d.first+d.size-1;if(e>f)return qb(d.first+d.size-1,Zd(d,f).text.length,!0,1);0>b&&(b=0);for(var g=Zd(d,e);;){var h=sb(a,g,e,b,c),i=qd(g),j=i&&i.find(0,!0);if(!i||!(h.ch>j.from.ch||h.ch==j.from.ch&&h.xRel>0))return h;e=be(g=j.to.line)}}function sb(a,b,c,d,e){function f(d){var e=ob(a,Mf(c,d),"line",b,j);return h=!0,g>e.bottom?e.left-i:gq)return qb(c,n,r,1);for(;;){if(k?n==m||n==mf(b,m,1):1>=n-m){var s=o>d||q-d>=d-o?m:n,t=s==m?p:r,u=d-(s==m?o:q);if(r&&!k&&!/\s/.test(b.text.charAt(s))&&u>0&&s1){var v=bb(a,j,s,"right");g<=v.bottom&&g>=v.top&&Math.abs(d-v.right)u?-1:u>1?1:0);return w}var x=Math.ceil(l/2),y=m+x;if(k){y=m;for(var z=0;x>z;++z)y=mf(b,y,1)}var A=f(y);A>d?(n=y,q=A,(r=h)&&(q+=1e3),l=x):(m=y,o=A,p=h,l-=x)}}function tb(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==Pf){Pf=Qe("pre");for(var b=0;49>b;++b)Pf.appendChild(document.createTextNode("x")),Pf.appendChild(Qe("br"));Pf.appendChild(document.createTextNode("x"))}Se(a.measure,Pf);var c=Pf.offsetHeight/50;return c>3&&(a.cachedTextHeight=c),Re(a.measure),c||1}function ub(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=Qe("span","xxxxxxxxxx"),c=Qe("pre",[b]);Se(a.measure,c);var d=b.getBoundingClientRect(),e=(d.right-d.left)/10;return e>2&&(a.cachedCharWidth=e),e||10}function vb(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Uf},Tf?Tf.ops.push(a.curOp):a.curOp.ownsGroup=Tf={ops:[a.curOp],delayedCallbacks:[]}}function wb(a){var b=a.delayedCallbacks,c=0;do{for(;c=c.viewTo)||c.maxLineChanged&&b.options.lineWrapping,a.update=a.mustUpdate&&new z(b,a.mustUpdate&&{top:a.scrollTop,ensure:a.scrollToPos},a.forceUpdate)}function Ab(a){a.updatedDisplay=a.mustUpdate&&B(a.cm,a.update)}function Bb(a){var b=a.cm,c=b.display;a.updatedDisplay&&F(b),a.barMeasure=o(b),c.maxLineChanged&&!b.options.lineWrapping&&(a.adjustWidthTo=$a(b,c.maxLine,c.maxLine.text.length).left+3,b.display.sizerWidth=a.adjustWidthTo,a.barMeasure.scrollWidth=Math.max(c.scroller.clientWidth,c.sizer.offsetLeft+a.adjustWidthTo+Ua(b)+b.display.barWidth),a.maxScrollLeft=Math.max(0,c.sizer.offsetLeft+a.adjustWidthTo-Va(b))),(a.updatedDisplay||a.selectionChanged)&&(a.preparedSelection=c.input.prepareSelection(a.focus))}function Cb(a){var b=a.cm;null!=a.adjustWidthTo&&(b.display.sizer.style.minWidth=a.adjustWidthTo+"px",a.maxScrollLeftf;f=d){var g=new Ib(a.doc,Zd(a.doc,f),f);d=f+g.size,e.push(g)}return e}function Kb(a,b,c,d){null==b&&(b=a.doc.first),null==c&&(c=a.doc.first+a.doc.size),d||(d=0);var e=a.display;if(d&&cb)&&(e.updateLineNumbers=b),a.curOp.viewChanged=!0,b>=e.viewTo)Lf&&ud(a.doc,b)e.viewFrom?Mb(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)Mb(a);else if(b<=e.viewFrom){var f=Ob(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):Mb(a)}else if(c>=e.viewTo){var f=Ob(a,b,b,-1);f?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):Mb(a)}else{var g=Ob(a,b,b,-1),h=Ob(a,c,c+d,1);g&&h?(e.view=e.view.slice(0,g.index).concat(Jb(a,g.lineN,h.lineN)).concat(e.view.slice(h.index)),e.viewTo+=d):Mb(a)}var i=e.externalMeasured;i&&(c=e.lineN&&b=d.viewTo)){var f=d.view[Nb(a,b)];if(null!=f.node){var g=f.changes||(f.changes=[]);-1==He(g,c)&&g.push(c)}}}function Mb(a){a.display.viewFrom=a.display.viewTo=a.doc.first,a.display.view=[],a.display.viewOffset=0}function Nb(a,b){if(b>=a.display.viewTo)return null;if(b-=a.display.viewFrom,0>b)return null;for(var c=a.display.view,d=0;db)return d}function Ob(a,b,c,d){var e,f=Nb(a,b),g=a.display.view;if(!Lf||c==a.doc.first+a.doc.size)return{index:f,lineN:c};for(var h=0,i=a.display.viewFrom;f>h;h++)i+=g[h].size;if(i!=b){if(d>0){if(f==g.length-1)return null;e=i+g[f].size-b,f++}else e=i-b;b+=e,c+=e}for(;ud(a.doc,c)!=c;){if(f==(0>d?0:g.length-1))return null;c+=d*g[f-(0>d?1:0)].size,f+=d}return{index:f,lineN:c}}function Pb(a,b,c){var d=a.display,e=d.view;0==e.length||b>=d.viewTo||c<=d.viewFrom?(d.view=Jb(a,b,c),d.viewFrom=b):(d.viewFrom>b?d.view=Jb(a,b,d.viewFrom).concat(d.view):d.viewFromc&&(d.view=d.view.slice(0,Nb(a,c)))),d.viewTo=c}function Qb(a){for(var b=a.display.view,c=0,d=0;d400}var e=a.display;Eg(e.scroller,"mousedown",Fb(a,Wb)),tf&&11>uf?Eg(e.scroller,"dblclick",Fb(a,function(b){if(!Ae(a,b)){var c=Vb(a,b);if(c&&!_b(a,b)&&!Ub(a.display,b)){Bg(b);var d=a.findWordAt(c);ua(a.doc,d.anchor,d.head)}}})):Eg(e.scroller,"dblclick",function(b){Ae(a,b)||Bg(b)}),Jf||Eg(e.scroller,"contextmenu",function(b){tc(a,b)});var f,g={end:0};Eg(e.scroller,"touchstart",function(b){if(!Ae(a,b)&&!c(b)){clearTimeout(f);var d=+new Date;e.activeTouch={start:d,moved:!1,prev:d-g.end<=300?g:null},1==b.touches.length&&(e.activeTouch.left=b.touches[0].pageX,e.activeTouch.top=b.touches[0].pageY)}}),Eg(e.scroller,"touchmove",function(){e.activeTouch&&(e.activeTouch.moved=!0)}),Eg(e.scroller,"touchend",function(c){var f=e.activeTouch;if(f&&!Ub(e,c)&&null!=f.left&&!f.moved&&new Date-f.start<300){var g,h=a.coordsChar(e.activeTouch,"page");g=!f.prev||d(f,f.prev)?new la(h,h):!f.prev.prev||d(f,f.prev.prev)?a.findWordAt(h):new la(Mf(h.line,0),pa(a.doc,Mf(h.line+1,0))),a.setSelection(g.anchor,g.head),a.focus(),Bg(c)}b()}),Eg(e.scroller,"touchcancel",b),Eg(e.scroller,"scroll",function(){e.scroller.clientHeight&&(ec(a,e.scroller.scrollTop),fc(a,e.scroller.scrollLeft,!0),Hg(a,"scroll",a))}),Eg(e.scroller,"mousewheel",function(b){gc(a,b)}),Eg(e.scroller,"DOMMouseScroll",function(b){gc(a,b)}),Eg(e.wrapper,"scroll",function(){e.wrapper.scrollTop=e.wrapper.scrollLeft=0}),e.dragFunctions={enter:function(b){Ae(a,b)||Dg(b)},over:function(b){Ae(a,b)||(cc(a,b),Dg(b))},start:function(b){bc(a,b)},drop:Fb(a,ac),leave:function(b){Ae(a,b)||dc(a)}};var h=e.input.getField();Eg(h,"keyup",function(b){oc.call(a,b)}),Eg(h,"keydown",Fb(a,mc)),Eg(h,"keypress",Fb(a,pc)),Eg(h,"focus",Me(rc,a)),Eg(h,"blur",Me(sc,a))}function Sb(b,c,d){var e=d&&d!=a.Init;if(!c!=!e){var f=b.display.dragFunctions,g=c?Eg:Gg;g(b.display.scroller,"dragstart",f.start),g(b.display.scroller,"dragenter",f.enter),g(b.display.scroller,"dragover",f.over),g(b.display.scroller,"dragleave",f.leave),g(b.display.scroller,"drop",f.drop)}}function Tb(a){var b=a.display;(b.lastWrapHeight!=b.wrapper.clientHeight||b.lastWrapWidth!=b.wrapper.clientWidth)&&(b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null,b.scrollbarsClipped=!1,a.setSize())}function Ub(a,b){for(var c=ve(b);c!=a.wrapper;c=c.parentNode)if(!c||1==c.nodeType&&"true"==c.getAttribute("cm-ignore-events")||c.parentNode==a.sizer&&c!=a.mover)return!0}function Vb(a,b,c,d){var e=a.display;if(!c&&"true"==ve(b).getAttribute("cm-not-content"))return null;var f,g,h=e.lineSpace.getBoundingClientRect();try{f=b.clientX-h.left,g=b.clientY-h.top}catch(b){return null}var i,j=rb(a,f,g);if(d&&1==j.xRel&&(i=Zd(a.doc,j.line).text).length==j.ch){var k=Og(i,i.length,a.options.tabSize)-i.length;j=Mf(j.line,Math.max(0,Math.round((f-Ta(a.display).left)/ub(a.display))-k))}return j}function Wb(a){var b=this,c=b.display;if(!(Ae(b,a)||c.activeTouch&&c.input.supportsTouch())){if(c.shift=a.shiftKey,Ub(c,a))return void(vf||(c.scroller.draggable=!1,setTimeout(function(){c.scroller.draggable=!0},100)));if(!_b(b,a)){var d=Vb(b,a);switch(window.focus(),we(a)){case 1:b.state.selectingText?b.state.selectingText(a):d?Xb(b,a,d):ve(a)==c.scroller&&Bg(a);break;case 2:vf&&(b.state.lastMiddleDown=+new Date),d&&ua(b.doc,d),setTimeout(function(){c.input.focus()},20),Bg(a);break;case 3:Jf?tc(b,a):qc(b)}}}}function Xb(a,b,c){tf?setTimeout(Me(Y,a),0):a.curOp.focus=Te();var d,e=+new Date;Rf&&Rf.time>e-400&&0==Nf(Rf.pos,c)?d="triple":Qf&&Qf.time>e-400&&0==Nf(Qf.pos,c)?(d="double",Rf={time:e,pos:c}):(d="single",Qf={time:e,pos:c});var f,g=a.doc.sel,h=Ef?b.metaKey:b.ctrlKey;a.options.dragDrop&&ah&&!a.isReadOnly()&&"single"==d&&(f=g.contains(c))>-1&&(Nf((f=g.ranges[f]).from(),c)<0||c.xRel>0)&&(Nf(f.to(),c)>0||c.xRel<0)?Yb(a,b,c,h):Zb(a,b,c,d,h)}function Yb(a,b,c,d){var e=a.display,f=+new Date,g=Fb(a,function(h){vf&&(e.scroller.draggable=!1),a.state.draggingText=!1,Gg(document,"mouseup",g),Gg(e.scroller,"drop",g),Math.abs(b.clientX-h.clientX)+Math.abs(b.clientY-h.clientY)<10&&(Bg(h),!d&&+new Date-200=o;o++){var r=Zd(j,o).text,s=Pg(r,i,f);i==n?e.push(new la(Mf(o,s),Mf(o,s))):r.length>s&&e.push(new la(Mf(o,s),Mf(o,Pg(r,n,f))))}e.length||e.push(new la(c,c)),Aa(j,ma(m.ranges.slice(0,l).concat(e),l),{origin:"*mouse",scroll:!1}),a.scrollIntoView(b)}else{var t=k,u=t.anchor,v=b;if("single"!=d){if("double"==d)var w=a.findWordAt(b);else var w=new la(Mf(b.line,0),pa(j,Mf(b.line+1,0)));Nf(w.anchor,u)>0?(v=w.head,u=X(t.from(),w.anchor)):(v=w.anchor,u=W(t.to(),w.head))}var e=m.ranges.slice(0);e[l]=new la(pa(j,u),v),Aa(j,ma(e,l),Mg)}}function g(b){var c=++s,e=Vb(a,b,!0,"rect"==d);if(e)if(0!=Nf(e,q)){a.curOp.focus=Te(),f(e);var h=u(i,j);(e.line>=h.to||e.liner.bottom?20:0;k&&setTimeout(Fb(a,function(){s==c&&(i.scroller.scrollTop+=k,g(b))}),50)}}function h(b){a.state.selectingText=!1,s=1/0,Bg(b),i.input.focus(),Gg(document,"mousemove",t),Gg(document,"mouseup",v),j.history.lastSelOrigin=null}var i=a.display,j=a.doc;Bg(b);var k,l,m=j.sel,n=m.ranges;if(e&&!b.shiftKey?(l=j.sel.contains(c),k=l>-1?n[l]:new la(c,c)):(k=j.sel.primary(),l=j.sel.primIndex),Ff?b.shiftKey&&b.metaKey:b.altKey)d="rect",e||(k=new la(c,c)),c=Vb(a,b,!0,!0),l=-1;else if("double"==d){var o=a.findWordAt(c);k=a.display.shift||j.extend?ta(j,k,o.anchor,o.head):o}else if("triple"==d){var p=new la(Mf(c.line,0),pa(j,Mf(c.line+1,0)));k=a.display.shift||j.extend?ta(j,k,p.anchor,p.head):p}else k=ta(j,k,c);e?-1==l?(l=n.length,Aa(j,ma(n.concat([k]),l),{scroll:!1,origin:"*mouse"})):n.length>1&&n[l].empty()&&"single"==d&&!b.shiftKey?(Aa(j,ma(n.slice(0,l).concat(n.slice(l+1)),0),{scroll:!1,origin:"*mouse"}),m=j.sel):wa(j,l,k,Mg):(l=0,Aa(j,new ka([k],0),Mg),m=j.sel);var q=c,r=i.wrapper.getBoundingClientRect(),s=0,t=Fb(a,function(a){we(a)?g(a):h(a)}),v=Fb(a,h);a.state.selectingText=v,Eg(document,"mousemove",t),Eg(document,"mouseup",v)}function $b(a,b,c,d){try{var e=b.clientX,f=b.clientY}catch(b){return!1}if(e>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&Bg(b);var g=a.display,h=g.lineDiv.getBoundingClientRect();if(f>h.bottom||!Ce(a,c))return ue(b);f-=h.top-g.viewOffset;for(var i=0;i=e){var k=ce(a.doc,f),l=a.options.gutters[i];return Hg(a,c,a,k,l,b),ue(b)}}}function _b(a,b){return $b(a,b,"gutterClick",!0)}function ac(a){var b=this;if(dc(b),!Ae(b,a)&&!Ub(b.display,a)){Bg(a),tf&&(Vf=+new Date);var c=Vb(b,a,!0),d=a.dataTransfer.files;if(c&&!b.isReadOnly())if(d&&d.length&&window.FileReader&&window.File)for(var e=d.length,f=Array(e),g=0,h=function(a,d){if(!b.options.allowDropFileTypes||-1!=He(b.options.allowDropFileTypes,a.type)){var h=new FileReader;h.onload=Fb(b,function(){var a=h.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(a)&&(a=""),f[d]=a,++g==e){c=pa(b.doc,c);var i={from:c,to:c,text:b.doc.splitLines(f.join(b.doc.lineSeparator())),origin:"paste"};Ac(b.doc,i),za(b.doc,na(c,_f(i)))}}),h.readAsText(a)}},i=0;e>i;++i)h(d[i],i);else{if(b.state.draggingText&&b.doc.sel.contains(c)>-1)return b.state.draggingText(a),void setTimeout(function(){b.display.input.focus()},20);try{var f=a.dataTransfer.getData("Text");if(f){if(b.state.draggingText&&!b.state.draggingText.copy)var j=b.listSelections();if(Ba(b.doc,na(c,c)),j)for(var i=0;ig.clientWidth,i=g.scrollHeight>g.clientHeight;if(d&&h||e&&i){if(e&&Ef&&vf)a:for(var j=b.target,k=f.view;j!=g;j=j.parentNode)for(var l=0;lm?n=Math.max(0,n+m-50):o=Math.min(a.doc.height,o+m+50),D(a,{top:n,bottom:o})}20>Wf&&(null==f.wheelStartX?(f.wheelStartX=g.scrollLeft,f.wheelStartY=g.scrollTop,f.wheelDX=d,f.wheelDY=e,setTimeout(function(){if(null!=f.wheelStartX){var a=g.scrollLeft-f.wheelStartX,b=g.scrollTop-f.wheelStartY,c=b&&f.wheelDY&&b/f.wheelDY||a&&f.wheelDX&&a/f.wheelDX;f.wheelStartX=f.wheelStartY=null,c&&(Xf=(Xf*Wf+c)/(Wf+1),++Wf)}},200)):(f.wheelDX+=d,f.wheelDY+=e))}}function hc(a,b,c){if("string"==typeof b&&(b=kg[b],!b))return!1;a.display.input.ensurePolled();var d=a.display.shift,e=!1;try{a.isReadOnly()&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=Kg}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function ic(a,b,c){for(var d=0;duf&&27==a.keyCode&&(a.returnValue=!1);var c=a.keyCode;b.display.shift=16==c||a.shiftKey;var d=kc(b,a);yf&&($f=d?c:null,!d&&88==c&&!dh&&(Ef?a.metaKey:a.ctrlKey)&&b.replaceSelection("",null,"cut")),18!=c||/\bCodeMirror-crosshair\b/.test(b.display.lineDiv.className)||nc(b)}}function nc(a){function b(a){18!=a.keyCode&&a.altKey||(Zg(c,"CodeMirror-crosshair"),Gg(document,"keyup",b),Gg(document,"mouseover",b))}var c=a.display.lineDiv;$g(c,"CodeMirror-crosshair"),Eg(document,"keyup",b),Eg(document,"mouseover",b)}function oc(a){16==a.keyCode&&(this.doc.sel.shift=!1),Ae(this,a)}function pc(a){var b=this;if(!(Ub(b.display,a)||Ae(b,a)||a.ctrlKey&&!a.altKey||Ef&&a.metaKey)){var c=a.keyCode,d=a.charCode;if(yf&&c==$f)return $f=null,void Bg(a);if(!yf||a.which&&!(a.which<10)||!kc(b,a)){var e=String.fromCharCode(null==d?c:d);lc(b,a,e)||b.display.input.onKeyPress(a)}}}function qc(a){a.state.delayingBlurEvent=!0,setTimeout(function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,sc(a))},100)}function rc(a){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1),"nocursor"!=a.options.readOnly&&(a.state.focused||(Hg(a,"focus",a),a.state.focused=!0,$g(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(a.display.input.reset(),vf&&setTimeout(function(){a.display.input.reset(!0)},20)),a.display.input.receivedFocus()),Ma(a))}function sc(a){a.state.delayingBlurEvent||(a.state.focused&&(Hg(a,"blur",a),a.state.focused=!1,Zg(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150))}function tc(a,b){Ub(a.display,b)||uc(a,b)||Ae(a,b,"contextmenu")||a.display.input.onContextMenu(b)}function uc(a,b){return Ce(a,"gutterContextMenu")?$b(a,b,"gutterContextMenu",!1):!1}function vc(a,b){if(Nf(a,b.from)<0)return a;if(Nf(a,b.to)<=0)return _f(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;return a.line==b.to.line&&(d+=_f(b).ch-b.to.ch),Mf(c,d)}function wc(a,b){for(var c=[],d=0;d=0;--e)Bc(a,{from:d[e].from,to:d[e].to,text:e?[""]:b.text});else Bc(a,b)}}function Bc(a,b){if(1!=b.text.length||""!=b.text[0]||0!=Nf(b.from,b.to)){var c=wc(a,b);je(a,b,c,a.cm?a.cm.curOp.id:NaN),Ec(a,b,c,fd(a,b));var d=[];Xd(a,function(a,c){c||-1!=He(d,a.history)||(te(a.history,b),d.push(a.history)),Ec(a,b,null,fd(a,b))})}}function Cc(a,b,c){if(!a.cm||!a.cm.state.suppressEdits||c){for(var d,e=a.history,f=a.sel,g="undo"==b?e.done:e.undone,h="undo"==b?e.undone:e.done,i=0;i=0;--i){var l=d.changes[i];if(l.origin=b,k&&!zc(a,l,!1))return void(g.length=0);j.push(ge(a,l));var m=i?wc(a,l):Ge(g);Ec(a,l,m,hd(a,l)),!i&&a.cm&&a.cm.scrollIntoView({from:l.from,to:_f(l)});var n=[];Xd(a,function(a,b){b||-1!=He(n,a.history)||(te(a.history,l),n.push(a.history)),Ec(a,l,null,hd(a,l))})}}}}function Dc(a,b){if(0!=b&&(a.first+=b,a.sel=new ka(Ie(a.sel.ranges,function(a){return new la(Mf(a.anchor.line+b,a.anchor.ch),Mf(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){Kb(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;da.lastLine())){if(b.from.linef&&(b={from:b.from,to:Mf(f,Zd(a,f).text.length),text:[b.text[0]],origin:b.origin}),b.removed=$d(a,b.from,b.to),c||(c=wc(a,b)),a.cm?Fc(a.cm,b,d):Ud(a,b,d),Ba(a,c,Lg)}}function Fc(a,b,c){var d=a.doc,e=a.display,g=b.from,h=b.to,i=!1,j=g.line;a.options.lineWrapping||(j=be(sd(Zd(d,g.line))),d.iter(j,h.line+1,function(a){return a==e.maxLine?(i=!0,!0):void 0})),d.sel.contains(b.from,b.to)>-1&&Be(a),Ud(d,b,c,f(a)),a.options.lineWrapping||(d.iter(j,g.line+b.text.length,function(a){var b=l(a);b>e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,i=!1)}),i&&(a.curOp.updateMaxLine=!0)),d.frontier=Math.min(d.frontier,g.line),Na(a,400);var k=b.text.length-(h.line-g.line)-1;b.full?Kb(a):g.line!=h.line||1!=b.text.length||Td(a.doc,b)?Kb(a,g.line,h.line+1,k):Lb(a,g.line,"text");var m=Ce(a,"changes"),n=Ce(a,"change");if(n||m){var o={from:g,to:h,text:b.text,removed:b.removed,origin:b.origin};n&&ye(a,"change",a,o),m&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(o)}a.display.selForContextMenu=null}function Gc(a,b,c,d,e){if(d||(d=c),Nf(d,c)<0){var f=d;d=c,c=f}"string"==typeof b&&(b=a.splitLines(b)),Ac(a,{from:c,to:d,text:b,origin:e})}function Hc(a,b){if(!Ae(a,"scrollCursorIntoView")){var c=a.display,d=c.sizer.getBoundingClientRect(),e=null;if(b.top+d.top<0?e=!0:b.bottom+d.top>(window.innerHeight||document.documentElement.clientHeight)&&(e=!1),null!=e&&!Bf){var f=Qe("div","​",null,"position: absolute; top: "+(b.top-c.viewOffset-Ra(a.display))+"px; height: "+(b.bottom-b.top+Ua(a)+c.barHeight)+"px; left: "+b.left+"px; width: 2px;");a.display.lineSpace.appendChild(f),f.scrollIntoView(e),a.display.lineSpace.removeChild(f)}}}function Ic(a,b,c,d){null==d&&(d=0);for(var e=0;5>e;e++){var f=!1,g=ob(a,b),h=c&&c!=b?ob(a,c):g,i=Kc(a,Math.min(g.left,h.left),Math.min(g.top,h.top)-d,Math.max(g.left,h.left),Math.max(g.bottom,h.bottom)+d),j=a.doc.scrollTop,k=a.doc.scrollLeft;if(null!=i.scrollTop&&(ec(a,i.scrollTop),Math.abs(a.doc.scrollTop-j)>1&&(f=!0)),null!=i.scrollLeft&&(fc(a,i.scrollLeft),Math.abs(a.doc.scrollLeft-k)>1&&(f=!0)),!f)break}return g}function Jc(a,b,c,d,e){var f=Kc(a,b,c,d,e);null!=f.scrollTop&&ec(a,f.scrollTop),null!=f.scrollLeft&&fc(a,f.scrollLeft)}function Kc(a,b,c,d,e){var f=a.display,g=tb(a.display);0>c&&(c=0);var h=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,i=Wa(a),j={};e-c>i&&(e=c+i);var k=a.doc.height+Sa(f),l=g>c,m=e>k-g;if(h>c)j.scrollTop=l?0:c;else if(e>h+i){var n=Math.min(c,(m?k:e)-i);n!=h&&(j.scrollTop=n)}var o=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:f.scroller.scrollLeft,p=Va(a)-(a.options.fixedGutter?f.gutters.offsetWidth:0),q=d-b>p;return q&&(d=b+p),10>b?j.scrollLeft=0:o>b?j.scrollLeft=Math.max(0,b-(q?0:10)):d>p+o-3&&(j.scrollLeft=d+(q?0:10)-p), -j}function Lc(a,b,c){(null!=b||null!=c)&&Nc(a),null!=b&&(a.curOp.scrollLeft=(null==a.curOp.scrollLeft?a.doc.scrollLeft:a.curOp.scrollLeft)+b),null!=c&&(a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+c)}function Mc(a){Nc(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?Mf(b.line,b.ch-1):b,d=Mf(b.line,b.ch+1)),a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function Nc(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=pb(a,b.from),d=pb(a,b.to),e=Kc(a,Math.min(c.left,d.left),Math.min(c.top,d.top)-b.margin,Math.max(c.right,d.right),Math.max(c.bottom,d.bottom)+b.margin);a.scrollTo(e.scrollLeft,e.scrollTop)}}function Oc(a,b,c,d){var e,f=a.doc;null==c&&(c="add"),"smart"==c&&(f.mode.indent?e=Qa(a,b):c="prev");var g=a.options.tabSize,h=Zd(f,b),i=Og(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var j,k=h.text.match(/^\s*/)[0];if(d||/\S/.test(h.text)){if("smart"==c&&(j=f.mode.indent(e,h.text.slice(k.length),h.text),j==Kg||j>150)){if(!d)return;c="prev"}}else j=0,c="not";"prev"==c?j=b>f.first?Og(Zd(f,b-1).text,null,g):0:"add"==c?j=i+a.options.indentUnit:"subtract"==c?j=i-a.options.indentUnit:"number"==typeof c&&(j=i+c),j=Math.max(0,j);var l="",m=0;if(a.options.indentWithTabs)for(var n=Math.floor(j/g);n;--n)m+=g,l+=" ";if(j>m&&(l+=Fe(j-m)),l!=k)return Gc(f,l,Mf(b,0),Mf(b,k.length),"+input"),h.stateAfter=null,!0;for(var n=0;n=0;b--)Gc(a.doc,"",d[b].from,d[b].to,"+delete");Mc(a)})}function Rc(a,b,c,d,e){function f(){var b=h+c;return b=a.first+a.size?!1:(h=b,k=Zd(a,b))}function g(a){var b=(e?mf:nf)(k,i,c,!0);if(null==b){if(a||!f())return!1;i=e?(0>c?ef:df)(k):0>c?k.text.length:0}else i=b;return!0}var h=b.line,i=b.ch,j=c,k=Zd(a,h);if("char"==d)g();else if("column"==d)g(!0);else if("word"==d||"group"==d)for(var l=null,m="group"==d,n=a.cm&&a.cm.getHelper(b,"wordChars"),o=!0;!(0>c)||g(!o);o=!1){var p=k.text.charAt(i)||"\n",q=Ne(p,n)?"w":m&&"\n"==p?"n":!m||/\s/.test(p)?null:"p";if(!m||o||q||(q="s"),l&&l!=q){0>c&&(c=1,g());break}if(q&&(l=q),c>0&&!g(!o))break}var r=Ga(a,Mf(h,i),b,j,!0);return Nf(b,r)||(r.hitSide=!0),r}function Sc(a,b,c,d){var e,f=a.doc,g=b.left;if("page"==d){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);e=b.top+c*(h-(0>c?1.5:.5)*tb(a.display))}else"line"==d&&(e=c>0?b.bottom+3:b.top-3);for(;;){var i=rb(a,g,e);if(!i.outside)break;if(0>c?0>=e:e>=f.height){i.hitSide=!0;break}e+=5*c}return i}function Tc(b,c,d,e){a.defaults[b]=c,d&&(bg[b]=e?function(a,b,c){c!=cg&&d(a,b,c)}:d)}function Uc(a){for(var b,c,d,e,f=a.split(/-(?!$)/),a=f[f.length-1],g=0;g0||0==g&&f.clearWhenEmpty!==!1)return f;if(f.replacedWith&&(f.collapsed=!0,f.widgetNode=Qe("span",[f.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||f.widgetNode.setAttribute("cm-ignore-events","true"),d.insertLeft&&(f.widgetNode.insertLeft=!0)),f.collapsed){if(rd(a,b.line,b,c,f)||b.line!=c.line&&rd(a,c.line,b,c,f))throw new Error("Inserting collapsed marker partially overlapping an existing one");Lf=!0}f.addToHistory&&je(a,{from:b,to:c,origin:"markText"},a.sel,NaN);var h,i=b.line,j=a.cm;if(a.iter(i,c.line+1,function(a){j&&f.collapsed&&!j.options.lineWrapping&&sd(a)==j.display.maxLine&&(h=!0),f.collapsed&&i!=b.line&&ae(a,0),cd(a,new _c(f,i==b.line?b.ch:null,i==c.line?c.ch:null)),++i}),f.collapsed&&a.iter(b.line,c.line+1,function(b){wd(a,b)&&ae(b,0)}),f.clearOnEnter&&Eg(f,"beforeCursorEnter",function(){f.clear()}),f.readOnly&&(Kf=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory()),f.collapsed&&(f.id=++qg,f.atomic=!0),j){if(h&&(j.curOp.updateMaxLine=!0),f.collapsed)Kb(j,b.line,c.line+1);else if(f.className||f.title||f.startStyle||f.endStyle||f.css)for(var k=b.line;k<=c.line;k++)Lb(j,k,"text");f.atomic&&Da(j.doc),ye(j,"markerAdded",j,f)}return f}function Xc(a,b,c,d,e){d=Le(d),d.shared=!1;var f=[Wc(a,b,c,d,e)],g=f[0],h=d.widgetNode;return Xd(a,function(a){h&&(d.widgetNode=h.cloneNode(!0)),f.push(Wc(a,pa(a,b),pa(a,c),d,e));for(var i=0;i=b:f.to>b);(d||(d=[])).push(new _c(g,f.from,i?null:f.to))}}return d}function ed(a,b,c){if(a)for(var d,e=0;e=b:f.to>b);if(h||f.from==b&&"bookmark"==g.type&&(!c||f.marker.insertLeft)){var i=null==f.from||(g.inclusiveLeft?f.from<=b:f.from0&&h)for(var l=0;ll;++l)o.push(p);o.push(i)}return o}function gd(a){for(var b=0;b0)){var k=[i,1],l=Nf(j.from,h.from),m=Nf(j.to,h.to);(0>l||!g.inclusiveLeft&&!l)&&k.push({from:j.from,to:h.from}),(m>0||!g.inclusiveRight&&!m)&&k.push({from:h.to,to:j.to}),e.splice.apply(e,k),i+=k.length-1}}return e}function jd(a){var b=a.markedSpans;if(b){for(var c=0;c=0&&0>=l||0>=k&&l>=0)&&(0>=k&&(i.marker.inclusiveRight&&e.inclusiveLeft?Nf(j.to,c)>=0:Nf(j.to,c)>0)||k>=0&&(i.marker.inclusiveRight&&e.inclusiveLeft?Nf(j.from,d)<=0:Nf(j.from,d)<0)))return!0}}}function sd(a){for(var b;b=pd(a);)a=b.find(-1,!0).line;return a}function td(a){for(var b,c;b=qd(a);)a=b.find(1,!0).line,(c||(c=[])).push(a);return c}function ud(a,b){var c=Zd(a,b),d=sd(c);return c==d?b:be(d)}function vd(a,b){if(b>a.lastLine())return b;var c,d=Zd(a,b);if(!wd(a,d))return b;for(;c=qd(d);)d=c.find(1,!0).line;return be(d)+1}function wd(a,b){var c=Lf&&b.markedSpans;if(c)for(var d,e=0;ef;f++){e&&(e[0]=a.innerMode(b,d).mode);var g=b.token(c,d);if(c.pos>c.start)return g}throw new Error("Mode "+b.name+" failed to advance stream.")}function Gd(a,b,c,d){function e(a){return{start:l.start,end:l.pos,string:l.current(),type:f||null,state:a?ig(g.mode,k):k}}var f,g=a.doc,h=g.mode;b=pa(g,b);var i,j=Zd(g,b.line),k=Qa(a,b.line,c),l=new pg(j.text,a.options.tabSize);for(d&&(i=[]);(d||l.posa.options.maxHighlightLength?(h=!1,g&&Kd(a,b,d,l.pos),l.pos=b.length,i=null):i=Dd(Fd(c,l,d,m),f),m){var n=m[0].name;n&&(i="m-"+(i?n+" "+i:n))}if(!h||k!=i){for(;jj;){var d=e[i];d>a&&e.splice(i,1,a,e[i+1],d),i+=2,j=Math.min(a,d)}if(b)if(h.opaque)e.splice(c,i-c,a,"cm-overlay "+b),i=c+2;else for(;i>c;c+=2){var f=e[c+1];e[c+1]=(f?f+" ":"")+"cm-overlay "+b}},f)}return{styles:e,classes:f.bgClass||f.textClass?f:null}}function Jd(a,b,c){if(!b.styles||b.styles[0]!=a.state.modeGen){var d=Qa(a,be(b)),e=Id(a,b,b.text.length>a.options.maxHighlightLength?ig(a.doc.mode,d):d);b.stateAfter=d,b.styles=e.styles,e.classes?b.styleClasses=e.classes:b.styleClasses&&(b.styleClasses=null),c===a.doc.frontier&&a.doc.frontier++}return b.styles}function Kd(a,b,c,d){var e=a.doc.mode,f=new pg(b,a.options.tabSize);for(f.start=f.pos=d||0,""==b&&Ed(e,c);!f.eol();)Fd(e,f,c),f.start=f.pos}function Ld(a,b){if(!a||/^\s*$/.test(a))return null;var c=b.addModeClass?wg:vg;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$&"))}function Md(a,b){var c=Qe("span",null,null,vf?"padding-right: .1px":null),d={pre:Qe("pre",[c],"CodeMirror-line"),content:c,col:0,pos:0,cm:a,trailingSpace:!1,splitSpaces:(tf||vf)&&a.getOption("lineWrapping")};b.measure={};for(var e=0;e<=(b.rest?b.rest.length:0);e++){var f,g=e?b.rest[e-1]:b.line;d.pos=0,d.addToken=Od,$e(a.display.measure)&&(f=ee(g))&&(d.addToken=Qd(d.addToken,f)),d.map=[];var h=b!=a.display.externalMeasured&&be(g);Sd(g,d,Jd(a,g,h)),g.styleClasses&&(g.styleClasses.bgClass&&(d.bgClass=Ve(g.styleClasses.bgClass,d.bgClass||"")),g.styleClasses.textClass&&(d.textClass=Ve(g.styleClasses.textClass,d.textClass||""))),0==d.map.length&&d.map.push(0,0,d.content.appendChild(Ze(a.display.measure))),0==e?(b.measure.map=d.map,b.measure.cache={}):((b.measure.maps||(b.measure.maps=[])).push(d.map),(b.measure.caches||(b.measure.caches=[])).push({}))}if(vf){var i=d.content.lastChild;(/\bcm-tab\b/.test(i.className)||i.querySelector&&i.querySelector(".cm-tab"))&&(d.content.className="cm-tab-wrap-hack")}return Hg(a,"renderLine",a,b.line,d.pre),d.pre.className&&(d.textClass=Ve(d.pre.className,d.textClass||"")),d}function Nd(a){var b=Qe("span","•","cm-invalidchar");return b.title="\\u"+a.charCodeAt(0).toString(16),b.setAttribute("aria-label",b.title),b}function Od(a,b,c,d,e,f,g){if(b){var h=a.splitSpaces?Pd(b,a.trailingSpace):b,i=a.cm.state.specialChars,j=!1;if(i.test(b))for(var k=document.createDocumentFragment(),l=0;;){i.lastIndex=l;var m=i.exec(b),n=m?m.index-l:b.length-l;if(n){var o=document.createTextNode(h.slice(l,l+n));tf&&9>uf?k.appendChild(Qe("span",[o])):k.appendChild(o),a.map.push(a.pos,a.pos+n,o),a.col+=n,a.pos+=n}if(!m)break;if(l+=n+1," "==m[0]){var p=a.cm.options.tabSize,q=p-a.col%p,o=k.appendChild(Qe("span",Fe(q),"cm-tab"));o.setAttribute("role","presentation"),o.setAttribute("cm-text"," "),a.col+=q}else if("\r"==m[0]||"\n"==m[0]){var o=k.appendChild(Qe("span","\r"==m[0]?"␍":"␤","cm-invalidchar"));o.setAttribute("cm-text",m[0]),a.col+=1}else{var o=a.cm.options.specialCharPlaceholder(m[0]);o.setAttribute("cm-text",m[0]),tf&&9>uf?k.appendChild(Qe("span",[o])):k.appendChild(o),a.col+=1}a.map.push(a.pos,a.pos+1,o),a.pos++}else{a.col+=b.length;var k=document.createTextNode(h);a.map.push(a.pos,a.pos+b.length,k),tf&&9>uf&&(j=!0),a.pos+=b.length}if(a.trailingSpace=32==h.charCodeAt(b.length-1),c||d||e||j||g){var r=c||"";d&&(r+=d),e&&(r+=e);var s=Qe("span",[k],r,g);return f&&(s.title=f),a.content.appendChild(s)}a.content.appendChild(k)}}function Pd(a,b){if(a.length>1&&!/ /.test(a))return a;for(var c=b,d="",e=0;ej&&m.from<=j)break}if(m.to>=k)return a(c,d,e,f,g,h,i);a(c,d.slice(0,m.to-j),e,f,null,h,i),f=null,d=d.slice(m.to-j),j=m.to}}}function Rd(a,b,c,d){var e=!d&&c.widgetNode;e&&a.map.push(a.pos,a.pos+b,e),!d&&a.cm.display.input.needsContentAttribute&&(e||(e=a.content.appendChild(document.createElement("span"))),e.setAttribute("cm-marker",c.id)),e&&(a.cm.display.input.setUneditable(e),a.content.appendChild(e)),a.pos+=b,a.trailingSpace=!1}function Sd(a,b,c){var d=a.markedSpans,e=a.text,f=0;if(d)for(var g,h,i,j,k,l,m,n=e.length,o=0,p=1,q="",r=0;;){if(r==o){i=j=k=l=h="",m=null,r=1/0;for(var s,t=[],u=0;uo||w.collapsed&&v.to==o&&v.from==o)?(null!=v.to&&v.to!=o&&r>v.to&&(r=v.to,j=""),w.className&&(i+=" "+w.className),w.css&&(h=(h?h+";":"")+w.css),w.startStyle&&v.from==o&&(k+=" "+w.startStyle),w.endStyle&&v.to==r&&(s||(s=[])).push(w.endStyle,v.to),w.title&&!l&&(l=w.title),w.collapsed&&(!m||nd(m.marker,w)<0)&&(m=v)):v.from>o&&r>v.from&&(r=v.from)}if(s)for(var u=0;u=n)break;for(var x=Math.min(n,r);;){if(q){var y=o+q.length;if(!m){var z=y>x?q.slice(0,x-o):q;b.addToken(b,z,g?g+i:i,k,o+z.length==r?j:"",l,h)}if(y>=x){q=q.slice(x-o),o=x;break}o=y,k=""}q=e.slice(f,f=c[p++]),g=Ld(c[p++],b.cm.options)}}else for(var p=1;pc;++c)f.push(new ug(j[c],e(c),d));return f}var h=b.from,i=b.to,j=b.text,k=Zd(a,h.line),l=Zd(a,i.line),m=Ge(j),n=e(j.length-1),o=i.line-h.line;if(b.full)a.insert(0,g(0,j.length)),a.remove(j.length,a.size-j.length);else if(Td(a,b)){var p=g(0,j.length-1);f(l,l.text,n),o&&a.remove(h.line,o),p.length&&a.insert(h.line,p)}else if(k==l)if(1==j.length)f(k,k.text.slice(0,h.ch)+m+k.text.slice(i.ch),n);else{var p=g(1,j.length-1);p.push(new ug(m+k.text.slice(i.ch),n,d)),f(k,k.text.slice(0,h.ch)+j[0],e(0)),a.insert(h.line+1,p)}else if(1==j.length)f(k,k.text.slice(0,h.ch)+j[0]+l.text.slice(i.ch),e(0)),a.remove(h.line+1,o);else{f(k,k.text.slice(0,h.ch)+j[0],e(0)),f(l,m+l.text.slice(i.ch),n);var p=g(1,j.length-1);o>1&&a.remove(h.line+1,o-1),a.insert(h.line+1,p)}ye(a,"change",a,b)}function Vd(a){this.lines=a,this.parent=null;for(var b=0,c=0;bb||b>=a.size)throw new Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(f>b){c=e;break}b-=f}return c.lines[b]}function $d(a,b,c){var d=[],e=b.line;return a.iter(b.line,c.line+1,function(a){var f=a.text;e==c.line&&(f=f.slice(0,c.ch)),e==b.line&&(f=f.slice(b.ch)),d.push(f),++e}),d}function _d(a,b,c){var d=[];return a.iter(b,c,function(a){d.push(a.text)}),d}function ae(a,b){var c=b-a.height;if(c)for(var d=a;d;d=d.parent)d.height+=c}function be(a){if(null==a.parent)return null;for(var b=a.parent,c=He(b.lines,a),d=b.parent;d;b=d,d=d.parent)for(var e=0;d.children[e]!=b;++e)c+=d.children[e].chunkSize();return c+b.first}function ce(a,b){var c=a.first;a:do{for(var d=0;db){a=e;continue a}b-=f,c+=e.chunkSize()}return c}while(!a.lines);for(var d=0;db)break;b-=h}return c+d}function de(a){a=sd(a);for(var b=0,c=a.parent,d=0;d1&&!a.done[a.done.length-2].ranges?(a.done.pop(),Ge(a.done)):void 0}function je(a,b,c,d){var e=a.history;e.undone.length=0;var f,g=+new Date;if((e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastModTime>g-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))&&(f=ie(e,e.lastOp==d))){var h=Ge(f.changes);0==Nf(b.from,b.to)&&0==Nf(b.from,h.to)?h.to=_f(b):f.changes.push(ge(a,b))}else{var i=Ge(e.done);for(i&&i.ranges||me(a.sel,e.done),f={changes:[ge(a,b)],generation:e.generation},e.done.push(f);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift()}e.done.push(c),e.generation=++e.maxGeneration,e.lastModTime=e.lastSelTime=g,e.lastOp=e.lastSelOp=d,e.lastOrigin=e.lastSelOrigin=b.origin,h||Hg(a,"historyAdded")}function ke(a,b,c,d){var e=b.charAt(0);return"*"==e||"+"==e&&c.ranges.length==d.ranges.length&&c.somethingSelected()==d.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}function le(a,b,c,d){var e=a.history,f=d&&d.origin;c==e.lastSelOp||f&&e.lastSelOrigin==f&&(e.lastModTime==e.lastSelTime&&e.lastOrigin==f||ke(a,f,Ge(e.done),b))?e.done[e.done.length-1]=b:me(b,e.done),e.lastSelTime=+new Date,e.lastSelOrigin=f,e.lastSelOp=c,d&&d.clearRedo!==!1&&he(e.undone)}function me(a,b){var c=Ge(b);c&&c.ranges&&c.equals(a)||b.push(a)}function ne(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans),++f})}function oe(a){if(!a)return null;for(var b,c=0;c-1&&(Ge(h)[l]=k[l],delete k[l])}}}return e}function re(a,b,c,d){c0?d.slice():Fg:d||Fg}function ye(a,b){function c(a){return function(){a.apply(null,f)}}var d=xe(a,b,!1);if(d.length){var e,f=Array.prototype.slice.call(arguments,2);Tf?e=Tf.delayedCallbacks:Ig?e=Ig:(e=Ig=[],setTimeout(ze,0));for(var g=0;g0}function De(a){a.prototype.on=function(a,b){Eg(this,a,b)},a.prototype.off=function(a,b){Gg(this,a,b)}}function Ee(){this.id=null}function Fe(a){for(;Qg.length<=a;)Qg.push(Ge(Qg)+" ");return Qg[a]}function Ge(a){return a[a.length-1]}function He(a,b){for(var c=0;c-1&&Ug(a)?!0:b.test(a):Ug(a)}function Oe(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function Pe(a){return a.charCodeAt(0)>=768&&Vg.test(a)}function Qe(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)e.appendChild(document.createTextNode(b));else if(b)for(var f=0;f0;--b)a.removeChild(a.firstChild);return a}function Se(a,b){return Re(a).appendChild(b)}function Te(){for(var a=document.activeElement;a&&a.root&&a.root.activeElement;)a=a.root.activeElement;return a}function Ue(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}function Ve(a,b){for(var c=a.split(" "),d=0;d2&&!(tf&&8>uf))}var c=Xg?Qe("span","​"):Qe("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return c.setAttribute("cm-text",""),c}function $e(a){if(null!=Yg)return Yg;var b=Se(a,document.createTextNode("AخA")),c=Sg(b,0,1).getBoundingClientRect(),d=Sg(b,1,2).getBoundingClientRect();return Re(a),c&&c.left!=c.right?Yg=d.right-c.right<3:!1}function _e(a){if(null!=eh)return eh;var b=Se(a,Qe("span","x")),c=b.getBoundingClientRect(),d=Sg(b,0,1).getBoundingClientRect();return eh=Math.abs(c.left-d.left)>1}function af(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;fb||b==c&&g.to==b)&&(d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr"),e=!0)}e||d(b,c,"ltr")}function bf(a){return a.level%2?a.to:a.from}function cf(a){return a.level%2?a.from:a.to}function df(a){var b=ee(a);return b?bf(b[0]):0}function ef(a){var b=ee(a);return b?cf(Ge(b)):a.text.length}function ff(a,b){var c=Zd(a.doc,b),d=sd(c);d!=c&&(b=be(d));var e=ee(d),f=e?e[0].level%2?ef(d):df(d):0;return Mf(b,f)}function gf(a,b){for(var c,d=Zd(a.doc,b);c=qd(d);)d=c.find(1,!0).line,b=null;var e=ee(d),f=e?e[0].level%2?df(d):ef(d):d.text.length;return Mf(null==b?be(d):b,f)}function hf(a,b){var c=ff(a,b.line),d=Zd(a.doc,c.line),e=ee(d);if(!e||0==e[0].level){var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&b.ch<=f&&b.ch;return Mf(c.line,g?0:f)}return c}function jf(a,b,c){var d=a[0].level;return b==d?!0:c==d?!1:c>b}function kf(a,b){gh=null;for(var c,d=0;db)return d;if(e.from==b||e.to==b){if(null!=c)return jf(a,e.level,a[c].level)?(e.from!=e.to&&(gh=c),d):(e.from!=e.to&&(gh=d),c);c=d}}return c}function lf(a,b,c,d){if(!d)return b+c;do b+=c;while(b>0&&Pe(a.text.charAt(b)));return b}function mf(a,b,c,d){var e=ee(a);if(!e)return nf(a,b,c,d);for(var f=kf(e,b),g=e[f],h=lf(a,b,g.level%2?-c:c,d);;){if(h>g.from&&h0==g.level%2?g.to:g.from);if(g=e[f+=c],!g)return null;h=c>0==g.level%2?lf(a,g.to,-1,d):lf(a,g.from,1,d)}}function nf(a,b,c,d){var e=b+c;if(d)for(;e>0&&Pe(a.text.charAt(e));)e+=c;return 0>e||e>a.text.length?null:e}var of=navigator.userAgent,pf=navigator.platform,qf=/gecko\/\d/i.test(of),rf=/MSIE \d/.test(of),sf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(of),tf=rf||sf,uf=tf&&(rf?document.documentMode||6:sf[1]),vf=/WebKit\//.test(of),wf=vf&&/Qt\/\d+\.\d+/.test(of),xf=/Chrome\//.test(of),yf=/Opera\//.test(of),zf=/Apple Computer/.test(navigator.vendor),Af=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(of),Bf=/PhantomJS/.test(of),Cf=/AppleWebKit/.test(of)&&/Mobile\/\w+/.test(of),Df=Cf||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(of),Ef=Cf||/Mac/.test(pf),Ff=/\bCrOS\b/.test(of),Gf=/win/i.test(pf),Hf=yf&&of.match(/Version\/(\d*\.\d*)/);Hf&&(Hf=Number(Hf[1])),Hf&&Hf>=15&&(yf=!1,vf=!0);var If=Ef&&(wf||yf&&(null==Hf||12.11>Hf)),Jf=qf||tf&&uf>=9,Kf=!1,Lf=!1;p.prototype=Le({update:function(a){var b=a.scrollWidth>a.clientWidth+1,c=a.scrollHeight>a.clientHeight+1,d=a.nativeBarWidth;if(c){this.vert.style.display="block",this.vert.style.bottom=b?d+"px":"0";var e=a.viewHeight-(b?d:0);this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+e)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(b){this.horiz.style.display="block",this.horiz.style.right=c?d+"px":"0",this.horiz.style.left=a.barLeft+"px";var f=a.viewWidth-a.barLeft-(c?d:0);this.horiz.firstChild.style.width=a.scrollWidth-a.clientWidth+f+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&a.clientHeight>0&&(0==d&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:c?d:0,bottom:b?d:0}},setScrollLeft:function(a){this.horiz.scrollLeft!=a&&(this.horiz.scrollLeft=a),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){var a=Ef&&!Af?"12px":"18px";this.horiz.style.height=this.vert.style.width=a,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none", -this.disableHoriz=new Ee,this.disableVert=new Ee},enableZeroWidthBar:function(a,b){function c(){var d=a.getBoundingClientRect(),e=document.elementFromPoint(d.left+1,d.bottom-1);e!=a?a.style.pointerEvents="none":b.set(1e3,c)}a.style.pointerEvents="auto",b.set(1e3,c)},clear:function(){var a=this.horiz.parentNode;a.removeChild(this.horiz),a.removeChild(this.vert)}},p.prototype),q.prototype=Le({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},q.prototype),a.scrollbarModel={"native":p,"null":q},z.prototype.signal=function(a,b){Ce(a,b)&&this.events.push(arguments)},z.prototype.finish=function(){for(var a=0;a=9&&c.hasSelection&&(c.hasSelection=null),c.poll()}),Eg(f,"paste",function(a){Ae(d,a)||$(a,d)||(d.state.pasteIncoming=!0,c.fastPoll())}),Eg(f,"cut",b),Eg(f,"copy",b),Eg(a.scroller,"paste",function(b){Ub(a,b)||Ae(d,b)||(d.state.pasteIncoming=!0,c.focus())}),Eg(a.lineSpace,"selectstart",function(b){Ub(a,b)||Bg(b)}),Eg(f,"compositionstart",function(){var a=d.getCursor("from");c.composing&&c.composing.range.clear(),c.composing={start:a,range:d.markText(a,d.getCursor("to"),{className:"CodeMirror-composing"})}}),Eg(f,"compositionend",function(){c.composing&&(c.poll(),c.composing.range.clear(),c.composing=null)})},prepareSelection:function(){var a=this.cm,b=a.display,c=a.doc,d=Ja(a);if(a.options.moveInputWithCursor){var e=ob(a,c.sel.primary().head,"div"),f=b.wrapper.getBoundingClientRect(),g=b.lineDiv.getBoundingClientRect();d.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,e.top+g.top-f.top)),d.teLeft=Math.max(0,Math.min(b.wrapper.clientWidth-10,e.left+g.left-f.left))}return d},showSelection:function(a){var b=this.cm,c=b.display;Se(c.cursorDiv,a.cursors),Se(c.selectionDiv,a.selection),null!=a.teTop&&(this.wrapper.style.top=a.teTop+"px",this.wrapper.style.left=a.teLeft+"px")},reset:function(a){if(!this.contextMenuPending){var b,c,d=this.cm,e=d.doc;if(d.somethingSelected()){this.prevInput="";var f=e.sel.primary();b=dh&&(f.to().line-f.from().line>100||(c=d.getSelection()).length>1e3);var g=b?"-":c||d.getSelection();this.textarea.value=g,d.state.focused&&Rg(this.textarea),tf&&uf>=9&&(this.hasSelection=g)}else a||(this.prevInput=this.textarea.value="",tf&&uf>=9&&(this.hasSelection=null));this.inaccurateSelection=b}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Df||Te()!=this.textarea))try{this.textarea.focus()}catch(a){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var a=this;a.pollingFast||a.polling.set(this.cm.options.pollInterval,function(){a.poll(),a.cm.state.focused&&a.slowPoll()})},fastPoll:function(){function a(){var d=c.poll();d||b?(c.pollingFast=!1,c.slowPoll()):(b=!0,c.polling.set(60,a))}var b=!1,c=this;c.pollingFast=!0,c.polling.set(20,a)},poll:function(){var a=this.cm,b=this.textarea,c=this.prevInput;if(this.contextMenuPending||!a.state.focused||ch(b)&&!c&&!this.composing||a.isReadOnly()||a.options.disableInput||a.state.keySeq)return!1;var d=b.value;if(d==c&&!a.somethingSelected())return!1;if(tf&&uf>=9&&this.hasSelection===d||Ef&&/[\uf700-\uf7ff]/.test(d))return a.display.input.reset(),!1;if(a.doc.sel==a.display.selForContextMenu){var e=d.charCodeAt(0);if(8203!=e||c||(c="​"),8666==e)return this.reset(),this.cm.execCommand("undo")}for(var f=0,g=Math.min(c.length,d.length);g>f&&c.charCodeAt(f)==d.charCodeAt(f);)++f;var h=this;return Eb(a,function(){Z(a,d.slice(f),c.length-f,null,h.composing?"*compose":null),d.length>1e3||d.indexOf("\n")>-1?b.value=h.prevInput="":h.prevInput=d,h.composing&&(h.composing.range.clear(),h.composing.range=a.markText(h.composing.start,a.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){tf&&uf>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(a){function b(){if(null!=g.selectionStart){var a=e.somethingSelected(),b="​"+(a?g.value:"");g.value="⇚",g.value=b,d.prevInput=a?"":"​",g.selectionStart=1,g.selectionEnd=b.length,f.selForContextMenu=e.doc.sel}}function c(){if(d.contextMenuPending=!1,d.wrapper.style.cssText=l,g.style.cssText=k,tf&&9>uf&&f.scrollbars.setScrollTop(f.scroller.scrollTop=i),null!=g.selectionStart){(!tf||tf&&9>uf)&&b();var a=0,c=function(){f.selForContextMenu==e.doc.sel&&0==g.selectionStart&&g.selectionEnd>0&&"​"==d.prevInput?Fb(e,kg.selectAll)(e):a++<10?f.detectingSelectAll=setTimeout(c,500):f.input.reset()};f.detectingSelectAll=setTimeout(c,200)}}var d=this,e=d.cm,f=e.display,g=d.textarea,h=Vb(e,a),i=f.scroller.scrollTop;if(h&&!yf){var j=e.options.resetSelectionOnContextMenu;j&&-1==e.doc.sel.contains(h)&&Fb(e,Aa)(e.doc,na(h),Lg);var k=g.style.cssText,l=d.wrapper.style.cssText;d.wrapper.style.cssText="position: absolute";var m=d.wrapper.getBoundingClientRect();if(g.style.cssText="position: absolute; width: 30px; height: 30px; top: "+(a.clientY-m.top-5)+"px; left: "+(a.clientX-m.left-5)+"px; z-index: 1000; background: "+(tf?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",vf)var n=window.scrollY;if(f.input.focus(),vf&&window.scrollTo(null,n),f.input.reset(),e.somethingSelected()||(g.value=d.prevInput=" "),d.contextMenuPending=!0,f.selForContextMenu=e.doc.sel,clearTimeout(f.detectingSelectAll),tf&&uf>=9&&b(),Jf){Dg(a);var o=function(){Gg(window,"mouseup",o),setTimeout(c,20)};Eg(window,"mouseup",o)}else setTimeout(c,50)}},readOnlyChanged:function(a){a||this.reset()},setUneditable:Je,needsContentAttribute:!1},ca.prototype),ea.prototype=Le({init:function(a){function b(a){if(!Ae(d,a)){if(d.somethingSelected())Of={lineWise:!1,text:d.getSelections()},"cut"==a.type&&d.replaceSelection("",null,"cut");else{if(!d.options.lineWiseCopyCut)return;var b=aa(d);Of={lineWise:!0,text:b.text},"cut"==a.type&&d.operation(function(){d.setSelections(b.ranges,0,Lg),d.replaceSelection("",null,"cut")})}if(a.clipboardData&&!Cf)a.preventDefault(),a.clipboardData.clearData(),a.clipboardData.setData("text/plain",Of.text.join("\n"));else{var c=da(),e=c.firstChild;d.display.lineSpace.insertBefore(c,d.display.lineSpace.firstChild),e.value=Of.text.join("\n");var f=document.activeElement;Rg(e),setTimeout(function(){d.display.lineSpace.removeChild(c),f.focus()},50)}}}var c=this,d=c.cm,e=c.div=a.lineDiv;ba(e),Eg(e,"paste",function(a){Ae(d,a)||$(a,d)}),Eg(e,"compositionstart",function(a){var b=a.data;if(c.composing={sel:d.doc.sel,data:b,startData:b},b){var e=d.doc.sel.primary(),f=d.getLine(e.head.line),g=f.indexOf(b,Math.max(0,e.head.ch-b.length));g>-1&&g<=e.head.ch&&(c.composing.sel=na(Mf(e.head.line,g),Mf(e.head.line,g+b.length)))}}),Eg(e,"compositionupdate",function(a){c.composing.data=a.data}),Eg(e,"compositionend",function(a){var b=c.composing;b&&(a.data==b.startData||/\u200b/.test(a.data)||(b.data=a.data),setTimeout(function(){b.handled||c.applyComposition(b),c.composing==b&&(c.composing=null)},50))}),Eg(e,"touchstart",function(){c.forceCompositionEnd()}),Eg(e,"input",function(){c.composing||(d.isReadOnly()||!c.pollContent())&&Eb(c.cm,function(){Kb(d)})}),Eg(e,"copy",b),Eg(e,"cut",b)},prepareSelection:function(){var a=Ja(this.cm,!1);return a.focus=this.cm.state.focused,a},showSelection:function(a,b){a&&this.cm.display.view.length&&((a.focus||b)&&this.showPrimarySelection(),this.showMultipleSelections(a))},showPrimarySelection:function(){var a=window.getSelection(),b=this.cm.doc.sel.primary(),c=ha(this.cm,a.anchorNode,a.anchorOffset),d=ha(this.cm,a.focusNode,a.focusOffset);if(!c||c.bad||!d||d.bad||0!=Nf(X(c,d),b.from())||0!=Nf(W(c,d),b.to())){var e=fa(this.cm,b.from()),f=fa(this.cm,b.to());if(e||f){var g=this.cm.display.view,h=a.rangeCount&&a.getRangeAt(0);if(e){if(!f){var i=g[g.length-1].measure,j=i.maps?i.maps[i.maps.length-1]:i.map;f={node:j[j.length-1],offset:j[j.length-2]-j[j.length-3]}}}else e={node:g[0].measure.map[2],offset:0};try{var k=Sg(e.node,e.offset,f.offset,f.node)}catch(l){}k&&(!qf&&this.cm.state.focused?(a.collapse(e.node,e.offset),k.collapsed||a.addRange(k)):(a.removeAllRanges(),a.addRange(k)),h&&null==a.anchorNode?a.addRange(h):qf&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var a=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){a.gracePeriod=!1,a.selectionChanged()&&a.cm.operation(function(){a.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(a){Se(this.cm.display.cursorDiv,a.cursors),Se(this.cm.display.selectionDiv,a.selection)},rememberSelection:function(){var a=window.getSelection();this.lastAnchorNode=a.anchorNode,this.lastAnchorOffset=a.anchorOffset,this.lastFocusNode=a.focusNode,this.lastFocusOffset=a.focusOffset},selectionInEditor:function(){var a=window.getSelection();if(!a.rangeCount)return!1;var b=a.getRangeAt(0).commonAncestorContainer;return Wg(this.div,b)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function a(){b.cm.state.focused&&(b.pollSelection(),b.polling.set(b.cm.options.pollInterval,a))}var b=this;this.selectionInEditor()?this.pollSelection():Eb(this.cm,function(){b.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,a)},selectionChanged:function(){var a=window.getSelection();return a.anchorNode!=this.lastAnchorNode||a.anchorOffset!=this.lastAnchorOffset||a.focusNode!=this.lastFocusNode||a.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var a=window.getSelection(),b=this.cm;this.rememberSelection();var c=ha(b,a.anchorNode,a.anchorOffset),d=ha(b,a.focusNode,a.focusOffset);c&&d&&Eb(b,function(){Aa(b.doc,na(c,d),Lg),(c.bad||d.bad)&&(b.curOp.selectionChanged=!0)})}},pollContent:function(){var a=this.cm,b=a.display,c=a.doc.sel.primary(),d=c.from(),e=c.to();if(d.lineb.viewTo-1)return!1;var f;if(d.line==b.viewFrom||0==(f=Nb(a,d.line)))var g=be(b.view[0].line),h=b.view[0].node;else var g=be(b.view[f].line),h=b.view[f-1].node.nextSibling;var i=Nb(a,e.line);if(i==b.view.length-1)var j=b.viewTo-1,k=b.lineDiv.lastChild;else var j=be(b.view[i+1].line)-1,k=b.view[i+1].node.previousSibling;for(var l=a.doc.splitLines(ja(a,h,k,g,j)),m=$d(a.doc,Mf(g,0),Mf(j,Zd(a.doc,j).text.length));l.length>1&&m.length>1;)if(Ge(l)==Ge(m))l.pop(),m.pop(),j--;else{if(l[0]!=m[0])break;l.shift(),m.shift(),g++}for(var n=0,o=0,p=l[0],q=m[0],r=Math.min(p.length,q.length);r>n&&p.charCodeAt(n)==q.charCodeAt(n);)++n;for(var s=Ge(l),t=Ge(m),u=Math.min(s.length-(1==l.length?n:0),t.length-(1==m.length?n:0));u>o&&s.charCodeAt(s.length-o-1)==t.charCodeAt(t.length-o-1);)++o;l[l.length-1]=s.slice(0,s.length-o),l[0]=l[0].slice(n);var v=Mf(g,n),w=Mf(j,m.length?Ge(m).length-o:0);return l.length>1||l[0]||Nf(v,w)?(Gc(a.doc,l,v,w,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(a){this.cm.isReadOnly()?Fb(this.cm,Kb)(this.cm):a.data&&a.data!=a.startData&&Fb(this.cm,Z)(this.cm,a.data,0,a.sel)},setUneditable:function(a){a.contentEditable="false"},onKeyPress:function(a){a.preventDefault(),this.cm.isReadOnly()||Fb(this.cm,Z)(this.cm,String.fromCharCode(null==a.charCode?a.keyCode:a.charCode),0)},readOnlyChanged:function(a){this.div.contentEditable=String("nocursor"!=a)},onContextMenu:Je,resetPosition:Je,needsContentAttribute:!0},ea.prototype),a.inputStyles={textarea:ca,contenteditable:ea},ka.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(a){if(a==this)return!0;if(a.primIndex!=this.primIndex||a.ranges.length!=this.ranges.length)return!1;for(var b=0;b=0&&Nf(a,d.to())<=0)return c}return-1}},la.prototype={from:function(){return X(this.anchor,this.head)},to:function(){return W(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Pf,Qf,Rf,Sf={left:0,right:0,top:0,bottom:0},Tf=null,Uf=0,Vf=0,Wf=0,Xf=null;tf?Xf=-.53:qf?Xf=15:xf?Xf=-.7:zf&&(Xf=-1/3);var Yf=function(a){var b=a.wheelDeltaX,c=a.wheelDeltaY;return null==b&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(b=a.detail),null==c&&a.detail&&a.axis==a.VERTICAL_AXIS?c=a.detail:null==c&&(c=a.wheelDelta),{x:b,y:c}};a.wheelEventPixels=function(a){var b=Yf(a);return b.x*=Xf,b.y*=Xf,b};var Zf=new Ee,$f=null,_f=a.changeEnd=function(a){return a.text?Mf(a.from.line+a.text.length-1,Ge(a.text).length+(1==a.text.length?a.from.ch:0)):a.to};a.prototype={constructor:a,focus:function(){window.focus(),this.display.input.focus()},setOption:function(a,b){var c=this.options,d=c[a];(c[a]!=b||"mode"==a)&&(c[a]=b,bg.hasOwnProperty(a)&&Fb(this,bg[a])(this,b,d))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](Vc(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;cc&&(Oc(this,e.head.line,a,!0),c=e.head.line,d==this.doc.sel.primIndex&&Mc(this));else{var f=e.from(),g=e.to(),h=Math.max(c,f.line);c=Math.min(this.lastLine(),g.line-(g.ch?0:1))+1;for(var i=h;c>i;++i)Oc(this,i,a);var j=this.doc.sel.ranges;0==f.ch&&b.length==j.length&&j[d].from().ch>0&&wa(this.doc,d,new la(f,j[d].to()),Lg)}}}),getTokenAt:function(a,b){return Gd(this,a,b)},getLineTokens:function(a,b){return Gd(this,Mf(a),b,!0)},getTokenTypeAt:function(a){a=pa(this.doc,a);var b,c=Jd(this,Zd(this.doc,a.line)),d=0,e=(c.length-1)/2,f=a.ch;if(0==f)b=c[2];else for(;;){var g=d+e>>1;if((g?c[2*g-1]:0)>=f)e=g;else{if(!(c[2*g+1]h?b:0==h?null:b.slice(0,h-1)},getModeAt:function(b){var c=this.doc.mode;return c.innerMode?a.innerMode(c,this.getTokenAt(b).state).mode:c},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var c=[];if(!hg.hasOwnProperty(b))return c;var d=hg[b],e=this.getModeAt(a);if("string"==typeof e[b])d[e[b]]&&c.push(d[e[b]]);else if(e[b])for(var f=0;fe&&(a=e,d=!0),c=Zd(this.doc,a)}else c=a;return lb(this,c,{top:0,left:0},b||"page").top+(d?this.doc.height-de(c):0)},defaultTextHeight:function(){return tb(this.display)},defaultCharWidth:function(){return ub(this.display)},setGutterMarker:Gb(function(a,b,c){return Pc(this.doc,a,"gutter",function(a){var d=a.gutterMarkers||(a.gutterMarkers={});return d[b]=c,!c&&Oe(d)&&(a.gutterMarkers=null),!0})}),clearGutter:Gb(function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,Lb(b,d,"gutter"),Oe(c.gutterMarkers)&&(c.gutterMarkers=null)),++d})}),lineInfo:function(a){if("number"==typeof a){if(!ra(this.doc,a))return null;var b=a;if(a=Zd(this.doc,a),!a)return null}else{var b=be(a);if(null==b)return null}return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=ob(this,pa(this.doc,a));var g=a.bottom,h=a.left;if(b.style.position="absolute",b.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(b),f.sizer.appendChild(b),"over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&Jc(this,h,g,h+b.offsetWidth,g+b.offsetHeight)},triggerOnKeyDown:Gb(mc),triggerOnKeyPress:Gb(pc),triggerOnKeyUp:oc,execCommand:function(a){return kg.hasOwnProperty(a)?kg[a].call(null,this):void 0},triggerElectric:Gb(function(a){_(this,a)}),findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,g=pa(this.doc,a);b>f&&(g=Rc(this.doc,g,e,c,d),!g.hitSide);++f);return g},moveH:Gb(function(a,b){var c=this;c.extendSelectionsBy(function(d){return c.display.shift||c.doc.extend||d.empty()?Rc(c.doc,d.head,a,b,c.options.rtlMoveVisually):0>a?d.from():d.to()},Ng)}),deleteH:Gb(function(a,b){var c=this.doc.sel,d=this.doc;c.somethingSelected()?d.replaceSelection("",null,"+delete"):Qc(this,function(c){var e=Rc(d,c.head,a,b,!1);return 0>a?{from:e,to:c.head}:{from:c.head,to:e}})}),findPosV:function(a,b,c,d){var e=1,f=d;0>b&&(e=-1,b=-b);for(var g=0,h=pa(this.doc,a);b>g;++g){var i=ob(this,h,"div");if(null==f?f=i.left:i.left=f,h=Sc(this,i,e,c),h.hitSide)break}return h},moveV:Gb(function(a,b){var c=this,d=this.doc,e=[],f=!c.display.shift&&!d.extend&&d.sel.somethingSelected();if(d.extendSelectionsBy(function(g){if(f)return 0>a?g.from():g.to();var h=ob(c,g.head,"div");null!=g.goalColumn&&(h.left=g.goalColumn),e.push(h.left);var i=Sc(c,h,a,b);return"page"==b&&g==d.sel.primary()&&Lc(c,null,nb(c,i,"div").top-h.top),i},Ng),e.length)for(var g=0;g0&&h(c.charAt(d-1));)--d;for(;e.5)&&g(this),Hg(this,"refresh",this)}),swapDoc:Gb(function(a){var b=this.doc;return b.cm=null,Yd(this,a),ib(this),this.display.input.reset(),this.scrollTo(a.scrollLeft,a.scrollTop),this.curOp.forceScroll=!0,ye(this,"swapDoc",this,b),b}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},De(a);var ag=a.defaults={},bg=a.optionHandlers={},cg=a.Init={toString:function(){return"CodeMirror.Init"}};Tc("value","",function(a,b){a.setValue(b)},!0),Tc("mode",null,function(a,b){a.doc.modeOption=b,c(a)},!0),Tc("indentUnit",2,c,!0),Tc("indentWithTabs",!1),Tc("smartIndent",!0),Tc("tabSize",4,function(a){d(a),ib(a),Kb(a)},!0),Tc("lineSeparator",null,function(a,b){if(a.doc.lineSep=b,b){var c=[],d=a.doc.first;a.doc.iter(function(a){for(var e=0;;){var f=a.text.indexOf(b,e);if(-1==f)break;e=f+b.length,c.push(Mf(d,f))}d++});for(var e=c.length-1;e>=0;e--)Gc(a.doc,b,c[e],Mf(c[e].line,c[e].ch+b.length))}}),Tc("specialChars",/[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(b,c,d){b.state.specialChars=new RegExp(c.source+(c.test(" ")?"":"| "),"g"),d!=a.Init&&b.refresh()}),Tc("specialCharPlaceholder",Nd,function(a){a.refresh()},!0),Tc("electricChars",!0),Tc("inputStyle",Df?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Tc("rtlMoveVisually",!Gf),Tc("wholeLineUpdateBefore",!0),Tc("theme","default",function(a){h(a),i(a)},!0),Tc("keyMap","default",function(b,c,d){var e=Vc(c),f=d!=a.Init&&Vc(d);f&&f.detach&&f.detach(b,e),e.attach&&e.attach(b,f||null)}),Tc("extraKeys",null),Tc("lineWrapping",!1,e,!0),Tc("gutters",[],function(a){n(a.options),i(a)},!0),Tc("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?y(a.display)+"px":"0",a.refresh()},!0),Tc("coverGutterNextToScrollbar",!1,function(a){s(a)},!0),Tc("scrollbarStyle","native",function(a){r(a),s(a),a.display.scrollbars.setScrollTop(a.doc.scrollTop),a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0),Tc("lineNumbers",!1,function(a){n(a.options),i(a)},!0),Tc("firstLineNumber",1,i,!0),Tc("lineNumberFormatter",function(a){return a},i,!0),Tc("showCursorWhenSelecting",!1,Ia,!0),Tc("resetSelectionOnContextMenu",!0),Tc("lineWiseCopyCut",!0),Tc("readOnly",!1,function(a,b){"nocursor"==b?(sc(a),a.display.input.blur(),a.display.disabled=!0):a.display.disabled=!1,a.display.input.readOnlyChanged(b)}),Tc("disableInput",!1,function(a,b){b||a.display.input.reset()},!0),Tc("dragDrop",!0,Sb),Tc("allowDropFileTypes",null),Tc("cursorBlinkRate",530),Tc("cursorScrollMargin",0),Tc("cursorHeight",1,Ia,!0),Tc("singleCursorHeightPerLine",!0,Ia,!0),Tc("workTime",100),Tc("workDelay",100),Tc("flattenSpans",!0,d,!0),Tc("addModeClass",!1,d,!0),Tc("pollInterval",100),Tc("undoDepth",200,function(a,b){a.doc.history.undoDepth=b}),Tc("historyEventDelay",1250),Tc("viewportMargin",10,function(a){a.refresh()},!0),Tc("maxHighlightLength",1e4,d,!0),Tc("moveInputWithCursor",!0,function(a,b){b||a.display.input.resetPosition()}),Tc("tabindex",null,function(a,b){a.display.input.getField().tabIndex=b||""}),Tc("autofocus",null);var dg=a.modes={},eg=a.mimeModes={};a.defineMode=function(b,c){a.defaults.mode||"null"==b||(a.defaults.mode=b),arguments.length>2&&(c.dependencies=Array.prototype.slice.call(arguments,2)),dg[b]=c},a.defineMIME=function(a,b){eg[a]=b},a.resolveMode=function(b){if("string"==typeof b&&eg.hasOwnProperty(b))b=eg[b];else if(b&&"string"==typeof b.name&&eg.hasOwnProperty(b.name)){var c=eg[b.name];"string"==typeof c&&(c={name:c}),b=Ke(c,b),b.name=c.name}else if("string"==typeof b&&/^[\w\-]+\/[\w\-]+\+xml$/.test(b))return a.resolveMode("application/xml");return"string"==typeof b?{name:b}:b||{name:"null"}},a.getMode=function(b,c){var c=a.resolveMode(c),d=dg[c.name];if(!d)return a.getMode(b,"text/plain");var e=d(b,c);if(fg.hasOwnProperty(c.name)){var f=fg[c.name];for(var g in f)f.hasOwnProperty(g)&&(e.hasOwnProperty(g)&&(e["_"+g]=e[g]),e[g]=f[g])}if(e.name=c.name,c.helperType&&(e.helperType=c.helperType),c.modeProps)for(var g in c.modeProps)e[g]=c.modeProps[g];return e},a.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),a.defineMIME("text/plain","null");var fg=a.modeExtensions={};a.extendMode=function(a,b){var c=fg.hasOwnProperty(a)?fg[a]:fg[a]={};Le(b,c)},a.defineExtension=function(b,c){a.prototype[b]=c},a.defineDocExtension=function(a,b){yg.prototype[a]=b},a.defineOption=Tc;var gg=[];a.defineInitHook=function(a){gg.push(a)};var hg=a.helpers={};a.registerHelper=function(b,c,d){hg.hasOwnProperty(b)||(hg[b]=a[b]={_global:[]}),hg[b][c]=d},a.registerGlobalHelper=function(b,c,d,e){a.registerHelper(b,c,e),hg[b]._global.push({pred:d,val:e})};var ig=a.copyState=function(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c},jg=a.startState=function(a,b,c){return a.startState?a.startState(b,c):!0};a.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);if(!c||c.mode==a)break;b=c.state,a=c.mode}return c||{mode:a,state:b}};var kg=a.commands={selectAll:function(a){a.setSelection(Mf(a.firstLine(),0),Mf(a.lastLine()),Lg)},singleSelection:function(a){a.setSelection(a.getCursor("anchor"),a.getCursor("head"),Lg)},killLine:function(a){Qc(a,function(b){if(b.empty()){var c=Zd(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.line0)e=new Mf(e.line,e.ch+1),a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),Mf(e.line,e.ch-2),e,"+transpose");else if(e.line>a.doc.first){var g=Zd(a.doc,e.line-1).text;g&&a.replaceRange(f.charAt(0)+a.doc.lineSeparator()+g.charAt(g.length-1),Mf(e.line-1,g.length-1),Mf(e.line,1),"+transpose"); -}c.push(new la(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){Eb(a,function(){for(var b=a.listSelections().length,c=0;b>c;c++){var d=a.listSelections()[c];a.replaceRange(a.doc.lineSeparator(),d.anchor,d.head,"+input"),a.indentLine(d.from().line+1,null,!0)}Mc(a)})},openLine:function(a){a.replaceSelection("\n","start")},toggleOverwrite:function(a){a.toggleOverwrite()}},lg=a.keyMap={};lg.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},lg.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},lg.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},lg.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},lg["default"]=Ef?lg.macDefault:lg.pcDefault,a.normalizeKeyMap=function(a){var b={};for(var c in a)if(a.hasOwnProperty(c)){var d=a[c];if(/^(name|fallthrough|(de|at)tach)$/.test(c))continue;if("..."==d){delete a[c];continue}for(var e=Ie(c.split(" "),Uc),f=0;f=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.posb},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);return b>-1?(this.pos=b,!0):void 0},backUp:function(a){this.pos-=a},column:function(){return this.lastColumnPos0?null:(d&&b!==!1&&(this.pos+=d[0].length),d)}var e=function(a){return c?a.toLowerCase():a},f=this.string.substr(this.pos,a.length);return e(f)==e(a)?(b!==!1&&(this.pos+=a.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}}};var qg=0,rg=a.TextMarker=function(a,b){this.lines=[],this.type=b,this.doc=a,this.id=++qg};De(rg),rg.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;if(b&&vb(a),Ce(this,"clear")){var c=this.find();c&&ye(this,"clear",c.from,c.to)}for(var d=null,e=null,f=0;fa.display.maxLineLength&&(a.display.maxLine=i,a.display.maxLineLength=j,a.display.maxLineChanged=!0)}null!=d&&a&&this.collapsed&&Kb(a,d,e+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&Da(a.doc)),a&&ye(a,"markerCleared",a,this),b&&xb(a),this.parent&&this.parent.clear()}},rg.prototype.find=function(a,b){null==a&&"bookmark"==this.type&&(a=1);for(var c,d,e=0;ec;++c){var e=this.lines[c];this.height-=e.height,Cd(e),ye(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.push.apply(a,this.lines)},insertInner:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0;da;++a)if(c(this.lines[a]))return!0}},Wd.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;ca){var f=Math.min(b,e-a),g=d.height;if(d.removeInner(a,f),this.height-=g-d.height,e==f&&(this.children.splice(c--,1),d.parent=null),0==(b-=f))break;a=0}else a-=e}if(this.size-b<25&&(this.children.length>1||!(this.children[0]instanceof Vd))){var h=[];this.collapse(h),this.children=[new Vd(h)],this.children[0].parent=this}},collapse:function(a){for(var b=0;b=a){if(e.insertInner(a,b,c),e.lines&&e.lines.length>50){for(var g=e.lines.length%25+25,h=g;h10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0;da){var g=Math.min(b,f-a);if(e.iterN(a,g,c))return!0;if(0==(b-=g))break;a=0}else a-=f}}};var xg=0,yg=a.Doc=function(a,b,c,d){if(!(this instanceof yg))return new yg(a,b,c,d);null==c&&(c=0),Wd.call(this,[new Vd([new ug("",null)])]),this.first=c,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=c;var e=Mf(c,0);this.sel=na(e),this.history=new fe(null),this.id=++xg,this.modeOption=b,this.lineSep=d,this.extend=!1,"string"==typeof a&&(a=this.splitLines(a)),Ud(this,{from:e,to:e,text:a}),Aa(this,na(e),Lg)};yg.prototype=Ke(Wd.prototype,{constructor:yg,iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0;d=0;f--)Ac(this,d[f]);h?za(this,h):this.cm&&Mc(this.cm)}),undo:Hb(function(){Cc(this,"undo")}),redo:Hb(function(){Cc(this,"redo")}),undoSelection:Hb(function(){Cc(this,"undo",!0)}),redoSelection:Hb(function(){Cc(this,"redo",!0)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d=a.ch)&&b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){a=pa(this,a),b=pa(this,b);var d=[],e=a.line;return this.iter(a.line,b.line+1,function(f){var g=f.markedSpans;if(g)for(var h=0;h=i.to||null==i.from&&e!=a.line||null!=i.from&&e==b.line&&i.from>=b.ch||c&&!c(i.marker)||d.push(i.marker.parent||i.marker)}++e}),d},getAllMarks:function(){var a=[];return this.iter(function(b){var c=b.markedSpans;if(c)for(var d=0;da?(b=a,!0):(a-=f,void++c)}),pa(this,Mf(c,b))},indexFromPos:function(a){a=pa(this,a);var b=a.ch;if(a.lineb&&(b=a.from),null!=a.to&&a.toh||h>=b)return g+(b-f);g+=h-f,g+=c-g%c,f=h+1}},Pg=a.findColumn=function(a,b,c){for(var d=0,e=0;;){var f=a.indexOf(" ",d);-1==f&&(f=a.length);var g=f-d;if(f==a.length||e+g>=b)return d+Math.min(g,b-e);if(e+=f-d,e+=c-e%c,d=f+1,e>=b)return d}},Qg=[""],Rg=function(a){a.select()};Cf?Rg=function(a){a.selectionStart=0,a.selectionEnd=a.value.length}:tf&&(Rg=function(a){try{a.select()}catch(b){}});var Sg,Tg=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ug=a.isWordChar=function(a){return/\w/.test(a)||a>"€"&&(a.toUpperCase()!=a.toLowerCase()||Tg.test(a))},Vg=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;Sg=document.createRange?function(a,b,c,d){var e=document.createRange();return e.setEnd(d||a,c),e.setStart(a,b),e}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(e){return d}return d.collapse(!0),d.moveEnd("character",c),d.moveStart("character",b),d};var Wg=a.contains=function(a,b){if(3==b.nodeType&&(b=b.parentNode),a.contains)return a.contains(b);do if(11==b.nodeType&&(b=b.host),b==a)return!0;while(b=b.parentNode)};tf&&11>uf&&(Te=function(){try{return document.activeElement}catch(a){return document.body}});var Xg,Yg,Zg=a.rmClass=function(a,b){var c=a.className,d=Ue(b).exec(c);if(d){var e=c.slice(d.index+d[0].length);a.className=c.slice(0,d.index)+(e?d[1]+e:"")}},$g=a.addClass=function(a,b){var c=a.className;Ue(b).test(c)||(a.className+=(c?" ":"")+b)},_g=!1,ah=function(){if(tf&&9>uf)return!1;var a=Qe("div");return"draggable"in a||"dragDrop"in a}(),bh=a.splitLines=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;d>=b;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)},ch=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},dh=function(){var a=Qe("div");return"oncopy"in a?!0:(a.setAttribute("oncopy","return;"),"function"==typeof a.oncopy)}(),eh=null,fh=a.keyNames={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:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var a=0;10>a;a++)fh[a+48]=fh[a+96]=String(a);for(var a=65;90>=a;a++)fh[a]=String.fromCharCode(a);for(var a=1;12>=a;a++)fh[a+111]=fh[a+63235]="F"+a}();var gh,hh=function(){function a(a){return 247>=a?c.charAt(a):a>=1424&&1524>=a?"R":a>=1536&&1773>=a?d.charAt(a-1536):a>=1774&&2220>=a?"r":a>=8192&&8203>=a?"w":8204==a?"b":"L"}function b(a,b,c){this.level=a,this.from=b,this.to=c}var c="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",d="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,f=/[stwN]/,g=/[LRr]/,h=/[Lb1n]/,i=/[1n]/,j="L";return function(c){if(!e.test(c))return!1;for(var d,k=c.length,l=[],m=0;k>m;++m)l.push(d=a(c.charCodeAt(m)));for(var m=0,n=j;k>m;++m){var d=l[m];"m"==d?l[m]=n:n=d}for(var m=0,o=j;k>m;++m){var d=l[m];"1"==d&&"r"==o?l[m]="n":g.test(d)&&(o=d,"r"==d&&(l[m]="R"))}for(var m=1,n=l[0];k-1>m;++m){var d=l[m];"+"==d&&"1"==n&&"1"==l[m+1]?l[m]="1":","!=d||n!=l[m+1]||"1"!=n&&"n"!=n||(l[m]=n),n=d}for(var m=0;k>m;++m){var d=l[m];if(","==d)l[m]="N";else if("%"==d){for(var p=m+1;k>p&&"%"==l[p];++p);for(var q=m&&"!"==l[m-1]||k>p&&"1"==l[p]?"1":"N",r=m;p>r;++r)l[r]=q;m=p-1}}for(var m=0,o=j;k>m;++m){var d=l[m];"L"==o&&"1"==d?l[m]="L":g.test(d)&&(o=d)}for(var m=0;k>m;++m)if(f.test(l[m])){for(var p=m+1;k>p&&f.test(l[p]);++p);for(var s="L"==(m?l[m-1]:j),t="L"==(k>p?l[p]:j),q=s||t?"L":"R",r=m;p>r;++r)l[r]=q;m=p-1}for(var u,v=[],m=0;k>m;)if(h.test(l[m])){var w=m;for(++m;k>m&&h.test(l[m]);++m);v.push(new b(0,w,m))}else{var x=m,y=v.length;for(++m;k>m&&"L"!=l[m];++m);for(var r=x;m>r;)if(i.test(l[r])){r>x&&v.splice(y,0,new b(1,x,r));var z=r;for(++r;m>r&&i.test(l[r]);++r);v.splice(y,0,new b(2,z,r)),x=r}else++r;m>x&&v.splice(y,0,new b(1,x,m))}return 1==v[0].level&&(u=c.match(/^\s+/))&&(v[0].from=u[0].length,v.unshift(new b(0,0,u[0].length))),1==Ge(v).level&&(u=c.match(/\s+$/))&&(Ge(v).to-=u[0].length,v.push(new b(0,k-u[0].length,k))),2==v[0].level&&v.unshift(new b(1,v[0].to,v[0].to)),v[0].level!=Ge(v).level&&v.push(new b(v[0].level,k,k)),v}}();return a.version="5.17.0",a}); \ No newline at end of file +!function(a){if("object"==typeof exports&&"object"==typeof module)module.exports=a();else{if("function"==typeof define&&define.amd)return define([],a);(this||window).CodeMirror=a()}}(function(){"use strict";function a(c,d){if(!(this instanceof a))return new a(c,d);this.options=d=d?Me(d):{},Me(bg,d,!1),n(d);var e=d.value;"string"==typeof e&&(e=new zg(e,d.mode,null,d.lineSeparator)),this.doc=e;var f=new a.inputStyles[d.inputStyle](this),g=this.display=new b(c,e,f);g.wrapper.CodeMirror=this,j(this),h(this),d.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),d.autofocus&&!Ef&&g.input.focus(),r(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Ee,keySeq:null,specialChars:null};var i=this;uf&&11>vf&&setTimeout(function(){i.display.input.reset(!0)},20),Rb(this),Ye(),vb(this),this.curOp.forceUpdate=!0,Yd(this,e),d.autofocus&&!Ef||i.hasFocus()?setTimeout(Ne(rc,this),20):sc(this);for(var k in cg)cg.hasOwnProperty(k)&&cg[k](this,d[k],dg);w(this),d.finishInit&&d.finishInit(this);for(var l=0;lvf&&(d.gutters.style.zIndex=-1,d.scroller.style.paddingRight=0),wf||rf&&Ef||(d.scroller.draggable=!0),a&&(a.appendChild?a.appendChild(d.wrapper):a(d.wrapper)),d.viewFrom=d.viewTo=b.first,d.reportedViewFrom=d.reportedViewTo=b.first,d.view=[],d.renderedView=null,d.externalMeasured=null,d.viewOffset=0,d.lastWrapHeight=d.lastWrapWidth=0,d.updateLineNumbers=null,d.nativeBarWidth=d.barHeight=d.barWidth=0,d.scrollbarsClipped=!1,d.lineNumWidth=d.lineNumInnerWidth=d.lineNumChars=null,d.alignWidgets=!1,d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null,d.maxLine=null,d.maxLineLength=0,d.maxLineChanged=!1,d.wheelDX=d.wheelDY=d.wheelStartX=d.wheelStartY=null,d.shift=!1,d.selForContextMenu=null,d.activeTouch=null,c.init(d)}function c(b){b.doc.mode=a.getMode(b.options,b.doc.modeOption),d(b)}function d(a){a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null)}),a.doc.frontier=a.doc.first,Na(a,100),a.state.modeGen++,a.curOp&&Kb(a)}function e(a){a.options.lineWrapping?(_g(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):($g(a.display.wrapper,"CodeMirror-wrap"),m(a)),g(a),Kb(a),ib(a),setTimeout(function(){s(a)},100)}function f(a){var b=tb(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/ub(a.display)-3);return function(e){if(wd(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;gb.maxLineLength&&(b.maxLineLength=c,b.maxLine=a)})}function n(a){var b=He(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):b>-1&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function o(a){var b=a.display,c=b.gutters.offsetWidth,d=Math.round(a.doc.height+Sa(a.display));return{clientHeight:b.scroller.clientHeight,viewHeight:b.wrapper.clientHeight,scrollWidth:b.scroller.scrollWidth,clientWidth:b.scroller.clientWidth,viewWidth:b.wrapper.clientWidth,barLeft:a.options.fixedGutter?c:0,docHeight:d,scrollHeight:d+Ua(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}function p(a,b,c){this.cm=c;var d=this.vert=Re("div",[Re("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),e=this.horiz=Re("div",[Re("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");a(d),a(e),Fg(d,"scroll",function(){d.clientHeight&&b(d.scrollTop,"vertical")}),Fg(e,"scroll",function(){e.clientWidth&&b(e.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,uf&&8>vf&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function q(){}function r(b){b.display.scrollbars&&(b.display.scrollbars.clear(),b.display.scrollbars.addClass&&$g(b.display.wrapper,b.display.scrollbars.addClass)),b.display.scrollbars=new a.scrollbarModel[b.options.scrollbarStyle](function(a){b.display.wrapper.insertBefore(a,b.display.scrollbarFiller),Fg(a,"mousedown",function(){b.state.focused&&setTimeout(function(){b.display.input.focus()},0)}),a.setAttribute("cm-not-content","true")},function(a,c){"horizontal"==c?fc(b,a):ec(b,a)},b),b.display.scrollbars.addClass&&_g(b.display.wrapper,b.display.scrollbars.addClass)}function s(a,b){b||(b=o(a));var c=a.display.barWidth,d=a.display.barHeight;t(a,b);for(var e=0;4>e&&c!=a.display.barWidth||d!=a.display.barHeight;e++)c!=a.display.barWidth&&a.options.lineWrapping&&F(a),t(a,o(a)),c=a.display.barWidth,d=a.display.barHeight}function t(a,b){var c=a.display,d=c.scrollbars.update(b);c.sizer.style.paddingRight=(c.barWidth=d.right)+"px",c.sizer.style.paddingBottom=(c.barHeight=d.bottom)+"px",c.heightForcer.style.borderBottom=d.bottom+"px solid transparent",d.right&&d.bottom?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=d.bottom+"px",c.scrollbarFiller.style.width=d.right+"px"):c.scrollbarFiller.style.display="",d.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d.bottom+"px",c.gutterFiller.style.width=b.gutterWidth+"px"):c.gutterFiller.style.display=""}function u(a,b,c){var d=c&&null!=c.top?Math.max(0,c.top):a.scroller.scrollTop;d=Math.floor(d-Ra(a));var e=c&&null!=c.bottom?c.bottom:d+a.wrapper.clientHeight,f=ce(b,d),g=ce(b,e);if(c&&c.ensure){var h=c.ensure.from.line,i=c.ensure.to.line;f>h?(f=h,g=ce(b,de(Zd(b,h))+a.wrapper.clientHeight)):Math.min(i,b.lastLine())>=g&&(f=ce(b,de(Zd(b,i))-a.wrapper.clientHeight),g=i)}return{from:f,to:Math.max(g,f+1)}}function v(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=y(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g=c.viewFrom&&b.visible.to<=c.viewTo&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo)&&c.renderedView==c.view&&0==Qb(a))return!1;w(a)&&(Mb(a),b.dims=H(a));var e=d.first+d.size,f=Math.max(b.visible.from-a.options.viewportMargin,d.first),g=Math.min(e,b.visible.to+a.options.viewportMargin);c.viewFromg&&c.viewTo-g<20&&(g=Math.min(e,c.viewTo)),Mf&&(f=ud(a.doc,f),g=vd(a.doc,g));var h=f!=c.viewFrom||g!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;Pb(a,f,g),c.viewOffset=de(Zd(a.doc,c.viewFrom)),a.display.mover.style.top=c.viewOffset+"px";var i=Qb(a);if(!h&&0==i&&!b.force&&c.renderedView==c.view&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;var j=Ue();return i>4&&(c.lineDiv.style.display="none"),I(a,c.updateLineNumbers,b.dims),i>4&&(c.lineDiv.style.display=""),c.renderedView=c.view,j&&Ue()!=j&&j.offsetHeight&&j.focus(),Se(c.cursorDiv),Se(c.selectionDiv),c.gutters.style.height=c.sizer.style.minHeight=0,h&&(c.lastWrapHeight=b.wrapperHeight,c.lastWrapWidth=b.wrapperWidth,Na(a,400)),c.updateLineNumbers=null,!0}function C(a,b){for(var c=b.viewport,d=!0;(d&&a.options.lineWrapping&&b.oldDisplayWidth!=Va(a)||(c&&null!=c.top&&(c={top:Math.min(a.doc.height+Sa(a.display)-Wa(a),c.top)}),b.visible=u(a.display,a.doc,c),!(b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo)))&&B(a,b);d=!1){F(a);var e=o(a);Ia(a),s(a,e),E(a,e)}b.signal(a,"update",a),(a.display.viewFrom!=a.display.reportedViewFrom||a.display.viewTo!=a.display.reportedViewTo)&&(b.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo)}function D(a,b){var c=new z(a,b);if(B(a,c)){F(a),C(a,c);var d=o(a);Ia(a),s(a,d),E(a,d),c.finish()}}function E(a,b){a.display.sizer.style.minHeight=b.docHeight+"px",a.display.heightForcer.style.top=b.docHeight+"px",a.display.gutters.style.height=b.docHeight+a.display.barHeight+Ua(a)+"px"}function F(a){for(var b=a.display,c=b.lineDiv.offsetTop,d=0;dvf){var g=f.node.offsetTop+f.node.offsetHeight;e=g-c,c=g}else{var h=f.node.getBoundingClientRect();e=h.bottom-h.top}var i=f.line.height-e;if(2>e&&(e=tb(b)),(i>.001||-.001>i)&&(ae(f.line,e),G(f.line),f.rest))for(var j=0;j=b&&l.lineNumber;l.changes&&(He(l.changes,"gutter")>-1&&(m=!1),J(a,l,j,c)),m&&(Se(l.lineNumber),l.lineNumber.appendChild(document.createTextNode(x(a.options,j)))),h=l.node.nextSibling}else{var n=R(a,l,j,c);g.insertBefore(n,h)}j+=l.size}for(;h;)h=d(h)}function J(a,b,c,d){for(var e=0;evf&&(a.node.style.zIndex=2)),a.node}function L(a){var b=a.bgClass?a.bgClass+" "+(a.line.bgClass||""):a.line.bgClass;if(b&&(b+=" CodeMirror-linebackground"),a.background)b?a.background.className=b:(a.background.parentNode.removeChild(a.background),a.background=null);else if(b){var c=K(a);a.background=c.insertBefore(Re("div",null,b),c.firstChild)}}function M(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):Md(a,b)}function N(a,b){var c=b.text.className,d=M(a,b);b.text==b.node&&(b.node=d.pre),b.text.parentNode.replaceChild(d.pre,b.text),b.text=d.pre,d.bgClass!=b.bgClass||d.textClass!=b.textClass?(b.bgClass=d.bgClass,b.textClass=d.textClass,O(b)):c&&(b.text.className=c)}function O(a){L(a),a.line.wrapClass?K(a).className=a.line.wrapClass:a.node!=a.text&&(a.node.className="");var b=a.textClass?a.textClass+" "+(a.line.textClass||""):a.line.textClass;a.text.className=b||""}function P(a,b,c,d){if(b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null),b.gutterBackground&&(b.node.removeChild(b.gutterBackground),b.gutterBackground=null),b.line.gutterClass){var e=K(b);b.gutterBackground=Re("div",null,"CodeMirror-gutter-background "+b.line.gutterClass,"left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px; width: "+d.gutterTotalWidth+"px"),e.insertBefore(b.gutterBackground,b.text)}var f=b.line.gutterMarkers;if(a.options.lineNumbers||f){var e=K(b),g=b.gutter=Re("div",null,"CodeMirror-gutter-wrapper","left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px");if(a.display.input.setUneditable(g),e.insertBefore(g,b.text),b.line.gutterClass&&(g.className+=" "+b.line.gutterClass),!a.options.lineNumbers||f&&f["CodeMirror-linenumbers"]||(b.lineNumber=g.appendChild(Re("div",x(a.options,c),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+d.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+a.display.lineNumInnerWidth+"px"))),f)for(var h=0;h1)if(Pf&&Pf.text.join("\n")==b){if(d.ranges.length%Pf.text.length==0){i=[];for(var j=0;j=0;j--){var k=d.ranges[j],l=k.from(),m=k.to();k.empty()&&(c&&c>0?l=Nf(l.line,l.ch-c):a.state.overwrite&&!g?m=Nf(m.line,Math.min(Zd(f,m.line).text.length,m.ch+Ge(h).length)):Pf&&Pf.lineWise&&Pf.text.join("\n")==b&&(l=m=Nf(l.line,0)));var n=a.curOp.updateInput,o={from:l,to:m,text:i?i[j%i.length]:h,origin:e||(g?"paste":a.state.cutIncoming?"cut":"+input")};Ac(a.doc,o),ye(a,"inputRead",a,o)}b&&!g&&_(a,b),Mc(a),a.curOp.updateInput=n,a.curOp.typing=!0,a.state.pasteIncoming=a.state.cutIncoming=!1}function $(a,b){var c=a.clipboardData&&a.clipboardData.getData("Text");return c?(a.preventDefault(),b.isReadOnly()||b.options.disableInput||Eb(b,function(){Z(b,c,0,null,"paste")}),!0):void 0}function _(a,b){if(a.options.electricChars&&a.options.smartIndent)for(var c=a.doc.sel,d=c.ranges.length-1;d>=0;d--){var e=c.ranges[d];if(!(e.head.ch>100||d&&c.ranges[d-1].head.line==e.head.line)){var f=a.getModeAt(e.head),g=!1;if(f.electricChars){for(var h=0;h-1){g=Oc(a,e.head.line,"smart");break}}else f.electricInput&&f.electricInput.test(Zd(a.doc,e.head.line).text.slice(0,e.head.ch))&&(g=Oc(a,e.head.line,"smart"));g&&ye(a,"electricInput",a,e.head.line)}}}function aa(a){for(var b=[],c=[],d=0;de?j.map:k[e],g=0;ge?a.line:a.rest[e]),l=f[g]+d;return(0>d||h!=b)&&(l=f[g+(d?1:0)]),Nf(i,l)}}}var e=a.text.firstChild,f=!1;if(!b||!Xg(e,b))return ga(Nf(be(a.line),0),!0);if(b==e&&(f=!0,b=e.childNodes[c],c=0,!b)){var g=a.rest?Ge(a.rest):a.line;return ga(Nf(be(g),g.text.length),f)}var h=3==b.nodeType?b:null,i=b;for(h||1!=b.childNodes.length||3!=b.firstChild.nodeType||(h=b.firstChild,c&&(c=h.nodeValue.length));i.parentNode!=e;)i=i.parentNode;var j=a.measure,k=j.maps,l=d(h,i,c);if(l)return ga(l,f);for(var m=i.nextSibling,n=h?h.nodeValue.length-c:0;m;m=m.nextSibling){if(l=d(m,m.firstChild,0))return ga(Nf(l.line,l.ch-n),f);n+=m.textContent.length}for(var o=i.previousSibling,n=c;o;o=o.previousSibling){if(l=d(o,o.firstChild,-1))return ga(Nf(l.line,l.ch+n),f);n+=o.textContent.length}}function ja(a,b,c,d,e){function f(a){return function(b){return b.id==a}}function g(b){if(1==b.nodeType){var c=b.getAttribute("cm-text");if(null!=c)return""==c&&(c=b.textContent.replace(/\u200b/g,"")),void(h+=c);var k,l=b.getAttribute("cm-marker");if(l){var m=a.findMarks(Nf(d,0),Nf(e+1,0),f(+l));return void(m.length&&(k=m[0].find())&&(h+=$d(a.doc,k.from,k.to).join(j)))}if("false"==b.getAttribute("contenteditable"))return;for(var n=0;n=0){var g=X(f.from(),e.from()),h=W(f.to(),e.to()),i=f.empty()?e.from()==e.head:f.from()==f.head;b>=d&&--b,a.splice(--d,2,new la(i?h:g,i?g:h))}}return new ka(a,b)}function na(a,b){return new ka([new la(a,b||a)],0)}function oa(a,b){return Math.max(a.first,Math.min(b,a.first+a.size-1))}function pa(a,b){if(b.linec?Nf(c,Zd(a,c).text.length):qa(b,Zd(a,b.line).text.length)}function qa(a,b){var c=a.ch;return null==c||c>b?Nf(a.line,b):0>c?Nf(a.line,0):a}function ra(a,b){return b>=a.first&&b=b.ch:h.to>b.ch))){if(e&&(Ig(i,"beforeCursorEnter"),i.explicitlyCleared)){if(f.markedSpans){--g;continue}break}if(!i.atomic)continue;if(c){var j,k=i.find(0>d?1:-1);if((0>d?i.inclusiveRight:i.inclusiveLeft)&&(k=Ha(a,k,-d,k&&k.line==b.line?f:null)),k&&k.line==b.line&&(j=Of(k,c))&&(0>d?0>j:j>0))return Fa(a,k,b,d,e)}var l=i.find(0>d?-1:1);return(0>d?i.inclusiveLeft:i.inclusiveRight)&&(l=Ha(a,l,d,l.line==b.line?f:null)),l?Fa(a,l,b,d,e):null}}return b}function Ga(a,b,c,d,e){var f=d||1,g=Fa(a,b,c,f,e)||!e&&Fa(a,b,c,f,!0)||Fa(a,b,c,-f,e)||!e&&Fa(a,b,c,-f,!0);return g?g:(a.cantEdit=!0,Nf(a.first,0))}function Ha(a,b,c,d){return 0>c&&0==b.ch?b.line>a.first?pa(a,Nf(b.line-1)):null:c>0&&b.ch==(d||Zd(a,b.line)).text.length?b.line=a.display.viewTo||h.to().lineb&&(b=0),b=Math.round(b),d=Math.round(d),h.appendChild(Re("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?k-a:c)+"px; height: "+(d-b)+"px"))}function e(b,c,e){function f(c,d){return nb(a,Nf(b,c),"div",l,d)}var h,i,l=Zd(g,b),m=l.text.length;return bf(ee(l),c||0,null==e?m:e,function(a,b,g){var l,n,o,p=f(a,"left");if(a==b)l=p,n=o=p.left;else{if(l=f(b-1,"right"),"rtl"==g){var q=p;p=l,l=q}n=p.left,o=l.right}null==c&&0==a&&(n=j),l.top-p.top>3&&(d(n,p.top,null,p.bottom),n=j,p.bottomi.bottom||l.bottom==i.bottom&&l.right>i.right)&&(i=l),j+1>n&&(n=j),d(n,l.top,o-n,l.bottom)}),{start:h,end:i}}var f=a.display,g=a.doc,h=document.createDocumentFragment(),i=Ta(a.display),j=i.left,k=Math.max(f.sizerWidth,Va(a)-f.sizer.offsetLeft)-i.right,l=b.from(),m=b.to();if(l.line==m.line)e(l.line,l.ch,m.ch);else{var n=Zd(g,l.line),o=Zd(g,m.line),p=sd(n)==sd(o),q=e(l.line,l.ch,p?n.text.length+1:null).end,r=e(m.line,p?0:null,m.ch).start;p&&(q.top0?b.blinker=setInterval(function(){b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate):a.options.cursorBlinkRate<0&&(b.cursorDiv.style.visibility="hidden")}}function Na(a,b){a.doc.mode.startState&&a.doc.frontier=a.display.viewTo)){var c=+new Date+a.options.workTime,d=jg(b.mode,Qa(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(b.frontier>=a.display.viewFrom){var g=f.styles,h=f.text.length>a.options.maxHighlightLength,i=Id(a,f,h?jg(b.mode,d):d,!0);f.styles=i.styles;var j=f.styleClasses,k=i.classes;k?f.styleClasses=k:j&&(f.styleClasses=null);for(var l=!g||g.length!=f.styles.length||j!=k&&(!j||!k||j.bgClass!=k.bgClass||j.textClass!=k.textClass),m=0;!l&&mc?(Na(a,a.options.workDelay),!0):void 0}),e.length&&Eb(a,function(){for(var b=0;bg;--h){if(h<=f.first)return f.first;var i=Zd(f,h-1);if(i.stateAfter&&(!c||h<=f.frontier))return h;var j=Pg(i.text,null,a.options.tabSize);(null==e||d>j)&&(e=h-1,d=j)}return e}function Qa(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0;var f=Pa(a,b,c),g=f>d.first&&Zd(d,f-1).stateAfter;return g=g?jg(d.mode,g):kg(d.mode),d.iter(f,b,function(c){Kd(a,c.text,g);var h=f==b-1||f%5==0||f>=e.viewFrom&&f2&&f.push((i.bottom+j.top)/2-c.top)}}f.push(c.bottom-c.top)}}function Ya(a,b,c){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};for(var d=0;dc)return{map:a.measure.maps[d],cache:a.measure.caches[d],before:!0}}function Za(a,b){b=sd(b);var c=be(b),d=a.display.externalMeasured=new Ib(a.doc,b,c);d.lineN=c;var e=d.built=Md(a,d);return d.text=e.pre,Te(a.display.lineMeasure,e.pre),d}function $a(a,b,c,d){return bb(a,ab(a,b),c,d)}function _a(a,b){if(b>=a.display.viewFrom&&b=c.lineN&&bb?(e=0,f=1,g="left"):j>b?(e=b-i,f=e+1):(h==a.length-3||b==j&&a[h+3]>b)&&(f=j-i,e=f-1,b>=j&&(g="right")),null!=e){if(d=a[h+2],i==j&&c==(d.insertLeft?"left":"right")&&(g=c),"left"==c&&0==e)for(;h&&a[h-2]==a[h-3]&&a[h-1].insertLeft;)d=a[(h-=3)+2],g="left";if("right"==c&&e==j-i)for(;h=0&&(c=a[d]).left==c.right;d--);return c}function eb(a,b,c,d){var e,f=cb(b.map,c,d),g=f.node,h=f.start,i=f.end,j=f.collapse;if(3==g.nodeType){for(var k=0;4>k;k++){for(;h&&Qe(b.line.text.charAt(f.coverStart+h));)--h;for(;f.coverStart+ivf&&0==h&&i==f.coverEnd-f.coverStart?g.parentNode.getBoundingClientRect():db(Tg(g,h,i).getClientRects(),d),e.left||e.right||0==h)break;i=h,h-=1,j="right"}uf&&11>vf&&(e=fb(a.display.measure,e))}else{h>0&&(j=d="right");var l;e=a.options.lineWrapping&&(l=g.getClientRects()).length>1?l["right"==d?l.length-1:0]:g.getBoundingClientRect()}if(uf&&9>vf&&!h&&(!e||!e.left&&!e.right)){var m=g.parentNode.getClientRects()[0];e=m?{left:m.left,right:m.left+ub(a.display),top:m.top,bottom:m.bottom}:Tf}for(var n=e.top-b.rect.top,o=e.bottom-b.rect.top,p=(n+o)/2,q=b.view.measure.heights,k=0;kc.from?g(a-1):g(a,d)}d=d||Zd(a.doc,b.line),e||(e=ab(a,d));var i=ee(d),j=b.ch;if(!i)return g(j);var k=lf(i,j),l=h(j,k);return null!=hh&&(l.other=h(j,hh)),l}function pb(a,b){var c=0,b=pa(a.doc,b);a.options.lineWrapping||(c=ub(a.display)*b.ch);var d=Zd(a.doc,b.line),e=de(d)+Ra(a.display);return{left:c,right:c,top:e,bottom:e+d.height}}function qb(a,b,c,d){var e=Nf(a,b);return e.xRel=d,c&&(e.outside=!0),e}function rb(a,b,c){var d=a.doc;if(c+=a.display.viewOffset,0>c)return qb(d.first,0,!0,-1);var e=ce(d,c),f=d.first+d.size-1;if(e>f)return qb(d.first+d.size-1,Zd(d,f).text.length,!0,1);0>b&&(b=0);for(var g=Zd(d,e);;){var h=sb(a,g,e,b,c),i=qd(g),j=i&&i.find(0,!0);if(!i||!(h.ch>j.from.ch||h.ch==j.from.ch&&h.xRel>0))return h;e=be(g=j.to.line)}}function sb(a,b,c,d,e){function f(d){var e=ob(a,Nf(c,d),"line",b,j);return h=!0,g>e.bottom?e.left-i:gq)return qb(c,n,r,1);for(;;){if(k?n==m||n==nf(b,m,1):1>=n-m){var s=o>d||q-d>=d-o?m:n,t=s==m?p:r,u=d-(s==m?o:q);if(r&&!k&&!/\s/.test(b.text.charAt(s))&&u>0&&s1){var v=bb(a,j,s,"right");g<=v.bottom&&g>=v.top&&Math.abs(d-v.right)u?-1:u>1?1:0);return w}var x=Math.ceil(l/2),y=m+x;if(k){y=m;for(var z=0;x>z;++z)y=nf(b,y,1)}var A=f(y);A>d?(n=y,q=A,(r=h)&&(q+=1e3),l=x):(m=y,o=A,p=h,l-=x)}}function tb(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==Qf){Qf=Re("pre");for(var b=0;49>b;++b)Qf.appendChild(document.createTextNode("x")),Qf.appendChild(Re("br"));Qf.appendChild(document.createTextNode("x"))}Te(a.measure,Qf);var c=Qf.offsetHeight/50;return c>3&&(a.cachedTextHeight=c),Se(a.measure),c||1}function ub(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=Re("span","xxxxxxxxxx"),c=Re("pre",[b]);Te(a.measure,c);var d=b.getBoundingClientRect(),e=(d.right-d.left)/10;return e>2&&(a.cachedCharWidth=e),e||10}function vb(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Vf},Uf?Uf.ops.push(a.curOp):a.curOp.ownsGroup=Uf={ops:[a.curOp],delayedCallbacks:[]}}function wb(a){var b=a.delayedCallbacks,c=0;do{for(;c=c.viewTo)||c.maxLineChanged&&b.options.lineWrapping,a.update=a.mustUpdate&&new z(b,a.mustUpdate&&{top:a.scrollTop,ensure:a.scrollToPos},a.forceUpdate)}function Ab(a){a.updatedDisplay=a.mustUpdate&&B(a.cm,a.update)}function Bb(a){var b=a.cm,c=b.display;a.updatedDisplay&&F(b),a.barMeasure=o(b),c.maxLineChanged&&!b.options.lineWrapping&&(a.adjustWidthTo=$a(b,c.maxLine,c.maxLine.text.length).left+3,b.display.sizerWidth=a.adjustWidthTo,a.barMeasure.scrollWidth=Math.max(c.scroller.clientWidth,c.sizer.offsetLeft+a.adjustWidthTo+Ua(b)+b.display.barWidth),a.maxScrollLeft=Math.max(0,c.sizer.offsetLeft+a.adjustWidthTo-Va(b))),(a.updatedDisplay||a.selectionChanged)&&(a.preparedSelection=c.input.prepareSelection(a.focus))}function Cb(a){var b=a.cm;null!=a.adjustWidthTo&&(b.display.sizer.style.minWidth=a.adjustWidthTo+"px",a.maxScrollLeftf;f=d){var g=new Ib(a.doc,Zd(a.doc,f),f);d=f+g.size,e.push(g)}return e}function Kb(a,b,c,d){null==b&&(b=a.doc.first),null==c&&(c=a.doc.first+a.doc.size),d||(d=0);var e=a.display;if(d&&cb)&&(e.updateLineNumbers=b),a.curOp.viewChanged=!0,b>=e.viewTo)Mf&&ud(a.doc,b)e.viewFrom?Mb(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)Mb(a);else if(b<=e.viewFrom){var f=Ob(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):Mb(a)}else if(c>=e.viewTo){var f=Ob(a,b,b,-1);f?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):Mb(a)}else{var g=Ob(a,b,b,-1),h=Ob(a,c,c+d,1);g&&h?(e.view=e.view.slice(0,g.index).concat(Jb(a,g.lineN,h.lineN)).concat(e.view.slice(h.index)),e.viewTo+=d):Mb(a)}var i=e.externalMeasured;i&&(c=e.lineN&&b=d.viewTo)){var f=d.view[Nb(a,b)];if(null!=f.node){var g=f.changes||(f.changes=[]);-1==He(g,c)&&g.push(c)}}}function Mb(a){a.display.viewFrom=a.display.viewTo=a.doc.first,a.display.view=[],a.display.viewOffset=0}function Nb(a,b){if(b>=a.display.viewTo)return null;if(b-=a.display.viewFrom,0>b)return null;for(var c=a.display.view,d=0;db)return d}function Ob(a,b,c,d){var e,f=Nb(a,b),g=a.display.view;if(!Mf||c==a.doc.first+a.doc.size)return{index:f,lineN:c};for(var h=0,i=a.display.viewFrom;f>h;h++)i+=g[h].size;if(i!=b){if(d>0){if(f==g.length-1)return null;e=i+g[f].size-b,f++}else e=i-b;b+=e,c+=e}for(;ud(a.doc,c)!=c;){if(f==(0>d?0:g.length-1))return null;c+=d*g[f-(0>d?1:0)].size,f+=d}return{index:f,lineN:c}}function Pb(a,b,c){var d=a.display,e=d.view;0==e.length||b>=d.viewTo||c<=d.viewFrom?(d.view=Jb(a,b,c),d.viewFrom=b):(d.viewFrom>b?d.view=Jb(a,b,d.viewFrom).concat(d.view):d.viewFromc&&(d.view=d.view.slice(0,Nb(a,c)))),d.viewTo=c}function Qb(a){for(var b=a.display.view,c=0,d=0;d400}var e=a.display;Fg(e.scroller,"mousedown",Fb(a,Wb)),uf&&11>vf?Fg(e.scroller,"dblclick",Fb(a,function(b){if(!Ae(a,b)){var c=Vb(a,b);if(c&&!_b(a,b)&&!Ub(a.display,b)){Cg(b);var d=a.findWordAt(c);ua(a.doc,d.anchor,d.head)}}})):Fg(e.scroller,"dblclick",function(b){Ae(a,b)||Cg(b)}),Kf||Fg(e.scroller,"contextmenu",function(b){tc(a,b)});var f,g={end:0};Fg(e.scroller,"touchstart",function(b){if(!Ae(a,b)&&!c(b)){clearTimeout(f);var d=+new Date;e.activeTouch={start:d,moved:!1,prev:d-g.end<=300?g:null},1==b.touches.length&&(e.activeTouch.left=b.touches[0].pageX,e.activeTouch.top=b.touches[0].pageY)}}),Fg(e.scroller,"touchmove",function(){e.activeTouch&&(e.activeTouch.moved=!0)}),Fg(e.scroller,"touchend",function(c){var f=e.activeTouch;if(f&&!Ub(e,c)&&null!=f.left&&!f.moved&&new Date-f.start<300){var g,h=a.coordsChar(e.activeTouch,"page");g=!f.prev||d(f,f.prev)?new la(h,h):!f.prev.prev||d(f,f.prev.prev)?a.findWordAt(h):new la(Nf(h.line,0),pa(a.doc,Nf(h.line+1,0))),a.setSelection(g.anchor,g.head),a.focus(),Cg(c)}b()}),Fg(e.scroller,"touchcancel",b),Fg(e.scroller,"scroll",function(){e.scroller.clientHeight&&(ec(a,e.scroller.scrollTop),fc(a,e.scroller.scrollLeft,!0),Ig(a,"scroll",a))}),Fg(e.scroller,"mousewheel",function(b){gc(a,b)}),Fg(e.scroller,"DOMMouseScroll",function(b){gc(a,b)}),Fg(e.wrapper,"scroll",function(){e.wrapper.scrollTop=e.wrapper.scrollLeft=0}),e.dragFunctions={enter:function(b){Ae(a,b)||Eg(b)},over:function(b){Ae(a,b)||(cc(a,b),Eg(b))},start:function(b){bc(a,b)},drop:Fb(a,ac),leave:function(b){Ae(a,b)||dc(a)}};var h=e.input.getField();Fg(h,"keyup",function(b){oc.call(a,b)}),Fg(h,"keydown",Fb(a,mc)),Fg(h,"keypress",Fb(a,pc)),Fg(h,"focus",Ne(rc,a)),Fg(h,"blur",Ne(sc,a))}function Sb(b,c,d){var e=d&&d!=a.Init;if(!c!=!e){var f=b.display.dragFunctions,g=c?Fg:Hg;g(b.display.scroller,"dragstart",f.start),g(b.display.scroller,"dragenter",f.enter),g(b.display.scroller,"dragover",f.over),g(b.display.scroller,"dragleave",f.leave),g(b.display.scroller,"drop",f.drop)}}function Tb(a){var b=a.display;(b.lastWrapHeight!=b.wrapper.clientHeight||b.lastWrapWidth!=b.wrapper.clientWidth)&&(b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null,b.scrollbarsClipped=!1,a.setSize())}function Ub(a,b){for(var c=ve(b);c!=a.wrapper;c=c.parentNode)if(!c||1==c.nodeType&&"true"==c.getAttribute("cm-ignore-events")||c.parentNode==a.sizer&&c!=a.mover)return!0}function Vb(a,b,c,d){var e=a.display;if(!c&&"true"==ve(b).getAttribute("cm-not-content"))return null;var f,g,h=e.lineSpace.getBoundingClientRect();try{f=b.clientX-h.left,g=b.clientY-h.top}catch(b){return null}var i,j=rb(a,f,g);if(d&&1==j.xRel&&(i=Zd(a.doc,j.line).text).length==j.ch){var k=Pg(i,i.length,a.options.tabSize)-i.length;j=Nf(j.line,Math.max(0,Math.round((f-Ta(a.display).left)/ub(a.display))-k))}return j}function Wb(a){var b=this,c=b.display;if(!(Ae(b,a)||c.activeTouch&&c.input.supportsTouch())){if(c.shift=a.shiftKey,Ub(c,a))return void(wf||(c.scroller.draggable=!1,setTimeout(function(){c.scroller.draggable=!0},100)));if(!_b(b,a)){var d=Vb(b,a);switch(window.focus(),we(a)){case 1:b.state.selectingText?b.state.selectingText(a):d?Xb(b,a,d):ve(a)==c.scroller&&Cg(a);break;case 2:wf&&(b.state.lastMiddleDown=+new Date),d&&ua(b.doc,d),setTimeout(function(){c.input.focus()},20),Cg(a);break;case 3:Kf?tc(b,a):qc(b)}}}}function Xb(a,b,c){uf?setTimeout(Ne(Y,a),0):a.curOp.focus=Ue();var d,e=+new Date;Sf&&Sf.time>e-400&&0==Of(Sf.pos,c)?d="triple":Rf&&Rf.time>e-400&&0==Of(Rf.pos,c)?(d="double",Sf={time:e,pos:c}):(d="single",Rf={time:e,pos:c});var f,g=a.doc.sel,h=Ff?b.metaKey:b.ctrlKey;a.options.dragDrop&&bh&&!a.isReadOnly()&&"single"==d&&(f=g.contains(c))>-1&&(Of((f=g.ranges[f]).from(),c)<0||c.xRel>0)&&(Of(f.to(),c)>0||c.xRel<0)?Yb(a,b,c,h):Zb(a,b,c,d,h)}function Yb(a,b,c,d){var e=a.display,f=+new Date,g=Fb(a,function(h){wf&&(e.scroller.draggable=!1),a.state.draggingText=!1,Hg(document,"mouseup",g),Hg(e.scroller,"drop",g),Math.abs(b.clientX-h.clientX)+Math.abs(b.clientY-h.clientY)<10&&(Cg(h),!d&&+new Date-200=o;o++){var r=Zd(j,o).text,s=Qg(r,i,f);i==n?e.push(new la(Nf(o,s),Nf(o,s))):r.length>s&&e.push(new la(Nf(o,s),Nf(o,Qg(r,n,f))))}e.length||e.push(new la(c,c)),Aa(j,ma(m.ranges.slice(0,l).concat(e),l),{origin:"*mouse",scroll:!1}),a.scrollIntoView(b)}else{var t=k,u=t.anchor,v=b;if("single"!=d){if("double"==d)var w=a.findWordAt(b);else var w=new la(Nf(b.line,0),pa(j,Nf(b.line+1,0)));Of(w.anchor,u)>0?(v=w.head,u=X(t.from(),w.anchor)):(v=w.anchor,u=W(t.to(),w.head))}var e=m.ranges.slice(0);e[l]=new la(pa(j,u),v),Aa(j,ma(e,l),Ng)}}function g(b){var c=++s,e=Vb(a,b,!0,"rect"==d);if(e)if(0!=Of(e,q)){a.curOp.focus=Ue(),f(e);var h=u(i,j);(e.line>=h.to||e.liner.bottom?20:0;k&&setTimeout(Fb(a,function(){s==c&&(i.scroller.scrollTop+=k,g(b))}),50)}}function h(b){a.state.selectingText=!1,s=1/0,Cg(b),i.input.focus(),Hg(document,"mousemove",t),Hg(document,"mouseup",v),j.history.lastSelOrigin=null}var i=a.display,j=a.doc;Cg(b);var k,l,m=j.sel,n=m.ranges;if(e&&!b.shiftKey?(l=j.sel.contains(c),k=l>-1?n[l]:new la(c,c)):(k=j.sel.primary(),l=j.sel.primIndex),Gf?b.shiftKey&&b.metaKey:b.altKey)d="rect",e||(k=new la(c,c)),c=Vb(a,b,!0,!0),l=-1;else if("double"==d){var o=a.findWordAt(c);k=a.display.shift||j.extend?ta(j,k,o.anchor,o.head):o}else if("triple"==d){var p=new la(Nf(c.line,0),pa(j,Nf(c.line+1,0)));k=a.display.shift||j.extend?ta(j,k,p.anchor,p.head):p}else k=ta(j,k,c);e?-1==l?(l=n.length,Aa(j,ma(n.concat([k]),l),{scroll:!1,origin:"*mouse"})):n.length>1&&n[l].empty()&&"single"==d&&!b.shiftKey?(Aa(j,ma(n.slice(0,l).concat(n.slice(l+1)),0),{scroll:!1,origin:"*mouse"}),m=j.sel):wa(j,l,k,Ng):(l=0,Aa(j,new ka([k],0),Ng),m=j.sel);var q=c,r=i.wrapper.getBoundingClientRect(),s=0,t=Fb(a,function(a){we(a)?g(a):h(a)}),v=Fb(a,h);a.state.selectingText=v,Fg(document,"mousemove",t),Fg(document,"mouseup",v)}function $b(a,b,c,d){try{var e=b.clientX,f=b.clientY}catch(b){return!1}if(e>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&Cg(b);var g=a.display,h=g.lineDiv.getBoundingClientRect();if(f>h.bottom||!Ce(a,c))return ue(b);f-=h.top-g.viewOffset;for(var i=0;i=e){var k=ce(a.doc,f),l=a.options.gutters[i];return Ig(a,c,a,k,l,b),ue(b)}}}function _b(a,b){return $b(a,b,"gutterClick",!0)}function ac(a){var b=this;if(dc(b),!Ae(b,a)&&!Ub(b.display,a)){Cg(a),uf&&(Wf=+new Date);var c=Vb(b,a,!0),d=a.dataTransfer.files;if(c&&!b.isReadOnly())if(d&&d.length&&window.FileReader&&window.File)for(var e=d.length,f=Array(e),g=0,h=function(a,d){if(!b.options.allowDropFileTypes||-1!=He(b.options.allowDropFileTypes,a.type)){var h=new FileReader;h.onload=Fb(b,function(){var a=h.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(a)&&(a=""),f[d]=a,++g==e){c=pa(b.doc,c);var i={from:c,to:c,text:b.doc.splitLines(f.join(b.doc.lineSeparator())),origin:"paste"};Ac(b.doc,i),za(b.doc,na(c,ag(i)))}}),h.readAsText(a)}},i=0;e>i;++i)h(d[i],i);else{if(b.state.draggingText&&b.doc.sel.contains(c)>-1)return b.state.draggingText(a),void setTimeout(function(){b.display.input.focus()},20);try{var f=a.dataTransfer.getData("Text");if(f){if(b.state.draggingText&&!b.state.draggingText.copy)var j=b.listSelections();if(Ba(b.doc,na(c,c)),j)for(var i=0;ig.clientWidth,i=g.scrollHeight>g.clientHeight;if(d&&h||e&&i){if(e&&Ff&&wf)a:for(var j=b.target,k=f.view;j!=g;j=j.parentNode)for(var l=0;lm?n=Math.max(0,n+m-50):o=Math.min(a.doc.height,o+m+50),D(a,{top:n,bottom:o})}20>Xf&&(null==f.wheelStartX?(f.wheelStartX=g.scrollLeft,f.wheelStartY=g.scrollTop,f.wheelDX=d,f.wheelDY=e,setTimeout(function(){if(null!=f.wheelStartX){var a=g.scrollLeft-f.wheelStartX,b=g.scrollTop-f.wheelStartY,c=b&&f.wheelDY&&b/f.wheelDY||a&&f.wheelDX&&a/f.wheelDX;f.wheelStartX=f.wheelStartY=null,c&&(Yf=(Yf*Xf+c)/(Xf+1),++Xf)}},200)):(f.wheelDX+=d,f.wheelDY+=e))}}function hc(a,b,c){if("string"==typeof b&&(b=lg[b],!b))return!1;a.display.input.ensurePolled();var d=a.display.shift,e=!1;try{a.isReadOnly()&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=Lg}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function ic(a,b,c){for(var d=0;dvf&&27==a.keyCode&&(a.returnValue=!1);var c=a.keyCode;b.display.shift=16==c||a.shiftKey;var d=kc(b,a);zf&&(_f=d?c:null,!d&&88==c&&!eh&&(Ff?a.metaKey:a.ctrlKey)&&b.replaceSelection("",null,"cut")),18!=c||/\bCodeMirror-crosshair\b/.test(b.display.lineDiv.className)||nc(b)}}function nc(a){function b(a){18!=a.keyCode&&a.altKey||($g(c,"CodeMirror-crosshair"),Hg(document,"keyup",b),Hg(document,"mouseover",b))}var c=a.display.lineDiv;_g(c,"CodeMirror-crosshair"),Fg(document,"keyup",b),Fg(document,"mouseover",b)}function oc(a){16==a.keyCode&&(this.doc.sel.shift=!1),Ae(this,a)}function pc(a){var b=this;if(!(Ub(b.display,a)||Ae(b,a)||a.ctrlKey&&!a.altKey||Ff&&a.metaKey)){var c=a.keyCode,d=a.charCode;if(zf&&c==_f)return _f=null,void Cg(a);if(!zf||a.which&&!(a.which<10)||!kc(b,a)){var e=String.fromCharCode(null==d?c:d);lc(b,a,e)||b.display.input.onKeyPress(a)}}}function qc(a){a.state.delayingBlurEvent=!0,setTimeout(function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,sc(a))},100)}function rc(a){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1),"nocursor"!=a.options.readOnly&&(a.state.focused||(Ig(a,"focus",a),a.state.focused=!0,_g(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(a.display.input.reset(),wf&&setTimeout(function(){a.display.input.reset(!0)},20)),a.display.input.receivedFocus()),Ma(a))}function sc(a){a.state.delayingBlurEvent||(a.state.focused&&(Ig(a,"blur",a),a.state.focused=!1,$g(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150))}function tc(a,b){Ub(a.display,b)||uc(a,b)||Ae(a,b,"contextmenu")||a.display.input.onContextMenu(b)}function uc(a,b){return Ce(a,"gutterContextMenu")?$b(a,b,"gutterContextMenu",!1):!1}function vc(a,b){if(Of(a,b.from)<0)return a;if(Of(a,b.to)<=0)return ag(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;return a.line==b.to.line&&(d+=ag(b).ch-b.to.ch),Nf(c,d)}function wc(a,b){for(var c=[],d=0;d=0;--e)Bc(a,{from:d[e].from,to:d[e].to,text:e?[""]:b.text});else Bc(a,b)}}function Bc(a,b){if(1!=b.text.length||""!=b.text[0]||0!=Of(b.from,b.to)){var c=wc(a,b);je(a,b,c,a.cm?a.cm.curOp.id:NaN),Ec(a,b,c,fd(a,b));var d=[];Xd(a,function(a,c){c||-1!=He(d,a.history)||(te(a.history,b),d.push(a.history)),Ec(a,b,null,fd(a,b))})}}function Cc(a,b,c){if(!a.cm||!a.cm.state.suppressEdits||c){for(var d,e=a.history,f=a.sel,g="undo"==b?e.done:e.undone,h="undo"==b?e.undone:e.done,i=0;i=0;--i){var l=d.changes[i];if(l.origin=b,k&&!zc(a,l,!1))return void(g.length=0);j.push(ge(a,l));var m=i?wc(a,l):Ge(g);Ec(a,l,m,hd(a,l)),!i&&a.cm&&a.cm.scrollIntoView({from:l.from,to:ag(l)});var n=[];Xd(a,function(a,b){b||-1!=He(n,a.history)||(te(a.history,l),n.push(a.history)),Ec(a,l,null,hd(a,l))})}}}}function Dc(a,b){if(0!=b&&(a.first+=b,a.sel=new ka(Ie(a.sel.ranges,function(a){return new la(Nf(a.anchor.line+b,a.anchor.ch),Nf(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){Kb(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;da.lastLine())){if(b.from.linef&&(b={from:b.from,to:Nf(f,Zd(a,f).text.length),text:[b.text[0]],origin:b.origin}),b.removed=$d(a,b.from,b.to),c||(c=wc(a,b)),a.cm?Fc(a.cm,b,d):Ud(a,b,d),Ba(a,c,Mg)}}function Fc(a,b,c){var d=a.doc,e=a.display,g=b.from,h=b.to,i=!1,j=g.line;a.options.lineWrapping||(j=be(sd(Zd(d,g.line))),d.iter(j,h.line+1,function(a){return a==e.maxLine?(i=!0,!0):void 0})),d.sel.contains(b.from,b.to)>-1&&Be(a),Ud(d,b,c,f(a)),a.options.lineWrapping||(d.iter(j,g.line+b.text.length,function(a){var b=l(a);b>e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,i=!1)}),i&&(a.curOp.updateMaxLine=!0)),d.frontier=Math.min(d.frontier,g.line),Na(a,400);var k=b.text.length-(h.line-g.line)-1;b.full?Kb(a):g.line!=h.line||1!=b.text.length||Td(a.doc,b)?Kb(a,g.line,h.line+1,k):Lb(a,g.line,"text");var m=Ce(a,"changes"),n=Ce(a,"change");if(n||m){var o={from:g,to:h,text:b.text,removed:b.removed,origin:b.origin};n&&ye(a,"change",a,o),m&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(o)}a.display.selForContextMenu=null}function Gc(a,b,c,d,e){if(d||(d=c),Of(d,c)<0){var f=d;d=c,c=f}"string"==typeof b&&(b=a.splitLines(b)),Ac(a,{from:c,to:d,text:b,origin:e})}function Hc(a,b){if(!Ae(a,"scrollCursorIntoView")){var c=a.display,d=c.sizer.getBoundingClientRect(),e=null;if(b.top+d.top<0?e=!0:b.bottom+d.top>(window.innerHeight||document.documentElement.clientHeight)&&(e=!1),null!=e&&!Cf){var f=Re("div","​",null,"position: absolute; top: "+(b.top-c.viewOffset-Ra(a.display))+"px; height: "+(b.bottom-b.top+Ua(a)+c.barHeight)+"px; left: "+b.left+"px; width: 2px;");a.display.lineSpace.appendChild(f),f.scrollIntoView(e),a.display.lineSpace.removeChild(f)}}}function Ic(a,b,c,d){null==d&&(d=0);for(var e=0;5>e;e++){var f=!1,g=ob(a,b),h=c&&c!=b?ob(a,c):g,i=Kc(a,Math.min(g.left,h.left),Math.min(g.top,h.top)-d,Math.max(g.left,h.left),Math.max(g.bottom,h.bottom)+d),j=a.doc.scrollTop,k=a.doc.scrollLeft;if(null!=i.scrollTop&&(ec(a,i.scrollTop),Math.abs(a.doc.scrollTop-j)>1&&(f=!0)),null!=i.scrollLeft&&(fc(a,i.scrollLeft),Math.abs(a.doc.scrollLeft-k)>1&&(f=!0)),!f)break}return g}function Jc(a,b,c,d,e){var f=Kc(a,b,c,d,e);null!=f.scrollTop&&ec(a,f.scrollTop),null!=f.scrollLeft&&fc(a,f.scrollLeft)}function Kc(a,b,c,d,e){var f=a.display,g=tb(a.display);0>c&&(c=0);var h=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,i=Wa(a),j={};e-c>i&&(e=c+i);var k=a.doc.height+Sa(f),l=g>c,m=e>k-g;if(h>c)j.scrollTop=l?0:c;else if(e>h+i){var n=Math.min(c,(m?k:e)-i);n!=h&&(j.scrollTop=n)}var o=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:f.scroller.scrollLeft,p=Va(a)-(a.options.fixedGutter?f.gutters.offsetWidth:0),q=d-b>p; +return q&&(d=b+p),10>b?j.scrollLeft=0:o>b?j.scrollLeft=Math.max(0,b-(q?0:10)):d>p+o-3&&(j.scrollLeft=d+(q?0:10)-p),j}function Lc(a,b,c){(null!=b||null!=c)&&Nc(a),null!=b&&(a.curOp.scrollLeft=(null==a.curOp.scrollLeft?a.doc.scrollLeft:a.curOp.scrollLeft)+b),null!=c&&(a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+c)}function Mc(a){Nc(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?Nf(b.line,b.ch-1):b,d=Nf(b.line,b.ch+1)),a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function Nc(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=pb(a,b.from),d=pb(a,b.to),e=Kc(a,Math.min(c.left,d.left),Math.min(c.top,d.top)-b.margin,Math.max(c.right,d.right),Math.max(c.bottom,d.bottom)+b.margin);a.scrollTo(e.scrollLeft,e.scrollTop)}}function Oc(a,b,c,d){var e,f=a.doc;null==c&&(c="add"),"smart"==c&&(f.mode.indent?e=Qa(a,b):c="prev");var g=a.options.tabSize,h=Zd(f,b),i=Pg(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var j,k=h.text.match(/^\s*/)[0];if(d||/\S/.test(h.text)){if("smart"==c&&(j=f.mode.indent(e,h.text.slice(k.length),h.text),j==Lg||j>150)){if(!d)return;c="prev"}}else j=0,c="not";"prev"==c?j=b>f.first?Pg(Zd(f,b-1).text,null,g):0:"add"==c?j=i+a.options.indentUnit:"subtract"==c?j=i-a.options.indentUnit:"number"==typeof c&&(j=i+c),j=Math.max(0,j);var l="",m=0;if(a.options.indentWithTabs)for(var n=Math.floor(j/g);n;--n)m+=g,l+=" ";if(j>m&&(l+=Fe(j-m)),l!=k)return Gc(f,l,Nf(b,0),Nf(b,k.length),"+input"),h.stateAfter=null,!0;for(var n=0;n=0;b--)Gc(a.doc,"",d[b].from,d[b].to,"+delete");Mc(a)})}function Rc(a,b,c,d,e){function f(){var b=h+c;return b=a.first+a.size?!1:(h=b,k=Zd(a,b))}function g(a){var b=(e?nf:of)(k,i,c,!0);if(null==b){if(a||!f())return!1;i=e?(0>c?ff:ef)(k):0>c?k.text.length:0}else i=b;return!0}var h=b.line,i=b.ch,j=c,k=Zd(a,h);if("char"==d)g();else if("column"==d)g(!0);else if("word"==d||"group"==d)for(var l=null,m="group"==d,n=a.cm&&a.cm.getHelper(b,"wordChars"),o=!0;!(0>c)||g(!o);o=!1){var p=k.text.charAt(i)||"\n",q=Oe(p,n)?"w":m&&"\n"==p?"n":!m||/\s/.test(p)?null:"p";if(!m||o||q||(q="s"),l&&l!=q){0>c&&(c=1,g());break}if(q&&(l=q),c>0&&!g(!o))break}var r=Ga(a,Nf(h,i),b,j,!0);return Of(b,r)||(r.hitSide=!0),r}function Sc(a,b,c,d){var e,f=a.doc,g=b.left;if("page"==d){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);e=b.top+c*(h-(0>c?1.5:.5)*tb(a.display))}else"line"==d&&(e=c>0?b.bottom+3:b.top-3);for(;;){var i=rb(a,g,e);if(!i.outside)break;if(0>c?0>=e:e>=f.height){i.hitSide=!0;break}e+=5*c}return i}function Tc(b,c,d,e){a.defaults[b]=c,d&&(cg[b]=e?function(a,b,c){c!=dg&&d(a,b,c)}:d)}function Uc(a){for(var b,c,d,e,f=a.split(/-(?!$)/),a=f[f.length-1],g=0;g0||0==g&&f.clearWhenEmpty!==!1)return f;if(f.replacedWith&&(f.collapsed=!0,f.widgetNode=Re("span",[f.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||f.widgetNode.setAttribute("cm-ignore-events","true"),d.insertLeft&&(f.widgetNode.insertLeft=!0)),f.collapsed){if(rd(a,b.line,b,c,f)||b.line!=c.line&&rd(a,c.line,b,c,f))throw new Error("Inserting collapsed marker partially overlapping an existing one");Mf=!0}f.addToHistory&&je(a,{from:b,to:c,origin:"markText"},a.sel,NaN);var h,i=b.line,j=a.cm;if(a.iter(i,c.line+1,function(a){j&&f.collapsed&&!j.options.lineWrapping&&sd(a)==j.display.maxLine&&(h=!0),f.collapsed&&i!=b.line&&ae(a,0),cd(a,new _c(f,i==b.line?b.ch:null,i==c.line?c.ch:null)),++i}),f.collapsed&&a.iter(b.line,c.line+1,function(b){wd(a,b)&&ae(b,0)}),f.clearOnEnter&&Fg(f,"beforeCursorEnter",function(){f.clear()}),f.readOnly&&(Lf=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory()),f.collapsed&&(f.id=++rg,f.atomic=!0),j){if(h&&(j.curOp.updateMaxLine=!0),f.collapsed)Kb(j,b.line,c.line+1);else if(f.className||f.title||f.startStyle||f.endStyle||f.css)for(var k=b.line;k<=c.line;k++)Lb(j,k,"text");f.atomic&&Da(j.doc),ye(j,"markerAdded",j,f)}return f}function Xc(a,b,c,d,e){d=Me(d),d.shared=!1;var f=[Wc(a,b,c,d,e)],g=f[0],h=d.widgetNode;return Xd(a,function(a){h&&(d.widgetNode=h.cloneNode(!0)),f.push(Wc(a,pa(a,b),pa(a,c),d,e));for(var i=0;i=b:f.to>b);(d||(d=[])).push(new _c(g,f.from,i?null:f.to))}}return d}function ed(a,b,c){if(a)for(var d,e=0;e=b:f.to>b);if(h||f.from==b&&"bookmark"==g.type&&(!c||f.marker.insertLeft)){var i=null==f.from||(g.inclusiveLeft?f.from<=b:f.from0&&h)for(var l=0;ll;++l)o.push(p);o.push(i)}return o}function gd(a){for(var b=0;b0)){var k=[i,1],l=Of(j.from,h.from),m=Of(j.to,h.to);(0>l||!g.inclusiveLeft&&!l)&&k.push({from:j.from,to:h.from}),(m>0||!g.inclusiveRight&&!m)&&k.push({from:h.to,to:j.to}),e.splice.apply(e,k),i+=k.length-1}}return e}function jd(a){var b=a.markedSpans;if(b){for(var c=0;c=0&&0>=l||0>=k&&l>=0)&&(0>=k&&(i.marker.inclusiveRight&&e.inclusiveLeft?Of(j.to,c)>=0:Of(j.to,c)>0)||k>=0&&(i.marker.inclusiveRight&&e.inclusiveLeft?Of(j.from,d)<=0:Of(j.from,d)<0)))return!0}}}function sd(a){for(var b;b=pd(a);)a=b.find(-1,!0).line;return a}function td(a){for(var b,c;b=qd(a);)a=b.find(1,!0).line,(c||(c=[])).push(a);return c}function ud(a,b){var c=Zd(a,b),d=sd(c);return c==d?b:be(d)}function vd(a,b){if(b>a.lastLine())return b;var c,d=Zd(a,b);if(!wd(a,d))return b;for(;c=qd(d);)d=c.find(1,!0).line;return be(d)+1}function wd(a,b){var c=Mf&&b.markedSpans;if(c)for(var d,e=0;ef;f++){e&&(e[0]=a.innerMode(b,d).mode);var g=b.token(c,d);if(c.pos>c.start)return g}throw new Error("Mode "+b.name+" failed to advance stream.")}function Gd(a,b,c,d){function e(a){return{start:l.start,end:l.pos,string:l.current(),type:f||null,state:a?jg(g.mode,k):k}}var f,g=a.doc,h=g.mode;b=pa(g,b);var i,j=Zd(g,b.line),k=Qa(a,b.line,c),l=new qg(j.text,a.options.tabSize);for(d&&(i=[]);(d||l.posa.options.maxHighlightLength?(h=!1,g&&Kd(a,b,d,l.pos),l.pos=b.length,i=null):i=Dd(Fd(c,l,d,m),f),m){var n=m[0].name;n&&(i="m-"+(i?n+" "+i:n))}if(!h||k!=i){for(;jj;){var d=e[i];d>a&&e.splice(i,1,a,e[i+1],d),i+=2,j=Math.min(a,d)}if(b)if(h.opaque)e.splice(c,i-c,a,"cm-overlay "+b),i=c+2;else for(;i>c;c+=2){var f=e[c+1];e[c+1]=(f?f+" ":"")+"cm-overlay "+b}},f)}return{styles:e,classes:f.bgClass||f.textClass?f:null}}function Jd(a,b,c){if(!b.styles||b.styles[0]!=a.state.modeGen){var d=Qa(a,be(b)),e=Id(a,b,b.text.length>a.options.maxHighlightLength?jg(a.doc.mode,d):d);b.stateAfter=d,b.styles=e.styles,e.classes?b.styleClasses=e.classes:b.styleClasses&&(b.styleClasses=null),c===a.doc.frontier&&a.doc.frontier++}return b.styles}function Kd(a,b,c,d){var e=a.doc.mode,f=new qg(b,a.options.tabSize);for(f.start=f.pos=d||0,""==b&&Ed(e,c);!f.eol();)Fd(e,f,c),f.start=f.pos}function Ld(a,b){if(!a||/^\s*$/.test(a))return null;var c=b.addModeClass?xg:wg;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$&"))}function Md(a,b){var c=Re("span",null,null,wf?"padding-right: .1px":null),d={pre:Re("pre",[c],"CodeMirror-line"),content:c,col:0,pos:0,cm:a,trailingSpace:!1,splitSpaces:(uf||wf)&&a.getOption("lineWrapping")};b.measure={};for(var e=0;e<=(b.rest?b.rest.length:0);e++){var f,g=e?b.rest[e-1]:b.line;d.pos=0,d.addToken=Od,_e(a.display.measure)&&(f=ee(g))&&(d.addToken=Qd(d.addToken,f)),d.map=[];var h=b!=a.display.externalMeasured&&be(g);Sd(g,d,Jd(a,g,h)),g.styleClasses&&(g.styleClasses.bgClass&&(d.bgClass=We(g.styleClasses.bgClass,d.bgClass||"")),g.styleClasses.textClass&&(d.textClass=We(g.styleClasses.textClass,d.textClass||""))),0==d.map.length&&d.map.push(0,0,d.content.appendChild($e(a.display.measure))),0==e?(b.measure.map=d.map,b.measure.cache={}):((b.measure.maps||(b.measure.maps=[])).push(d.map),(b.measure.caches||(b.measure.caches=[])).push({}))}if(wf){var i=d.content.lastChild;(/\bcm-tab\b/.test(i.className)||i.querySelector&&i.querySelector(".cm-tab"))&&(d.content.className="cm-tab-wrap-hack")}return Ig(a,"renderLine",a,b.line,d.pre),d.pre.className&&(d.textClass=We(d.pre.className,d.textClass||"")),d}function Nd(a){var b=Re("span","•","cm-invalidchar");return b.title="\\u"+a.charCodeAt(0).toString(16),b.setAttribute("aria-label",b.title),b}function Od(a,b,c,d,e,f,g){if(b){var h=a.splitSpaces?Pd(b,a.trailingSpace):b,i=a.cm.state.specialChars,j=!1;if(i.test(b))for(var k=document.createDocumentFragment(),l=0;;){i.lastIndex=l;var m=i.exec(b),n=m?m.index-l:b.length-l;if(n){var o=document.createTextNode(h.slice(l,l+n));uf&&9>vf?k.appendChild(Re("span",[o])):k.appendChild(o),a.map.push(a.pos,a.pos+n,o),a.col+=n,a.pos+=n}if(!m)break;if(l+=n+1," "==m[0]){var p=a.cm.options.tabSize,q=p-a.col%p,o=k.appendChild(Re("span",Fe(q),"cm-tab"));o.setAttribute("role","presentation"),o.setAttribute("cm-text"," "),a.col+=q}else if("\r"==m[0]||"\n"==m[0]){var o=k.appendChild(Re("span","\r"==m[0]?"␍":"␤","cm-invalidchar"));o.setAttribute("cm-text",m[0]),a.col+=1}else{var o=a.cm.options.specialCharPlaceholder(m[0]);o.setAttribute("cm-text",m[0]),uf&&9>vf?k.appendChild(Re("span",[o])):k.appendChild(o),a.col+=1}a.map.push(a.pos,a.pos+1,o),a.pos++}else{a.col+=b.length;var k=document.createTextNode(h);a.map.push(a.pos,a.pos+b.length,k),uf&&9>vf&&(j=!0),a.pos+=b.length}if(a.trailingSpace=32==h.charCodeAt(b.length-1),c||d||e||j||g){var r=c||"";d&&(r+=d),e&&(r+=e);var s=Re("span",[k],r,g);return f&&(s.title=f),a.content.appendChild(s)}a.content.appendChild(k)}}function Pd(a,b){if(a.length>1&&!/ /.test(a))return a;for(var c=b,d="",e=0;ej&&m.from<=j)break}if(m.to>=k)return a(c,d,e,f,g,h,i);a(c,d.slice(0,m.to-j),e,f,null,h,i),f=null,d=d.slice(m.to-j),j=m.to}}}function Rd(a,b,c,d){var e=!d&&c.widgetNode;e&&a.map.push(a.pos,a.pos+b,e),!d&&a.cm.display.input.needsContentAttribute&&(e||(e=a.content.appendChild(document.createElement("span"))),e.setAttribute("cm-marker",c.id)),e&&(a.cm.display.input.setUneditable(e),a.content.appendChild(e)),a.pos+=b,a.trailingSpace=!1}function Sd(a,b,c){var d=a.markedSpans,e=a.text,f=0;if(d)for(var g,h,i,j,k,l,m,n=e.length,o=0,p=1,q="",r=0;;){if(r==o){i=j=k=l=h="",m=null,r=1/0;for(var s,t=[],u=0;uo||w.collapsed&&v.to==o&&v.from==o)?(null!=v.to&&v.to!=o&&r>v.to&&(r=v.to,j=""),w.className&&(i+=" "+w.className),w.css&&(h=(h?h+";":"")+w.css),w.startStyle&&v.from==o&&(k+=" "+w.startStyle),w.endStyle&&v.to==r&&(s||(s=[])).push(w.endStyle,v.to),w.title&&!l&&(l=w.title),w.collapsed&&(!m||nd(m.marker,w)<0)&&(m=v)):v.from>o&&r>v.from&&(r=v.from)}if(s)for(var u=0;u=n)break;for(var x=Math.min(n,r);;){if(q){var y=o+q.length;if(!m){var z=y>x?q.slice(0,x-o):q;b.addToken(b,z,g?g+i:i,k,o+z.length==r?j:"",l,h)}if(y>=x){q=q.slice(x-o),o=x;break}o=y,k=""}q=e.slice(f,f=c[p++]),g=Ld(c[p++],b.cm.options)}}else for(var p=1;pc;++c)f.push(new vg(j[c],e(c),d));return f}var h=b.from,i=b.to,j=b.text,k=Zd(a,h.line),l=Zd(a,i.line),m=Ge(j),n=e(j.length-1),o=i.line-h.line;if(b.full)a.insert(0,g(0,j.length)),a.remove(j.length,a.size-j.length);else if(Td(a,b)){var p=g(0,j.length-1);f(l,l.text,n),o&&a.remove(h.line,o),p.length&&a.insert(h.line,p)}else if(k==l)if(1==j.length)f(k,k.text.slice(0,h.ch)+m+k.text.slice(i.ch),n);else{var p=g(1,j.length-1);p.push(new vg(m+k.text.slice(i.ch),n,d)),f(k,k.text.slice(0,h.ch)+j[0],e(0)),a.insert(h.line+1,p)}else if(1==j.length)f(k,k.text.slice(0,h.ch)+j[0]+l.text.slice(i.ch),e(0)),a.remove(h.line+1,o);else{f(k,k.text.slice(0,h.ch)+j[0],e(0)),f(l,m+l.text.slice(i.ch),n);var p=g(1,j.length-1);o>1&&a.remove(h.line+1,o-1),a.insert(h.line+1,p)}ye(a,"change",a,b)}function Vd(a){this.lines=a,this.parent=null;for(var b=0,c=0;bb||b>=a.size)throw new Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(f>b){c=e;break}b-=f}return c.lines[b]}function $d(a,b,c){var d=[],e=b.line;return a.iter(b.line,c.line+1,function(a){var f=a.text;e==c.line&&(f=f.slice(0,c.ch)),e==b.line&&(f=f.slice(b.ch)),d.push(f),++e}),d}function _d(a,b,c){var d=[];return a.iter(b,c,function(a){d.push(a.text)}),d}function ae(a,b){var c=b-a.height;if(c)for(var d=a;d;d=d.parent)d.height+=c}function be(a){if(null==a.parent)return null;for(var b=a.parent,c=He(b.lines,a),d=b.parent;d;b=d,d=d.parent)for(var e=0;d.children[e]!=b;++e)c+=d.children[e].chunkSize();return c+b.first}function ce(a,b){var c=a.first;a:do{for(var d=0;db){a=e;continue a}b-=f,c+=e.chunkSize()}return c}while(!a.lines);for(var d=0;db)break;b-=h}return c+d}function de(a){a=sd(a);for(var b=0,c=a.parent,d=0;d1&&!a.done[a.done.length-2].ranges?(a.done.pop(),Ge(a.done)):void 0}function je(a,b,c,d){var e=a.history;e.undone.length=0;var f,g=+new Date;if((e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastModTime>g-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))&&(f=ie(e,e.lastOp==d))){var h=Ge(f.changes);0==Of(b.from,b.to)&&0==Of(b.from,h.to)?h.to=ag(b):f.changes.push(ge(a,b))}else{var i=Ge(e.done);for(i&&i.ranges||me(a.sel,e.done),f={changes:[ge(a,b)],generation:e.generation},e.done.push(f);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift()}e.done.push(c),e.generation=++e.maxGeneration,e.lastModTime=e.lastSelTime=g,e.lastOp=e.lastSelOp=d,e.lastOrigin=e.lastSelOrigin=b.origin,h||Ig(a,"historyAdded")}function ke(a,b,c,d){var e=b.charAt(0);return"*"==e||"+"==e&&c.ranges.length==d.ranges.length&&c.somethingSelected()==d.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}function le(a,b,c,d){var e=a.history,f=d&&d.origin;c==e.lastSelOp||f&&e.lastSelOrigin==f&&(e.lastModTime==e.lastSelTime&&e.lastOrigin==f||ke(a,f,Ge(e.done),b))?e.done[e.done.length-1]=b:me(b,e.done),e.lastSelTime=+new Date,e.lastSelOrigin=f,e.lastSelOp=c,d&&d.clearRedo!==!1&&he(e.undone)}function me(a,b){var c=Ge(b);c&&c.ranges&&c.equals(a)||b.push(a)}function ne(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans),++f})}function oe(a){if(!a)return null;for(var b,c=0;c-1&&(Ge(h)[l]=k[l],delete k[l])}}}return e}function re(a,b,c,d){c0?d.slice():Gg:d||Gg}function ye(a,b){function c(a){return function(){a.apply(null,f)}}var d=xe(a,b,!1);if(d.length){var e,f=Array.prototype.slice.call(arguments,2);Uf?e=Uf.delayedCallbacks:Jg?e=Jg:(e=Jg=[],setTimeout(ze,0));for(var g=0;g0}function De(a){a.prototype.on=function(a,b){Fg(this,a,b)},a.prototype.off=function(a,b){Hg(this,a,b)}}function Ee(){this.id=null}function Fe(a){for(;Rg.length<=a;)Rg.push(Ge(Rg)+" ");return Rg[a]}function Ge(a){return a[a.length-1]}function He(a,b){for(var c=0;c-1&&Vg(a)?!0:b.test(a):Vg(a)}function Pe(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function Qe(a){return a.charCodeAt(0)>=768&&Wg.test(a)}function Re(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)e.appendChild(document.createTextNode(b));else if(b)for(var f=0;f0;--b)a.removeChild(a.firstChild);return a}function Te(a,b){return Se(a).appendChild(b)}function Ue(){for(var a=document.activeElement;a&&a.root&&a.root.activeElement;)a=a.root.activeElement;return a}function Ve(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}function We(a,b){for(var c=a.split(" "),d=0;d2&&!(uf&&8>vf))}var c=Yg?Re("span","​"):Re("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return c.setAttribute("cm-text",""),c}function _e(a){if(null!=Zg)return Zg;var b=Te(a,document.createTextNode("AخA")),c=Tg(b,0,1).getBoundingClientRect(),d=Tg(b,1,2).getBoundingClientRect();return Se(a),c&&c.left!=c.right?Zg=d.right-c.right<3:!1}function af(a){if(null!=fh)return fh;var b=Te(a,Re("span","x")),c=b.getBoundingClientRect(),d=Tg(b,0,1).getBoundingClientRect();return fh=Math.abs(c.left-d.left)>1}function bf(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;fb||b==c&&g.to==b)&&(d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr"),e=!0)}e||d(b,c,"ltr")}function cf(a){return a.level%2?a.to:a.from}function df(a){return a.level%2?a.from:a.to}function ef(a){var b=ee(a);return b?cf(b[0]):0}function ff(a){var b=ee(a);return b?df(Ge(b)):a.text.length}function gf(a,b){var c=Zd(a.doc,b),d=sd(c);d!=c&&(b=be(d));var e=ee(d),f=e?e[0].level%2?ff(d):ef(d):0;return Nf(b,f)}function hf(a,b){for(var c,d=Zd(a.doc,b);c=qd(d);)d=c.find(1,!0).line,b=null;var e=ee(d),f=e?e[0].level%2?ef(d):ff(d):d.text.length;return Nf(null==b?be(d):b,f)}function jf(a,b){var c=gf(a,b.line),d=Zd(a.doc,c.line),e=ee(d);if(!e||0==e[0].level){var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&b.ch<=f&&b.ch;return Nf(c.line,g?0:f)}return c}function kf(a,b,c){var d=a[0].level;return b==d?!0:c==d?!1:c>b}function lf(a,b){hh=null;for(var c,d=0;db)return d;if(e.from==b||e.to==b){if(null!=c)return kf(a,e.level,a[c].level)?(e.from!=e.to&&(hh=c),d):(e.from!=e.to&&(hh=d),c);c=d}}return c}function mf(a,b,c,d){if(!d)return b+c;do b+=c;while(b>0&&Qe(a.text.charAt(b)));return b}function nf(a,b,c,d){var e=ee(a);if(!e)return of(a,b,c,d);for(var f=lf(e,b),g=e[f],h=mf(a,b,g.level%2?-c:c,d);;){if(h>g.from&&h0==g.level%2?g.to:g.from);if(g=e[f+=c],!g)return null;h=c>0==g.level%2?mf(a,g.to,-1,d):mf(a,g.from,1,d)}}function of(a,b,c,d){var e=b+c;if(d)for(;e>0&&Qe(a.text.charAt(e));)e+=c;return 0>e||e>a.text.length?null:e}var pf=navigator.userAgent,qf=navigator.platform,rf=/gecko\/\d/i.test(pf),sf=/MSIE \d/.test(pf),tf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(pf),uf=sf||tf,vf=uf&&(sf?document.documentMode||6:tf[1]),wf=/WebKit\//.test(pf),xf=wf&&/Qt\/\d+\.\d+/.test(pf),yf=/Chrome\//.test(pf),zf=/Opera\//.test(pf),Af=/Apple Computer/.test(navigator.vendor),Bf=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(pf),Cf=/PhantomJS/.test(pf),Df=/AppleWebKit/.test(pf)&&/Mobile\/\w+/.test(pf),Ef=Df||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(pf),Ff=Df||/Mac/.test(qf),Gf=/\bCrOS\b/.test(pf),Hf=/win/i.test(qf),If=zf&&pf.match(/Version\/(\d*\.\d*)/);If&&(If=Number(If[1])),If&&If>=15&&(zf=!1,wf=!0);var Jf=Ff&&(xf||zf&&(null==If||12.11>If)),Kf=rf||uf&&vf>=9,Lf=!1,Mf=!1;p.prototype=Me({update:function(a){var b=a.scrollWidth>a.clientWidth+1,c=a.scrollHeight>a.clientHeight+1,d=a.nativeBarWidth;if(c){this.vert.style.display="block",this.vert.style.bottom=b?d+"px":"0";var e=a.viewHeight-(b?d:0);this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+e)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(b){this.horiz.style.display="block",this.horiz.style.right=c?d+"px":"0",this.horiz.style.left=a.barLeft+"px";var f=a.viewWidth-a.barLeft-(c?d:0);this.horiz.firstChild.style.width=a.scrollWidth-a.clientWidth+f+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&a.clientHeight>0&&(0==d&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:c?d:0,bottom:b?d:0}},setScrollLeft:function(a){this.horiz.scrollLeft!=a&&(this.horiz.scrollLeft=a),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert); +},zeroWidthHack:function(){var a=Ff&&!Bf?"12px":"18px";this.horiz.style.height=this.vert.style.width=a,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Ee,this.disableVert=new Ee},enableZeroWidthBar:function(a,b){function c(){var d=a.getBoundingClientRect(),e=document.elementFromPoint(d.left+1,d.bottom-1);e!=a?a.style.pointerEvents="none":b.set(1e3,c)}a.style.pointerEvents="auto",b.set(1e3,c)},clear:function(){var a=this.horiz.parentNode;a.removeChild(this.horiz),a.removeChild(this.vert)}},p.prototype),q.prototype=Me({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},q.prototype),a.scrollbarModel={"native":p,"null":q},z.prototype.signal=function(a,b){Ce(a,b)&&this.events.push(arguments)},z.prototype.finish=function(){for(var a=0;a=9&&c.hasSelection&&(c.hasSelection=null),c.poll()}),Fg(f,"paste",function(a){Ae(d,a)||$(a,d)||(d.state.pasteIncoming=!0,c.fastPoll())}),Fg(f,"cut",b),Fg(f,"copy",b),Fg(a.scroller,"paste",function(b){Ub(a,b)||Ae(d,b)||(d.state.pasteIncoming=!0,c.focus())}),Fg(a.lineSpace,"selectstart",function(b){Ub(a,b)||Cg(b)}),Fg(f,"compositionstart",function(){var a=d.getCursor("from");c.composing&&c.composing.range.clear(),c.composing={start:a,range:d.markText(a,d.getCursor("to"),{className:"CodeMirror-composing"})}}),Fg(f,"compositionend",function(){c.composing&&(c.poll(),c.composing.range.clear(),c.composing=null)})},prepareSelection:function(){var a=this.cm,b=a.display,c=a.doc,d=Ja(a);if(a.options.moveInputWithCursor){var e=ob(a,c.sel.primary().head,"div"),f=b.wrapper.getBoundingClientRect(),g=b.lineDiv.getBoundingClientRect();d.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,e.top+g.top-f.top)),d.teLeft=Math.max(0,Math.min(b.wrapper.clientWidth-10,e.left+g.left-f.left))}return d},showSelection:function(a){var b=this.cm,c=b.display;Te(c.cursorDiv,a.cursors),Te(c.selectionDiv,a.selection),null!=a.teTop&&(this.wrapper.style.top=a.teTop+"px",this.wrapper.style.left=a.teLeft+"px")},reset:function(a){if(!this.contextMenuPending){var b,c,d=this.cm,e=d.doc;if(d.somethingSelected()){this.prevInput="";var f=e.sel.primary();b=eh&&(f.to().line-f.from().line>100||(c=d.getSelection()).length>1e3);var g=b?"-":c||d.getSelection();this.textarea.value=g,d.state.focused&&Sg(this.textarea),uf&&vf>=9&&(this.hasSelection=g)}else a||(this.prevInput=this.textarea.value="",uf&&vf>=9&&(this.hasSelection=null));this.inaccurateSelection=b}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Ef||Ue()!=this.textarea))try{this.textarea.focus()}catch(a){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var a=this;a.pollingFast||a.polling.set(this.cm.options.pollInterval,function(){a.poll(),a.cm.state.focused&&a.slowPoll()})},fastPoll:function(){function a(){var d=c.poll();d||b?(c.pollingFast=!1,c.slowPoll()):(b=!0,c.polling.set(60,a))}var b=!1,c=this;c.pollingFast=!0,c.polling.set(20,a)},poll:function(){var a=this.cm,b=this.textarea,c=this.prevInput;if(this.contextMenuPending||!a.state.focused||dh(b)&&!c&&!this.composing||a.isReadOnly()||a.options.disableInput||a.state.keySeq)return!1;var d=b.value;if(d==c&&!a.somethingSelected())return!1;if(uf&&vf>=9&&this.hasSelection===d||Ff&&/[\uf700-\uf7ff]/.test(d))return a.display.input.reset(),!1;if(a.doc.sel==a.display.selForContextMenu){var e=d.charCodeAt(0);if(8203!=e||c||(c="​"),8666==e)return this.reset(),this.cm.execCommand("undo")}for(var f=0,g=Math.min(c.length,d.length);g>f&&c.charCodeAt(f)==d.charCodeAt(f);)++f;var h=this;return Eb(a,function(){Z(a,d.slice(f),c.length-f,null,h.composing?"*compose":null),d.length>1e3||d.indexOf("\n")>-1?b.value=h.prevInput="":h.prevInput=d,h.composing&&(h.composing.range.clear(),h.composing.range=a.markText(h.composing.start,a.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){uf&&vf>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(a){function b(){if(null!=g.selectionStart){var a=e.somethingSelected(),b="​"+(a?g.value:"");g.value="⇚",g.value=b,d.prevInput=a?"":"​",g.selectionStart=1,g.selectionEnd=b.length,f.selForContextMenu=e.doc.sel}}function c(){if(d.contextMenuPending=!1,d.wrapper.style.cssText=l,g.style.cssText=k,uf&&9>vf&&f.scrollbars.setScrollTop(f.scroller.scrollTop=i),null!=g.selectionStart){(!uf||uf&&9>vf)&&b();var a=0,c=function(){f.selForContextMenu==e.doc.sel&&0==g.selectionStart&&g.selectionEnd>0&&"​"==d.prevInput?Fb(e,lg.selectAll)(e):a++<10?f.detectingSelectAll=setTimeout(c,500):f.input.reset()};f.detectingSelectAll=setTimeout(c,200)}}var d=this,e=d.cm,f=e.display,g=d.textarea,h=Vb(e,a),i=f.scroller.scrollTop;if(h&&!zf){var j=e.options.resetSelectionOnContextMenu;j&&-1==e.doc.sel.contains(h)&&Fb(e,Aa)(e.doc,na(h),Mg);var k=g.style.cssText,l=d.wrapper.style.cssText;d.wrapper.style.cssText="position: absolute";var m=d.wrapper.getBoundingClientRect();if(g.style.cssText="position: absolute; width: 30px; height: 30px; top: "+(a.clientY-m.top-5)+"px; left: "+(a.clientX-m.left-5)+"px; z-index: 1000; background: "+(uf?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",wf)var n=window.scrollY;if(f.input.focus(),wf&&window.scrollTo(null,n),f.input.reset(),e.somethingSelected()||(g.value=d.prevInput=" "),d.contextMenuPending=!0,f.selForContextMenu=e.doc.sel,clearTimeout(f.detectingSelectAll),uf&&vf>=9&&b(),Kf){Eg(a);var o=function(){Hg(window,"mouseup",o),setTimeout(c,20)};Fg(window,"mouseup",o)}else setTimeout(c,50)}},readOnlyChanged:function(a){a||this.reset()},setUneditable:Ke,needsContentAttribute:!1},ca.prototype),ea.prototype=Me({init:function(a){function b(a){if(!Ae(d,a)){if(d.somethingSelected())Pf={lineWise:!1,text:d.getSelections()},"cut"==a.type&&d.replaceSelection("",null,"cut");else{if(!d.options.lineWiseCopyCut)return;var b=aa(d);Pf={lineWise:!0,text:b.text},"cut"==a.type&&d.operation(function(){d.setSelections(b.ranges,0,Mg),d.replaceSelection("",null,"cut")})}if(a.clipboardData){a.clipboardData.clearData();var f=Pf.text.join("\n");if(a.clipboardData.setData("Text",f),a.clipboardData.getData("Text")==f)return void a.preventDefault()}var g=da(),h=g.firstChild;d.display.lineSpace.insertBefore(g,d.display.lineSpace.firstChild),h.value=Pf.text.join("\n");var i=document.activeElement;Sg(h),setTimeout(function(){d.display.lineSpace.removeChild(g),i.focus(),i==e&&c.showPrimarySelection()},50)}}var c=this,d=c.cm,e=c.div=a.lineDiv;ba(e,d.options.spellcheck),Fg(e,"paste",function(a){Ae(d,a)||$(a,d)||11>=vf&&setTimeout(Fb(d,function(){c.pollContent()||Kb(d)}),20)}),Fg(e,"compositionstart",function(a){var b=a.data;if(c.composing={sel:d.doc.sel,data:b,startData:b},b){var e=d.doc.sel.primary(),f=d.getLine(e.head.line),g=f.indexOf(b,Math.max(0,e.head.ch-b.length));g>-1&&g<=e.head.ch&&(c.composing.sel=na(Nf(e.head.line,g),Nf(e.head.line,g+b.length)))}}),Fg(e,"compositionupdate",function(a){c.composing.data=a.data}),Fg(e,"compositionend",function(a){var b=c.composing;b&&(a.data==b.startData||/\u200b/.test(a.data)||(b.data=a.data),setTimeout(function(){b.handled||c.applyComposition(b),c.composing==b&&(c.composing=null)},50))}),Fg(e,"touchstart",function(){c.forceCompositionEnd()}),Fg(e,"input",function(){c.composing||(d.isReadOnly()||!c.pollContent())&&Eb(c.cm,function(){Kb(d)})}),Fg(e,"copy",b),Fg(e,"cut",b)},prepareSelection:function(){var a=Ja(this.cm,!1);return a.focus=this.cm.state.focused,a},showSelection:function(a,b){a&&this.cm.display.view.length&&((a.focus||b)&&this.showPrimarySelection(),this.showMultipleSelections(a))},showPrimarySelection:function(){var a=window.getSelection(),b=this.cm.doc.sel.primary(),c=ha(this.cm,a.anchorNode,a.anchorOffset),d=ha(this.cm,a.focusNode,a.focusOffset);if(!c||c.bad||!d||d.bad||0!=Of(X(c,d),b.from())||0!=Of(W(c,d),b.to())){var e=fa(this.cm,b.from()),f=fa(this.cm,b.to());if(e||f){var g=this.cm.display.view,h=a.rangeCount&&a.getRangeAt(0);if(e){if(!f){var i=g[g.length-1].measure,j=i.maps?i.maps[i.maps.length-1]:i.map;f={node:j[j.length-1],offset:j[j.length-2]-j[j.length-3]}}}else e={node:g[0].measure.map[2],offset:0};try{var k=Tg(e.node,e.offset,f.offset,f.node)}catch(l){}k&&(!rf&&this.cm.state.focused?(a.collapse(e.node,e.offset),k.collapsed||a.addRange(k)):(a.removeAllRanges(),a.addRange(k)),h&&null==a.anchorNode?a.addRange(h):rf&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var a=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){a.gracePeriod=!1,a.selectionChanged()&&a.cm.operation(function(){a.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(a){Te(this.cm.display.cursorDiv,a.cursors),Te(this.cm.display.selectionDiv,a.selection)},rememberSelection:function(){var a=window.getSelection();this.lastAnchorNode=a.anchorNode,this.lastAnchorOffset=a.anchorOffset,this.lastFocusNode=a.focusNode,this.lastFocusOffset=a.focusOffset},selectionInEditor:function(){var a=window.getSelection();if(!a.rangeCount)return!1;var b=a.getRangeAt(0).commonAncestorContainer;return Xg(this.div,b)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function a(){b.cm.state.focused&&(b.pollSelection(),b.polling.set(b.cm.options.pollInterval,a))}var b=this;this.selectionInEditor()?this.pollSelection():Eb(this.cm,function(){b.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,a)},selectionChanged:function(){var a=window.getSelection();return a.anchorNode!=this.lastAnchorNode||a.anchorOffset!=this.lastAnchorOffset||a.focusNode!=this.lastFocusNode||a.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var a=window.getSelection(),b=this.cm;this.rememberSelection();var c=ha(b,a.anchorNode,a.anchorOffset),d=ha(b,a.focusNode,a.focusOffset);c&&d&&Eb(b,function(){Aa(b.doc,na(c,d),Mg),(c.bad||d.bad)&&(b.curOp.selectionChanged=!0)})}},pollContent:function(){var a=this.cm,b=a.display,c=a.doc.sel.primary(),d=c.from(),e=c.to();if(d.lineb.viewTo-1)return!1;var f;if(d.line==b.viewFrom||0==(f=Nb(a,d.line)))var g=be(b.view[0].line),h=b.view[0].node;else var g=be(b.view[f].line),h=b.view[f-1].node.nextSibling;var i=Nb(a,e.line);if(i==b.view.length-1)var j=b.viewTo-1,k=b.lineDiv.lastChild;else var j=be(b.view[i+1].line)-1,k=b.view[i+1].node.previousSibling;for(var l=a.doc.splitLines(ja(a,h,k,g,j)),m=$d(a.doc,Nf(g,0),Nf(j,Zd(a.doc,j).text.length));l.length>1&&m.length>1;)if(Ge(l)==Ge(m))l.pop(),m.pop(),j--;else{if(l[0]!=m[0])break;l.shift(),m.shift(),g++}for(var n=0,o=0,p=l[0],q=m[0],r=Math.min(p.length,q.length);r>n&&p.charCodeAt(n)==q.charCodeAt(n);)++n;for(var s=Ge(l),t=Ge(m),u=Math.min(s.length-(1==l.length?n:0),t.length-(1==m.length?n:0));u>o&&s.charCodeAt(s.length-o-1)==t.charCodeAt(t.length-o-1);)++o;l[l.length-1]=s.slice(0,s.length-o),l[0]=l[0].slice(n);var v=Nf(g,n),w=Nf(j,m.length?Ge(m).length-o:0);return l.length>1||l[0]||Of(v,w)?(Gc(a.doc,l,v,w,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(a){this.cm.isReadOnly()?Fb(this.cm,Kb)(this.cm):a.data&&a.data!=a.startData&&Fb(this.cm,Z)(this.cm,a.data,0,a.sel)},setUneditable:function(a){a.contentEditable="false"},onKeyPress:function(a){a.preventDefault(),this.cm.isReadOnly()||Fb(this.cm,Z)(this.cm,String.fromCharCode(null==a.charCode?a.keyCode:a.charCode),0)},readOnlyChanged:function(a){this.div.contentEditable=String("nocursor"!=a)},onContextMenu:Ke,resetPosition:Ke,needsContentAttribute:!0},ea.prototype),a.inputStyles={textarea:ca,contenteditable:ea},ka.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(a){if(a==this)return!0;if(a.primIndex!=this.primIndex||a.ranges.length!=this.ranges.length)return!1;for(var b=0;b=0&&Of(a,d.to())<=0)return c}return-1}},la.prototype={from:function(){return X(this.anchor,this.head)},to:function(){return W(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Qf,Rf,Sf,Tf={left:0,right:0,top:0,bottom:0},Uf=null,Vf=0,Wf=0,Xf=0,Yf=null;uf?Yf=-.53:rf?Yf=15:yf?Yf=-.7:Af&&(Yf=-1/3);var Zf=function(a){var b=a.wheelDeltaX,c=a.wheelDeltaY;return null==b&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(b=a.detail),null==c&&a.detail&&a.axis==a.VERTICAL_AXIS?c=a.detail:null==c&&(c=a.wheelDelta),{x:b,y:c}};a.wheelEventPixels=function(a){var b=Zf(a);return b.x*=Yf,b.y*=Yf,b};var $f=new Ee,_f=null,ag=a.changeEnd=function(a){return a.text?Nf(a.from.line+a.text.length-1,Ge(a.text).length+(1==a.text.length?a.from.ch:0)):a.to};a.prototype={constructor:a,focus:function(){window.focus(),this.display.input.focus()},setOption:function(a,b){var c=this.options,d=c[a];(c[a]!=b||"mode"==a)&&(c[a]=b,cg.hasOwnProperty(a)&&Fb(this,cg[a])(this,b,d))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](Vc(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;cc&&(Oc(this,e.head.line,a,!0),c=e.head.line,d==this.doc.sel.primIndex&&Mc(this));else{var f=e.from(),g=e.to(),h=Math.max(c,f.line);c=Math.min(this.lastLine(),g.line-(g.ch?0:1))+1;for(var i=h;c>i;++i)Oc(this,i,a);var j=this.doc.sel.ranges;0==f.ch&&b.length==j.length&&j[d].from().ch>0&&wa(this.doc,d,new la(f,j[d].to()),Mg)}}}),getTokenAt:function(a,b){return Gd(this,a,b)},getLineTokens:function(a,b){return Gd(this,Nf(a),b,!0)},getTokenTypeAt:function(a){a=pa(this.doc,a);var b,c=Jd(this,Zd(this.doc,a.line)),d=0,e=(c.length-1)/2,f=a.ch;if(0==f)b=c[2];else for(;;){var g=d+e>>1;if((g?c[2*g-1]:0)>=f)e=g;else{if(!(c[2*g+1]h?b:0==h?null:b.slice(0,h-1)},getModeAt:function(b){var c=this.doc.mode;return c.innerMode?a.innerMode(c,this.getTokenAt(b).state).mode:c},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var c=[];if(!ig.hasOwnProperty(b))return c;var d=ig[b],e=this.getModeAt(a);if("string"==typeof e[b])d[e[b]]&&c.push(d[e[b]]);else if(e[b])for(var f=0;fe&&(a=e,d=!0),c=Zd(this.doc,a)}else c=a;return lb(this,c,{top:0,left:0},b||"page").top+(d?this.doc.height-de(c):0)},defaultTextHeight:function(){return tb(this.display)},defaultCharWidth:function(){return ub(this.display)},setGutterMarker:Gb(function(a,b,c){return Pc(this.doc,a,"gutter",function(a){var d=a.gutterMarkers||(a.gutterMarkers={});return d[b]=c,!c&&Pe(d)&&(a.gutterMarkers=null),!0})}),clearGutter:Gb(function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,Lb(b,d,"gutter"),Pe(c.gutterMarkers)&&(c.gutterMarkers=null)),++d})}),lineInfo:function(a){if("number"==typeof a){if(!ra(this.doc,a))return null;var b=a;if(a=Zd(this.doc,a),!a)return null}else{var b=be(a);if(null==b)return null}return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=ob(this,pa(this.doc,a));var g=a.bottom,h=a.left;if(b.style.position="absolute",b.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(b),f.sizer.appendChild(b),"over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&Jc(this,h,g,h+b.offsetWidth,g+b.offsetHeight)},triggerOnKeyDown:Gb(mc),triggerOnKeyPress:Gb(pc),triggerOnKeyUp:oc,execCommand:function(a){return lg.hasOwnProperty(a)?lg[a].call(null,this):void 0},triggerElectric:Gb(function(a){_(this,a)}),findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,g=pa(this.doc,a);b>f&&(g=Rc(this.doc,g,e,c,d),!g.hitSide);++f);return g},moveH:Gb(function(a,b){var c=this;c.extendSelectionsBy(function(d){return c.display.shift||c.doc.extend||d.empty()?Rc(c.doc,d.head,a,b,c.options.rtlMoveVisually):0>a?d.from():d.to()},Og)}),deleteH:Gb(function(a,b){var c=this.doc.sel,d=this.doc;c.somethingSelected()?d.replaceSelection("",null,"+delete"):Qc(this,function(c){var e=Rc(d,c.head,a,b,!1);return 0>a?{from:e,to:c.head}:{from:c.head,to:e}})}),findPosV:function(a,b,c,d){var e=1,f=d;0>b&&(e=-1,b=-b);for(var g=0,h=pa(this.doc,a);b>g;++g){var i=ob(this,h,"div");if(null==f?f=i.left:i.left=f,h=Sc(this,i,e,c),h.hitSide)break}return h},moveV:Gb(function(a,b){var c=this,d=this.doc,e=[],f=!c.display.shift&&!d.extend&&d.sel.somethingSelected();if(d.extendSelectionsBy(function(g){if(f)return 0>a?g.from():g.to();var h=ob(c,g.head,"div");null!=g.goalColumn&&(h.left=g.goalColumn),e.push(h.left);var i=Sc(c,h,a,b);return"page"==b&&g==d.sel.primary()&&Lc(c,null,nb(c,i,"div").top-h.top),i},Og),e.length)for(var g=0;g0&&h(c.charAt(d-1));)--d;for(;e.5)&&g(this),Ig(this,"refresh",this)}),swapDoc:Gb(function(a){var b=this.doc;return b.cm=null,Yd(this,a),ib(this),this.display.input.reset(),this.scrollTo(a.scrollLeft,a.scrollTop),this.curOp.forceScroll=!0,ye(this,"swapDoc",this,b),b}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},De(a);var bg=a.defaults={},cg=a.optionHandlers={},dg=a.Init={toString:function(){return"CodeMirror.Init"}};Tc("value","",function(a,b){a.setValue(b)},!0),Tc("mode",null,function(a,b){a.doc.modeOption=b,c(a)},!0),Tc("indentUnit",2,c,!0),Tc("indentWithTabs",!1),Tc("smartIndent",!0),Tc("tabSize",4,function(a){d(a),ib(a),Kb(a)},!0),Tc("lineSeparator",null,function(a,b){if(a.doc.lineSep=b,b){var c=[],d=a.doc.first;a.doc.iter(function(a){for(var e=0;;){var f=a.text.indexOf(b,e);if(-1==f)break;e=f+b.length,c.push(Nf(d,f))}d++});for(var e=c.length-1;e>=0;e--)Gc(a.doc,b,c[e],Nf(c[e].line,c[e].ch+b.length))}}),Tc("specialChars",/[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(b,c,d){b.state.specialChars=new RegExp(c.source+(c.test(" ")?"":"| "),"g"),d!=a.Init&&b.refresh()}),Tc("specialCharPlaceholder",Nd,function(a){a.refresh()},!0),Tc("electricChars",!0),Tc("inputStyle",Ef?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Tc("spellcheck",!1,function(a,b){a.getInputField().spellcheck=b},!0),Tc("rtlMoveVisually",!Hf),Tc("wholeLineUpdateBefore",!0),Tc("theme","default",function(a){h(a),i(a)},!0),Tc("keyMap","default",function(b,c,d){var e=Vc(c),f=d!=a.Init&&Vc(d);f&&f.detach&&f.detach(b,e),e.attach&&e.attach(b,f||null)}),Tc("extraKeys",null),Tc("lineWrapping",!1,e,!0),Tc("gutters",[],function(a){n(a.options),i(a)},!0),Tc("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?y(a.display)+"px":"0",a.refresh()},!0),Tc("coverGutterNextToScrollbar",!1,function(a){s(a)},!0),Tc("scrollbarStyle","native",function(a){r(a),s(a),a.display.scrollbars.setScrollTop(a.doc.scrollTop),a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0),Tc("lineNumbers",!1,function(a){n(a.options),i(a)},!0),Tc("firstLineNumber",1,i,!0),Tc("lineNumberFormatter",function(a){return a},i,!0),Tc("showCursorWhenSelecting",!1,Ia,!0),Tc("resetSelectionOnContextMenu",!0),Tc("lineWiseCopyCut",!0),Tc("readOnly",!1,function(a,b){"nocursor"==b?(sc(a),a.display.input.blur(),a.display.disabled=!0):a.display.disabled=!1,a.display.input.readOnlyChanged(b)}),Tc("disableInput",!1,function(a,b){b||a.display.input.reset()},!0),Tc("dragDrop",!0,Sb),Tc("allowDropFileTypes",null),Tc("cursorBlinkRate",530),Tc("cursorScrollMargin",0),Tc("cursorHeight",1,Ia,!0),Tc("singleCursorHeightPerLine",!0,Ia,!0),Tc("workTime",100),Tc("workDelay",100),Tc("flattenSpans",!0,d,!0),Tc("addModeClass",!1,d,!0),Tc("pollInterval",100),Tc("undoDepth",200,function(a,b){a.doc.history.undoDepth=b}),Tc("historyEventDelay",1250),Tc("viewportMargin",10,function(a){a.refresh()},!0),Tc("maxHighlightLength",1e4,d,!0),Tc("moveInputWithCursor",!0,function(a,b){b||a.display.input.resetPosition()}),Tc("tabindex",null,function(a,b){a.display.input.getField().tabIndex=b||""}),Tc("autofocus",null);var eg=a.modes={},fg=a.mimeModes={};a.defineMode=function(b,c){a.defaults.mode||"null"==b||(a.defaults.mode=b),arguments.length>2&&(c.dependencies=Array.prototype.slice.call(arguments,2)),eg[b]=c},a.defineMIME=function(a,b){fg[a]=b},a.resolveMode=function(b){if("string"==typeof b&&fg.hasOwnProperty(b))b=fg[b];else if(b&&"string"==typeof b.name&&fg.hasOwnProperty(b.name)){var c=fg[b.name];"string"==typeof c&&(c={name:c}),b=Le(c,b),b.name=c.name}else{if("string"==typeof b&&/^[\w\-]+\/[\w\-]+\+xml$/.test(b))return a.resolveMode("application/xml");if("string"==typeof b&&/^[\w\-]+\/[\w\-]+\+json$/.test(b))return a.resolveMode("application/json")}return"string"==typeof b?{name:b}:b||{name:"null"}},a.getMode=function(b,c){var c=a.resolveMode(c),d=eg[c.name];if(!d)return a.getMode(b,"text/plain");var e=d(b,c);if(gg.hasOwnProperty(c.name)){var f=gg[c.name];for(var g in f)f.hasOwnProperty(g)&&(e.hasOwnProperty(g)&&(e["_"+g]=e[g]),e[g]=f[g])}if(e.name=c.name,c.helperType&&(e.helperType=c.helperType),c.modeProps)for(var g in c.modeProps)e[g]=c.modeProps[g];return e},a.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),a.defineMIME("text/plain","null");var gg=a.modeExtensions={};a.extendMode=function(a,b){var c=gg.hasOwnProperty(a)?gg[a]:gg[a]={};Me(b,c)},a.defineExtension=function(b,c){a.prototype[b]=c},a.defineDocExtension=function(a,b){zg.prototype[a]=b},a.defineOption=Tc;var hg=[];a.defineInitHook=function(a){hg.push(a)};var ig=a.helpers={};a.registerHelper=function(b,c,d){ig.hasOwnProperty(b)||(ig[b]=a[b]={_global:[]}),ig[b][c]=d},a.registerGlobalHelper=function(b,c,d,e){a.registerHelper(b,c,e),ig[b]._global.push({pred:d,val:e})};var jg=a.copyState=function(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c},kg=a.startState=function(a,b,c){return a.startState?a.startState(b,c):!0};a.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);if(!c||c.mode==a)break;b=c.state,a=c.mode}return c||{mode:a,state:b}};var lg=a.commands={selectAll:function(a){a.setSelection(Nf(a.firstLine(),0),Nf(a.lastLine()),Mg)},singleSelection:function(a){a.setSelection(a.getCursor("anchor"),a.getCursor("head"),Mg)},killLine:function(a){Qc(a,function(b){if(b.empty()){var c=Zd(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.line0)e=new Nf(e.line,e.ch+1),a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),Nf(e.line,e.ch-2),e,"+transpose");else if(e.line>a.doc.first){var g=Zd(a.doc,e.line-1).text;g&&a.replaceRange(f.charAt(0)+a.doc.lineSeparator()+g.charAt(g.length-1),Nf(e.line-1,g.length-1),Nf(e.line,1),"+transpose")}c.push(new la(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){Eb(a,function(){for(var b=a.listSelections().length,c=0;b>c;c++){var d=a.listSelections()[c];a.replaceRange(a.doc.lineSeparator(),d.anchor,d.head,"+input"),a.indentLine(d.from().line+1,null,!0)}Mc(a)})},openLine:function(a){a.replaceSelection("\n","start")},toggleOverwrite:function(a){a.toggleOverwrite()}},mg=a.keyMap={};mg.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},mg.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},mg.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},mg.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},mg["default"]=Ff?mg.macDefault:mg.pcDefault,a.normalizeKeyMap=function(a){var b={};for(var c in a)if(a.hasOwnProperty(c)){var d=a[c];if(/^(name|fallthrough|(de|at)tach)$/.test(c))continue;if("..."==d){delete a[c];continue}for(var e=Ie(c.split(" "),Uc),f=0;f=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.posb},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);return b>-1?(this.pos=b,!0):void 0},backUp:function(a){this.pos-=a},column:function(){return this.lastColumnPos0?null:(d&&b!==!1&&(this.pos+=d[0].length),d)}var e=function(a){return c?a.toLowerCase():a},f=this.string.substr(this.pos,a.length);return e(f)==e(a)?(b!==!1&&(this.pos+=a.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}}};var rg=0,sg=a.TextMarker=function(a,b){this.lines=[],this.type=b,this.doc=a,this.id=++rg};De(sg),sg.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;if(b&&vb(a),Ce(this,"clear")){var c=this.find();c&&ye(this,"clear",c.from,c.to)}for(var d=null,e=null,f=0;fa.display.maxLineLength&&(a.display.maxLine=i,a.display.maxLineLength=j,a.display.maxLineChanged=!0)}null!=d&&a&&this.collapsed&&Kb(a,d,e+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&Da(a.doc)),a&&ye(a,"markerCleared",a,this),b&&xb(a),this.parent&&this.parent.clear()}},sg.prototype.find=function(a,b){null==a&&"bookmark"==this.type&&(a=1);for(var c,d,e=0;ec;++c){var e=this.lines[c];this.height-=e.height,Cd(e),ye(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.push.apply(a,this.lines)},insertInner:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0;da;++a)if(c(this.lines[a]))return!0}},Wd.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;ca){var f=Math.min(b,e-a),g=d.height;if(d.removeInner(a,f),this.height-=g-d.height,e==f&&(this.children.splice(c--,1),d.parent=null),0==(b-=f))break;a=0}else a-=e}if(this.size-b<25&&(this.children.length>1||!(this.children[0]instanceof Vd))){var h=[];this.collapse(h),this.children=[new Vd(h)],this.children[0].parent=this}},collapse:function(a){for(var b=0;b=a){if(e.insertInner(a,b,c),e.lines&&e.lines.length>50){for(var g=e.lines.length%25+25,h=g;h10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0;da){var g=Math.min(b,f-a);if(e.iterN(a,g,c))return!0;if(0==(b-=g))break;a=0}else a-=f}}};var yg=0,zg=a.Doc=function(a,b,c,d){if(!(this instanceof zg))return new zg(a,b,c,d);null==c&&(c=0),Wd.call(this,[new Vd([new vg("",null)])]),this.first=c,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=c;var e=Nf(c,0);this.sel=na(e),this.history=new fe(null),this.id=++yg,this.modeOption=b,this.lineSep=d,this.extend=!1,"string"==typeof a&&(a=this.splitLines(a)),Ud(this,{from:e,to:e,text:a}),Aa(this,na(e),Mg)};zg.prototype=Le(Wd.prototype,{constructor:zg,iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0;d=0;f--)Ac(this,d[f]);h?za(this,h):this.cm&&Mc(this.cm)}),undo:Hb(function(){Cc(this,"undo")}),redo:Hb(function(){Cc(this,"redo")}),undoSelection:Hb(function(){Cc(this,"undo",!0)}),redoSelection:Hb(function(){Cc(this,"redo",!0)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d=a.ch)&&b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){a=pa(this,a),b=pa(this,b);var d=[],e=a.line;return this.iter(a.line,b.line+1,function(f){var g=f.markedSpans;if(g)for(var h=0;h=i.to||null==i.from&&e!=a.line||null!=i.from&&e==b.line&&i.from>=b.ch||c&&!c(i.marker)||d.push(i.marker.parent||i.marker)}++e}),d},getAllMarks:function(){var a=[];return this.iter(function(b){var c=b.markedSpans;if(c)for(var d=0;da?(b=a,!0):(a-=f,void++c)}),pa(this,Nf(c,b))},indexFromPos:function(a){a=pa(this,a);var b=a.ch;if(a.lineb&&(b=a.from),null!=a.to&&a.toh||h>=b)return g+(b-f);g+=h-f,g+=c-g%c,f=h+1}},Qg=a.findColumn=function(a,b,c){for(var d=0,e=0;;){var f=a.indexOf(" ",d);-1==f&&(f=a.length);var g=f-d;if(f==a.length||e+g>=b)return d+Math.min(g,b-e);if(e+=f-d,e+=c-e%c,d=f+1,e>=b)return d}},Rg=[""],Sg=function(a){a.select()};Df?Sg=function(a){a.selectionStart=0,a.selectionEnd=a.value.length}:uf&&(Sg=function(a){try{a.select()}catch(b){}});var Tg,Ug=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Vg=a.isWordChar=function(a){return/\w/.test(a)||a>"€"&&(a.toUpperCase()!=a.toLowerCase()||Ug.test(a))},Wg=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;Tg=document.createRange?function(a,b,c,d){var e=document.createRange();return e.setEnd(d||a,c),e.setStart(a,b),e}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(e){return d}return d.collapse(!0),d.moveEnd("character",c),d.moveStart("character",b),d};var Xg=a.contains=function(a,b){if(3==b.nodeType&&(b=b.parentNode),a.contains)return a.contains(b);do if(11==b.nodeType&&(b=b.host),b==a)return!0;while(b=b.parentNode)};uf&&11>vf&&(Ue=function(){try{return document.activeElement}catch(a){return document.body}});var Yg,Zg,$g=a.rmClass=function(a,b){var c=a.className,d=Ve(b).exec(c);if(d){var e=c.slice(d.index+d[0].length);a.className=c.slice(0,d.index)+(e?d[1]+e:"")}},_g=a.addClass=function(a,b){var c=a.className;Ve(b).test(c)||(a.className+=(c?" ":"")+b)},ah=!1,bh=function(){if(uf&&9>vf)return!1;var a=Re("div");return"draggable"in a||"dragDrop"in a}(),ch=a.splitLines=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;d>=b;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)},dh=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},eh=function(){var a=Re("div");return"oncopy"in a?!0:(a.setAttribute("oncopy","return;"),"function"==typeof a.oncopy)}(),fh=null,gh=a.keyNames={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:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var a=0;10>a;a++)gh[a+48]=gh[a+96]=String(a);for(var a=65;90>=a;a++)gh[a]=String.fromCharCode(a);for(var a=1;12>=a;a++)gh[a+111]=gh[a+63235]="F"+a}();var hh,ih=function(){function a(a){return 247>=a?c.charAt(a):a>=1424&&1524>=a?"R":a>=1536&&1773>=a?d.charAt(a-1536):a>=1774&&2220>=a?"r":a>=8192&&8203>=a?"w":8204==a?"b":"L"}function b(a,b,c){this.level=a,this.from=b,this.to=c}var c="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",d="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,f=/[stwN]/,g=/[LRr]/,h=/[Lb1n]/,i=/[1n]/,j="L";return function(c){if(!e.test(c))return!1;for(var d,k=c.length,l=[],m=0;k>m;++m)l.push(d=a(c.charCodeAt(m)));for(var m=0,n=j;k>m;++m){var d=l[m];"m"==d?l[m]=n:n=d}for(var m=0,o=j;k>m;++m){var d=l[m];"1"==d&&"r"==o?l[m]="n":g.test(d)&&(o=d,"r"==d&&(l[m]="R"))}for(var m=1,n=l[0];k-1>m;++m){var d=l[m];"+"==d&&"1"==n&&"1"==l[m+1]?l[m]="1":","!=d||n!=l[m+1]||"1"!=n&&"n"!=n||(l[m]=n),n=d}for(var m=0;k>m;++m){var d=l[m];if(","==d)l[m]="N";else if("%"==d){for(var p=m+1;k>p&&"%"==l[p];++p);for(var q=m&&"!"==l[m-1]||k>p&&"1"==l[p]?"1":"N",r=m;p>r;++r)l[r]=q;m=p-1}}for(var m=0,o=j;k>m;++m){var d=l[m];"L"==o&&"1"==d?l[m]="L":g.test(d)&&(o=d)}for(var m=0;k>m;++m)if(f.test(l[m])){for(var p=m+1;k>p&&f.test(l[p]);++p);for(var s="L"==(m?l[m-1]:j),t="L"==(k>p?l[p]:j),q=s||t?"L":"R",r=m;p>r;++r)l[r]=q;m=p-1}for(var u,v=[],m=0;k>m;)if(h.test(l[m])){var w=m;for(++m;k>m&&h.test(l[m]);++m);v.push(new b(0,w,m))}else{var x=m,y=v.length;for(++m;k>m&&"L"!=l[m];++m);for(var r=x;m>r;)if(i.test(l[r])){r>x&&v.splice(y,0,new b(1,x,r));var z=r;for(++r;m>r&&i.test(l[r]);++r);v.splice(y,0,new b(2,z,r)),x=r}else++r;m>x&&v.splice(y,0,new b(1,x,m))}return 1==v[0].level&&(u=c.match(/^\s+/))&&(v[0].from=u[0].length,v.unshift(new b(0,0,u[0].length))),1==Ge(v).level&&(u=c.match(/\s+$/))&&(Ge(v).to-=u[0].length,v.push(new b(0,k-u[0].length,k))),2==v[0].level&&v.unshift(new b(1,v[0].to,v[0].to)),v[0].level!=Ge(v).level&&v.push(new b(v[0].level,k,k)),v}}();return a.version="5.18.0",a}); \ No newline at end of file diff --git a/media/editors/codemirror/mode/htmlmixed/htmlmixed.js b/media/editors/codemirror/mode/htmlmixed/htmlmixed.js index d74083ee1a360..eb21fcc1493f3 100644 --- a/media/editors/codemirror/mode/htmlmixed/htmlmixed.js +++ b/media/editors/codemirror/mode/htmlmixed/htmlmixed.js @@ -46,7 +46,7 @@ function getAttrValue(text, attr) { var match = text.match(getAttrRegexp(attr)) - return match ? match[2] : "" + return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : "" } function getTagRegexp(tagName, anchored) { diff --git a/media/editors/codemirror/mode/htmlmixed/htmlmixed.min.js b/media/editors/codemirror/mode/htmlmixed/htmlmixed.min.js index 8a07b32e554fb..ba025199eeb09 100644 --- a/media/editors/codemirror/mode/htmlmixed/htmlmixed.min.js +++ b/media/editors/codemirror/mode/htmlmixed/htmlmixed.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c){var d=a.current(),e=d.search(b);return e>-1?a.backUp(d.length-e):d.match(/<\/?$/)&&(a.backUp(d.length),a.match(b,!1)||a.match(d)),c}function c(a){var b=i[a];return b?b:i[a]=new RegExp("\\s+"+a+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")}function d(a,b){var d=a.match(c(b));return d?d[2]:""}function e(a,b){return new RegExp((b?"^":"")+"","i")}function f(a,b){for(var c in a)for(var d=b[c]||(b[c]=[]),e=a[c],f=e.length-1;f>=0;f--)d.unshift(e[f])}function g(a,b){for(var c=0;c\s\/]/.test(d.current())&&(h=f.htmlState.tagName&&f.htmlState.tagName.toLowerCase())&&k.hasOwnProperty(h))f.inTag=h+" ";else if(f.inTag&&m&&/>$/.test(d.current())){var n=/^([\S]+) (.*)/.exec(f.inTag);f.inTag=null;var o=">"==d.current()&&g(k[n[1]],n[2]),p=a.getMode(c,o),q=e(n[1],!0),r=e(n[1],!1);f.token=function(a,c){return a.match(q,!1)?(c.token=i,c.localState=c.localMode=null,null):b(a,r,c.localMode.token(a,c.localState))},f.localMode=p,f.localState=a.startState(p,j.indent(f.htmlState,""))}else f.inTag&&(f.inTag+=d.current(),d.eol()&&(f.inTag+=" "));return l}var j=a.getMode(c,{name:"xml",htmlMode:!0,multilineTagIndentFactor:d.multilineTagIndentFactor,multilineTagIndentPastTag:d.multilineTagIndentPastTag}),k={},l=d&&d.tags,m=d&&d.scriptTypes;if(f(h,k),l&&f(l,k),m)for(var n=m.length-1;n>=0;n--)k.script.unshift(["type",m[n].matches,m[n].mode]);return{startState:function(){var b=a.startState(j);return{token:i,inTag:null,localMode:null,localState:null,htmlState:b}},copyState:function(b){var c;return b.localState&&(c=a.copyState(b.localMode,b.localState)),{token:b.token,inTag:b.inTag,localMode:b.localMode,localState:c,htmlState:a.copyState(j,b.htmlState)}},token:function(a,b){return b.token(a,b)},indent:function(b,c){return!b.localMode||/^\s*<\//.test(c)?j.indent(b.htmlState,c):b.localMode.indent?b.localMode.indent(b.localState,c):a.Pass},innerMode:function(a){return{state:a.localState||a.htmlState,mode:a.localMode||j}}}},"xml","javascript","css"),a.defineMIME("text/html","htmlmixed")}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c){var d=a.current(),e=d.search(b);return e>-1?a.backUp(d.length-e):d.match(/<\/?$/)&&(a.backUp(d.length),a.match(b,!1)||a.match(d)),c}function c(a){var b=i[a];return b?b:i[a]=new RegExp("\\s+"+a+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")}function d(a,b){var d=a.match(c(b));return d?/^\s*(.*?)\s*$/.exec(d[2])[1]:""}function e(a,b){return new RegExp((b?"^":"")+"","i")}function f(a,b){for(var c in a)for(var d=b[c]||(b[c]=[]),e=a[c],f=e.length-1;f>=0;f--)d.unshift(e[f])}function g(a,b){for(var c=0;c\s\/]/.test(d.current())&&(h=f.htmlState.tagName&&f.htmlState.tagName.toLowerCase())&&k.hasOwnProperty(h))f.inTag=h+" ";else if(f.inTag&&m&&/>$/.test(d.current())){var n=/^([\S]+) (.*)/.exec(f.inTag);f.inTag=null;var o=">"==d.current()&&g(k[n[1]],n[2]),p=a.getMode(c,o),q=e(n[1],!0),r=e(n[1],!1);f.token=function(a,c){return a.match(q,!1)?(c.token=i,c.localState=c.localMode=null,null):b(a,r,c.localMode.token(a,c.localState))},f.localMode=p,f.localState=a.startState(p,j.indent(f.htmlState,""))}else f.inTag&&(f.inTag+=d.current(),d.eol()&&(f.inTag+=" "));return l}var j=a.getMode(c,{name:"xml",htmlMode:!0,multilineTagIndentFactor:d.multilineTagIndentFactor,multilineTagIndentPastTag:d.multilineTagIndentPastTag}),k={},l=d&&d.tags,m=d&&d.scriptTypes;if(f(h,k),l&&f(l,k),m)for(var n=m.length-1;n>=0;n--)k.script.unshift(["type",m[n].matches,m[n].mode]);return{startState:function(){var b=a.startState(j);return{token:i,inTag:null,localMode:null,localState:null,htmlState:b}},copyState:function(b){var c;return b.localState&&(c=a.copyState(b.localMode,b.localState)),{token:b.token,inTag:b.inTag,localMode:b.localMode,localState:c,htmlState:a.copyState(j,b.htmlState)}},token:function(a,b){return b.token(a,b)},indent:function(b,c){return!b.localMode||/^\s*<\//.test(c)?j.indent(b.htmlState,c):b.localMode.indent?b.localMode.indent(b.localState,c):a.Pass},innerMode:function(a){return{state:a.localState||a.htmlState,mode:a.localMode||j}}}},"xml","javascript","css"),a.defineMIME("text/html","htmlmixed")}); \ No newline at end of file diff --git a/media/editors/codemirror/mode/jade/jade.min.js b/media/editors/codemirror/mode/jade/jade.min.js deleted file mode 100644 index 1db0848b0756c..0000000000000 --- a/media/editors/codemirror/mode/jade/jade.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../javascript/javascript"),require("../css/css"),require("../htmlmixed/htmlmixed")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../javascript/javascript","../css/css","../htmlmixed/htmlmixed"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("jade",function(b){function c(){this.javaScriptLine=!1,this.javaScriptLineExcludesColon=!1,this.javaScriptArguments=!1,this.javaScriptArgumentsDepth=0,this.isInterpolating=!1,this.interpolationNesting=0,this.jsState=a.startState(Z),this.restOfLine="",this.isIncludeFiltered=!1,this.isEach=!1,this.lastTag="",this.scriptType="",this.isAttrs=!1,this.attrsNest=[],this.inAttributeName=!0,this.attributeIsType=!1,this.attrValue="",this.indentOf=1/0,this.indentToken="",this.innerMode=null,this.innerState=null,this.innerModeForLine=!1}function d(a,b){if(a.sol()&&(b.javaScriptLine=!1,b.javaScriptLineExcludesColon=!1),b.javaScriptLine){if(b.javaScriptLineExcludesColon&&":"===a.peek())return b.javaScriptLine=!1,void(b.javaScriptLineExcludesColon=!1);var c=Z.token(a,b.jsState);return a.eol()&&(b.javaScriptLine=!1),c||!0}}function e(a,b){if(b.javaScriptArguments){if(0===b.javaScriptArgumentsDepth&&"("!==a.peek())return void(b.javaScriptArguments=!1);if("("===a.peek()?b.javaScriptArgumentsDepth++:")"===a.peek()&&b.javaScriptArgumentsDepth--,0===b.javaScriptArgumentsDepth)return void(b.javaScriptArguments=!1);var c=Z.token(a,b.jsState);return c||!0}}function f(a){return a.match(/^yield\b/)?"keyword":void 0}function g(a){return a.match(/^(?:doctype) *([^\n]+)?/)?V:void 0}function h(a,b){return a.match("#{")?(b.isInterpolating=!0,b.interpolationNesting=0,"punctuation"):void 0}function i(a,b){if(b.isInterpolating){if("}"===a.peek()){if(b.interpolationNesting--,b.interpolationNesting<0)return a.next(),b.isInterpolating=!1,"punctuation"}else"{"===a.peek()&&b.interpolationNesting++;return Z.token(a,b.jsState)||!0}}function j(a,b){return a.match(/^case\b/)?(b.javaScriptLine=!0,U):void 0}function k(a,b){return a.match(/^when\b/)?(b.javaScriptLine=!0,b.javaScriptLineExcludesColon=!0,U):void 0}function l(a){return a.match(/^default\b/)?U:void 0}function m(a,b){return a.match(/^extends?\b/)?(b.restOfLine="string",U):void 0}function n(a,b){return a.match(/^append\b/)?(b.restOfLine="variable",U):void 0}function o(a,b){return a.match(/^prepend\b/)?(b.restOfLine="variable",U):void 0}function p(a,b){return a.match(/^block\b *(?:(prepend|append)\b)?/)?(b.restOfLine="variable",U):void 0}function q(a,b){return a.match(/^include\b/)?(b.restOfLine="string",U):void 0}function r(a,b){return a.match(/^include:([a-zA-Z0-9\-]+)/,!1)&&a.match("include")?(b.isIncludeFiltered=!0,U):void 0}function s(a,b){if(b.isIncludeFiltered){var c=B(a,b);return b.isIncludeFiltered=!1,b.restOfLine="string",c}}function t(a,b){return a.match(/^mixin\b/)?(b.javaScriptLine=!0,U):void 0}function u(a,b){return a.match(/^\+([-\w]+)/)?(a.match(/^\( *[-\w]+ *=/,!1)||(b.javaScriptArguments=!0,b.javaScriptArgumentsDepth=0),"variable"):a.match(/^\+#{/,!1)?(a.next(),b.mixinCallAfter=!0,h(a,b)):void 0}function v(a,b){return b.mixinCallAfter?(b.mixinCallAfter=!1,a.match(/^\( *[-\w]+ *=/,!1)||(b.javaScriptArguments=!0,b.javaScriptArgumentsDepth=0),!0):void 0}function w(a,b){return a.match(/^(if|unless|else if|else)\b/)?(b.javaScriptLine=!0,U):void 0}function x(a,b){return a.match(/^(- *)?(each|for)\b/)?(b.isEach=!0,U):void 0}function y(a,b){if(b.isEach){if(a.match(/^ in\b/))return b.javaScriptLine=!0,b.isEach=!1,U;if(a.sol()||a.eol())b.isEach=!1;else if(a.next()){for(;!a.match(/^ in\b/,!1)&&a.next(););return"variable"}}}function z(a,b){return a.match(/^while\b/)?(b.javaScriptLine=!0,U):void 0}function A(a,b){var c;return(c=a.match(/^(\w(?:[-:\w]*\w)?)\/?/))?(b.lastTag=c[1].toLowerCase(),"script"===b.lastTag&&(b.scriptType="application/javascript"),"tag"):void 0}function B(c,d){if(c.match(/^:([\w\-]+)/)){var e;return b&&b.innerModes&&(e=b.innerModes(c.current().substring(1))),e||(e=c.current().substring(1)),"string"==typeof e&&(e=a.getMode(b,e)),O(c,d,e),"atom"}}function C(a,b){return a.match(/^(!?=|-)/)?(b.javaScriptLine=!0,"punctuation"):void 0}function D(a){return a.match(/^#([\w-]+)/)?W:void 0}function E(a){return a.match(/^\.([\w-]+)/)?X:void 0}function F(a,b){return"("==a.peek()?(a.next(),b.isAttrs=!0,b.attrsNest=[],b.inAttributeName=!0,b.attrValue="",b.attributeIsType=!1,"punctuation"):void 0}function G(b,c){if(c.isAttrs){if(Y[b.peek()]&&c.attrsNest.push(Y[b.peek()]),c.attrsNest[c.attrsNest.length-1]===b.peek())c.attrsNest.pop();else if(b.eat(")"))return c.isAttrs=!1,"punctuation";if(c.inAttributeName&&b.match(/^[^=,\)!]+/))return("="===b.peek()||"!"===b.peek())&&(c.inAttributeName=!1,c.jsState=a.startState(Z),"script"===c.lastTag&&"type"===b.current().trim().toLowerCase()?c.attributeIsType=!0:c.attributeIsType=!1),"attribute";var d=Z.token(b,c.jsState);if(c.attributeIsType&&"string"===d&&(c.scriptType=b.current().toString()),0===c.attrsNest.length&&("string"===d||"variable"===d||"keyword"===d))try{return Function("","var x "+c.attrValue.replace(/,\s*$/,"").replace(/^!/,"")),c.inAttributeName=!0,c.attrValue="",b.backUp(b.current().length),G(b,c)}catch(e){}return c.attrValue+=b.current(),d||!0}}function H(a,b){return a.match(/^&attributes\b/)?(b.javaScriptArguments=!0,b.javaScriptArgumentsDepth=0,"keyword"):void 0}function I(a){return a.sol()&&a.eatSpace()?"indent":void 0}function J(a,b){return a.match(/^ *\/\/(-)?([^\n]*)/)?(b.indentOf=a.indentation(),b.indentToken="comment","comment"):void 0}function K(a){return a.match(/^: */)?"colon":void 0}function L(a,b){return a.match(/^(?:\| ?| )([^\n]+)/)?"string":a.match(/^(<[^\n]*)/,!1)?(O(a,b,"htmlmixed"),b.innerModeForLine=!0,P(a,b,!0)):void 0}function M(a,b){if(a.eat(".")){var c=null;return"script"===b.lastTag&&-1!=b.scriptType.toLowerCase().indexOf("javascript")?c=b.scriptType.toLowerCase().replace(/"|'/g,""):"style"===b.lastTag&&(c="css"),O(a,b,c),"dot"}}function N(a){return a.next(),null}function O(c,d,e){e=a.mimeModes[e]||e,e=b.innerModes?b.innerModes(e)||e:e,e=a.mimeModes[e]||e,e=a.getMode(b,e),d.indentOf=c.indentation(),e&&"null"!==e.name?d.innerMode=e:d.indentToken="string"}function P(b,c,d){return b.indentation()>c.indentOf||c.innerModeForLine&&!b.sol()||d?c.innerMode?(c.innerState||(c.innerState=c.innerMode.startState?a.startState(c.innerMode,b.indentation()):{}),b.hideFirstChars(c.indentOf+2,function(){return c.innerMode.token(b,c.innerState)||!0})):(b.skipToEnd(),c.indentToken):void(b.sol()&&(c.indentOf=1/0,c.indentToken=null,c.innerMode=null,c.innerState=null))}function Q(a,b){if(a.sol()&&(b.restOfLine=""),b.restOfLine){a.skipToEnd();var c=b.restOfLine;return b.restOfLine="",c}}function R(){return new c}function S(a){return a.copy()}function T(a,b){var c=P(a,b)||Q(a,b)||i(a,b)||s(a,b)||y(a,b)||G(a,b)||d(a,b)||e(a,b)||v(a,b)||f(a,b)||g(a,b)||h(a,b)||j(a,b)||k(a,b)||l(a,b)||m(a,b)||n(a,b)||o(a,b)||p(a,b)||q(a,b)||r(a,b)||t(a,b)||u(a,b)||w(a,b)||x(a,b)||z(a,b)||A(a,b)||B(a,b)||C(a,b)||D(a,b)||E(a,b)||F(a,b)||H(a,b)||I(a,b)||L(a,b)||J(a,b)||K(a,b)||M(a,b)||N(a,b);return c===!0?null:c}var U="keyword",V="meta",W="builtin",X="qualifier",Y={"{":"}","(":")","[":"]"},Z=a.getMode(b,"javascript");return c.prototype.copy=function(){var b=new c;return b.javaScriptLine=this.javaScriptLine,b.javaScriptLineExcludesColon=this.javaScriptLineExcludesColon,b.javaScriptArguments=this.javaScriptArguments,b.javaScriptArgumentsDepth=this.javaScriptArgumentsDepth,b.isInterpolating=this.isInterpolating,b.interpolationNesting=this.interpolationNesting,b.jsState=a.copyState(Z,this.jsState),b.innerMode=this.innerMode,this.innerMode&&this.innerState&&(b.innerState=a.copyState(this.innerMode,this.innerState)),b.restOfLine=this.restOfLine,b.isIncludeFiltered=this.isIncludeFiltered,b.isEach=this.isEach,b.lastTag=this.lastTag,b.scriptType=this.scriptType,b.isAttrs=this.isAttrs,b.attrsNest=this.attrsNest.slice(),b.inAttributeName=this.inAttributeName,b.attributeIsType=this.attributeIsType,b.attrValue=this.attrValue,b.indentOf=this.indentOf,b.indentToken=this.indentToken,b.innerModeForLine=this.innerModeForLine,b},{startState:R,copyState:S,token:T}},"javascript","css","htmlmixed"),a.defineMIME("text/x-jade","jade")}); \ No newline at end of file diff --git a/media/editors/codemirror/mode/javascript/javascript.js b/media/editors/codemirror/mode/javascript/javascript.js index 3909c85e6ac2f..d7c5716b08dde 100644 --- a/media/editors/codemirror/mode/javascript/javascript.js +++ b/media/editors/codemirror/mode/javascript/javascript.js @@ -1,8 +1,6 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: http://codemirror.net/LICENSE -// TODO actually recognize syntax of TypeScript constructs - (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); @@ -216,7 +214,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var bracket = brackets.indexOf(ch); if (bracket >= 0 && bracket < 3) { if (!depth) { ++pos; break; } - if (--depth == 0) break; + if (--depth == 0) { if (ch == "(") sawSomething = true; break; } } else if (bracket >= 3 && bracket < 6) { ++depth; } else if (wordRE.test(ch)) { @@ -463,8 +461,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "variable") {cx.marked = "property"; return cont();} } function objprop(type, value) { - if (type == "async") return cont(objprop); - if (type == "variable" || cx.style == "keyword") { + if (type == "async") { + cx.marked = "property"; + return cont(objprop); + } else if (type == "variable" || cx.style == "keyword") { cx.marked = "property"; if (value == "get" || value == "set") return cont(getterSetter); return cont(afterprop); @@ -479,6 +479,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return cont(expression, expect("]"), afterprop); } else if (type == "spread") { return cont(expression); + } else if (type == ":") { + return pass(afterprop) } } function getterSetter(type) { @@ -525,6 +527,23 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function typeexpr(type) { if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);} + if (type == "{") return cont(commasep(typeprop, "}")) + if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType) + } + function maybeReturnType(type) { + if (type == "=>") return cont(typeexpr) + } + function typeprop(type) { + if (type == "variable" || cx.style == "keyword") { + cx.marked = "property" + return cont(typeprop) + } else if (type == ":") { + return cont(typeexpr) + } + } + function typearg(type) { + if (type == "variable") return cont(typearg) + else if (type == ":") return cont(typeexpr) } function afterType(type, value) { if (value == "<") return cont(commasep(typeexpr, ">"), afterType) @@ -593,7 +612,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "variable") {register(value); return cont(classNameAfter);} } function classNameAfter(type, value) { - if (value == "extends") return cont(expression, classNameAfter); + if (value == "extends") return cont(isTS ? typeexpr : expression, classNameAfter); if (type == "{") return cont(pushlex("}"), classBody, poplex); } function classBody(type, value) { @@ -641,7 +660,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function arrayLiteral(type) { if (type == "]") return cont(); - return pass(expressionNoComma, commasep(expressionNoComma, "]")); + return pass(commasep(expressionNoComma, "]")); } function isContinuedStatement(state, textAfter) { diff --git a/media/editors/codemirror/mode/javascript/javascript.min.js b/media/editors/codemirror/mode/javascript/javascript.min.js index 32467586b2eb7..6469b80bd5718 100644 --- a/media/editors/codemirror/mode/javascript/javascript.min.js +++ b/media/editors/codemirror/mode/javascript/javascript.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c){return/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(b.lastType)||"quasi"==b.lastType&&/\{\s*$/.test(a.string.slice(0,a.pos-(c||0)))}a.defineMode("javascript",function(c,d){function e(a){for(var b,c=!1,d=!1;null!=(b=a.next());){if(!c){if("/"==b&&!d)return;"["==b?d=!0:d&&"]"==b&&(d=!1)}c=!c&&"\\"==b}}function f(a,b,c){return ta=a,ua=c,b}function g(a,c){var d=a.next();if('"'==d||"'"==d)return c.tokenize=h(d),c.tokenize(a,c);if("."==d&&a.match(/^\d+(?:[eE][+\-]?\d+)?/))return f("number","number");if("."==d&&a.match(".."))return f("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(d))return f(d);if("="==d&&a.eat(">"))return f("=>","operator");if("0"==d&&a.eat(/x/i))return a.eatWhile(/[\da-f]/i),f("number","number");if("0"==d&&a.eat(/o/i))return a.eatWhile(/[0-7]/i),f("number","number");if("0"==d&&a.eat(/b/i))return a.eatWhile(/[01]/i),f("number","number");if(/\d/.test(d))return a.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),f("number","number");if("/"==d)return a.eat("*")?(c.tokenize=i,i(a,c)):a.eat("/")?(a.skipToEnd(),f("comment","comment")):b(a,c,1)?(e(a),a.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),f("regexp","string-2")):(a.eatWhile(Ca),f("operator","operator",a.current()));if("`"==d)return c.tokenize=j,j(a,c);if("#"==d)return a.skipToEnd(),f("error","error");if(Ca.test(d))return a.eatWhile(Ca),f("operator","operator",a.current());if(Aa.test(d)){a.eatWhile(Aa);var g=a.current(),k=Ba.propertyIsEnumerable(g)&&Ba[g];return k&&"."!=c.lastType?f(k.type,k.style,g):f("variable","variable",g)}}function h(a){return function(b,c){var d,e=!1;if(xa&&"@"==b.peek()&&b.match(Da))return c.tokenize=g,f("jsonld-keyword","meta");for(;null!=(d=b.next())&&(d!=a||e);)e=!e&&"\\"==d;return e||(c.tokenize=g),f("string","string")}}function i(a,b){for(var c,d=!1;c=a.next();){if("/"==c&&d){b.tokenize=g;break}d="*"==c}return f("comment","comment")}function j(a,b){for(var c,d=!1;null!=(c=a.next());){if(!d&&("`"==c||"$"==c&&a.eat("{"))){b.tokenize=g;break}d=!d&&"\\"==c}return f("quasi","string-2",a.current())}function k(a,b){b.fatArrowAt&&(b.fatArrowAt=null);var c=a.string.indexOf("=>",a.start);if(!(0>c)){for(var d=0,e=!1,f=c-1;f>=0;--f){var g=a.string.charAt(f),h=Ea.indexOf(g);if(h>=0&&3>h){if(!d){++f;break}if(0==--d)break}else if(h>=3&&6>h)++d;else if(Aa.test(g))e=!0;else{if(/["'\/]/.test(g))return;if(e&&!d){++f;break}}}e&&!d&&(b.fatArrowAt=f)}}function l(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,null!=d&&(this.align=d)}function m(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0;for(var d=a.context;d;d=d.prev)for(var c=d.vars;c;c=c.next)if(c.name==b)return!0}function n(a,b,c,d,e){var f=a.cc;for(Ga.state=a,Ga.stream=e,Ga.marked=null,Ga.cc=f,Ga.style=b,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);;){var g=f.length?f.pop():ya?x:w;if(g(c,d)){for(;f.length&&f[f.length-1].lex;)f.pop()();return Ga.marked?Ga.marked:"variable"==c&&m(a,d)?"variable-2":b}}}function o(){for(var a=arguments.length-1;a>=0;a--)Ga.cc.push(arguments[a])}function p(){return o.apply(null,arguments),!0}function q(a){function b(b){for(var c=b;c;c=c.next)if(c.name==a)return!0;return!1}var c=Ga.state;if(Ga.marked="def",c.context){if(b(c.localVars))return;c.localVars={name:a,next:c.localVars}}else{if(b(c.globalVars))return;d.globalVars&&(c.globalVars={name:a,next:c.globalVars})}}function r(){Ga.state.context={prev:Ga.state.context,vars:Ga.state.localVars},Ga.state.localVars=Ha}function s(){Ga.state.localVars=Ga.state.context.vars,Ga.state.context=Ga.state.context.prev}function t(a,b){var c=function(){var c=Ga.state,d=c.indented;if("stat"==c.lexical.type)d=c.lexical.indented;else for(var e=c.lexical;e&&")"==e.type&&e.align;e=e.prev)d=e.indented;c.lexical=new l(d,Ga.stream.column(),a,null,c.lexical,b)};return c.lex=!0,c}function u(){var a=Ga.state;a.lexical.prev&&(")"==a.lexical.type&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function v(a){function b(c){return c==a?p():";"==a?o():p(b)}return b}function w(a,b){return"var"==a?p(t("vardef",b.length),X,v(";"),u):"keyword a"==a?p(t("form"),x,w,u):"keyword b"==a?p(t("form"),w,u):"{"==a?p(t("}"),S,u):";"==a?p():"if"==a?("else"==Ga.state.lexical.info&&Ga.state.cc[Ga.state.cc.length-1]==u&&Ga.state.cc.pop()(),p(t("form"),x,w,u,aa)):"function"==a?p(ga):"for"==a?p(t("form"),ba,w,u):"variable"==a?p(t("stat"),L):"switch"==a?p(t("form"),x,t("}","switch"),v("{"),S,u,u):"case"==a?p(x,v(":")):"default"==a?p(v(":")):"catch"==a?p(t("form"),r,v("("),ha,v(")"),w,u,s):"class"==a?p(t("form"),ia,u):"export"==a?p(t("stat"),ma,u):"import"==a?p(t("stat"),na,u):"module"==a?p(t("form"),Y,t("}"),v("{"),S,u,u):"async"==a?p(w):o(t("stat"),x,v(";"),u)}function x(a){return z(a,!1)}function y(a){return z(a,!0)}function z(a,b){if(Ga.state.fatArrowAt==Ga.stream.start){var c=b?H:G;if("("==a)return p(r,t(")"),Q(Y,")"),u,v("=>"),c,s);if("variable"==a)return o(r,Y,v("=>"),c,s)}var d=b?D:C;return Fa.hasOwnProperty(a)?p(d):"function"==a?p(ga,d):"keyword c"==a||"async"==a?p(b?B:A):"("==a?p(t(")"),A,v(")"),u,d):"operator"==a||"spread"==a?p(b?y:x):"["==a?p(t("]"),ra,u,d):"{"==a?R(N,"}",null,d):"quasi"==a?o(E,d):"new"==a?p(I(b)):p()}function A(a){return a.match(/[;\}\)\],]/)?o():o(x)}function B(a){return a.match(/[;\}\)\],]/)?o():o(y)}function C(a,b){return","==a?p(x):D(a,b,!1)}function D(a,b,c){var d=0==c?C:D,e=0==c?x:y;return"=>"==a?p(r,c?H:G,s):"operator"==a?/\+\+|--/.test(b)?p(d):"?"==b?p(x,v(":"),e):p(e):"quasi"==a?o(E,d):";"!=a?"("==a?R(y,")","call",d):"."==a?p(M,d):"["==a?p(t("]"),A,v("]"),u,d):void 0:void 0}function E(a,b){return"quasi"!=a?o():"${"!=b.slice(b.length-2)?p(E):p(x,F)}function F(a){return"}"==a?(Ga.marked="string-2",Ga.state.tokenize=j,p(E)):void 0}function G(a){return k(Ga.stream,Ga.state),o("{"==a?w:x)}function H(a){return k(Ga.stream,Ga.state),o("{"==a?w:y)}function I(a){return function(b){return"."==b?p(a?K:J):o(a?y:x)}}function J(a,b){return"target"==b?(Ga.marked="keyword",p(C)):void 0}function K(a,b){return"target"==b?(Ga.marked="keyword",p(D)):void 0}function L(a){return":"==a?p(u,w):o(C,v(";"),u)}function M(a){return"variable"==a?(Ga.marked="property",p()):void 0}function N(a,b){return"async"==a?p(N):"variable"==a||"keyword"==Ga.style?(Ga.marked="property",p("get"==b||"set"==b?O:P)):"number"==a||"string"==a?(Ga.marked=xa?"property":Ga.style+" property",p(P)):"jsonld-keyword"==a?p(P):"modifier"==a?p(N):"["==a?p(x,v("]"),P):"spread"==a?p(x):void 0}function O(a){return"variable"!=a?o(P):(Ga.marked="property",p(ga))}function P(a){return":"==a?p(y):"("==a?o(ga):void 0}function Q(a,b){function c(d,e){if(","==d){var f=Ga.state.lexical;return"call"==f.info&&(f.pos=(f.pos||0)+1),p(function(c,d){return c==b||d==b?o():o(a)},c)}return d==b||e==b?p():p(v(b))}return function(d,e){return d==b||e==b?p():o(a,c)}}function R(a,b,c){for(var d=3;d"),W):"["==a?p(v("]"),W):void 0}function X(){return o(Y,T,$,_)}function Y(a,b){return"modifier"==a?p(Y):"variable"==a?(q(b),p()):"spread"==a?p(Y):"["==a?R(Y,"]"):"{"==a?R(Z,"}"):void 0}function Z(a,b){return"variable"!=a||Ga.stream.match(/^\s*:/,!1)?("variable"==a&&(Ga.marked="property"),"spread"==a?p(Y):"}"==a?o():p(v(":"),Y,$)):(q(b),p($))}function $(a,b){return"="==b?p(y):void 0}function _(a){return","==a?p(X):void 0}function aa(a,b){return"keyword b"==a&&"else"==b?p(t("form","else"),w,u):void 0}function ba(a){return"("==a?p(t(")"),ca,v(")"),u):void 0}function ca(a){return"var"==a?p(X,v(";"),ea):";"==a?p(ea):"variable"==a?p(da):o(x,v(";"),ea)}function da(a,b){return"in"==b||"of"==b?(Ga.marked="keyword",p(x)):p(C,ea)}function ea(a,b){return";"==a?p(fa):"in"==b||"of"==b?(Ga.marked="keyword",p(x)):o(x,v(";"),fa)}function fa(a){")"!=a&&p(x)}function ga(a,b){return"*"==b?(Ga.marked="keyword",p(ga)):"variable"==a?(q(b),p(ga)):"("==a?p(r,t(")"),Q(ha,")"),u,T,w,s):void 0}function ha(a){return"spread"==a?p(ha):o(Y,T,U)}function ia(a,b){return"variable"==a?(q(b),p(ja)):void 0}function ja(a,b){return"extends"==b?p(x,ja):"{"==a?p(t("}"),ka,u):void 0}function ka(a,b){return"variable"==a||"keyword"==Ga.style?"static"==b?(Ga.marked="keyword",p(ka)):(Ga.marked="property","get"==b||"set"==b?p(la,ga,ka):p(ga,ka)):"*"==b?(Ga.marked="keyword",p(ka)):";"==a?p(ka):"}"==a?p():void 0}function la(a){return"variable"!=a?o():(Ga.marked="property",p())}function ma(a,b){return"*"==b?(Ga.marked="keyword",p(qa,v(";"))):"default"==b?(Ga.marked="keyword",p(x,v(";"))):o(w)}function na(a){return"string"==a?p():o(oa,qa)}function oa(a,b){return"{"==a?R(oa,"}"):("variable"==a&&q(b),"*"==b&&(Ga.marked="keyword"),p(pa))}function pa(a,b){return"as"==b?(Ga.marked="keyword",p(oa)):void 0}function qa(a,b){return"from"==b?(Ga.marked="keyword",p(x)):void 0}function ra(a){return"]"==a?p():o(y,Q(y,"]"))}function sa(a,b){return"operator"==a.lastType||","==a.lastType||Ca.test(b.charAt(0))||/[,.]/.test(b.charAt(0))}var ta,ua,va=c.indentUnit,wa=d.statementIndent,xa=d.jsonld,ya=d.json||xa,za=d.typescript,Aa=d.wordCharacters||/[\w$\xa1-\uffff]/,Ba=function(){function a(a){return{type:a,style:"keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("operator"),f={type:"atom",style:"atom"},g={"if":a("if"),"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":d,"break":d,"continue":d,"new":a("new"),"delete":d,"throw":d,"debugger":d,"var":a("var"),"const":a("var"),let:a("var"),"function":a("function"),"catch":a("catch"),"for":a("for"),"switch":a("switch"),"case":a("case"),"default":a("default"),"in":e,"typeof":e,"instanceof":e,"true":f,"false":f,"null":f,undefined:f,NaN:f,Infinity:f,"this":a("this"),"class":a("class"),"super":a("atom"),"yield":d,"export":a("export"),"import":a("import"),"extends":d,await:d,async:a("async")};if(za){var h={type:"variable",style:"variable-3"},i={"interface":a("class"),"implements":d,namespace:d,module:a("module"),"enum":a("module"),"public":a("modifier"),"private":a("modifier"),"protected":a("modifier"),"abstract":a("modifier"),as:e,string:h,number:h,"boolean":h,any:h};for(var j in i)g[j]=i[j]}return g}(),Ca=/[+\-*&%=<>!?|~^]/,Da=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,Ea="([{}])",Fa={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},Ga={state:null,column:null,marked:null,cc:null},Ha={name:"this",next:{name:"arguments"}};return u.lex=!0,{startState:function(a){var b={tokenize:g,lastType:"sof",cc:[],lexical:new l((a||0)-va,0,"block",!1),localVars:d.localVars,context:d.localVars&&{vars:d.localVars},indented:a||0};return d.globalVars&&"object"==typeof d.globalVars&&(b.globalVars=d.globalVars),b},token:function(a,b){if(a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation(),k(a,b)),b.tokenize!=i&&a.eatSpace())return null;var c=b.tokenize(a,b);return"comment"==ta?c:(b.lastType="operator"!=ta||"++"!=ua&&"--"!=ua?ta:"incdec",n(b,c,ta,ua,a))},indent:function(b,c){if(b.tokenize==i)return a.Pass;if(b.tokenize!=g)return 0;var e=c&&c.charAt(0),f=b.lexical;if(!/^\s*else\b/.test(c))for(var h=b.cc.length-1;h>=0;--h){var j=b.cc[h];if(j==u)f=f.prev;else if(j!=aa)break}"stat"==f.type&&"}"==e&&(f=f.prev),wa&&")"==f.type&&"stat"==f.prev.type&&(f=f.prev);var k=f.type,l=e==k;return"vardef"==k?f.indented+("operator"==b.lastType||","==b.lastType?f.info+1:0):"form"==k&&"{"==e?f.indented:"form"==k?f.indented+va:"stat"==k?f.indented+(sa(b,c)?wa||va:0):"switch"!=f.info||l||0==d.doubleIndentSwitch?f.align?f.column+(l?0:1):f.indented+(l?0:va):f.indented+(/^(?:case|default)\b/.test(c)?va:2*va)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:ya?null:"/*",blockCommentEnd:ya?null:"*/",lineComment:ya?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:ya?"json":"javascript",jsonldMode:xa,jsonMode:ya,expressionAllowed:b,skipExpression:function(a){var b=a.cc[a.cc.length-1];(b==x||b==y)&&a.cc.pop()}}}),a.registerHelper("wordChars","javascript",/[\w$]/),a.defineMIME("text/javascript","javascript"),a.defineMIME("text/ecmascript","javascript"),a.defineMIME("application/javascript","javascript"),a.defineMIME("application/x-javascript","javascript"),a.defineMIME("application/ecmascript","javascript"),a.defineMIME("application/json",{name:"javascript",json:!0}),a.defineMIME("application/x-json",{name:"javascript",json:!0}),a.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),a.defineMIME("text/typescript",{name:"javascript",typescript:!0}),a.defineMIME("application/typescript",{name:"javascript",typescript:!0})}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c){return/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(b.lastType)||"quasi"==b.lastType&&/\{\s*$/.test(a.string.slice(0,a.pos-(c||0)))}a.defineMode("javascript",function(c,d){function e(a){for(var b,c=!1,d=!1;null!=(b=a.next());){if(!c){if("/"==b&&!d)return;"["==b?d=!0:d&&"]"==b&&(d=!1)}c=!c&&"\\"==b}}function f(a,b,c){return wa=a,xa=c,b}function g(a,c){var d=a.next();if('"'==d||"'"==d)return c.tokenize=h(d),c.tokenize(a,c);if("."==d&&a.match(/^\d+(?:[eE][+\-]?\d+)?/))return f("number","number");if("."==d&&a.match(".."))return f("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(d))return f(d);if("="==d&&a.eat(">"))return f("=>","operator");if("0"==d&&a.eat(/x/i))return a.eatWhile(/[\da-f]/i),f("number","number");if("0"==d&&a.eat(/o/i))return a.eatWhile(/[0-7]/i),f("number","number");if("0"==d&&a.eat(/b/i))return a.eatWhile(/[01]/i),f("number","number");if(/\d/.test(d))return a.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),f("number","number");if("/"==d)return a.eat("*")?(c.tokenize=i,i(a,c)):a.eat("/")?(a.skipToEnd(),f("comment","comment")):b(a,c,1)?(e(a),a.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),f("regexp","string-2")):(a.eatWhile(Fa),f("operator","operator",a.current()));if("`"==d)return c.tokenize=j,j(a,c);if("#"==d)return a.skipToEnd(),f("error","error");if(Fa.test(d))return a.eatWhile(Fa),f("operator","operator",a.current());if(Da.test(d)){a.eatWhile(Da);var g=a.current(),k=Ea.propertyIsEnumerable(g)&&Ea[g];return k&&"."!=c.lastType?f(k.type,k.style,g):f("variable","variable",g)}}function h(a){return function(b,c){var d,e=!1;if(Aa&&"@"==b.peek()&&b.match(Ga))return c.tokenize=g,f("jsonld-keyword","meta");for(;null!=(d=b.next())&&(d!=a||e);)e=!e&&"\\"==d;return e||(c.tokenize=g),f("string","string")}}function i(a,b){for(var c,d=!1;c=a.next();){if("/"==c&&d){b.tokenize=g;break}d="*"==c}return f("comment","comment")}function j(a,b){for(var c,d=!1;null!=(c=a.next());){if(!d&&("`"==c||"$"==c&&a.eat("{"))){b.tokenize=g;break}d=!d&&"\\"==c}return f("quasi","string-2",a.current())}function k(a,b){b.fatArrowAt&&(b.fatArrowAt=null);var c=a.string.indexOf("=>",a.start);if(!(0>c)){for(var d=0,e=!1,f=c-1;f>=0;--f){var g=a.string.charAt(f),h=Ha.indexOf(g);if(h>=0&&3>h){if(!d){++f;break}if(0==--d){"("==g&&(e=!0);break}}else if(h>=3&&6>h)++d;else if(Da.test(g))e=!0;else{if(/["'\/]/.test(g))return;if(e&&!d){++f;break}}}e&&!d&&(b.fatArrowAt=f)}}function l(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,null!=d&&(this.align=d)}function m(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0;for(var d=a.context;d;d=d.prev)for(var c=d.vars;c;c=c.next)if(c.name==b)return!0}function n(a,b,c,d,e){var f=a.cc;for(Ja.state=a,Ja.stream=e,Ja.marked=null,Ja.cc=f,Ja.style=b,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);;){var g=f.length?f.pop():Ba?x:w;if(g(c,d)){for(;f.length&&f[f.length-1].lex;)f.pop()();return Ja.marked?Ja.marked:"variable"==c&&m(a,d)?"variable-2":b}}}function o(){for(var a=arguments.length-1;a>=0;a--)Ja.cc.push(arguments[a])}function p(){return o.apply(null,arguments),!0}function q(a){function b(b){for(var c=b;c;c=c.next)if(c.name==a)return!0;return!1}var c=Ja.state;if(Ja.marked="def",c.context){if(b(c.localVars))return;c.localVars={name:a,next:c.localVars}}else{if(b(c.globalVars))return;d.globalVars&&(c.globalVars={name:a,next:c.globalVars})}}function r(){Ja.state.context={prev:Ja.state.context,vars:Ja.state.localVars},Ja.state.localVars=Ka}function s(){Ja.state.localVars=Ja.state.context.vars,Ja.state.context=Ja.state.context.prev}function t(a,b){var c=function(){var c=Ja.state,d=c.indented;if("stat"==c.lexical.type)d=c.lexical.indented;else for(var e=c.lexical;e&&")"==e.type&&e.align;e=e.prev)d=e.indented;c.lexical=new l(d,Ja.stream.column(),a,null,c.lexical,b)};return c.lex=!0,c}function u(){var a=Ja.state;a.lexical.prev&&(")"==a.lexical.type&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function v(a){function b(c){return c==a?p():";"==a?o():p(b)}return b}function w(a,b){return"var"==a?p(t("vardef",b.length),$,v(";"),u):"keyword a"==a?p(t("form"),x,w,u):"keyword b"==a?p(t("form"),w,u):"{"==a?p(t("}"),S,u):";"==a?p():"if"==a?("else"==Ja.state.lexical.info&&Ja.state.cc[Ja.state.cc.length-1]==u&&Ja.state.cc.pop()(),p(t("form"),x,w,u,da)):"function"==a?p(ja):"for"==a?p(t("form"),ea,w,u):"variable"==a?p(t("stat"),L):"switch"==a?p(t("form"),x,t("}","switch"),v("{"),S,u,u):"case"==a?p(x,v(":")):"default"==a?p(v(":")):"catch"==a?p(t("form"),r,v("("),ka,v(")"),w,u,s):"class"==a?p(t("form"),la,u):"export"==a?p(t("stat"),pa,u):"import"==a?p(t("stat"),qa,u):"module"==a?p(t("form"),_,t("}"),v("{"),S,u,u):"async"==a?p(w):o(t("stat"),x,v(";"),u)}function x(a){return z(a,!1)}function y(a){return z(a,!0)}function z(a,b){if(Ja.state.fatArrowAt==Ja.stream.start){var c=b?H:G;if("("==a)return p(r,t(")"),Q(_,")"),u,v("=>"),c,s);if("variable"==a)return o(r,_,v("=>"),c,s)}var d=b?D:C;return Ia.hasOwnProperty(a)?p(d):"function"==a?p(ja,d):"keyword c"==a||"async"==a?p(b?B:A):"("==a?p(t(")"),A,v(")"),u,d):"operator"==a||"spread"==a?p(b?y:x):"["==a?p(t("]"),ua,u,d):"{"==a?R(N,"}",null,d):"quasi"==a?o(E,d):"new"==a?p(I(b)):p()}function A(a){return a.match(/[;\}\)\],]/)?o():o(x)}function B(a){return a.match(/[;\}\)\],]/)?o():o(y)}function C(a,b){return","==a?p(x):D(a,b,!1)}function D(a,b,c){var d=0==c?C:D,e=0==c?x:y;return"=>"==a?p(r,c?H:G,s):"operator"==a?/\+\+|--/.test(b)?p(d):"?"==b?p(x,v(":"),e):p(e):"quasi"==a?o(E,d):";"!=a?"("==a?R(y,")","call",d):"."==a?p(M,d):"["==a?p(t("]"),A,v("]"),u,d):void 0:void 0}function E(a,b){return"quasi"!=a?o():"${"!=b.slice(b.length-2)?p(E):p(x,F)}function F(a){return"}"==a?(Ja.marked="string-2",Ja.state.tokenize=j,p(E)):void 0}function G(a){return k(Ja.stream,Ja.state),o("{"==a?w:x)}function H(a){return k(Ja.stream,Ja.state),o("{"==a?w:y)}function I(a){return function(b){return"."==b?p(a?K:J):o(a?y:x)}}function J(a,b){return"target"==b?(Ja.marked="keyword",p(C)):void 0}function K(a,b){return"target"==b?(Ja.marked="keyword",p(D)):void 0}function L(a){return":"==a?p(u,w):o(C,v(";"),u)}function M(a){return"variable"==a?(Ja.marked="property",p()):void 0}function N(a,b){return"async"==a?(Ja.marked="property",p(N)):"variable"==a||"keyword"==Ja.style?(Ja.marked="property",p("get"==b||"set"==b?O:P)):"number"==a||"string"==a?(Ja.marked=Aa?"property":Ja.style+" property",p(P)):"jsonld-keyword"==a?p(P):"modifier"==a?p(N):"["==a?p(x,v("]"),P):"spread"==a?p(x):":"==a?o(P):void 0}function O(a){return"variable"!=a?o(P):(Ja.marked="property",p(ja))}function P(a){return":"==a?p(y):"("==a?o(ja):void 0}function Q(a,b){function c(d,e){if(","==d){var f=Ja.state.lexical;return"call"==f.info&&(f.pos=(f.pos||0)+1),p(function(c,d){return c==b||d==b?o():o(a)},c)}return d==b||e==b?p():p(v(b))}return function(d,e){return d==b||e==b?p():o(a,c)}}function R(a,b,c){for(var d=3;d"==a?p(V):void 0}function X(a){return"variable"==a||"keyword"==Ja.style?(Ja.marked="property",p(X)):":"==a?p(V):void 0}function Y(a){return"variable"==a?p(Y):":"==a?p(V):void 0}function Z(a,b){return"<"==b?p(Q(V,">"),Z):"["==a?p(v("]"),Z):void 0}function $(){return o(_,T,ba,ca)}function _(a,b){return"modifier"==a?p(_):"variable"==a?(q(b),p()):"spread"==a?p(_):"["==a?R(_,"]"):"{"==a?R(aa,"}"):void 0}function aa(a,b){return"variable"!=a||Ja.stream.match(/^\s*:/,!1)?("variable"==a&&(Ja.marked="property"),"spread"==a?p(_):"}"==a?o():p(v(":"),_,ba)):(q(b),p(ba))}function ba(a,b){return"="==b?p(y):void 0}function ca(a){return","==a?p($):void 0}function da(a,b){return"keyword b"==a&&"else"==b?p(t("form","else"),w,u):void 0}function ea(a){return"("==a?p(t(")"),fa,v(")"),u):void 0}function fa(a){return"var"==a?p($,v(";"),ha):";"==a?p(ha):"variable"==a?p(ga):o(x,v(";"),ha)}function ga(a,b){return"in"==b||"of"==b?(Ja.marked="keyword",p(x)):p(C,ha)}function ha(a,b){return";"==a?p(ia):"in"==b||"of"==b?(Ja.marked="keyword",p(x)):o(x,v(";"),ia)}function ia(a){")"!=a&&p(x)}function ja(a,b){return"*"==b?(Ja.marked="keyword",p(ja)):"variable"==a?(q(b),p(ja)):"("==a?p(r,t(")"),Q(ka,")"),u,T,w,s):void 0}function ka(a){return"spread"==a?p(ka):o(_,T,U)}function la(a,b){return"variable"==a?(q(b),p(ma)):void 0}function ma(a,b){return"extends"==b?p(Ca?V:x,ma):"{"==a?p(t("}"),na,u):void 0}function na(a,b){return"variable"==a||"keyword"==Ja.style?"static"==b?(Ja.marked="keyword",p(na)):(Ja.marked="property","get"==b||"set"==b?p(oa,ja,na):p(ja,na)):"*"==b?(Ja.marked="keyword",p(na)):";"==a?p(na):"}"==a?p():void 0}function oa(a){return"variable"!=a?o():(Ja.marked="property",p())}function pa(a,b){return"*"==b?(Ja.marked="keyword",p(ta,v(";"))):"default"==b?(Ja.marked="keyword",p(x,v(";"))):o(w)}function qa(a){return"string"==a?p():o(ra,ta)}function ra(a,b){return"{"==a?R(ra,"}"):("variable"==a&&q(b),"*"==b&&(Ja.marked="keyword"),p(sa))}function sa(a,b){return"as"==b?(Ja.marked="keyword",p(ra)):void 0}function ta(a,b){return"from"==b?(Ja.marked="keyword",p(x)):void 0}function ua(a){return"]"==a?p():o(Q(y,"]"))}function va(a,b){return"operator"==a.lastType||","==a.lastType||Fa.test(b.charAt(0))||/[,.]/.test(b.charAt(0))}var wa,xa,ya=c.indentUnit,za=d.statementIndent,Aa=d.jsonld,Ba=d.json||Aa,Ca=d.typescript,Da=d.wordCharacters||/[\w$\xa1-\uffff]/,Ea=function(){function a(a){return{type:a,style:"keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("operator"),f={type:"atom",style:"atom"},g={"if":a("if"),"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":d,"break":d,"continue":d,"new":a("new"),"delete":d,"throw":d,"debugger":d,"var":a("var"),"const":a("var"),let:a("var"),"function":a("function"),"catch":a("catch"),"for":a("for"),"switch":a("switch"),"case":a("case"),"default":a("default"),"in":e,"typeof":e,"instanceof":e,"true":f,"false":f,"null":f,undefined:f,NaN:f,Infinity:f,"this":a("this"),"class":a("class"),"super":a("atom"),"yield":d,"export":a("export"),"import":a("import"),"extends":d,await:d,async:a("async")};if(Ca){var h={type:"variable",style:"variable-3"},i={"interface":a("class"),"implements":d,namespace:d,module:a("module"),"enum":a("module"),"public":a("modifier"),"private":a("modifier"),"protected":a("modifier"),"abstract":a("modifier"),as:e,string:h,number:h,"boolean":h,any:h};for(var j in i)g[j]=i[j]}return g}(),Fa=/[+\-*&%=<>!?|~^]/,Ga=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,Ha="([{}])",Ia={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},Ja={state:null,column:null,marked:null,cc:null},Ka={name:"this",next:{name:"arguments"}};return u.lex=!0,{startState:function(a){var b={tokenize:g,lastType:"sof",cc:[],lexical:new l((a||0)-ya,0,"block",!1),localVars:d.localVars,context:d.localVars&&{vars:d.localVars},indented:a||0};return d.globalVars&&"object"==typeof d.globalVars&&(b.globalVars=d.globalVars),b},token:function(a,b){if(a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation(),k(a,b)),b.tokenize!=i&&a.eatSpace())return null;var c=b.tokenize(a,b);return"comment"==wa?c:(b.lastType="operator"!=wa||"++"!=xa&&"--"!=xa?wa:"incdec",n(b,c,wa,xa,a))},indent:function(b,c){if(b.tokenize==i)return a.Pass;if(b.tokenize!=g)return 0;var e=c&&c.charAt(0),f=b.lexical;if(!/^\s*else\b/.test(c))for(var h=b.cc.length-1;h>=0;--h){var j=b.cc[h];if(j==u)f=f.prev;else if(j!=da)break}"stat"==f.type&&"}"==e&&(f=f.prev),za&&")"==f.type&&"stat"==f.prev.type&&(f=f.prev);var k=f.type,l=e==k;return"vardef"==k?f.indented+("operator"==b.lastType||","==b.lastType?f.info+1:0):"form"==k&&"{"==e?f.indented:"form"==k?f.indented+ya:"stat"==k?f.indented+(va(b,c)?za||ya:0):"switch"!=f.info||l||0==d.doubleIndentSwitch?f.align?f.column+(l?0:1):f.indented+(l?0:ya):f.indented+(/^(?:case|default)\b/.test(c)?ya:2*ya)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:Ba?null:"/*",blockCommentEnd:Ba?null:"*/",lineComment:Ba?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:Ba?"json":"javascript",jsonldMode:Aa,jsonMode:Ba,expressionAllowed:b,skipExpression:function(a){var b=a.cc[a.cc.length-1];(b==x||b==y)&&a.cc.pop()}}}),a.registerHelper("wordChars","javascript",/[\w$]/),a.defineMIME("text/javascript","javascript"),a.defineMIME("text/ecmascript","javascript"),a.defineMIME("application/javascript","javascript"),a.defineMIME("application/x-javascript","javascript"),a.defineMIME("application/ecmascript","javascript"),a.defineMIME("application/json",{name:"javascript",json:!0}),a.defineMIME("application/x-json",{name:"javascript",json:!0}),a.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),a.defineMIME("text/typescript",{name:"javascript",typescript:!0}),a.defineMIME("application/typescript",{name:"javascript",typescript:!0})}); \ No newline at end of file diff --git a/media/editors/codemirror/mode/jsx/jsx.js b/media/editors/codemirror/mode/jsx/jsx.js index aff01b8d35566..45c3024aba303 100644 --- a/media/editors/codemirror/mode/jsx/jsx.js +++ b/media/editors/codemirror/mode/jsx/jsx.js @@ -144,4 +144,5 @@ }, "xml", "javascript") CodeMirror.defineMIME("text/jsx", "jsx") + CodeMirror.defineMIME("text/typescript-jsx", {name: "jsx", base: {name: "javascript", typescript: true}}) }); diff --git a/media/editors/codemirror/mode/jsx/jsx.min.js b/media/editors/codemirror/mode/jsx/jsx.min.js index 4e32c33f25846..5c440027b6af2 100644 --- a/media/editors/codemirror/mode/jsx/jsx.min.js +++ b/media/editors/codemirror/mode/jsx/jsx.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c,d){this.state=a,this.mode=b,this.depth=c,this.prev=d}function c(d){return new b(a.copyState(d.mode,d.state),d.mode,d.depth,d.prev&&c(d.prev))}a.defineMode("jsx",function(d,e){function f(a){var b=a.tagName;a.tagName=null;var c=j.indent(a,"");return a.tagName=b,c}function g(a,b){return b.context.mode==j?h(a,b,b.context):i(a,b,b.context)}function h(c,e,h){if(2==h.depth)return c.match(/^.*?\*\//)?h.depth=1:c.skipToEnd(),"comment";if("{"==c.peek()){j.skipAttribute(h.state);var i=f(h.state),l=h.state.context;if(l&&c.match(/^[^>]*>\s*$/,!1)){for(;l.prev&&!l.startOfLine;)l=l.prev;l.startOfLine?i-=d.indentUnit:h.prev.state.lexical&&(i=h.prev.state.lexical.indented)}else 1==h.depth&&(i+=d.indentUnit);return e.context=new b(a.startState(k,i),k,0,e.context),null}if(1==h.depth){if("<"==c.peek())return j.skipAttribute(h.state),e.context=new b(a.startState(j,f(h.state)),j,0,e.context),null;if(c.match("//"))return c.skipToEnd(),"comment";if(c.match("/*"))return h.depth=2,g(c,e)}var m,n=j.token(c,h.state),o=c.current();return/\btag\b/.test(n)?/>$/.test(o)?h.state.context?h.depth=0:e.context=e.context.prev:/^-1&&c.backUp(o.length-m),n}function i(c,d,e){if("<"==c.peek()&&k.expressionAllowed(c,e.state))return k.skipExpression(e.state),d.context=new b(a.startState(j,k.indent(e.state,"")),j,0,d.context),null;var f=k.token(c,e.state);if(!f&&null!=e.depth){var g=c.current();"{"==g?e.depth++:"}"==g&&0==--e.depth&&(d.context=d.context.prev)}return f}var j=a.getMode(d,{name:"xml",allowMissing:!0,multilineTagIndentPastTag:!1}),k=a.getMode(d,e&&e.base||"javascript");return{startState:function(){return{context:new b(a.startState(k),k)}},copyState:function(a){return{context:c(a.context)}},token:g,indent:function(a,b,c){return a.context.mode.indent(a.context.state,b,c)},innerMode:function(a){return a.context}}},"xml","javascript"),a.defineMIME("text/jsx","jsx")}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c,d){this.state=a,this.mode=b,this.depth=c,this.prev=d}function c(d){return new b(a.copyState(d.mode,d.state),d.mode,d.depth,d.prev&&c(d.prev))}a.defineMode("jsx",function(d,e){function f(a){var b=a.tagName;a.tagName=null;var c=j.indent(a,"");return a.tagName=b,c}function g(a,b){return b.context.mode==j?h(a,b,b.context):i(a,b,b.context)}function h(c,e,h){if(2==h.depth)return c.match(/^.*?\*\//)?h.depth=1:c.skipToEnd(),"comment";if("{"==c.peek()){j.skipAttribute(h.state);var i=f(h.state),l=h.state.context;if(l&&c.match(/^[^>]*>\s*$/,!1)){for(;l.prev&&!l.startOfLine;)l=l.prev;l.startOfLine?i-=d.indentUnit:h.prev.state.lexical&&(i=h.prev.state.lexical.indented)}else 1==h.depth&&(i+=d.indentUnit);return e.context=new b(a.startState(k,i),k,0,e.context),null}if(1==h.depth){if("<"==c.peek())return j.skipAttribute(h.state),e.context=new b(a.startState(j,f(h.state)),j,0,e.context),null;if(c.match("//"))return c.skipToEnd(),"comment";if(c.match("/*"))return h.depth=2,g(c,e)}var m,n=j.token(c,h.state),o=c.current();return/\btag\b/.test(n)?/>$/.test(o)?h.state.context?h.depth=0:e.context=e.context.prev:/^-1&&c.backUp(o.length-m),n}function i(c,d,e){if("<"==c.peek()&&k.expressionAllowed(c,e.state))return k.skipExpression(e.state),d.context=new b(a.startState(j,k.indent(e.state,"")),j,0,d.context),null;var f=k.token(c,e.state);if(!f&&null!=e.depth){var g=c.current();"{"==g?e.depth++:"}"==g&&0==--e.depth&&(d.context=d.context.prev)}return f}var j=a.getMode(d,{name:"xml",allowMissing:!0,multilineTagIndentPastTag:!1}),k=a.getMode(d,e&&e.base||"javascript");return{startState:function(){return{context:new b(a.startState(k),k)}},copyState:function(a){return{context:c(a.context)}},token:g,indent:function(a,b,c){return a.context.mode.indent(a.context.state,b,c)},innerMode:function(a){return a.context}}},"xml","javascript"),a.defineMIME("text/jsx","jsx"),a.defineMIME("text/typescript-jsx",{name:"jsx",base:{name:"javascript",typescript:!0}})}); \ No newline at end of file diff --git a/media/editors/codemirror/mode/livescript/livescript.js b/media/editors/codemirror/mode/livescript/livescript.js index 4b26e04619cd6..1e363f87699c7 100644 --- a/media/editors/codemirror/mode/livescript/livescript.js +++ b/media/editors/codemirror/mode/livescript/livescript.js @@ -50,7 +50,7 @@ startState: function(){ return { next: 'start', - lastToken: null + lastToken: {style: null, indent: 0, content: ""} }; }, token: function(stream, state){ diff --git a/media/editors/codemirror/mode/livescript/livescript.min.js b/media/editors/codemirror/mode/livescript/livescript.min.js index eae94dc1bd162..d544456bca644 100644 --- a/media/editors/codemirror/mode/livescript/livescript.min.js +++ b/media/editors/codemirror/mode/livescript/livescript.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("livescript",function(){var a=function(a,b){var c=b.next||"start";if(c){b.next=b.next;var d=f[c];if(d.splice){for(var e=0;e|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*"+b+")?))\\s*$"),d="(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))",e={token:"string",regex:".+"},f={start:[{token:"comment.doc",regex:"/\\*",next:"comment"},{token:"comment",regex:"#.*"},{token:"keyword",regex:"(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)"+d},{token:"constant.language",regex:"(?:true|false|yes|no|on|off|null|void|undefined)"+d},{token:"invalid.illegal",regex:"(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)"+d},{token:"language.support.class",regex:"(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)"+d},{token:"language.support.function",regex:"(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)"+d},{token:"variable.language",regex:"(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)"+d},{token:"identifier",regex:b+"\\s*:(?![:=])"},{token:"variable",regex:b},{token:"keyword.operator",regex:"(?:\\.{3}|\\s+\\?)"},{token:"keyword.variable",regex:"(?:@+|::|\\.\\.)",next:"key"},{token:"keyword.operator",regex:"\\.\\s*",next:"key"},{token:"string",regex:"\\\\\\S[^\\s,;)}\\]]*"},{token:"string.doc",regex:"'''",next:"qdoc"},{token:"string.doc",regex:'"""',next:"qqdoc"},{token:"string",regex:"'",next:"qstring"},{token:"string",regex:'"',next:"qqstring"},{token:"string",regex:"`",next:"js"},{token:"string",regex:"<\\[",next:"words"},{token:"string.regex",regex:"//",next:"heregex"},{token:"string.regex",regex:"\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}",next:"key"},{token:"constant.numeric",regex:"(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)"},{token:"lparen",regex:"[({[]"},{token:"rparen",regex:"[)}\\]]",next:"key"},{token:"keyword.operator",regex:"\\S+"},{token:"text",regex:"\\s+"}],heregex:[{token:"string.regex",regex:".*?//[gimy$?]{0,4}",next:"start"},{token:"string.regex",regex:"\\s*#{"},{token:"comment.regex",regex:"\\s+(?:#.*)?"},{token:"string.regex",regex:"\\S+"}],key:[{token:"keyword.operator",regex:"[.?@!]+"},{token:"identifier",regex:b,next:"start"},{token:"text",regex:"",next:"start"}],comment:[{token:"comment.doc",regex:".*?\\*/",next:"start"},{token:"comment.doc",regex:".+"}],qdoc:[{token:"string",regex:".*?'''",next:"key"},e],qqdoc:[{token:"string",regex:'.*?"""',next:"key"},e],qstring:[{token:"string",regex:"[^\\\\']*(?:\\\\.[^\\\\']*)*'",next:"key"},e],qqstring:[{token:"string",regex:'[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',next:"key"},e],js:[{token:"string",regex:"[^\\\\`]*(?:\\\\.[^\\\\`]*)*`",next:"key"},e],words:[{token:"string",regex:".*?\\]>",next:"key"},e]};for(var g in f){var h=f[g];if(h.splice)for(var i=0,j=h.length;j>i;++i){var k=h[i];"string"==typeof k.regex&&(f[g][i].regex=new RegExp("^"+k.regex))}else"string"==typeof k.regex&&(f[g].regex=new RegExp("^"+h.regex))}a.defineMIME("text/x-livescript","livescript")}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("livescript",function(){var a=function(a,b){var c=b.next||"start";if(c){b.next=b.next;var d=f[c];if(d.splice){for(var e=0;e|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*"+b+")?))\\s*$"),d="(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))",e={token:"string",regex:".+"},f={start:[{token:"comment.doc",regex:"/\\*",next:"comment"},{token:"comment",regex:"#.*"},{token:"keyword",regex:"(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)"+d},{token:"constant.language",regex:"(?:true|false|yes|no|on|off|null|void|undefined)"+d},{token:"invalid.illegal",regex:"(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)"+d},{token:"language.support.class",regex:"(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)"+d},{token:"language.support.function",regex:"(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)"+d},{token:"variable.language",regex:"(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)"+d},{token:"identifier",regex:b+"\\s*:(?![:=])"},{token:"variable",regex:b},{token:"keyword.operator",regex:"(?:\\.{3}|\\s+\\?)"},{token:"keyword.variable",regex:"(?:@+|::|\\.\\.)",next:"key"},{token:"keyword.operator",regex:"\\.\\s*",next:"key"},{token:"string",regex:"\\\\\\S[^\\s,;)}\\]]*"},{token:"string.doc",regex:"'''",next:"qdoc"},{token:"string.doc",regex:'"""',next:"qqdoc"},{token:"string",regex:"'",next:"qstring"},{token:"string",regex:'"',next:"qqstring"},{token:"string",regex:"`",next:"js"},{token:"string",regex:"<\\[",next:"words"},{token:"string.regex",regex:"//",next:"heregex"},{token:"string.regex",regex:"\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}",next:"key"},{token:"constant.numeric",regex:"(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)"},{token:"lparen",regex:"[({[]"},{token:"rparen",regex:"[)}\\]]",next:"key"},{token:"keyword.operator",regex:"\\S+"},{token:"text",regex:"\\s+"}],heregex:[{token:"string.regex",regex:".*?//[gimy$?]{0,4}",next:"start"},{token:"string.regex",regex:"\\s*#{"},{token:"comment.regex",regex:"\\s+(?:#.*)?"},{token:"string.regex",regex:"\\S+"}],key:[{token:"keyword.operator",regex:"[.?@!]+"},{token:"identifier",regex:b,next:"start"},{token:"text",regex:"",next:"start"}],comment:[{token:"comment.doc",regex:".*?\\*/",next:"start"},{token:"comment.doc",regex:".+"}],qdoc:[{token:"string",regex:".*?'''",next:"key"},e],qqdoc:[{token:"string",regex:'.*?"""',next:"key"},e],qstring:[{token:"string",regex:"[^\\\\']*(?:\\\\.[^\\\\']*)*'",next:"key"},e],qqstring:[{token:"string",regex:'[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',next:"key"},e],js:[{token:"string",regex:"[^\\\\`]*(?:\\\\.[^\\\\`]*)*`",next:"key"},e],words:[{token:"string",regex:".*?\\]>",next:"key"},e]};for(var g in f){var h=f[g];if(h.splice)for(var i=0,j=h.length;j>i;++i){var k=h[i];"string"==typeof k.regex&&(f[g][i].regex=new RegExp("^"+k.regex))}else"string"==typeof k.regex&&(f[g].regex=new RegExp("^"+h.regex))}a.defineMIME("text/x-livescript","livescript")}); \ No newline at end of file diff --git a/media/editors/codemirror/mode/meta.js b/media/editors/codemirror/mode/meta.js index eb25e242dda34..2e9ac7ce4b24b 100644 --- a/media/editors/codemirror/mode/meta.js +++ b/media/editors/codemirror/mode/meta.js @@ -66,7 +66,7 @@ {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]}, {name: "HTTP", mime: "message/http", mode: "http"}, {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]}, - {name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]}, + {name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]}, {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]}, {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]}, {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"], diff --git a/media/editors/codemirror/mode/meta.min.js b/media/editors/codemirror/mode/meta.min.js index b273cc2c57478..aa542f018f08d 100644 --- a/media/editors/codemirror/mode/meta.min.js +++ b/media/editors/codemirror/mode/meta.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../lib/codemirror")):"function"==typeof define&&define.amd?define(["../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["pgp"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists.txt$/},{name:"CoffeeScript",mime:"text/x-coffeescript",mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history).md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"]},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Jade",mime:"text/x-jade",mode:"jade",ext:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"null",mode:"jinja2"},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mime:"text/n-triples",mode:"ntriples",ext:["nt"]},{name:"Objective C",mime:"text/x-objectivec",mode:"clike",ext:["m","mm"],alias:["objective-c","objc"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mime:"application/x-httpd-php",mode:"php",ext:["php","php3","php4","php5","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mime:"text/x-sh",mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki ",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mime:"text/x-yaml",mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]}];for(var b=0;b-1&&b.substring(e+1,b.length);return f?a.findModeByExtension(f):void 0},a.findModeByName=function(b){b=b.toLowerCase();for(var c=0;c-1&&b.substring(e+1,b.length);return f?a.findModeByExtension(f):void 0},a.findModeByName=function(b){b=b.toLowerCase();for(var c=0;cc.indentOf||c.innerModeForLine&&!b.sol()||d?c.innerMode?(c.innerState||(c.innerState=c.innerMode.startState?a.startState(c.innerMode,b.indentation()):{}),b.hideFirstChars(c.indentOf+2,function(){return c.innerMode.token(b,c.innerState)||!0})):(b.skipToEnd(),c.indentToken):void(b.sol()&&(c.indentOf=1/0,c.indentToken=null,c.innerMode=null,c.innerState=null))}function Q(a,b){if(a.sol()&&(b.restOfLine=""),b.restOfLine){a.skipToEnd();var c=b.restOfLine;return b.restOfLine="",c}}function R(){return new c}function S(a){return a.copy()}function T(a,b){var c=P(a,b)||Q(a,b)||i(a,b)||s(a,b)||y(a,b)||G(a,b)||d(a,b)||e(a,b)||v(a,b)||f(a,b)||g(a,b)||h(a,b)||j(a,b)||k(a,b)||l(a,b)||m(a,b)||n(a,b)||o(a,b)||p(a,b)||q(a,b)||r(a,b)||t(a,b)||u(a,b)||w(a,b)||x(a,b)||z(a,b)||A(a,b)||B(a,b)||C(a,b)||D(a,b)||E(a,b)||F(a,b)||H(a,b)||I(a,b)||L(a,b)||J(a,b)||K(a,b)||M(a,b)||N(a,b);return c===!0?null:c}var U="keyword",V="meta",W="builtin",X="qualifier",Y={"{":"}","(":")","[":"]"},Z=a.getMode(b,"javascript");return c.prototype.copy=function(){var b=new c;return b.javaScriptLine=this.javaScriptLine,b.javaScriptLineExcludesColon=this.javaScriptLineExcludesColon,b.javaScriptArguments=this.javaScriptArguments,b.javaScriptArgumentsDepth=this.javaScriptArgumentsDepth,b.isInterpolating=this.isInterpolating,b.interpolationNesting=this.interpolationNesting,b.jsState=a.copyState(Z,this.jsState),b.innerMode=this.innerMode,this.innerMode&&this.innerState&&(b.innerState=a.copyState(this.innerMode,this.innerState)),b.restOfLine=this.restOfLine,b.isIncludeFiltered=this.isIncludeFiltered,b.isEach=this.isEach,b.lastTag=this.lastTag,b.scriptType=this.scriptType,b.isAttrs=this.isAttrs,b.attrsNest=this.attrsNest.slice(),b.inAttributeName=this.inAttributeName,b.attributeIsType=this.attributeIsType,b.attrValue=this.attrValue,b.indentOf=this.indentOf,b.indentToken=this.indentToken,b.innerModeForLine=this.innerModeForLine,b},{startState:R,copyState:S,token:T}},"javascript","css","htmlmixed"),a.defineMIME("text/x-pug","pug"),a.defineMIME("text/x-jade","pug")}); \ No newline at end of file diff --git a/media/editors/codemirror/mode/python/python.js b/media/editors/codemirror/mode/python/python.js index be65ad76876c7..efeed7f15434c 100644 --- a/media/editors/codemirror/mode/python/python.js +++ b/media/editors/codemirror/mode/python/python.js @@ -55,7 +55,7 @@ if (parserConf.extra_builtins != undefined) myBuiltins = myBuiltins.concat(parserConf.extra_builtins); - var py3 = parserConf.version && parseInt(parserConf.version, 10) == 3 + var py3 = !(parserConf.version && Number(parserConf.version) < 3) if (py3) { // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/; @@ -185,7 +185,7 @@ } function tokenStringFactory(delimiter) { - while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) + while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) delimiter = delimiter.substr(1); var singleline = delimiter.length == 1; diff --git a/media/editors/codemirror/mode/python/python.min.js b/media/editors/codemirror/mode/python/python.min.js index 0b4a8fbcb1159..dadbcc9dfc4bc 100644 --- a/media/editors/codemirror/mode/python/python.min.js +++ b/media/editors/codemirror/mode/python/python.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){return new RegExp("^(("+a.join(")|(")+"))\\b")}function c(a){return a.scopes[a.scopes.length-1]}var d=b(["and","or","not","is"]),e=["as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","lambda","pass","raise","return","try","while","with","yield","in"],f=["abs","all","any","bin","bool","bytearray","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip","__import__","NotImplemented","Ellipsis","__debug__"];a.registerHelper("hintWords","python",e.concat(f)),a.defineMode("python",function(g,h){function i(a,b){if(a.sol()&&(b.indent=a.indentation()),a.sol()&&"py"==c(b).type){var d=c(b).offset;if(a.eatSpace()){var e=a.indentation();return e>d?l(b):d>e&&n(a,b)&&(b.errorToken=!0),null}var f=j(a,b);return d>0&&n(a,b)&&(f+=" "+p),f}return j(a,b)}function j(a,b){if(a.eatSpace())return null;var c=a.peek();if("#"==c)return a.skipToEnd(),"comment";if(a.match(/^[0-9\.]/,!1)){var e=!1;if(a.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)&&(e=!0),a.match(/^\d+\.\d*/)&&(e=!0),a.match(/^\.\d+/)&&(e=!0),e)return a.eat(/J/i),"number";var f=!1;if(a.match(/^0x[0-9a-f]+/i)&&(f=!0),a.match(/^0b[01]+/i)&&(f=!0),a.match(/^0o[0-7]+/i)&&(f=!0),a.match(/^[1-9]\d*(e[\+\-]?\d+)?/)&&(a.eat(/J/i),f=!0),a.match(/^0(?![\dx])/i)&&(f=!0),f)return a.eat(/L/i),"number"}return a.match(A)?(b.tokenize=k(a.current()),b.tokenize(a,b)):a.match(t)||a.match(s)?"punctuation":a.match(r)||a.match(y)?"operator":a.match(q)?"punctuation":"."==b.lastToken&&a.match(z)?"property":a.match(B)||a.match(d)?"keyword":a.match(C)?"builtin":a.match(/^(self|cls)\b/)?"variable-2":a.match(z)?"def"==b.lastToken||"class"==b.lastToken?"def":"variable":(a.next(),p)}function k(a){function b(b,e){for(;!b.eol();)if(b.eatWhile(/[^'"\\]/),b.eat("\\")){if(b.next(),c&&b.eol())return d}else{if(b.match(a))return e.tokenize=i,d;b.eat(/['"]/)}if(c){if(h.singleLineStringErrors)return p;e.tokenize=i}return d}for(;"rub".indexOf(a.charAt(0).toLowerCase())>=0;)a=a.substr(1);var c=1==a.length,d="string";return b.isString=!0,b}function l(a){for(;"py"!=c(a).type;)a.scopes.pop();a.scopes.push({offset:c(a).offset+g.indentUnit,type:"py",align:null})}function m(a,b,c){var d=a.match(/^([\s\[\{\(]|#.*)*$/,!1)?null:a.column()+1;b.scopes.push({offset:b.indent+u,type:c,align:d})}function n(a,b){for(var d=a.indentation();b.scopes.length>1&&c(b).offset>d;){if("py"!=c(b).type)return!0;b.scopes.pop()}return c(b).offset!=d}function o(a,b){a.sol()&&(b.beginningOfLine=!0);var d=b.tokenize(a,b),e=a.current();if(b.beginningOfLine&&"@"==e)return a.match(z,!1)?"meta":x?"operator":p;/\S/.test(e)&&(b.beginningOfLine=!1),"variable"!=d&&"builtin"!=d||"meta"!=b.lastToken||(d="meta"),("pass"==e||"return"==e)&&(b.dedent+=1),"lambda"==e&&(b.lambda=!0),":"!=e||b.lambda||"py"!=c(b).type||l(b);var f=1==e.length?"[({".indexOf(e):-1;if(-1!=f&&m(a,b,"])}".slice(f,f+1)),f="])}".indexOf(e),-1!=f){if(c(b).type!=e)return p;b.indent=b.scopes.pop().offset-u}return b.dedent>0&&a.eol()&&"py"==c(b).type&&(b.scopes.length>1&&b.scopes.pop(),b.dedent-=1),d}var p="error",q=h.singleDelimiters||/^[\(\)\[\]\{\}@,:`=;\.]/,r=h.doubleOperators||/^([!<>]==|<>|<<|>>|\/\/|\*\*)/,s=h.doubleDelimiters||/^(\+=|\-=|\*=|%=|\/=|&=|\|=|\^=)/,t=h.tripleDelimiters||/^(\/\/=|>>=|<<=|\*\*=)/,u=h.hangingIndent||g.indentUnit,v=e,w=f;void 0!=h.extra_keywords&&(v=v.concat(h.extra_keywords)),void 0!=h.extra_builtins&&(w=w.concat(h.extra_builtins));var x=h.version&&3==parseInt(h.version,10);if(x){var y=h.singleOperators||/^[\+\-\*\/%&|\^~<>!@]/,z=h.identifiers||/^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;v=v.concat(["nonlocal","False","True","None","async","await"]),w=w.concat(["ascii","bytes","exec","print"]);var A=new RegExp("^(([rbuf]|(br))?('{3}|\"{3}|['\"]))","i")}else{var y=h.singleOperators||/^[\+\-\*\/%&|\^~<>!]/,z=h.identifiers||/^[_A-Za-z][_A-Za-z0-9]*/;v=v.concat(["exec","print"]),w=w.concat(["apply","basestring","buffer","cmp","coerce","execfile","file","intern","long","raw_input","reduce","reload","unichr","unicode","xrange","False","True","None"]);var A=new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))","i")}var B=b(v),C=b(w),D={startState:function(a){return{tokenize:i,scopes:[{offset:a||0,type:"py",align:null}],indent:a||0,lastToken:null,lambda:!1,dedent:0}},token:function(a,b){var c=b.errorToken;c&&(b.errorToken=!1);var d=o(a,b);return d&&"comment"!=d&&(b.lastToken="keyword"==d||"punctuation"==d?a.current():d),"punctuation"==d&&(d=null),a.eol()&&b.lambda&&(b.lambda=!1),c?d+" "+p:d},indent:function(b,d){if(b.tokenize!=i)return b.tokenize.isString?a.Pass:0;var e=c(b),f=e.type==d.charAt(0);return null!=e.align?e.align-(f?1:0):e.offset-(f?u:0)},electricInput:/^\s*[\}\]\)]$/,closeBrackets:{triples:"'\""},lineComment:"#",fold:"indent"};return D}),a.defineMIME("text/x-python","python");var g=function(a){return a.split(" ")};a.defineMIME("text/x-cython",{name:"python",extra_keywords:g("by cdef cimport cpdef ctypedef enum exceptextern gil include nogil property publicreadonly struct union DEF IF ELIF ELSE")})}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){return new RegExp("^(("+a.join(")|(")+"))\\b")}function c(a){return a.scopes[a.scopes.length-1]}var d=b(["and","or","not","is"]),e=["as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","lambda","pass","raise","return","try","while","with","yield","in"],f=["abs","all","any","bin","bool","bytearray","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip","__import__","NotImplemented","Ellipsis","__debug__"];a.registerHelper("hintWords","python",e.concat(f)),a.defineMode("python",function(g,h){function i(a,b){if(a.sol()&&(b.indent=a.indentation()),a.sol()&&"py"==c(b).type){var d=c(b).offset;if(a.eatSpace()){var e=a.indentation();return e>d?l(b):d>e&&n(a,b)&&(b.errorToken=!0),null}var f=j(a,b);return d>0&&n(a,b)&&(f+=" "+p),f}return j(a,b)}function j(a,b){if(a.eatSpace())return null;var c=a.peek();if("#"==c)return a.skipToEnd(),"comment";if(a.match(/^[0-9\.]/,!1)){var e=!1;if(a.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)&&(e=!0),a.match(/^\d+\.\d*/)&&(e=!0),a.match(/^\.\d+/)&&(e=!0),e)return a.eat(/J/i),"number";var f=!1;if(a.match(/^0x[0-9a-f]+/i)&&(f=!0),a.match(/^0b[01]+/i)&&(f=!0),a.match(/^0o[0-7]+/i)&&(f=!0),a.match(/^[1-9]\d*(e[\+\-]?\d+)?/)&&(a.eat(/J/i),f=!0),a.match(/^0(?![\dx])/i)&&(f=!0),f)return a.eat(/L/i),"number"}return a.match(A)?(b.tokenize=k(a.current()),b.tokenize(a,b)):a.match(t)||a.match(s)?"punctuation":a.match(r)||a.match(y)?"operator":a.match(q)?"punctuation":"."==b.lastToken&&a.match(z)?"property":a.match(B)||a.match(d)?"keyword":a.match(C)?"builtin":a.match(/^(self|cls)\b/)?"variable-2":a.match(z)?"def"==b.lastToken||"class"==b.lastToken?"def":"variable":(a.next(),p)}function k(a){function b(b,e){for(;!b.eol();)if(b.eatWhile(/[^'"\\]/),b.eat("\\")){if(b.next(),c&&b.eol())return d}else{if(b.match(a))return e.tokenize=i,d;b.eat(/['"]/)}if(c){if(h.singleLineStringErrors)return p;e.tokenize=i}return d}for(;"rubf".indexOf(a.charAt(0).toLowerCase())>=0;)a=a.substr(1);var c=1==a.length,d="string";return b.isString=!0,b}function l(a){for(;"py"!=c(a).type;)a.scopes.pop();a.scopes.push({offset:c(a).offset+g.indentUnit,type:"py",align:null})}function m(a,b,c){var d=a.match(/^([\s\[\{\(]|#.*)*$/,!1)?null:a.column()+1;b.scopes.push({offset:b.indent+u,type:c,align:d})}function n(a,b){for(var d=a.indentation();b.scopes.length>1&&c(b).offset>d;){if("py"!=c(b).type)return!0;b.scopes.pop()}return c(b).offset!=d}function o(a,b){a.sol()&&(b.beginningOfLine=!0);var d=b.tokenize(a,b),e=a.current();if(b.beginningOfLine&&"@"==e)return a.match(z,!1)?"meta":x?"operator":p;/\S/.test(e)&&(b.beginningOfLine=!1),"variable"!=d&&"builtin"!=d||"meta"!=b.lastToken||(d="meta"),("pass"==e||"return"==e)&&(b.dedent+=1),"lambda"==e&&(b.lambda=!0),":"!=e||b.lambda||"py"!=c(b).type||l(b);var f=1==e.length?"[({".indexOf(e):-1;if(-1!=f&&m(a,b,"])}".slice(f,f+1)),f="])}".indexOf(e),-1!=f){if(c(b).type!=e)return p;b.indent=b.scopes.pop().offset-u}return b.dedent>0&&a.eol()&&"py"==c(b).type&&(b.scopes.length>1&&b.scopes.pop(),b.dedent-=1),d}var p="error",q=h.singleDelimiters||/^[\(\)\[\]\{\}@,:`=;\.]/,r=h.doubleOperators||/^([!<>]==|<>|<<|>>|\/\/|\*\*)/,s=h.doubleDelimiters||/^(\+=|\-=|\*=|%=|\/=|&=|\|=|\^=)/,t=h.tripleDelimiters||/^(\/\/=|>>=|<<=|\*\*=)/,u=h.hangingIndent||g.indentUnit,v=e,w=f;void 0!=h.extra_keywords&&(v=v.concat(h.extra_keywords)),void 0!=h.extra_builtins&&(w=w.concat(h.extra_builtins));var x=!(h.version&&Number(h.version)<3);if(x){var y=h.singleOperators||/^[\+\-\*\/%&|\^~<>!@]/,z=h.identifiers||/^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;v=v.concat(["nonlocal","False","True","None","async","await"]),w=w.concat(["ascii","bytes","exec","print"]);var A=new RegExp("^(([rbuf]|(br))?('{3}|\"{3}|['\"]))","i")}else{var y=h.singleOperators||/^[\+\-\*\/%&|\^~<>!]/,z=h.identifiers||/^[_A-Za-z][_A-Za-z0-9]*/;v=v.concat(["exec","print"]),w=w.concat(["apply","basestring","buffer","cmp","coerce","execfile","file","intern","long","raw_input","reduce","reload","unichr","unicode","xrange","False","True","None"]);var A=new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))","i")}var B=b(v),C=b(w),D={startState:function(a){return{tokenize:i,scopes:[{offset:a||0,type:"py",align:null}],indent:a||0,lastToken:null,lambda:!1,dedent:0}},token:function(a,b){var c=b.errorToken;c&&(b.errorToken=!1);var d=o(a,b);return d&&"comment"!=d&&(b.lastToken="keyword"==d||"punctuation"==d?a.current():d),"punctuation"==d&&(d=null),a.eol()&&b.lambda&&(b.lambda=!1),c?d+" "+p:d},indent:function(b,d){if(b.tokenize!=i)return b.tokenize.isString?a.Pass:0;var e=c(b),f=e.type==d.charAt(0);return null!=e.align?e.align-(f?1:0):e.offset-(f?u:0)},electricInput:/^\s*[\}\]\)]$/,closeBrackets:{triples:"'\""},lineComment:"#",fold:"indent"};return D}),a.defineMIME("text/x-python","python");var g=function(a){return a.split(" ")};a.defineMIME("text/x-cython",{name:"python",extra_keywords:g("by cdef cimport cpdef ctypedef enum exceptextern gil include nogil property publicreadonly struct union DEF IF ELIF ELSE")})}); \ No newline at end of file diff --git a/media/editors/codemirror/mode/sas/sas.js b/media/editors/codemirror/mode/sas/sas.js index fe114827c05da..a6109eb11c98f 100644 --- a/media/editors/codemirror/mode/sas/sas.js +++ b/media/editors/codemirror/mode/sas/sas.js @@ -137,12 +137,13 @@ stream.next(); return 'comment'; } - } else if (!state.continueString && (ch === '"' || ch === "'")) { - // Have we found a string? - state.continueString = ch; //save the matching quote in the state - return "string"; - } else if (state.continueString !== null) { - if (stream.skipTo(state.continueString)) { + } else if ((ch === '"' || ch === "'") && !state.continueString) { + state.continueString = ch + return "string" + } else if (state.continueString) { + if (state.continueString == ch) { + state.continueString = null; + } else if (stream.skipTo(state.continueString)) { // quote found on this line stream.next(); state.continueString = null; @@ -187,12 +188,12 @@ if (stream.peek() === '.') stream.skipTo(' '); state.nextword = false; return 'variable-2'; - } + word = word.toLowerCase() // Are we in a DATA Step? if (state.inDataStep) { - if (word.toLowerCase() === 'run;' || stream.match(/run\s;/)) { + if (word === 'run;' || stream.match(/run\s;/)) { state.inDataStep = false; return 'builtin'; } @@ -203,84 +204,84 @@ else return 'variable'; } // do we have a DATA Step keyword - if (word && words.hasOwnProperty(word.toLowerCase()) && - (words[word.toLowerCase()].state.indexOf("inDataStep") !== -1 || - words[word.toLowerCase()].state.indexOf("ALL") !== -1)) { + if (word && words.hasOwnProperty(word) && + (words[word].state.indexOf("inDataStep") !== -1 || + words[word].state.indexOf("ALL") !== -1)) { //backup to the start of the word if (stream.start < stream.pos) stream.backUp(stream.pos - stream.start); //advance the length of the word and return for (var i = 0; i < word.length; ++i) stream.next(); - return words[word.toLowerCase()].style; + return words[word].style; } } // Are we in an Proc statement? if (state.inProc) { - if (word.toLowerCase() === 'run;' || word.toLowerCase() === 'quit;') { + if (word === 'run;' || word === 'quit;') { state.inProc = false; return 'builtin'; } // do we have a proc keyword - if (word && words.hasOwnProperty(word.toLowerCase()) && - (words[word.toLowerCase()].state.indexOf("inProc") !== -1 || - words[word.toLowerCase()].state.indexOf("ALL") !== -1)) { + if (word && words.hasOwnProperty(word) && + (words[word].state.indexOf("inProc") !== -1 || + words[word].state.indexOf("ALL") !== -1)) { stream.match(/[\w]+/); return words[word].style; } } // Are we in a Macro statement? if (state.inMacro) { - if (word.toLowerCase() === '%mend') { + if (word === '%mend') { if (stream.peek() === ';') stream.next(); state.inMacro = false; return 'builtin'; } - if (word && words.hasOwnProperty(word.toLowerCase()) && - (words[word.toLowerCase()].state.indexOf("inMacro") !== -1 || - words[word.toLowerCase()].state.indexOf("ALL") !== -1)) { + if (word && words.hasOwnProperty(word) && + (words[word].state.indexOf("inMacro") !== -1 || + words[word].state.indexOf("ALL") !== -1)) { stream.match(/[\w]+/); - return words[word.toLowerCase()].style; + return words[word].style; } return 'atom'; } // Do we have Keywords specific words? - if (word && words.hasOwnProperty(word.toLowerCase())) { + if (word && words.hasOwnProperty(word)) { // Negates the initial next() stream.backUp(1); // Actually move the stream stream.match(/[\w]+/); - if (word.toLowerCase() === 'data' && /=/.test(stream.peek()) === false) { + if (word === 'data' && /=/.test(stream.peek()) === false) { state.inDataStep = true; state.nextword = true; return 'builtin'; } - if (word.toLowerCase() === 'proc') { + if (word === 'proc') { state.inProc = true; state.nextword = true; return 'builtin'; } - if (word.toLowerCase() === '%macro') { + if (word === '%macro') { state.inMacro = true; state.nextword = true; return 'builtin'; } - if (/title[1-9]/i.test(word)) return 'def'; + if (/title[1-9]/.test(word)) return 'def'; - if (word.toLowerCase() === 'footnote') { + if (word === 'footnote') { stream.eat(/[1-9]/); return 'def'; } // Returns their value as state in the prior define methods - if (state.inDataStep === true && words[word.toLowerCase()].state.indexOf("inDataStep") !== -1) - return words[word.toLowerCase()].style; - if (state.inProc === true && words[word.toLowerCase()].state.indexOf("inProc") !== -1) - return words[word.toLowerCase()].style; - if (state.inMacro === true && words[word.toLowerCase()].state.indexOf("inMacro") !== -1) - return words[word.toLowerCase()].style; - if (words[word.toLowerCase()].state.indexOf("ALL") !== -1) - return words[word.toLowerCase()].style; + if (state.inDataStep === true && words[word].state.indexOf("inDataStep") !== -1) + return words[word].style; + if (state.inProc === true && words[word].state.indexOf("inProc") !== -1) + return words[word].style; + if (state.inMacro === true && words[word].state.indexOf("inMacro") !== -1) + return words[word].style; + if (words[word].state.indexOf("ALL") !== -1) + return words[word].style; return null; } // Unrecognized syntax diff --git a/media/editors/codemirror/mode/sas/sas.min.js b/media/editors/codemirror/mode/sas/sas.min.js index 834745409be7e..ed3d0de47ea31 100644 --- a/media/editors/codemirror/mode/sas/sas.min.js +++ b/media/editors/codemirror/mode/sas/sas.min.js @@ -1 +1 @@ -!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("sas",function(){function a(a,b,d){if(d)for(var e=b.split(" "),f=0;f=|!=|<>)/,f=/[=\(:\),{}.*<>+\-\/^\[\]]/;return a("def","stack pgm view source debug nesting nolist",["inDataStep"]),a("def","if while until for do do; end end; then else cancel",["inDataStep"]),a("def","label format _n_ _error_",["inDataStep"]),a("def","ALTER BUFNO BUFSIZE CNTLLEV COMPRESS DLDMGACTION ENCRYPT ENCRYPTKEY EXTENDOBSCOUNTER GENMAX GENNUM INDEX LABEL OBSBUF OUTREP PW PWREQ READ REPEMPTY REPLACE REUSE ROLE SORTEDBY SPILL TOBSNO TYPE WRITE FILECLOSE FIRSTOBS IN OBS POINTOBS WHERE WHEREUP IDXNAME IDXWHERE DROP KEEP RENAME",["inDataStep"]),a("def","filevar finfo finv fipname fipnamel fipstate first firstobs floor",["inDataStep"]),a("def","varfmt varinfmt varlabel varlen varname varnum varray varrayx vartype verify vformat vformatd vformatdx vformatn vformatnx vformatw vformatwx vformatx vinarray vinarrayx vinformat vinformatd vinformatdx vinformatn vinformatnx vinformatw vinformatwx vinformatx vlabel vlabelx vlength vlengthx vname vnamex vnferr vtype vtypex weekday",["inDataStep"]),a("def","zipfips zipname zipnamel zipstate",["inDataStep"]),a("def","put putc putn",["inDataStep"]),a("builtin","data run",["inDataStep"]),a("def","data",["inProc"]),a("def","%if %end %end; %else %else; %do %do; %then",["inMacro"]),a("builtin","proc run; quit; libname filename %macro %mend option options",["ALL"]),a("def","footnote title libname ods",["ALL"]),a("def","%let %put %global %sysfunc %eval ",["ALL"]),a("variable","&sysbuffr &syscc &syscharwidth &syscmd &sysdate &sysdate9 &sysday &sysdevic &sysdmg &sysdsn &sysencoding &sysenv &syserr &syserrortext &sysfilrc &syshostname &sysindex &sysinfo &sysjobid &syslast &syslckrc &syslibrc &syslogapplname &sysmacroname &sysmenv &sysmsg &sysncpu &sysodspath &sysparm &syspbuff &sysprocessid &sysprocessname &sysprocname &sysrc &sysscp &sysscpl &sysscpl &syssite &sysstartid &sysstartname &systcpiphostname &systime &sysuserid &sysver &sysvlong &sysvlong4 &syswarningtext",["ALL"]),a("def","source2 nosource2 page pageno pagesize",["ALL"]),a("def","_all_ _character_ _cmd_ _freq_ _i_ _infile_ _last_ _msg_ _null_ _numeric_ _temporary_ _type_ abort abs addr adjrsq airy alpha alter altlog altprint and arcos array arsin as atan attrc attrib attrn authserver autoexec awscontrol awsdef awsmenu awsmenumerge awstitle backward band base betainv between blocksize blshift bnot bor brshift bufno bufsize bxor by byerr byline byte calculated call cards cards4 catcache cbufno cdf ceil center cexist change chisq cinv class cleanup close cnonct cntllev coalesce codegen col collate collin column comamid comaux1 comaux2 comdef compbl compound compress config continue convert cos cosh cpuid create cross crosstab css curobs cv daccdb daccdbsl daccsl daccsyd dacctab dairy datalines datalines4 datejul datepart datetime day dbcslang dbcstype dclose ddm delete delimiter depdb depdbsl depsl depsyd deptab dequote descending descript design= device dflang dhms dif digamma dim dinfo display distinct dkricond dkrocond dlm dnum do dopen doptname doptnum dread drop dropnote dsname dsnferr echo else emaildlg emailid emailpw emailserver emailsys encrypt end endsas engine eof eov erf erfc error errorcheck errors exist exp fappend fclose fcol fdelete feedback fetch fetchobs fexist fget file fileclose fileexist filefmt filename fileref fmterr fmtsearch fnonct fnote font fontalias fopen foptname foptnum force formatted formchar formdelim formdlim forward fpoint fpos fput fread frewind frlen from fsep fuzz fwrite gaminv gamma getoption getvarc getvarn go goto group gwindow hbar hbound helpenv helploc hms honorappearance hosthelp hostprint hour hpct html hvar ibessel ibr id if index indexc indexw initcmd initstmt inner input inputc inputn inr insert int intck intnx into intrr invaliddata irr is jbessel join juldate keep kentb kurtosis label lag last lbound leave left length levels lgamma lib library libref line linesize link list log log10 log2 logpdf logpmf logsdf lostcard lowcase lrecl ls macro macrogen maps mautosource max maxdec maxr mdy mean measures median memtype merge merror min minute missing missover mlogic mod mode model modify month mopen mort mprint mrecall msglevel msymtabmax mvarsize myy n nest netpv new news nmiss no nobatch nobs nocaps nocardimage nocenter nocharcode nocmdmac nocol nocum nodate nodbcs nodetails nodmr nodms nodmsbatch nodup nodupkey noduplicates noechoauto noequals noerrorabend noexitwindows nofullstimer noicon noimplmac noint nolist noloadlist nomiss nomlogic nomprint nomrecall nomsgcase nomstored nomultenvappl nonotes nonumber noobs noovp nopad nopercent noprint noprintinit normal norow norsasuser nosetinit nosplash nosymbolgen note notes notitle notitles notsorted noverbose noxsync noxwait npv null number numkeys nummousekeys nway obs on open order ordinal otherwise out outer outp= output over ovp p(1 5 10 25 50 75 90 95 99) pad pad2 paired parm parmcards path pathdll pathname pdf peek peekc pfkey pmf point poisson poke position printer probbeta probbnml probchi probf probgam probhypr probit probnegb probnorm probsig probt procleave prt ps pw pwreq qtr quote r ranbin rancau ranexp rangam range ranks rannor ranpoi rantbl rantri ranuni read recfm register regr remote remove rename repeat replace resolve retain return reuse reverse rewind right round rsquare rtf rtrace rtraceloc s s2 samploc sasautos sascontrol sasfrscr sasmsg sasmstore sasscript sasuser saving scan sdf second select selection separated seq serror set setcomm setot sign simple sin sinh siteinfo skewness skip sle sls sortedby sortpgm sortseq sortsize soundex spedis splashlocation split spool sqrt start std stderr stdin stfips stimer stname stnamel stop stopover subgroup subpopn substr sum sumwgt symbol symbolgen symget symput sysget sysin sysleave sysmsg sysparm sysprint sysprintfont sysprod sysrc system t table tables tan tanh tapeclose tbufsize terminal test then timepart tinv tnonct to today tol tooldef totper transformout translate trantab tranwrd trigamma trim trimn trunc truncover type unformatted uniform union until upcase update user usericon uss validate value var weight when where while wincharset window work workinit workterm write wsum xsync xwait yearcutoff yes yyq min max",["inDataStep","inProc"]),a("operator","and not ",["inDataStep","inProc"]),{startState:function(){return{inDataStep:!1,inProc:!1,inMacro:!1,nextword:!1,continueString:null,continueComment:!1}},token:function(a,c){return a.eatSpace()?null:b(a,c)},blockCommentStart:"/*",blockCommentEnd:"*/"}}),a.defineMIME("text/x-sas","sas")}); \ No newline at end of file +!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("sas",function(){function a(a,b,d){if(d)for(var e=b.split(" "),f=0;f=|!=|<>)/,f=/[=\(:\),{}.*<>+\-\/^\[\]]/;return a("def","stack pgm view source debug nesting nolist",["inDataStep"]),a("def","if while until for do do; end end; then else cancel",["inDataStep"]),a("def","label format _n_ _error_",["inDataStep"]),a("def","ALTER BUFNO BUFSIZE CNTLLEV COMPRESS DLDMGACTION ENCRYPT ENCRYPTKEY EXTENDOBSCOUNTER GENMAX GENNUM INDEX LABEL OBSBUF OUTREP PW PWREQ READ REPEMPTY REPLACE REUSE ROLE SORTEDBY SPILL TOBSNO TYPE WRITE FILECLOSE FIRSTOBS IN OBS POINTOBS WHERE WHEREUP IDXNAME IDXWHERE DROP KEEP RENAME",["inDataStep"]),a("def","filevar finfo finv fipname fipnamel fipstate first firstobs floor",["inDataStep"]),a("def","varfmt varinfmt varlabel varlen varname varnum varray varrayx vartype verify vformat vformatd vformatdx vformatn vformatnx vformatw vformatwx vformatx vinarray vinarrayx vinformat vinformatd vinformatdx vinformatn vinformatnx vinformatw vinformatwx vinformatx vlabel vlabelx vlength vlengthx vname vnamex vnferr vtype vtypex weekday",["inDataStep"]),a("def","zipfips zipname zipnamel zipstate",["inDataStep"]),a("def","put putc putn",["inDataStep"]),a("builtin","data run",["inDataStep"]),a("def","data",["inProc"]),a("def","%if %end %end; %else %else; %do %do; %then",["inMacro"]),a("builtin","proc run; quit; libname filename %macro %mend option options",["ALL"]),a("def","footnote title libname ods",["ALL"]),a("def","%let %put %global %sysfunc %eval ",["ALL"]),a("variable","&sysbuffr &syscc &syscharwidth &syscmd &sysdate &sysdate9 &sysday &sysdevic &sysdmg &sysdsn &sysencoding &sysenv &syserr &syserrortext &sysfilrc &syshostname &sysindex &sysinfo &sysjobid &syslast &syslckrc &syslibrc &syslogapplname &sysmacroname &sysmenv &sysmsg &sysncpu &sysodspath &sysparm &syspbuff &sysprocessid &sysprocessname &sysprocname &sysrc &sysscp &sysscpl &sysscpl &syssite &sysstartid &sysstartname &systcpiphostname &systime &sysuserid &sysver &sysvlong &sysvlong4 &syswarningtext",["ALL"]),a("def","source2 nosource2 page pageno pagesize",["ALL"]),a("def","_all_ _character_ _cmd_ _freq_ _i_ _infile_ _last_ _msg_ _null_ _numeric_ _temporary_ _type_ abort abs addr adjrsq airy alpha alter altlog altprint and arcos array arsin as atan attrc attrib attrn authserver autoexec awscontrol awsdef awsmenu awsmenumerge awstitle backward band base betainv between blocksize blshift bnot bor brshift bufno bufsize bxor by byerr byline byte calculated call cards cards4 catcache cbufno cdf ceil center cexist change chisq cinv class cleanup close cnonct cntllev coalesce codegen col collate collin column comamid comaux1 comaux2 comdef compbl compound compress config continue convert cos cosh cpuid create cross crosstab css curobs cv daccdb daccdbsl daccsl daccsyd dacctab dairy datalines datalines4 datejul datepart datetime day dbcslang dbcstype dclose ddm delete delimiter depdb depdbsl depsl depsyd deptab dequote descending descript design= device dflang dhms dif digamma dim dinfo display distinct dkricond dkrocond dlm dnum do dopen doptname doptnum dread drop dropnote dsname dsnferr echo else emaildlg emailid emailpw emailserver emailsys encrypt end endsas engine eof eov erf erfc error errorcheck errors exist exp fappend fclose fcol fdelete feedback fetch fetchobs fexist fget file fileclose fileexist filefmt filename fileref fmterr fmtsearch fnonct fnote font fontalias fopen foptname foptnum force formatted formchar formdelim formdlim forward fpoint fpos fput fread frewind frlen from fsep fuzz fwrite gaminv gamma getoption getvarc getvarn go goto group gwindow hbar hbound helpenv helploc hms honorappearance hosthelp hostprint hour hpct html hvar ibessel ibr id if index indexc indexw initcmd initstmt inner input inputc inputn inr insert int intck intnx into intrr invaliddata irr is jbessel join juldate keep kentb kurtosis label lag last lbound leave left length levels lgamma lib library libref line linesize link list log log10 log2 logpdf logpmf logsdf lostcard lowcase lrecl ls macro macrogen maps mautosource max maxdec maxr mdy mean measures median memtype merge merror min minute missing missover mlogic mod mode model modify month mopen mort mprint mrecall msglevel msymtabmax mvarsize myy n nest netpv new news nmiss no nobatch nobs nocaps nocardimage nocenter nocharcode nocmdmac nocol nocum nodate nodbcs nodetails nodmr nodms nodmsbatch nodup nodupkey noduplicates noechoauto noequals noerrorabend noexitwindows nofullstimer noicon noimplmac noint nolist noloadlist nomiss nomlogic nomprint nomrecall nomsgcase nomstored nomultenvappl nonotes nonumber noobs noovp nopad nopercent noprint noprintinit normal norow norsasuser nosetinit nosplash nosymbolgen note notes notitle notitles notsorted noverbose noxsync noxwait npv null number numkeys nummousekeys nway obs on open order ordinal otherwise out outer outp= output over ovp p(1 5 10 25 50 75 90 95 99) pad pad2 paired parm parmcards path pathdll pathname pdf peek peekc pfkey pmf point poisson poke position printer probbeta probbnml probchi probf probgam probhypr probit probnegb probnorm probsig probt procleave prt ps pw pwreq qtr quote r ranbin rancau ranexp rangam range ranks rannor ranpoi rantbl rantri ranuni read recfm register regr remote remove rename repeat replace resolve retain return reuse reverse rewind right round rsquare rtf rtrace rtraceloc s s2 samploc sasautos sascontrol sasfrscr sasmsg sasmstore sasscript sasuser saving scan sdf second select selection separated seq serror set setcomm setot sign simple sin sinh siteinfo skewness skip sle sls sortedby sortpgm sortseq sortsize soundex spedis splashlocation split spool sqrt start std stderr stdin stfips stimer stname stnamel stop stopover subgroup subpopn substr sum sumwgt symbol symbolgen symget symput sysget sysin sysleave sysmsg sysparm sysprint sysprintfont sysprod sysrc system t table tables tan tanh tapeclose tbufsize terminal test then timepart tinv tnonct to today tol tooldef totper transformout translate trantab tranwrd trigamma trim trimn trunc truncover type unformatted uniform union until upcase update user usericon uss validate value var weight when where while wincharset window work workinit workterm write wsum xsync xwait yearcutoff yes yyq min max",["inDataStep","inProc"]),a("operator","and not ",["inDataStep","inProc"]),{startState:function(){return{inDataStep:!1,inProc:!1,inMacro:!1,nextword:!1,continueString:null,continueComment:!1}},token:function(a,c){return a.eatSpace()?null:b(a,c)},blockCommentStart:"/*",blockCommentEnd:"*/"}}),a.defineMIME("text/x-sas","sas")}); \ No newline at end of file diff --git a/media/editors/codemirror/theme/solarized.css b/media/editors/codemirror/theme/solarized.css index 4b1e16307a520..1f39c7edb21fd 100644 --- a/media/editors/codemirror/theme/solarized.css +++ b/media/editors/codemirror/theme/solarized.css @@ -155,8 +155,8 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png .cm-s-solarized .CodeMirror-cursor { border-left: 1px solid #819090; } /* Fat cursor */ -.cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #fdf6e3; } -.cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #fdf6e3; } +.cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #77ee77; } +.cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #77ee77; } .cm-s-solarized.cm-s-dark.cm-fat-cursor .CodeMirror-cursor { background: #586e75; } .cm-s-solarized.cm-s-dark .cm-animate-fat-cursor { background-color: #586e75; } diff --git a/plugins/editors/codemirror/codemirror.xml b/plugins/editors/codemirror/codemirror.xml index 9c3b4c418b337..9f7dcfdd0b021 100644 --- a/plugins/editors/codemirror/codemirror.xml +++ b/plugins/editors/codemirror/codemirror.xml @@ -1,7 +1,7 @@ plg_editors_codemirror - 5.17.0 + 5.18.0 28 March 2011 Marijn Haverbeke marijnh@gmail.com