'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(g,q,v){g instanceof String&&(g=String(g));for(var x=g.length,m=0;m<x;m++){var U=g[m];if(q.call(v,U,m,g))return{i:m,v:U}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(g,q,v){g!=Array.prototype&&g!=Object.prototype&&(g[q]=v.value)};$jscomp.getGlobal=function(g){return"undefined"!=typeof window&&window===g?g:"undefined"!=typeof global&&null!=global?global:g};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(g,q,v,x){if(q){v=$jscomp.global;g=g.split(".");for(x=0;x<g.length-1;x++){var m=g[x];m in v||(v[m]={});v=v[m]}g=g[g.length-1];x=v[g];q=q(x);q!=x&&null!=q&&$jscomp.defineProperty(v,g,{configurable:!0,writable:!0,value:q})}};$jscomp.polyfill("Array.prototype.find",function(g){return g?g:function(g,v){return $jscomp.findInternal(this,g,v).v}},"es6","es3");$jscomp.arrayIteratorImpl=function(g){var q=0;return function(){return q<g.length?{done:!1,value:g[q++]}:{done:!0}}};
$jscomp.arrayIterator=function(g){return{next:$jscomp.arrayIteratorImpl(g)}};$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.SymbolClass=function(g,q){this.$jscomp$symbol$id_=g;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:q})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};
$jscomp.Symbol=function(){function g(v){if(this instanceof g)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(v||"")+"_"+q++,v)}var q=0;return g}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var g=$jscomp.global.Symbol.iterator;g||(g=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[g]&&$jscomp.defineProperty(Array.prototype,g,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var g=$jscomp.global.Symbol.asyncIterator;g||(g=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(g){$jscomp.initSymbolIterator();g={next:g};g[$jscomp.global.Symbol.iterator]=function(){return this};return g};
$jscomp.iteratorFromArray=function(g,q){$jscomp.initSymbolIterator();g instanceof String&&(g+="");var v=0,x={next:function(){if(v<g.length){var m=v++;return{value:q(m,g[m]),done:!1}}x.next=function(){return{done:!0,value:void 0}};return x.next()}};x[Symbol.iterator]=function(){return x};return x};$jscomp.polyfill("Array.prototype.keys",function(g){return g?g:function(){return $jscomp.iteratorFromArray(this,function(g){return g})}},"es6","es3");
$jscomp.checkStringArgs=function(g,q,v){if(null==g)throw new TypeError("The 'this' value for String.prototype."+v+" must not be null or undefined");if(q instanceof RegExp)throw new TypeError("First argument to String.prototype."+v+" must not be a regular expression");return g+""};
$jscomp.polyfill("String.prototype.repeat",function(g){return g?g:function(g){var q=$jscomp.checkStringArgs(this,null,"repeat");if(0>g||1342177279<g)throw new RangeError("Invalid count value");g|=0;for(var x="";g;)if(g&1&&(x+=q),g>>>=1)q+=q;return x}},"es6","es3");
(function(g){"object"==typeof exports&&"object"==typeof module?g(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/dialog/dialog"),require("../addon/edit/matchbrackets.js")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/dialog/dialog","../addon/edit/matchbrackets"],g):g(CodeMirror)})(function(g){var q=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",
type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"<Del>",type:"keyToKey",toKeys:"x",context:"normal"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",
toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",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:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",
type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",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:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",
motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",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<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},
{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<character>",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:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",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:"indentAuto"},{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:"expandToLine",motionArgs:{linewise:!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:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",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:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",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<character>",type:"action",action:"replace",
isEdit:!0},{keys:"@<character>",type:"action",action:"replayMacro"},{keys:"q<character>",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:"<C-r>",type:"action",
action:"redo"},{keys:"m<character>",type:"action",action:"setMark"},{keys:'"<character>',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<CR>",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:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",
actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<character>",type:"motion",motion:"textObjectManipulation"},{keys:"i<character>",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"}],v=q.length,x=[{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"}],m=g.Pos;g.Vim=function(){function U(a,b){if(this==g.keyMap.vim&&(g.rmClass(a.getWrapperElement(),"cm-fat-cursor"),"contenteditable"==a.getOption("inputStyle")&&null!=document.body.style.caretColor)){var c=a.state.fatCursorMarks;if(c)for(var d=0;d<c.length;d++)c[d].clear();a.state.fatCursorMarks=null;a.off("cursorActivity",Aa);a.getInputField().style.caretColor=""}b&&b.attach==V||(a.setOption("disableInput",!1),a.off("cursorActivity",Ba),g.off(a.getInputField(),"paste",Ca(a)),a.state.vim=
null)}function V(a,b){this==g.keyMap.vim&&(g.addClass(a.getWrapperElement(),"cm-fat-cursor"),"contenteditable"==a.getOption("inputStyle")&&null!=document.body.style.caretColor&&(a.state.fatCursorMarks=Da(a),a.on("cursorActivity",Aa),a.getInputField().style.caretColor="transparent"));b&&b.attach==V||(a.setOption("disableInput",!0),a.setOption("showCursorWhenSelecting",!1),g.signal(a,"vim-mode-change",{mode:"normal"}),a.on("cursorActivity",Ba),da(a),g.on(a.getInputField(),"paste",Ca(a)))}function Da(a){for(var b=
a.listSelections(),c=[],d=0;d<b.length;d++){var f=b[d];if(f.empty())if(f.anchor.ch<a.getLine(f.anchor.line).length)c.push(a.markText(f.anchor,m(f.anchor.line,f.anchor.ch+1),{className:"cm-fat-cursor-mark"}));else{var e=document.createElement("span");e.textContent="\u00a0";e.className="cm-fat-cursor-mark";c.push(a.setBookmark(f.anchor,{widget:e}))}}return c}function Aa(a){var b=a.state.fatCursorMarks;if(b)for(var c=0;c<b.length;c++)b[c].clear();a.state.fatCursorMarks=Da(a)}function na(a,b){if(b){if(this[a])return this[a];
a=nb(a);if(!a)return!1;var c=g.Vim.findKey(b,a);"function"==typeof c&&g.signal(b,"vim-keypress",a);return c}}function nb(a){if("'"==a.charAt(0))return a.charAt(1);a=a.split(/-(?!$)/);var b=a[a.length-1];if(1==a.length&&1==a[0].length||2==a.length&&"Shift"==a[0]&&1==b.length)return!1;for(var c=!1,d=0;d<a.length;d++){var f=a[d];f in Ea?a[d]=Ea[f]:c=!0;f in Fa&&(a[d]=Fa[f])}if(!c)return!1;W(b)&&(a[a.length-1]=b.toLowerCase());return"<"+a.join("-")+">"}function Ca(a){var b=a.state.vim;b.onPasteFn||(b.onPasteFn=
function(){b.insertMode||(a.setCursor(E(a.getCursor(),0,1)),ea.enterInsertMode(a,{},b))});return b.onPasteFn}function oa(a,b){for(var c=[],d=a;d<a+b;d++)c.push(String.fromCharCode(d));return c}function pa(a,b){return b>=a.firstLine()&&b<=a.lastLine()}function W(a){return/^[A-Z]$/.test(a)}function S(a){return/^\s*$/.test(a)}function qa(a,b){for(var c=0;c<b.length;c++)if(b[c]==a)return!0;return!1}function fa(a,b,c,d,f){if(void 0===b&&!f)throw Error("defaultValue is required unless callback is provided");
c||(c="string");N[a]={type:c,defaultValue:b,callback:f};if(d)for(c=0;c<d.length;c++)N[d[c]]=N[a];b&&ra(a,b)}function ra(a,b,c,d){var f=N[a];d=d||{};d=d.scope;if(!f)return Error("Unknown option: "+a);if("boolean"==f.type){if(b&&!0!==b)return Error("Invalid argument: "+a+"="+b);!1!==b&&(b=!0)}f.callback?("local"!==d&&f.callback(b,void 0),"global"!==d&&c&&f.callback(b,c)):("local"!==d&&(f.value="boolean"==f.type?!!b:b),"global"!==d&&c&&(c.state.vim.options[a]={value:b}))}function X(a,b,c){var d=N[a];
c=c||{};c=c.scope;if(!d)return Error("Unknown option: "+a);if(d.callback){a=b&&d.callback(void 0,b);if("global"!==c&&void 0!==a)return a;if("local"!==c)return d.callback()}else return a="global"!==c&&b&&b.state.vim.options[a],(a||"local"!==c&&d||{}).value}function Ga(){this.latestRegister=void 0;this.isRecording=this.isPlaying=!1;this.replaySearchQueries=[];this.onRecordingDone=void 0;this.lastInsertModeChanges=Ha()}function da(a){a.state.vim||(a.state.vim={inputState:new ha,lastEditInputState:void 0,
lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}});return a.state.vim}function Ia(){n={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:ob(),macroModeState:new Ga,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Ja({}),searchHistoryController:new sa,
exCommandHistoryController:new sa};for(var a in N){var b=N[a];b.value=b.defaultValue}}function ha(){this.prefixRepeat=[];this.motionRepeat=[];this.motionArgs=this.motion=this.operatorArgs=this.operator=null;this.keyBuffer=[];this.registerName=null}function G(a,b){a.state.vim.inputState=new ha;g.signal(a,"vim-command-done",b)}function I(a,b,c){this.clear();this.keyBuffer=[a||""];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!!b;this.blockwise=!!c}function Ja(a){this.registers=a;this.unnamedRegister=
a['"']=new I;a["."]=new I;a[":"]=new I;a["/"]=new I}function sa(){this.historyBuffer=[];this.iterator=0;this.initialPrefix=null}function Ka(a,b){for(var c=[],d=0;d<b;d++)c.push(a);return c}function F(a,b,c){var d=Math.min(Math.max(a.firstLine(),b.line),a.lastLine());a=D(a,d)-1;return m(d,Math.min(Math.max(0,b.ch),c?a+1:a))}function ia(a){var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function E(a,b,c){"object"===typeof b&&(c=b.ch,b=b.line);return m(a.line+b,a.ch+c)}function pb(a,
b){return{line:b.line-a.line,ch:b.line-a.line}}function La(a,b,c){return function(){for(var d=0;d<c;d++)b(a)}}function A(a){return m(a.line,a.ch)}function J(a,b){return a.ch==b.ch&&a.line==b.line}function B(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch?!0:!1}function H(a,b){2<arguments.length&&(b=H.apply(void 0,Array.prototype.slice.call(arguments,1)));return B(a,b)?a:b}function T(a,b){2<arguments.length&&(b=T.apply(void 0,Array.prototype.slice.call(arguments,1)));return B(a,b)?b:a}function Ma(a,
b,c){a=B(a,b);b=B(b,c);return a&&b}function D(a,b){return a.getLine(b).length}function ta(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function qb(a,b,c){var d=D(a,b);c=Array(c-d+1).join(" ");a.setCursor(m(b,d));a.replaceRange(c,a.getCursor())}function Na(a,b){var c=[],d=a.listSelections(),f=A(a.clipPos(b)),e=!J(b,f),k;a:{var l=a.getCursor("head");for(k=0;k<d.length;k++){var h=J(d[k].anchor,l),y=J(d[k].head,l);if(h||y)break a}k=-1}l=J(d[k].head,d[k].anchor);h=d.length-1;var g=h-k>k?h:0;k=
d[g].anchor;var C=Math.min(k.line,f.line);h=Math.max(k.line,f.line);y=k.ch;f=f.ch;d=d[g].head.ch-y;g=f-y;0<d&&0>=g?(y++,e||f--):0>d&&0<=g?(y--,l||f++):0>d&&-1==g&&(y--,f++);for(e=C;e<=h;e++)d={anchor:new m(e,y),head:new m(e,f)},c.push(d);a.setSelections(c);b.ch=f;k.ch=y;return k}function Oa(a,b,c){for(var d=[],f=0;f<c;f++){var e=E(b,f,0);d.push({anchor:e,head:e})}a.setSelections(d,0)}function rb(a,b){var c=b.lastSelection,d=function(){var b=a.listSelections(),c=b[0];b=b[b.length-1];c=B(c.anchor,c.head)?
c.anchor:c.head;b=B(b.anchor,b.head)?b.head:b.anchor;return[c,b]},f=function(){var b=a.getCursor(),d=a.getCursor(),f=c.visualBlock;if(f){d=m(b.line+f.height,b.ch+f.width);f=[];for(var h=b.line;h<d.line;h++){var y=m(h,b.ch),g=m(h,d.ch);f.push({anchor:y,head:g})}a.setSelections(f)}else h=c.anchorMark.find(),y=c.headMark.find(),f=y.line-h.line,h=y.ch-h.ch,d={line:d.line+f,ch:f?d.ch:h+d.ch},c.visualLine&&(b=m(b.line,0),d=m(d.line,D(a,d.line))),a.setSelection(b,d);return[b,d]};return b.visualMode?d():
f()}function Pa(a,b){var c=b.sel.anchor,d=b.sel.head;b.lastPastedText&&(d=a.posFromIndex(a.indexFromPos(c)+b.lastPastedText.length),b.lastPastedText=null);b.lastSelection={anchorMark:a.setBookmark(c),headMark:a.setBookmark(d),anchor:A(c),head:A(d),visualMode:b.visualMode,visualLine:b.visualLine,visualBlock:b.visualBlock}}function Y(a,b,c){var d=a.state.vim;b=b||d.sel;c=c||d.visualLine?"line":d.visualBlock?"block":"char";b=ua(a,b,c);a.setSelections(b.ranges,b.primary);Qa(a)}function ua(a,b,c,d){var f=
A(b.head),e=A(b.anchor);if("char"==c)return f=d||B(b.head,b.anchor)?0:1,e=B(b.head,b.anchor)?1:0,f=E(b.head,0,f),e=E(b.anchor,0,e),{ranges:[{anchor:e,head:f}],primary:0};if("line"==c)return B(b.head,b.anchor)?(f.ch=0,e.ch=D(a,e.line)):(e.ch=0,b=a.lastLine(),f.line>b&&(f.line=b),f.ch=D(a,f.line)),{ranges:[{anchor:e,head:f}],primary:0};if("block"==c){b=Math.min(e.line,f.line);a=Math.min(e.ch,f.ch);c=Math.max(e.ch,f.ch)+1;e=Math.max(e.line,f.line)-b+1;f=f.line==b?0:e-1;d=[];for(var k=0;k<e;k++)d.push({anchor:m(b+
k,a),head:m(b+k,c)});return{ranges:d,primary:f}}}function K(a,b){var c=a.state.vim;!1!==b&&a.setCursor(F(a,c.sel.head));Pa(a,c);c.visualMode=!1;c.visualLine=!1;c.visualBlock=!1;g.signal(a,"vim-mode-change",{mode:"normal"});c.fakeCursor&&c.fakeCursor.clear()}function L(a){if(!a)return 0;var b=a.search(/\S/);return-1==b?a.length:b}function ja(a,b,c,d,f){c=a.getCursor("head");1==a.getSelection().length&&(c=H(c,a.getCursor("anchor")));a=a.getLine(c.line);var e=c.ch;for(f=f?ka[0]:va[0];!f(a.charAt(e));)if(e++,
e>=a.length)return null;d?f=va[0]:(f=ka[0],f(a.charAt(e))||(f=ka[1]));for(d=e;f(a.charAt(d))&&d<a.length;)d++;for(;f(a.charAt(e))&&0<=e;)e--;e++;if(b){for(b=d;/\s/.test(a.charAt(d))&&d<a.length;)d++;if(b==d){for(b=e;/\s/.test(a.charAt(e-1))&&0<e;)e--;e||(e=b)}}return{start:m(c.line,e),end:m(c.line,d)}}function Ra(a,b){n.lastCharacterSearch.increment=a;n.lastCharacterSearch.forward=b.forward;n.lastCharacterSearch.selectedCharacter=b.selectedCharacter}function wa(a,b,c,d){for(var f=a.getCursor(),e=
f.ch,k,l=0;l<b;l++){k=a.getLine(f.line);var h=d;k=c?k.indexOf(h,e+1):k.lastIndexOf(h,e-1);if(-1==k)return null;e=k}return m(a.getCursor().line,k)}function O(a,b,c,d){qa(c,sb)&&(b.marks[c]&&b.marks[c].clear(),b.marks[c]=a.setBookmark(d))}function Sa(a,b,c,d,f){function e(b,c,d){return d?!a.getLine(b)!=!a.getLine(b+c):!!a.getLine(b)&&!a.getLine(b+c)}b=b.line;var k=a.firstLine(),l=a.lastLine(),h=b;if(d){for(;k<=h&&h<=l&&0<c;)e(h,d)&&c--,h+=d;return new m(h,0)}h=a.state.vim;h.visualLine&&e(b,1,!0)&&(h=
h.sel.anchor,e(h.line,-1,!0)&&(f&&h.line==b||(b+=1)));d=!a.getLine(b);for(h=b;h<=l&&c;h++)e(h,1,!0)&&(f&&!a.getLine(h)==d||c--);c=new m(h,0);h>l&&!d?d=!0:f=!1;for(h=b;h>k&&(f&&!a.getLine(h)!=d&&h!=b||!e(h,-1,!0));h--);return{start:new m(h,0),end:c}}function tb(a,b,c,d){function f(a,b){0>b.pos+b.dir||b.pos+b.dir>=b.line.length?(b.ln+=b.dir,pa(a,b.ln)?(b.line=a.getLine(b.ln),b.pos=0<b.dir?0:b.line.length-1):(b.line=null,b.ln=null,b.pos=null)):b.pos+=b.dir}function e(a,b,c,d){var e=a.getLine(b),h=""===
e;e={line:e,ln:b,pos:c,dir:d};b={ln:e.ln,pos:e.pos};c=""===e.line;for(f(a,e);null!==e.line;){b.ln=e.ln;b.pos=e.pos;if(""!==e.line||c){if(h&&""!==e.line&&!S(e.line[e.pos]))return{ln:e.ln,pos:e.pos};-1==".?!".indexOf(e.line[e.pos])||h||e.pos!==e.line.length-1&&!S(e.line[e.pos+1])||(h=!0)}else return{ln:e.ln,pos:e.pos};f(a,e)}e=a.getLine(b.ln);b.pos=0;for(a=e.length-1;0<=a;--a)if(!S(e[a])){b.pos=a;break}return b}function k(a,b,c,d){var e=a.getLine(b);e={line:e,ln:b,pos:c,dir:d};b={ln:e.ln,pos:null};
c=""===e.line;for(f(a,e);null!==e.line;){if(""!==e.line||c){if(-1!=".?!".indexOf(e.line[e.pos])&&null!==b.pos&&(e.ln!==b.ln||e.pos+1!==b.pos))return b;""===e.line||S(e.line[e.pos])||(c=!1,b={ln:e.ln,pos:e.pos})}else return null!==b.pos?b:{ln:e.ln,pos:e.pos};f(a,e)}e=a.getLine(b.ln);for(a=b.pos=0;a<e.length;++a)if(!S(e[a])){b.pos=a;break}return b}for(b={ln:b.line,pos:b.ch};0<c;)b=0>d?k(a,b.ln,b.pos,d):e(a,b.ln,b.pos,d),c--;return m(b.ln,b.pos)}function Ta(){}function P(a){a=a.state.vim;return a.searchState_||
(a.searchState_=new Ta)}function Ua(a,b){b=Va(a,b)||[];if(!b.length)return[];var c=[];if(0===b[0]){for(var d=0;d<b.length;d++)"number"==typeof b[d]&&c.push(a.substring(b[d]+1,b[d+1]));return c}}function Va(a,b){b||(b="/");for(var c=!1,d=[],f=0;f<a.length;f++){var e=a.charAt(f);c||e!=b||d.push(f);c=!c&&"\\"==e}return d}function w(a,b){a.openNotification?a.openNotification('<span style="color: red">'+b+"</span>",{bottom:!0,duration:5E3}):alert(b)}function la(a,b){var c=(b.prefix||"")+" "+(b.desc||""),
d=b.desc,f='<span style="font-family: monospace; white-space: pre">'+(b.prefix||"")+'<input type="text"></span>';d&&(f+=' <span style="color: #888">'+d+"</span>");d=b.onClose;a.openDialog?a.openDialog(f,d,{bottom:!0,value:b.value,onKeyDown:b.onKeyDown,onKeyUp:b.onKeyUp,selectValueOnOpen:!1}):d(prompt(c,""))}function Z(a,b,c,d){if(b){var f=P(a);c=!!c;d=!!d;n.registerController.getRegister("/").setText(b);if(b instanceof RegExp)var e=b;else{var k=Va(b,"/");if(k.length){var l=b.substring(0,k[0]);e=-1!=
b.substring(k[0]).indexOf("i")}else l=b;if(l){if(!X("pcre")){b=l;k=!1;l=[];for(var h=-1;h<b.length;h++){var g=b.charAt(h)||"",p=b.charAt(h+1)||"",m=p&&-1!="|(){".indexOf(p);k?("\\"===g&&m||l.push(g),k=!1):"\\"===g?(k=!0,p&&-1!="}".indexOf(p)&&(m=!0),m&&"\\"!==p||l.push(g)):(l.push(g),m&&"\\"!==p&&l.push("\\"))}l=l.join("")}d&&(c=/^[^A-Z]*$/.test(l));e=new RegExp(l,c||e?"i":void 0)}else e=null}if(e){Wa(a,e);a:if(a=f.getQuery(),e instanceof RegExp&&a instanceof RegExp){c=["global","multiline","ignoreCase",
"source"];for(d=0;d<c.length;d++)if(b=c[d],e[b]!==a[b]){a=!1;break a}a=!0}else a=!1;if(a)return e;f.setQuery(e);return e}}}function ub(a){if("^"==a.source.charAt(0))var b=!0;return{token:function(c){if(b&&!c.sol())c.skipToEnd();else{var d=c.match(a,!1);if(d){if(0==d[0].length)return c.next(),"searching";if(!c.sol()&&(c.backUp(1),!a.exec(c.next()+d[0])))return c.next(),null;c.match(a);return"searching"}for(;!c.eol()&&(c.next(),!c.match(a,!1)););}},query:a}}function Wa(a,b){var c=P(a),d=c.getOverlay();
d&&b==d.query||(d&&a.removeOverlay(d),d=ub(b),a.addOverlay(d),a.showMatchesOnScrollbar&&(c.getScrollbarAnnotate()&&c.getScrollbarAnnotate().clear(),c.setScrollbarAnnotate(a.showMatchesOnScrollbar(b))),c.setOverlay(d))}function Xa(a,b,c,d){void 0===d&&(d=1);return a.operation(function(){for(var f=a.getCursor(),e=a.getSearchCursor(c,f),k=0;k<d;k++){var l=e.find(b);0==k&&l&&J(e.from(),f)&&(l=e.find(b));if(!l&&(e=a.getSearchCursor(c,b?m(a.lastLine()):m(a.firstLine(),0)),!e.find(b)))return}return e.from()})}
function xa(a){var b=P(a);a.removeOverlay(P(a).getOverlay());b.setOverlay(null);b.getScrollbarAnnotate()&&(b.getScrollbarAnnotate().clear(),b.setScrollbarAnnotate(null))}function vb(a,b,c){"number"!=typeof a&&(a=a.line);return b instanceof Array?qa(a,b):c?a>=b&&a<=c:a==b}function ya(a){var b=a.getScrollInfo(),c=a.coordsChar({left:0,top:6+b.top},"local");a=a.coordsChar({left:0,top:b.clientHeight-10+b.top},"local");return{top:c.line,bottom:a.line}}function Ya(a,b,c){if("'"==c)return a=a.doc.history.done,
(a=a[a.length-2])&&a.ranges&&a.ranges[0].head;if("."==c){if(0==a.doc.history.lastModTime)return;a=a.doc.history.done.filter(function(a){if(void 0!==a.changes)return a});a.reverse();return a[0].changes[0].to}return(a=b.marks[c])&&a.find()}function wb(a,b,c,d,f,e,k,l,h){function y(){a.operation(function(){for(;!t;)p(),m();n()})}function p(){var b=a.getRange(e.from(),e.to()).replace(k,l);e.replace(b)}function m(){for(;e.findNext()&&vb(e.from(),d,f);)if(c||!r||e.from().line!=r.line){a.scrollIntoView(e.from(),
30);a.setSelection(e.from(),e.to());r=e.from();t=!1;return}t=!0}function n(b){b&&b();a.focus();r&&(a.setCursor(r),b=a.state.vim,b.exMode=!1,b.lastHPos=b.lastHSPos=r.ch);h&&h()}a.state.vim.exMode=!0;var t=!1,r=e.from();m();t?w(a,"No matches for "+k.source):b?la(a,{prefix:"replace with <strong>"+l+"</strong> (y/n/a/q/l)",onKeyDown:function(b,c,d){g.e_stop(b);switch(g.keyName(b)){case "Y":p();m();break;case "N":m();break;case "A":b=h;h=void 0;a.operation(y);h=b;break;case "L":p();case "Q":case "Esc":case "Ctrl-C":case "Ctrl-[":n(d)}t&&
n(d);return!0}}):(y(),h&&h())}function aa(a){var b=a.state.vim,c=n.macroModeState,d=n.registerController.getRegister("."),f=c.isPlaying,e=c.lastInsertModeChanges;f||(a.off("change",Za),g.off(a.getInputField(),"keydown",$a));!f&&1<b.insertModeRepeat&&(ab(a,b,b.insertModeRepeat-1,!0),b.lastEditInputState.repeatOverride=b.insertModeRepeat);delete b.insertModeRepeat;b.insertMode=!1;a.setCursor(a.getCursor().line,a.getCursor().ch-1);a.setOption("keyMap","vim");a.setOption("disableInput",!0);a.toggleOverwrite(!1);
d.setText(e.changes.join(""));g.signal(a,"vim-mode-change",{mode:"normal"});c.isRecording&&(c.isPlaying||(a=n.registerController.getRegister(c.latestRegister))&&a.pushInsertModeChanges&&a.pushInsertModeChanges(c.lastInsertModeChanges))}function bb(a){q.unshift(a)}function Za(a,b){var c=n.macroModeState,d=c.lastInsertModeChanges;if(!c.isPlaying)for(;b;){d.expectCursorActivityForChange=!0;if(1<d.ignoreCount)d.ignoreCount--;else if("+input"==b.origin||"paste"==b.origin||void 0===b.origin)c=a.listSelections().length,
1<c&&(d.ignoreCount=c),c=b.text.join("\n"),d.maybeReset&&(d.changes=[],d.maybeReset=!1),c&&(a.state.overwrite&&!/\n/.test(c)?d.changes.push([c]):d.changes.push(c));b=b.next}}function Ba(a){var b=a.state.vim;if(b.insertMode){var c=n.macroModeState;if(c.isPlaying)return;c=c.lastInsertModeChanges;c.expectCursorActivityForChange?c.expectCursorActivityForChange=!1:c.maybeReset=!0}else if(!a.curOp.isVimOp){c=a.getCursor("anchor");var d=a.getCursor("head");b.visualMode&&!a.somethingSelected()?K(a,!1):b.visualMode||
b.insertMode||!a.somethingSelected()||(b.visualMode=!0,b.visualLine=!1,g.signal(a,"vim-mode-change",{mode:"visual"}));if(b.visualMode){var f=B(d,c)?0:-1,e=B(d,c)?-1:0;d=E(d,0,f);c=E(c,0,e);b.sel={anchor:c,head:d};O(a,b,"<",H(d,c));O(a,b,">",T(d,c))}else b.insertMode||(b.lastHPos=a.getCursor().ch)}b.visualMode&&Qa(a)}function Qa(a){var b=a.state.vim,c=F(a,A(b.sel.head)),d=E(c,0,1);b.fakeCursor&&b.fakeCursor.clear();b.fakeCursor=a.markText(c,d,{className:"cm-animate-fat-cursor"})}function za(a){this.keyName=
a}function $a(a){function b(){c.maybeReset&&(c.changes=[],c.maybeReset=!1);c.changes.push(new za(d));return!0}var c=n.macroModeState.lastInsertModeChanges,d=g.keyName(a);d&&(-1==d.indexOf("Delete")&&-1==d.indexOf("Backspace")||g.lookupKey(d,"vim-insert",b))}function ab(a,b,c,d){function f(){l?R.processAction(a,b,b.lastEditActionCommand):R.evalInput(a,b)}function e(c){0<k.lastInsertModeChanges.changes.length&&(c=b.lastEditActionCommand?c:1,cb(a,k.lastInsertModeChanges.changes,c))}var k=n.macroModeState;
k.isPlaying=!0;var l=!!b.lastEditActionCommand,h=b.inputState;b.inputState=b.lastEditInputState;if(l&&b.lastEditActionCommand.interlaceInsertRepeat)for(var g=0;g<c;g++)f(),e(1);else d||f(),e(c);b.inputState=h;b.insertMode&&!d&&aa(a);k.isPlaying=!1}function cb(a,b,c){function d(b){if("string"==typeof b)g.commands[b](a);else b(a);return!0}var f=a.getCursor("head"),e=n.macroModeState.lastInsertModeChanges.inVisualBlock;e&&(c=a.state.vim.lastSelection,c=pb(c.anchor,c.head),Oa(a,f,c.line+1),c=a.listSelections().length,
a.setCursor(f));for(var k=0;k<c;k++){e&&a.setCursor(E(f,k,0));for(var l=0;l<b.length;l++){var h=b[l];if(h instanceof za)g.lookupKey(h.keyName,"vim-insert",d);else if("string"==typeof h){var y=a.getCursor();a.replaceRange(h,y,y)}else{y=a.getCursor();var p=E(y,0,h[0].length);a.replaceRange(h[0],y,p)}}}e&&a.setCursor(E(f,0,1))}g.defineOption("vimMode",!1,function(a,b,c){b&&"vim"!=a.getOption("keyMap")?a.setOption("keyMap","vim"):!b&&c!=g.Init&&/^vim/.test(a.getOption("keyMap"))&&a.setOption("keyMap",
"default")});var Ea={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},Fa={Enter:"CR",Backspace:"BS",Delete:"Del",Insert:"Ins"},xb=/[\d]/,ka=[g.isWordChar,function(a){return a&&!g.isWordChar(a)&&!/\s/.test(a)}],va=[function(a){return/\S/.test(a)}],db=oa(65,26),eb=oa(97,26),fb=oa(48,10),sb=[].concat(db,eb,fb,["<",">"]),gb=[].concat(db,eb,fb,["-",'"',".",":","/"]),N={};fa("filetype",void 0,"string",["ft"],function(a,b){if(void 0!==b){if(void 0===a)return a=b.getOption("mode"),"null"==a?"":a;b.setOption("mode",
""==a?"null":a)}});var ob=function(){var a=-1,b=0,c=0,d=Array(100);return{cachedCursor:void 0,add:function(f,e,k){function l(b){var c=++a%100,e=d[c];e&&e.clear();d[c]=f.setBookmark(b)}var h=d[a%100];h?(h=h.find())&&!J(h,e)&&l(e):l(e);l(k);b=a;c=a-100+1;0>c&&(c=0)},move:function(f,e){a+=e;a>b?a=b:a<c&&(a=c);var k=d[(100+a)%100];if(k&&!k.find()){e=0<e?1:-1;var l;f=f.getCursor();do if(a+=e,(k=d[(100+a)%100])&&(l=k.find())&&!J(f,l))break;while(a<b&&a>c)}return k}}},Ha=function(a){return a?{changes:a.changes,
expectCursorActivityForChange:a.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};Ga.prototype={exitMacroRecordMode:function(){var a=n.macroModeState;if(a.onRecordingDone)a.onRecordingDone();a.onRecordingDone=void 0;a.isRecording=!1},enterMacroRecordMode:function(a,b){var c=n.registerController.getRegister(b);c&&(c.clear(),this.latestRegister=b,a.openDialog&&(this.onRecordingDone=a.openDialog("(recording)["+b+"]",null,{bottom:!0})),this.isRecording=!0)}};var n,ba,yb={buildKeyMap:function(){},
getRegisterController:function(){return n.registerController},resetVimGlobalState_:Ia,getVimGlobalState_:function(){return n},maybeInitVimState_:da,suppressErrorLogging:!1,InsertModeKey:za,map:function(a,b,c){M.map(a,b,c)},unmap:function(a,b){M.unmap(a,b)},noremap:function(a,b,c){function d(a){return a?[a]:["normal","insert","visual"]}for(var f=d(c),e=q.length,k=e-v;k<e&&f.length;k++){var l=q[k];if(!(l.keys!=b||c&&l.context&&l.context!==c)&&"ex"!==l.type.substr(0,2)&&"key"!==l.type.substr(0,3)){var h=
{},g;for(g in l)h[g]=l[g];h.keys=a;c&&!h.context&&(h.context=c);this._mapCommand(h);var p=d(l.context);f=f.filter(function(a){return-1===p.indexOf(a)})}}},mapclear:function(a){var b=q.length,c=q.slice(0,b-v);q=q.slice(b-v);if(a)for(b=c.length-1;0<=b;b--){var d=c[b];if(a!==d.context)if(d.context)this._mapCommand(d);else{var f=["normal","insert","visual"],e;for(e in f)if(f[e]!==a){var k={},l;for(l in d)k[l]=d[l];k.context=f[e];this._mapCommand(k)}}}},setOption:ra,getOption:X,defineOption:fa,defineEx:function(a,
b,c){if(!b)b=a;else if(0!==a.indexOf(b))throw Error('(Vim.defineEx) "'+b+'" is not a prefix of "'+a+'", command not registered');hb[a]=c;M.commandMap_[b]={name:a,shortName:b,type:"api"}},handleKey:function(a,b,c){a=this.findKey(a,b,c);if("function"===typeof a)return a()},findKey:function(a,b,c){function d(){if("<Esc>"==b)return G(a),k.visualMode?K(a):k.insertMode&&aa(a),!0}function f(){if(d())return!0;for(var c=k.inputState.keyBuffer+=b,e=1==b.length,f=R.matchCommand(c,q,k.inputState,"insert");1<
c.length&&"full"!=f.type;){c=k.inputState.keyBuffer=c.slice(1);var l=R.matchCommand(c,q,k.inputState,"insert");"none"!=l.type&&(f=l)}if("none"==f.type)return G(a),!1;if("partial"==f.type)return ba&&window.clearTimeout(ba),ba=window.setTimeout(function(){k.insertMode&&k.inputState.keyBuffer&&G(a)},X("insertModeEscKeysTimeout")),!e;ba&&window.clearTimeout(ba);if(e){e=a.listSelections();for(l=0;l<e.length;l++){var g=e[l].head;a.replaceRange("",E(g,0,-(c.length-1)),g,"+input")}n.macroModeState.lastInsertModeChanges.changes.pop()}G(a);
return f.command}function e(){a:{var e=n.macroModeState;if(e.isRecording){if("q"==b){e.exitMacroRecordMode();G(a);var f=!0;break a}"mapping"!=c&&(f=b,e.isPlaying||(e=n.registerController.getRegister(e.latestRegister))&&e.pushText(f))}f=void 0}if(f||d())return!0;f=k.inputState.keyBuffer+=b;if(/^[1-9]\d*$/.test(f))return!0;e=/^(\d*)(.*)$/.exec(f);if(!e)return G(a),!1;var l=R.matchCommand(e[2]||e[1],q,k.inputState,k.visualMode?"visual":"normal");if("none"==l.type)return G(a),!1;if("partial"==l.type)return!0;
k.inputState.keyBuffer="";e=/^(\d*)(.*)$/.exec(f);e[1]&&"0"!=e[1]&&k.inputState.pushRepeatDigit(e[1]);return l.command}var k=da(a);var l=k.insertMode?f():e();return!1===l?k.insertMode||1!==b.length?void 0:function(){return!0}:!0===l?function(){return!0}:function(){return a.operation(function(){a.curOp.isVimOp=!0;try{if("keyToKey"==l.type)for(var c=l.toKeys,d;c;)d=/<\w+-.+?>|<\w+>|./.exec(c),b=d[0],c=c.substring(d.index+b.length),g.Vim.handleKey(a,b,"mapping");else R.processCommand(a,k,l)}catch(p){throw a.state.vim=
void 0,da(a),g.Vim.suppressErrorLogging||console.log(p),p;}return!0})}},handleEx:function(a,b){M.processCommand(a,b)},defineMotion:function(a,b){Q[a]=b},defineAction:function(a,b){ea[a]=b},defineOperator:function(a,b){ib[a]=b},mapCommand:function(a,b,c,d,f){a={keys:a,type:b};a[b]=c;a[b+"Args"]=d;for(var e in f)a[e]=f[e];bb(a)},_mapCommand:bb,defineRegister:function(a,b){var c=n.registerController.registers;if(!a||1!=a.length)throw Error("Register name must be 1 character");if(c[a])throw Error("Register already defined "+
a);c[a]=b;gb.push(a)},exitVisualMode:K,exitInsertMode:aa};ha.prototype.pushRepeatDigit=function(a){this.operator?this.motionRepeat=this.motionRepeat.concat(a):this.prefixRepeat=this.prefixRepeat.concat(a)};ha.prototype.getRepeat=function(){var a=0;if(0<this.prefixRepeat.length||0<this.motionRepeat.length)a=1,0<this.prefixRepeat.length&&(a*=parseInt(this.prefixRepeat.join(""),10)),0<this.motionRepeat.length&&(a*=parseInt(this.motionRepeat.join(""),10));return a};I.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(Ha(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("")}};Ja.prototype={pushText:function(a,b,c,d,f){d&&"\n"!==c.charAt(c.length-
1)&&(c+="\n");var e=this.isValidRegister(a)?this.getRegister(a):null;if(e)W(a)?e.pushText(c,d):e.setText(c,d,f),this.unnamedRegister.setText(e.toString(),d);else{switch(b){case "yank":this.registers["0"]=new I(c,d,f);break;case "delete":case "change":-1==c.indexOf("\n")?this.registers["-"]=new I(c,d):(this.shiftNumericRegisters_(),this.registers["1"]=new I(c,d))}this.unnamedRegister.setText(c,d,f)}},getRegister:function(a){if(!this.isValidRegister(a))return this.unnamedRegister;a=a.toLowerCase();
this.registers[a]||(this.registers[a]=new I);return this.registers[a]},isValidRegister:function(a){return a&&qa(a,gb)},shiftNumericRegisters_:function(){for(var a=9;2<=a;a--)this.registers[a]=this.getRegister(""+(a-1))}};sa.prototype={nextMatch:function(a,b){var c=this.historyBuffer,d=b?-1:1;null===this.initialPrefix&&(this.initialPrefix=a);for(var f=this.iterator+d;b?0<=f:f<c.length;f+=d)for(var e=c[f],k=0;k<=e.length;k++)if(this.initialPrefix==e.substring(0,k))return this.iterator=f,e;if(f>=c.length)return this.iterator=
c.length,this.initialPrefix;if(0>f)return a},pushInput:function(a){var b=this.historyBuffer.indexOf(a);-1<b&&this.historyBuffer.splice(b,1);a.length&&this.historyBuffer.push(a)},reset:function(){this.initialPrefix=null;this.iterator=this.historyBuffer.length}};var R={matchCommand:function(a,b,c,d){var f=[];var e=[];for(var k=0;k<b.length;k++){var l=b[k],h;if(h=!("insert"==d&&"insert"!=l.context||l.context&&l.context!=d||c.operator&&"action"==l.type)){var g=a;var m=l.keys;if("<character>"==m.slice(-11)){h=
m.length-11;var n=g.slice(0,h);m=m.slice(0,h);g=n==m&&g.length>h?"full":0==m.indexOf(n)?"partial":!1}else g=g==m?"full":0==m.indexOf(g)?"partial":!1;h=g}h&&("partial"==g&&f.push(l),"full"==g&&e.push(l))}b=f.length&&f;e=e.length&&e;if(!e&&!b)return{type:"none"};if(!e&&b)return{type:"partial"};var u;for(b=0;b<e.length;b++)d=e[b],u||(u=d);if("<character>"==u.keys.slice(-11)){a=(e=/^.*(<[^>]+>)$/.exec(a))?e[1]:a.slice(-1);if(1<a.length)switch(a){case "<CR>":a="\n";break;case "<Space>":a=" ";break;default:a=
""}if(!a)return{type:"none"};c.selectedCharacter=a}return{type:"full",command:u}},processCommand:function(a,b,c){b.inputState.repeatOverride=c.repeatOverride;switch(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=ia(c.motionArgs);this.evalInput(a,b)},processOperator:function(a,b,c){var d=b.inputState;if(d.operator){if(d.operator==c.operator){d.motion="expandToLine";d.motionArgs={linewise:!0};this.evalInput(a,b);return}G(a)}d.operator=c.operator;d.operatorArgs=ia(c.operatorArgs);b.visualMode&&this.evalInput(a,b)},processOperatorMotion:function(a,b,c){var d=b.visualMode,f=ia(c.operatorMotionArgs);f&&d&&f.visualLine&&(b.visualLine=!0);this.processOperator(a,b,c);d||this.processMotion(a,
b,c)},processAction:function(a,b,c){var d=b.inputState,f=d.getRepeat(),e=!!f,k=ia(c.actionArgs)||{};d.selectedCharacter&&(k.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);k.repeat=f||1;k.repeatIsExplicit=e;k.registerName=d.registerName;G(a);b.lastMotion=null;c.isEdit&&this.recordLastEdit(b,d,c);ea[c.action](a,k,b)},processSearch:function(a,b,c){function d(d,e,f){n.searchHistoryController.pushInput(d);
n.searchHistoryController.reset();try{Z(a,d,e,f)}catch(Bb){w(a,"Invalid regex: "+d);G(a);return}R.processMotion(a,b,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:c.searchArgs.toJumplist}})}function f(b){a.scrollTo(C.left,C.top);d(b,!0,!0);var c=n.macroModeState;c.isRecording&&(c.isPlaying||(c=n.registerController.getRegister(c.latestRegister))&&c.pushSearchQuery&&c.pushSearchQuery(b))}function e(b,c,d){var e=g.keyName(b);if("Up"==e||"Down"==e){var f=b.target?b.target.selectionEnd:
0;c=n.searchHistoryController.nextMatch(c,"Up"==e?!0:!1)||"";d(c);f&&b.target&&(b.target.selectionEnd=b.target.selectionStart=Math.min(f,b.target.value.length))}else"Left"!=e&&"Right"!=e&&"Ctrl"!=e&&"Alt"!=e&&"Shift"!=e&&n.searchHistoryController.reset();try{var h=Z(a,c,!0,!0)}catch(ma){}h?a.scrollIntoView(Xa(a,!l,h),30):(xa(a),a.scrollTo(C.left,C.top))}function k(b,c,d){var e=g.keyName(b);"Esc"==e||"Ctrl-C"==e||"Ctrl-["==e||"Backspace"==e&&""==c?(n.searchHistoryController.pushInput(c),n.searchHistoryController.reset(),
Z(a,p),xa(a),a.scrollTo(C.left,C.top),g.e_stop(b),G(a),d(),a.focus()):"Up"==e||"Down"==e?g.e_stop(b):"Ctrl-U"==e&&(g.e_stop(b),d(""))}if(a.getSearchCursor){var l=c.searchArgs.forward,h=c.searchArgs.wholeWordOnly;P(a).setReversed(!l);var m=l?"/":"?",p=P(a).getQuery(),C=a.getScrollInfo();switch(c.searchArgs.querySrc){case "prompt":h=n.macroModeState;h.isPlaying?(m=h.replaySearchQueries.shift(),d(m,!0,!1)):la(a,{onClose:f,prefix:m,desc:zb,onKeyUp:e,onKeyDown:k});break;case "wordUnderCursor":var u=ja(a,
!1,!0,!1,!0),t=!0;u||(u=ja(a,!1,!0,!1,!1),t=!1);u&&(m=a.getLine(u.start.line).substring(u.start.ch,u.end.ch),m=t&&h?"\\b"+m+"\\b":m.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1"),n.jumpList.cachedCursor=a.getCursor(),a.setCursor(u.start),d(m,!0,!1))}}},processEx:function(a,b,c){function d(b){n.exCommandHistoryController.pushInput(b);n.exCommandHistoryController.reset();M.processCommand(a,b)}function f(b,c,d){var e=g.keyName(b);if("Esc"==e||"Ctrl-C"==e||"Ctrl-["==e||"Backspace"==e&&""==c)n.exCommandHistoryController.pushInput(c),
n.exCommandHistoryController.reset(),g.e_stop(b),G(a),d(),a.focus();if("Up"==e||"Down"==e){g.e_stop(b);var f=b.target?b.target.selectionEnd:0;c=n.exCommandHistoryController.nextMatch(c,"Up"==e?!0:!1)||"";d(c);f&&b.target&&(b.target.selectionEnd=b.target.selectionStart=Math.min(f,b.target.value.length))}else"Ctrl-U"==e?(g.e_stop(b),d("")):"Left"!=e&&"Right"!=e&&"Ctrl"!=e&&"Alt"!=e&&"Shift"!=e&&n.exCommandHistoryController.reset()}"keyToEx"==c.type?M.processCommand(a,c.exArgs.input):b.visualMode?la(a,
{onClose:d,prefix:":",value:"'<,'>",onKeyDown:f,selectValueOnOpen:!1}):la(a,{onClose:d,prefix:":",onKeyDown:f})},evalInput:function(a,b){var c=b.inputState,d=c.motion,f=c.motionArgs||{},e=c.operator,k=c.operatorArgs||{},l=c.registerName,h=b.sel,g=A(b.visualMode?F(a,h.head):a.getCursor("head")),p=A(b.visualMode?F(a,h.anchor):a.getCursor("anchor")),C=A(g);p=A(p);e&&this.recordLastEdit(b,c);var u=void 0!==c.repeatOverride?c.repeatOverride:c.getRepeat();if(0<u&&f.explicitRepeat)f.repeatIsExplicit=!0;
else if(f.noRepeat||!f.explicitRepeat&&0===u)u=1,f.repeatIsExplicit=!1;c.selectedCharacter&&(f.selectedCharacter=k.selectedCharacter=c.selectedCharacter);f.repeat=u;G(a);if(d){var t=Q[d](a,g,f,b);b.lastMotion=Q[d];if(!t)return;f.toJumplist&&(d=n.jumpList,(c=d.cachedCursor)?(J(c,t)||n.jumpList.add(a,c,t),delete d.cachedCursor):J(g,t)||n.jumpList.add(a,g,t));if(t instanceof Array){var r=t[0];t=t[1]}t||(t=A(g));b.visualMode?(b.visualBlock&&Infinity===t.ch||(t=F(a,t,b.visualBlock)),r&&(r=F(a,r,!0)),r=
r||p,h.anchor=r,h.head=t,Y(a),O(a,b,"<",B(r,t)?r:t),O(a,b,">",B(r,t)?t:r)):e||(t=F(a,t),a.setCursor(t.line,t.ch))}if(e){k.lastSel?(r=p,h=k.lastSel,t=Math.abs(h.head.line-h.anchor.line),g=Math.abs(h.head.ch-h.anchor.ch),t=h.visualLine?m(p.line+t,p.ch):h.visualBlock?m(p.line+t,p.ch+g):h.head.line==h.anchor.line?m(p.line,p.ch+g):m(p.line+t,p.ch),b.visualMode=!0,b.visualLine=h.visualLine,b.visualBlock=h.visualBlock,h=b.sel={anchor:r,head:t},Y(a)):b.visualMode&&(k.lastSel={anchor:A(h.anchor),head:A(h.head),
visualBlock:b.visualBlock,visualLine:b.visualLine});if(b.visualMode){if(r=H(h.head,h.anchor),h=T(h.head,h.anchor),C=b.visualLine||k.linewise,f=b.visualBlock?"block":C?"line":"char",r=ua(a,{anchor:r,head:h},f),C)if(h=r.ranges,"block"==f)for(f=0;f<h.length;f++)h[f].head.ch=D(a,h[f].head.line);else"line"==f&&(h[0].head=m(h[0].head.line+1,0))}else{r=A(r||p);h=A(t||C);B(h,r)&&(C=r,r=h,h=C);if(C=f.linewise||k.linewise)g=h,r.ch=0,g.ch=0,g.line++;else if(f.forward&&(g=h,d=a.getRange(r,g),/\n\s*$/.test(d))){d=
d.split("\n");d.pop();for(c=d.pop();0<d.length&&c&&S(c);c=d.pop())g.line--,g.ch=0;c?(g.line--,g.ch=D(a,g.line)):g.ch=0}r=ua(a,{anchor:r,head:h},"char",!f.inclusive||C)}a.setSelections(r.ranges,r.primary);b.lastMotion=null;k.repeat=u;k.registerName=l;k.linewise=C;e=ib[e](a,k,r.ranges,p,t);b.visualMode&&K(a,null!=e);e&&a.setCursor(e)}},recordLastEdit:function(a,b,c){var d=n.macroModeState;d.isPlaying||(a.lastEditInputState=b,a.lastEditActionCommand=c,d.lastInsertModeChanges.changes=[],d.lastInsertModeChanges.expectCursorActivityForChange=
!1)}},Q={moveToTopLine:function(a,b,c){b=ya(a).top+c.repeat-1;return m(b,L(a.getLine(b)))},moveToMiddleLine:function(a){var b=ya(a);b=Math.floor(.5*(b.top+b.bottom));return m(b,L(a.getLine(b)))},moveToBottomLine:function(a,b,c){b=ya(a).bottom-c.repeat+1;return m(b,L(a.getLine(b)))},expandToLine:function(a,b,c){return m(b.line+c.repeat-1,Infinity)},findNext:function(a,b,c){b=P(a);var d=b.getQuery();if(d){var f=!c.forward;f=b.isReversed()?!f:f;Wa(a,d);return Xa(a,f,d,c.repeat)}},goToMark:function(a,
b,c,d){return(b=Ya(a,d,c.selectedCharacter))?c.linewise?{line:b.line,ch:L(a.getLine(b.line))}:b:null},moveToOtherHighlightedEnd:function(a,b,c,d){return d.visualBlock&&c.sameLine?(b=d.sel,[F(a,m(b.anchor.line,b.head.ch)),F(a,m(b.head.line,b.anchor.ch))]):[d.sel.head,d.sel.anchor]},jumpToMark:function(a,b,c,d){for(var f=0;f<c.repeat;f++){var e=b,k;for(k in d.marks)if(/^[a-z]$/.test(k)){var g=d.marks[k].find();if(c.forward?!B(g,e):!B(e,g))if(!c.linewise||g.line!=e.line){var h=J(e,b),y=c.forward?Ma(e,
g,b):Ma(b,g,e);if(h||y)b=g}}}c.linewise&&(b=m(b.line,L(a.getLine(b.line))));return b},moveByCharacters:function(a,b,c){a=c.repeat;return m(b.line,c.forward?b.ch+a:b.ch-a)},moveByLines:function(a,b,c,d){var f=b.ch;switch(d.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:f=d.lastHPos;break;default:d.lastHPos=f}var e=c.repeat+(c.repeatOffset||0);e=c.forward?b.line+e:b.line-e;var k=a.firstLine(),g=a.lastLine();if(e<k&&b.line==
k)return this.moveToStartOfLine(a,b,c,d);if(e>g&&b.line==g)return this.moveToEol(a,b,c,d);c.toFirstChar&&(f=L(a.getLine(e)),d.lastHPos=f);d.lastHSPos=a.charCoords(m(e,f),"div").left;return m(e,f)},moveByDisplayLines:function(a,b,c,d){switch(d.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:d.lastHSPos=a.charCoords(b,"div").left}var f=c.repeat;b=a.findPosV(b,c.forward?f:-f,"line",d.lastHSPos);b.hitSide&&
(c.forward?(c={top:a.charCoords(b,"div").top+8,left:d.lastHSPos},b=a.coordsChar(c,"div")):(c=a.charCoords(m(a.firstLine(),0),"div"),c.left=d.lastHSPos,b=a.coordsChar(c,"div")));d.lastHPos=b.ch;return b},moveByPage:function(a,b,c){var d=c.repeat;return a.findPosV(b,c.forward?d:-d,"page")},moveByParagraph:function(a,b,c){return Sa(a,b,c.repeat,c.forward?1:-1)},moveBySentence:function(a,b,c){return tb(a,b,c.repeat,c.forward?1:-1)},moveByScroll:function(a,b,c,d){var f=a.getScrollInfo(),e=c.repeat;e||
(e=f.clientHeight/(2*a.defaultTextHeight()));var k=a.charCoords(b,"local");c.repeat=e;b=Q.moveByDisplayLines(a,b,c,d);if(!b)return null;c=a.charCoords(b,"local");a.scrollTo(null,f.top+c.top-k.top);return b},moveByWords:function(a,b,c){var d=b,f=c.repeat;b=!!c.forward;var e=!!c.wordEnd,k=!!c.bigWord;c=A(d);var g=[];(b&&!e||!b&&e)&&f++;for(var h=!(b&&e),y=0;y<f;y++){b:{var p=a;var n=b,u=k,t=h,r=d.line,q=d.ch,z=p.getLine(r),v=n?1:-1;u=u?va:ka;if(t&&""==z){r+=v;z=p.getLine(r);if(!pa(p,r)){p=null;break b}q=
n?0:z.length}for(;;){if(t&&""==z){p={from:0,to:0,line:r};break b}n=0<v?z.length:-1;for(var w,ca;q!=n;){for(var ma=!1,x=0;x<u.length&&!ma;++x)if(u[x](z.charAt(q))){for(w=q;q!=n&&u[x](z.charAt(q));)q+=v;ca=q;ma=w!=ca;if(w!=d.ch||r!=d.line||ca!=w+v){p={from:Math.min(w,ca+1),to:Math.max(w,ca),line:r};break b}}ma||(q+=v)}r+=v;if(!pa(p,r)){p=null;break b}z=p.getLine(r);q=0<v?0:z.length}}if(!p){k=D(a,a.lastLine());g.push(b?{line:a.lastLine(),from:k,to:k}:{line:0,from:0,to:0});break}g.push(p);d=m(p.line,
b?p.to-1:p.from)}a=g.length!=f;f=g[0];k=g.pop();b&&!e?(a||f.from==c.ch&&f.line==c.line||(k=g.pop()),b=m(k.line,k.from)):b&&e?b=m(k.line,k.to-1):!b&&e?(a||f.to==c.ch&&f.line==c.line||(k=g.pop()),b=m(k.line,k.to)):b=m(k.line,k.from);return b},moveTillCharacter:function(a,b,c){a=wa(a,c.repeat,c.forward,c.selectedCharacter);b=c.forward?-1:1;Ra(b,c);if(!a)return null;a.ch+=b;return a},moveToCharacter:function(a,b,c){var d=c.repeat;Ra(0,c);return wa(a,d,c.forward,c.selectedCharacter)||b},moveToSymbol:function(a,
b,c){var d=c.repeat,f=c.forward,e=c.selectedCharacter;c=A(a.getCursor());var k=f?1:-1,g=f?a.lineCount():-1,h=c.ch,n=c.line,p=a.getLine(n);f={lineText:p,nextCh:p.charAt(h),lastCh:null,index:h,symb:e,reverseSymb:(f?{")":"(","}":"{"}:{"(":")","{":"}"})[e],forward:f,depth:0,curMoveThrough:!1};if(h=Ab[e]){e=jb[h].init;h=jb[h].isComplete;for(e&&e(f);n!==g&&d;)f.index+=k,f.nextCh=f.lineText.charAt(f.index),f.nextCh||(n+=k,f.lineText=a.getLine(n)||"",0<k?f.index=0:(e=f.lineText.length,f.index=0<e?e-1:0),
f.nextCh=f.lineText.charAt(f.index)),h(f)&&(c.line=n,c.ch=f.index,d--);a=f.nextCh||f.curMoveThrough?m(n,f.index):c}else a=c;return a||b},moveToColumn:function(a,b,c,d){c=c.repeat;d.lastHPos=c-1;d.lastHSPos=a.charCoords(b,"div").left;b=a.getCursor().line;return F(a,m(b,c-1))},moveToEol:function(a,b,c,d){d.lastHPos=Infinity;b=m(b.line+c.repeat-1,Infinity);c=a.clipPos(b);c.ch--;d.lastHSPos=a.charCoords(c,"div").left;return b},moveToFirstNonWhiteSpaceCharacter:function(a,b){return m(b.line,L(a.getLine(b.line)))},
moveToMatchedSymbol:function(a,b){for(var c=b.line,d=b.ch,f=a.getLine(c),e;d<f.length&&(!(e=f.charAt(d))||-1=="()[]{}".indexOf(e)||(e=a.getTokenTypeAt(m(c,d+1)),"string"===e||"comment"===e));d++);return d<f.length?(b="<"===d||">"===d?/[(){}[\]<>]/:/[(){}[\]]/,a.findMatchingBracket(m(c,d),{bracketRegex:b}).to):b},moveToStartOfLine:function(a,b){return m(b.line,0)},moveToLineOrEdgeOfDocument:function(a,b,c){b=c.forward?a.lastLine():a.firstLine();c.repeatIsExplicit&&(b=c.repeat-a.getOption("firstLineNumber"));
return m(b,L(a.getLine(b)))},textObjectManipulation:function(a,b,c,d){var f={"'":!0,'"':!0},e=c.selectedCharacter;"b"==e?e="(":"B"==e&&(e="{");var k=!c.textObjectInner;if({"(":")",")":"(","{":"}","}":"{","[":"]","]":"[","<":">",">":"<"}[e]){var g={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[e];var h={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[e];c=a.getLine(b.line).charAt(b.ch)===h?1:0;h=a.scanForBracket(m(b.line,b.ch+c),-1,void 0,
{bracketRegex:g});g=a.scanForBracket(m(b.line,b.ch+c),1,void 0,{bracketRegex:g});if(h&&g){h=h.pos;g=g.pos;if(h.line==g.line&&h.ch>g.ch||h.line>g.line)b=h,h=g,g=b;k?g.ch+=1:h.ch+=1;b={start:h,end:g}}else b={start:b,end:b}}else if(f[e]){c=e;b=A(b);d=a.getLine(b.line).split("");e=d.indexOf(c);b.ch<e?b.ch=e:e<b.ch&&d[b.ch]==c&&(g=b.ch,--b.ch);if(d[b.ch]!=c||g)for(e=b.ch;-1<e&&!h;e--)d[e]==c&&(h=e+1);else h=b.ch+1;if(h&&!g)for(e=h,f=d.length;e<f&&!g;e++)d[e]==c&&(g=e);h&&g?(k&&(--h,++g),b={start:m(b.line,
h),end:m(b.line,g)}):b={start:b,end:b}}else if("W"===e)b=ja(a,k,!0,!0);else if("w"===e)b=ja(a,k,!0,!1);else if("p"===e)if(b=Sa(a,b,c.repeat,0,k),c.linewise=!0,d.visualMode)d.visualLine||(d.visualLine=!0);else{if(k=d.inputState.operatorArgs)k.linewise=!0;b.end.line--}else return null;return a.state.vim.visualMode?(k=b.start,b=b.end,g=a.state.vim.sel,h=g.head,g=g.anchor,B(b,k)&&(c=b,b=k,k=c),B(h,g)?(h=H(k,h),g=T(g,b)):(g=H(k,g),h=T(h,b),h=E(h,0,-1),-1==h.ch&&h.line!=a.firstLine()&&(h=m(h.line-1,D(a,
h.line-1)))),[g,h]):[b.start,b.end]},repeatLastCharacterSearch:function(a,b,c){var d=n.lastCharacterSearch,f=c.repeat,e=c.forward===d.forward,g=(d.increment?1:0)*(e?-1:1);a.moveH(-g,"char");c.inclusive=e?!0:!1;c=wa(a,f,e,d.selectedCharacter);if(!c)return a.moveH(g,"char"),b;c.ch+=g;return c}},ib={change:function(a,b,c){var d=a.state.vim;n.macroModeState.lastInsertModeChanges.inVisualBlock=d.visualBlock;if(d.visualMode){var f=a.getSelection();var e=Ka("",c.length);a.replaceSelections(e);e=H(c[0].head,
c[0].anchor)}else{e=c[0].anchor;var k=c[0].head;f=a.getRange(e,k);d=d.lastEditInputState||{};if("moveByWords"==d.motion&&!S(f)){var l=/\s+$/.exec(f);l&&d.motionArgs&&d.motionArgs.forward&&(k=E(k,0,-l[0].length),f=f.slice(0,-l[0].length))}d=new m(e.line-1,Number.MAX_VALUE);l=a.firstLine()==a.lastLine();k.line>a.lastLine()&&b.linewise&&!l?a.replaceRange("",d,k):a.replaceRange("",e,k);b.linewise&&(l||(a.setCursor(d),g.commands.newlineAndIndent(a)),e.ch=Number.MAX_VALUE)}n.registerController.pushText(b.registerName,
"change",f,b.linewise,1<c.length);ea.enterInsertMode(a,{head:e},a.state.vim)},"delete":function(a,b,c){var d=a.state.vim;if(d.visualBlock){var f=a.getSelection();var e=Ka("",c.length);a.replaceSelections(e);c=c[0].anchor}else e=c[0].anchor,c=c[0].head,b.linewise&&c.line!=a.firstLine()&&e.line==a.lastLine()&&e.line==c.line-1&&(e.line==a.firstLine()?e.ch=0:e=m(e.line-1,D(a,e.line-1))),f=a.getRange(e,c),a.replaceRange("",e,c),c=e,b.linewise&&(c=Q.moveToFirstNonWhiteSpaceCharacter(a,e));n.registerController.pushText(b.registerName,
"delete",f,b.linewise,d.visualBlock);return F(a,c,d.insertMode)},indent:function(a,b,c){var d=a.state.vim,f=c[0].anchor.line,e=d.visualBlock?c[c.length-1].anchor.line:c[0].head.line;d=d.visualMode?b.repeat:1;for(b.linewise&&e--;f<=e;f++)for(var g=0;g<d;g++)a.indentLine(f,b.indentRight);return Q.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},indentAuto:function(a,b,c){a.execCommand("indentAuto");return Q.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},changeCase:function(a,b,c,d,f){for(var e=
a.getSelections(),g=[],l=b.toLower,h=0;h<e.length;h++){var m=e[h],p="";if(!0===l)p=m.toLowerCase();else if(!1===l)p=m.toUpperCase();else for(var n=0;n<m.length;n++){var u=m.charAt(n);p+=W(u)?u.toLowerCase():u.toUpperCase()}g.push(p)}a.replaceSelections(g);return b.shouldMoveCursor?f:!a.state.vim.visualMode&&b.linewise&&c[0].anchor.line+1==c[0].head.line?Q.moveToFirstNonWhiteSpaceCharacter(a,d):b.linewise?d:H(c[0].anchor,c[0].head)},yank:function(a,b,c,d){var f=a.state.vim;a=a.getSelection();c=f.visualMode?
H(f.sel.anchor,f.sel.head,c[0].head,c[0].anchor):d;n.registerController.pushText(b.registerName,"yank",a,b.linewise,f.visualBlock);return c}},ea={jumpListWalk:function(a,b,c){c.visualMode||(c=b.repeat,b=(b=(b=n.jumpList.move(a,b.forward?c:-c))?b.find():void 0)?b:a.getCursor(),a.setCursor(b))},scroll:function(a,b,c){if(!c.visualMode){var d=b.repeat||1;c=a.defaultTextHeight();var f=a.getScrollInfo().top;d*=c;f=b.forward?f+d:f-d;d=A(a.getCursor());var e=a.charCoords(d,"local");b.forward?f>e.top?(d.line+=
(f-e.top)/c,d.line=Math.ceil(d.line),a.setCursor(d),e=a.charCoords(d,"local"),a.scrollTo(null,e.top)):a.scrollTo(null,f):(b=f+a.getScrollInfo().clientHeight,b<e.bottom?(d.line-=(e.bottom-b)/c,d.line=Math.floor(d.line),a.setCursor(d),e=a.charCoords(d,"local"),a.scrollTo(null,e.bottom-a.getScrollInfo().clientHeight)):a.scrollTo(null,f))}},scrollToCursor:function(a,b){var c=a.getCursor().line,d=a.charCoords(m(c,0),"local");c=a.getScrollInfo().clientHeight;var f=d.top;d=d.bottom-f;switch(b.position){case "center":f=
f-c/2+d;break;case "bottom":f=f-c+d}a.scrollTo(null,f)},replayMacro:function(a,b,c){var d=b.selectedCharacter;b=b.repeat;var f=n.macroModeState;"@"==d&&(d=f.latestRegister);for(;b--;){var e=a,k=c,l=f,h=d,m=n.registerController.getRegister(h);if(":"==h)m.keyBuffer[0]&&M.processCommand(e,m.keyBuffer[0]);else{h=m.keyBuffer;var p=0;l.isPlaying=!0;l.replaySearchQueries=m.searchQueries.slice(0);for(var q=0;q<h.length;q++)for(var u=h[q],t,r;u;)t=/<\w+-.+?>|<\w+>|./.exec(u),r=t[0],u=u.substring(t.index+r.length),
g.Vim.handleKey(e,r,"macro"),k.insertMode&&(t=m.insertModeChanges[p++].changes,n.macroModeState.lastInsertModeChanges.changes=t,cb(e,t,1),aa(e))}l.isPlaying=!1}},enterMacroRecordMode:function(a,b){var c=n.macroModeState;b=b.selectedCharacter;n.registerController.isValidRegister(b)&&c.enterMacroRecordMode(a,b)},toggleOverwrite:function(a){a.state.overwrite?(a.toggleOverwrite(!1),a.setOption("keyMap","vim-insert"),g.signal(a,"vim-mode-change",{mode:"insert"})):(a.toggleOverwrite(!0),a.setOption("keyMap",
"vim-replace"),g.signal(a,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(a,b,c){if(!a.getOption("readOnly")){c.insertMode=!0;c.insertModeRepeat=b&&b.repeat||1;var d=b?b.insertAt:null,f=c.sel,e=b.head||a.getCursor("head"),k=a.listSelections().length;if("eol"==d)e=m(e.line,D(a,e.line));else if("charAfter"==d)e=E(e,0,1);else if("firstNonBlank"==d)e=Q.moveToFirstNonWhiteSpaceCharacter(a,e);else if("startOfSelectedArea"==d)c.visualBlock?(e=m(Math.min(f.head.line,f.anchor.line),Math.min(f.head.ch,
f.anchor.ch)),k=Math.abs(f.head.line-f.anchor.line)+1):e=f.head.line<f.anchor.line?f.head:m(f.anchor.line,0);else if("endOfSelectedArea"==d)c.visualBlock?(e=m(Math.min(f.head.line,f.anchor.line),Math.max(f.head.ch+1,f.anchor.ch)),k=Math.abs(f.head.line-f.anchor.line)+1):e=f.head.line>=f.anchor.line?E(f.head,0,1):m(f.anchor.line,0);else if("inplace"==d&&c.visualMode)return;a.setOption("disableInput",!1);b&&b.replace?(a.toggleOverwrite(!0),a.setOption("keyMap","vim-replace"),g.signal(a,"vim-mode-change",
{mode:"replace"})):(a.toggleOverwrite(!1),a.setOption("keyMap","vim-insert"),g.signal(a,"vim-mode-change",{mode:"insert"}));n.macroModeState.isPlaying||(a.on("change",Za),g.on(a.getInputField(),"keydown",$a));c.visualMode&&K(a);Oa(a,e,k)}},toggleVisualMode:function(a,b,c){var d=b.repeat,f=a.getCursor();c.visualMode?c.visualLine^b.linewise||c.visualBlock^b.blockwise?(c.visualLine=!!b.linewise,c.visualBlock=!!b.blockwise,g.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?
"blockwise":""}),Y(a)):K(a):(c.visualMode=!0,c.visualLine=!!b.linewise,c.visualBlock=!!b.blockwise,b=F(a,m(f.line,f.ch+d-1),!0),c.sel={anchor:f,head:b},g.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}),Y(a),O(a,c,"<",H(f,b)),O(a,c,">",T(f,b)))},reselectLastSelection:function(a,b,c){b=c.lastSelection;c.visualMode&&Pa(a,c);if(b){var d=b.anchorMark.find(),f=b.headMark.find();d&&f&&(c.sel={anchor:d,head:f},c.visualMode=!0,c.visualLine=b.visualLine,
c.visualBlock=b.visualBlock,Y(a),O(a,c,"<",H(d,f)),O(a,c,">",T(d,f)),g.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}))}},joinLines:function(a,b,c){if(c.visualMode){b=a.getCursor("anchor");var d=a.getCursor("head");if(B(d,b)){var f=d;d=b;b=f}d.ch=D(a,d.line)-1}else d=Math.max(b.repeat,2),b=a.getCursor(),d=F(a,m(b.line+d-1,Infinity));for(var e=0,g=b.line;g<d.line;g++){e=D(a,b.line);f=m(b.line+1,D(a,b.line+1));var l=a.getRange(b,f);l=l.replace(/\n\s*/g,
" ");a.replaceRange(l,b,f)}b=m(b.line,e);c.visualMode&&K(a,!1);a.setCursor(b)},newLineAndEnterInsertMode:function(a,b,c){c.insertMode=!0;var d=A(a.getCursor());d.line!==a.firstLine()||b.after?(d.line=b.after?d.line:d.line-1,d.ch=D(a,d.line),a.setCursor(d),(g.commands.newlineAndIndentContinueComment||g.commands.newlineAndIndent)(a)):(a.replaceRange("\n",m(a.firstLine(),0)),a.setCursor(a.firstLine(),0));this.enterInsertMode(a,{repeat:b.repeat},c)},paste:function(a,b,c){var d=A(a.getCursor()),f=n.registerController.getRegister(b.registerName),
e=f.toString();if(e){if(b.matchIndent){var g=a.getOption("tabSize"),l=function(a){var b=a.split("\t").length-1;a=a.split(" ").length-1;return b*g+1*a},h=a.getLine(a.getCursor().line),q=l(h.match(/^\s*/)[0]);h=e.replace(/\n$/,"");var p=e!==h,C=l(e.match(/^\s*/)[0]);e=h.replace(/^\s*/gm,function(b){b=q+(l(b)-C);return 0>b?"":a.getOption("indentWithTabs")?Array(Math.floor(b/g)+1).join("\t"):Array(b+1).join(" ")});e+=p?"\n":""}1<b.repeat&&(e=Array(b.repeat+1).join(e));h=f.linewise;f=f.blockwise;if(h)c.visualMode?
e=c.visualLine?e.slice(0,-1):"\n"+e.slice(0,e.length-1)+"\n":b.after?(e="\n"+e.slice(0,e.length-1),d.ch=D(a,d.line)):d.ch=0;else{if(f)for(e=e.split("\n"),p=0;p<e.length;p++)e[p]=""==e[p]?" ":e[p];d.ch+=b.after?1:0}var u;if(c.visualMode){c.lastPastedText=e;b=rb(a,c);d=b[0];b=b[1];p=a.getSelection();var t=a.listSelections();t=Array(t.length).join("1").split("1");c.lastSelection&&(u=c.lastSelection.headMark.find());n.registerController.unnamedRegister.setText(p);f?(a.replaceSelections(t),b=m(d.line+
e.length-1,d.ch),a.setCursor(d),Na(a,b),a.replaceSelections(e),e=d):c.visualBlock?(a.replaceSelections(t),a.setCursor(d),a.replaceRange(e,d,d),e=d):(a.replaceRange(e,d,b),e=a.posFromIndex(a.indexFromPos(d)+e.length-1));u&&(c.lastSelection.headMark=a.setBookmark(u));h&&(e.ch=0)}else if(f){a.setCursor(d);for(p=0;p<e.length;p++)u=d.line+p,u>a.lastLine()&&a.replaceRange("\n",m(u,0)),D(a,u)<d.ch&&qb(a,u,d.ch);a.setCursor(d);Na(a,m(d.line+e.length-1,d.ch));a.replaceSelections(e);e=d}else a.replaceRange(e,
d),h&&b.after?e=m(d.line+1,L(a.getLine(d.line+1))):h&&!b.after?e=m(d.line,L(a.getLine(d.line))):!h&&b.after?(u=a.indexFromPos(d),e=a.posFromIndex(u+e.length-1)):(u=a.indexFromPos(d),e=a.posFromIndex(u+e.length));c.visualMode&&K(a,!1);a.setCursor(e)}},undo:function(a,b){a.operation(function(){La(a,g.commands.undo,b.repeat)();a.setCursor(a.getCursor("anchor"))})},redo:function(a,b){La(a,g.commands.redo,b.repeat)()},setRegister:function(a,b,c){c.inputState.registerName=b.selectedCharacter},setMark:function(a,
b,c){O(a,c,b.selectedCharacter,a.getCursor())},replace:function(a,b,c){var d=b.selectedCharacter,f=a.getCursor(),e=a.listSelections();if(c.visualMode){f=a.getCursor("start");var k=a.getCursor("end")}else k=a.getLine(f.line),b=f.ch+b.repeat,b>k.length&&(b=k.length),k=m(f.line,b);"\n"==d?(c.visualMode||a.replaceRange("",f,k),(g.commands.newlineAndIndentContinueComment||g.commands.newlineAndIndent)(a)):(b=a.getRange(f,k),b=b.replace(/[^\n]/g,d),c.visualBlock?(f=Array(a.getOption("tabSize")+1).join(" "),
b=a.getSelection(),b=b.replace(/\t/g,f).replace(/[^\n]/g,d).split("\n"),a.replaceSelections(b)):a.replaceRange(b,f,k),c.visualMode?(f=B(e[0].anchor,e[0].head)?e[0].anchor:e[0].head,a.setCursor(f),K(a,!1)):a.setCursor(E(k,0,-1)))},incrementNumberToken:function(a,b){for(var c=a.getCursor(),d=a.getLine(c.line),f=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi,e,g,l;null!==(e=f.exec(d))&&!(g=e.index,l=g+e[0].length,c.ch<l););if((b.backtrack||!(l<=c.ch))&&e){d=e[2]||e[4];f=e[3]||e[5];var h=b.increase?1:-1,n={"0b":2,
0:8,"":10,"0x":16}[d.toLowerCase()];b=(parseInt(e[1]+f,n)+h*b.repeat).toString(n);e=d?Array(f.length-b.length+1+e[1].length).join("0"):"";b="-"===b.charAt(0)?"-"+d+e+b.substr(1):d+e+b;e=m(c.line,g);l=m(c.line,l);a.replaceRange(b,e,l);a.setCursor(m(c.line,g+b.length-1))}},repeatLastEdit:function(a,b,c){if(c.lastEditInputState){var d=b.repeat;d&&b.repeatIsExplicit?c.lastEditInputState.repeatOverride=d:d=c.lastEditInputState.repeatOverride||d;ab(a,c,d,!1)}},indent:function(a,b){a.indentLine(a.getCursor().line,
b.indentRight)},exitInsertMode:aa},Ab={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},jb={bracket:{isComplete:function(a){if(a.nextCh===a.symb){if(a.depth++,1<=a.depth)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;a.lastCh=a.nextCh;return 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}}};fa("pcre",
!0,"boolean");Ta.prototype={getQuery:function(){return n.query},setQuery:function(a){n.query=a},getOverlay:function(){return this.searchOverlay},setOverlay:function(a){this.searchOverlay=a},isReversed:function(){return n.isReversed},setReversed:function(a){n.isReversed=a},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(a){this.annotate=a}};var kb={"\\n":"\n","\\r":"\r","\\t":"\t"},lb={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":"\t"},zb="(Javascript regexp)",
mb=function(){this.buildCommandMap_()};mb.prototype={processCommand:function(a,b,c){var d=this;a.operation(function(){a.curOp.isVimOp=!0;d._processCommand(a,b,c)})},_processCommand:function(a,b,c){var d=a.state.vim,f=n.registerController.getRegister(":"),e=f.toString();d.visualMode&&K(a);d=new g.StringStream(b);f.setText(b);c=c||{};c.input=b;try{this.parseInput_(a,d,c)}catch(h){throw w(a,h),h;}var k;if(c.commandName){if(k=this.matchCommand_(c.commandName)){var l=k.name;k.excludeFromCommandHistory&&
f.setText(e);this.parseCommandArgs_(d,c,k);if("exToKey"==k.type){for(b=0;b<k.toKeys.length;b++)g.Vim.handleKey(a,k.toKeys[b],"mapping");return}if("exToEx"==k.type){this.processCommand(a,k.toInput);return}}}else void 0!==c.line&&(l="move");if(l)try{hb[l](a,c),k&&k.possiblyAsync||!c.callback||c.callback()}catch(h){throw w(a,h),h;}else w(a,'Not an editor command ":'+b+'"')},parseInput_:function(a,b,c){b.eatWhile(":");b.eat("%")?(c.line=a.firstLine(),c.lineEnd=a.lastLine()):(c.line=this.parseLineSpec_(a,
b),void 0!==c.line&&b.eat(",")&&(c.lineEnd=this.parseLineSpec_(a,b)));a=b.match(/^(\w+)/);c.commandName=a?a[1]:b.match(/.*/)[0];return c},parseLineSpec_:function(a,b){var c=b.match(/^(\d+)/);if(c)return parseInt(c[1],10)-1;switch(b.next()){case ".":return this.parseLineSpecOffset_(b,a.getCursor().line);case "$":return this.parseLineSpecOffset_(b,a.lastLine());case "'":c=b.next();a=Ya(a,a.state.vim,c);if(!a)throw Error("Mark not set");return this.parseLineSpecOffset_(b,a.line);case "-":case "+":return b.backUp(1),
this.parseLineSpecOffset_(b,a.getCursor().line);default:b.backUp(1)}},parseLineSpecOffset_:function(a,b){if(a=a.match(/^([+-])?(\d+)/)){var c=parseInt(a[2],10);b="-"==a[1]?b-c:b+c}return b},parseCommandArgs_:function(a,b,c){a.eol()||(b.argString=a.match(/.*/)[0],a=c.argDelimiter||/\s+/,a=ta(b.argString).split(a),a.length&&a[0]&&(b.args=a))},matchCommand_:function(a){for(var b=a.length;0<b;b--){var c=a.substring(0,b);if(this.commandMap_[c]&&(c=this.commandMap_[c],0===c.name.indexOf(a)))return c}return null},
buildCommandMap_:function(){this.commandMap_={};for(var a=0;a<x.length;a++){var b=x[a];this.commandMap_[b.shortName||b.name]=b}},map:function(a,b,c){if(":"!=a&&":"==a.charAt(0)){if(c)throw Error("Mode not supported for ex mappings");c=a.substring(1);":"!=b&&":"==b.charAt(0)?this.commandMap_[c]={name:c,type:"exToEx",toInput:b.substring(1),user:!0}:this.commandMap_[c]={name:c,type:"exToKey",toKeys:b,user:!0}}else b=":"!=b&&":"==b.charAt(0)?{keys:a,type:"keyToEx",exArgs:{input:b.substring(1)}}:{keys:a,
type:"keyToKey",toKeys:b},c&&(b.context=c),q.unshift(b)},unmap:function(a,b){if(":"!=a&&":"==a.charAt(0)){if(b)throw Error("Mode not supported for ex mappings");a=a.substring(1);if(this.commandMap_[a]&&this.commandMap_[a].user){delete this.commandMap_[a];return}}else for(var c=0;c<q.length;c++)if(a==q[c].keys&&q[c].context===b){q.splice(c,1);return}throw Error("No such mapping.");}};var hb={colorscheme:function(a,b){!b.args||1>b.args.length?w(a,a.getOption("theme")):a.setOption("theme",b.args[0])},
map:function(a,b,c){var d=b.args;!d||2>d.length?a&&w(a,"Invalid mapping: "+b.input):M.map(d[0],d[1],c)},imap:function(a,b){this.map(a,b,"insert")},nmap:function(a,b){this.map(a,b,"normal")},vmap:function(a,b){this.map(a,b,"visual")},unmap:function(a,b,c){var d=b.args;!d||1>d.length?a&&w(a,"No such mapping: "+b.input):M.unmap(d[0],c)},move:function(a,b){R.processCommand(a,a.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:b.line+
1})},set:function(a,b){var c=b.args,d=b.setCfg||{};if(!c||1>c.length)a&&w(a,"Invalid mapping: "+b.input);else{var f=c[0].split("=");c=f[0];f=f[1];var e=!1;if("?"==c.charAt(c.length-1)){if(f)throw Error("Trailing characters: "+b.argString);c=c.substring(0,c.length-1);e=!0}void 0===f&&"no"==c.substring(0,2)&&(c=c.substring(2),f=!1);(b=N[c]&&"boolean"==N[c].type)&&void 0==f&&(f=!0);!b&&void 0===f||e?(d=X(c,a,d),d instanceof Error?w(a,d.message):!0===d||!1===d?w(a," "+(d?"":"no")+c):w(a,"  "+c+"="+d)):
(d=ra(c,f,a,d),d instanceof Error&&w(a,d.message))}},setlocal:function(a,b){b.setCfg={scope:"local"};this.set(a,b)},setglobal:function(a,b){b.setCfg={scope:"global"};this.set(a,b)},registers:function(a,b){var c=b.args;b=n.registerController.registers;var d="----------Registers----------<br><br>";if(c){c=c.join("");for(var f=0;f<c.length;f++)if(g=c.charAt(f),n.registerController.isValidRegister(g)){var e=b[g]||new I;d+='"'+g+"    "+e.toString()+"<br>"}}else for(var g in b)c=b[g].toString(),c.length&&
(d+='"'+g+"    "+c+"<br>");w(a,d)},sort:function(a,b){function c(a,b){if(f){var c=a;a=b;b=c}e&&(a=a.toLowerCase(),b=b.toLowerCase());c=l&&u.exec(a);var d=l&&u.exec(b);if(!c)return a<b?-1:1;c=parseInt((c[1]+c[2]).toLowerCase(),t);d=parseInt((d[1]+d[2]).toLowerCase(),t);return c-d}function d(a,b){if(f){var c=a;a=b;b=c}e&&(a[0]=a[0].toLowerCase(),b[0]=b[0].toLowerCase());return a[0]<b[0]?-1:1}var f,e,k,l,h,n=function(){if(b.argString){var a=new g.StringStream(b.argString);a.eat("!")&&(f=!0);if(!a.eol()){if(!a.eatSpace())return"Invalid arguments";
var c=a.match(/([dinuox]+)?\s*(\/.+\/)?\s*/);if(!c&&!a.eol())return"Invalid arguments";if(c[1]){e=-1!=c[1].indexOf("i");k=-1!=c[1].indexOf("u");a=-1!=c[1].indexOf("d")||-1!=c[1].indexOf("n")&&1;var d=-1!=c[1].indexOf("x")&&1,m=-1!=c[1].indexOf("o")&&1;if(1<a+d+m)return"Invalid arguments";l=a&&"decimal"||d&&"hex"||m&&"octal"}c[2]&&(h=new RegExp(c[2].substr(1,c[2].length-2),e?"i":""))}}}();if(n)w(a,n+": "+b.argString);else{n=b.line||a.firstLine();var p=b.lineEnd||b.line||a.lastLine();if(n!=p){n=m(n,
0);p=m(p,D(a,p));var q=a.getRange(n,p).split("\n"),u=h?h:"decimal"==l?/(-?)([\d]+)/:"hex"==l?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==l?/([0-7]+)/:null,t="decimal"==l?10:"hex"==l?16:"octal"==l?8:null,r=[],v=[];if(l||h)for(var z=0;z<q.length;z++){var x=h?q[z].match(h):null;x&&""!=x[0]?r.push(x):!h&&u.exec(q[z])?r.push(q[z]):v.push(q[z])}else v=q;r.sort(h?d:c);if(h)for(z=0;z<r.length;z++)r[z]=r[z].input;else l||v.sort(c);q=f?r.concat(v):v.concat(r);if(k)for(r=q,q=[],z=0;z<r.length;z++){r[z]!=A&&q.push(r[z]);
var A=r[z]}a.replaceRange(q.join("\n"),n,p)}}},global:function(a,b){var c=b.argString;if(c){var d=void 0!==b.line?b.line:a.firstLine();b=b.lineEnd||b.line||a.lastLine();var f=Ua(c,"/");if(f.length){c=f[0];var e=f.slice(1,f.length).join("/")}if(c)try{Z(a,c,!0,!0)}catch(y){w(a,"Invalid regex: "+c);return}c=P(a).getQuery();var g=[];for(f="";d<=b;d++)c.test(a.getLine(d))&&(g.push(d+1),f+=a.getLine(d)+"<br>");if(e){var l=0,h=function(){l<g.length&&M.processCommand(a,g[l]+e,{callback:h});l++};h()}else w(a,
f)}else w(a,"Regular Expression missing from global")},substitute:function(a,b){if(!a.getSearchCursor)throw Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var c=b.argString,d=c?Ua(c,c[0]):[],f="",e,k=!1,l=!1;if(d.length){var h=d[0];f=d[1];h&&"$"===h[h.length-1]&&(h=h.slice(0,h.length-1)+"\\n",f=f?f+"\n":"\n");if(void 0!==f){if(X("pcre")){f=new g.StringStream(f);for(e=[];!f.eol();){for(;f.peek()&&"\\"!=f.peek();)e.push(f.next());c=!1;for(var q in lb)if(f.match(q,
!0)){c=!0;e.push(lb[q]);break}c||e.push(f.next())}f=e.join("")}else{q=!1;e=[];for(c=-1;c<f.length;c++){var p=f.charAt(c)||"",v=f.charAt(c+1)||"";kb[p+v]?(e.push(kb[p+v]),c++):q?(e.push(p),q=!1):"\\"===p?(q=!0,xb.test(v)||"$"===v?e.push("$"):"/"!==v&&"\\"!==v&&e.push("\\")):("$"===p&&e.push("$"),e.push(p),"/"===v&&e.push("\\"))}f=e.join("")}n.lastSubstituteReplacePart=f}e=d[2]?d[2].split(" "):[]}else if(c&&c.length){w(a,"Substitutions should be of the form :s/pattern/replace/");return}if(e){d=e[0];
var u=parseInt(e[1]);d&&(-1!=d.indexOf("c")&&(k=!0,d.replace("c","")),-1!=d.indexOf("g")&&(l=!0,d.replace("g","")),h=h.replace(/\//g,"\\/")+"/"+d)}if(h)try{Z(a,h,!0,!0)}catch(t){w(a,"Invalid regex: "+h);return}f=f||n.lastSubstituteReplacePart;void 0===f?w(a,"No previous substitute regular expression"):(h=P(a).getQuery(),d=void 0!==b.line?b.line:a.getCursor().line,q=b.lineEnd||d,d==a.firstLine()&&q==a.lastLine()&&(q=Infinity),u&&(d=q,q=d+u-1),u=F(a,m(d,0)),u=a.getSearchCursor(h,u),wb(a,k,l,d,q,u,h,
f,b.callback))},redo:g.commands.redo,undo:g.commands.undo,write:function(a){g.commands.save?g.commands.save(a):a.save&&a.save()},nohlsearch:function(a){xa(a)},yank:function(a){var b=A(a.getCursor()).line;a=a.getLine(b);n.registerController.pushText("0","yank",a,!0,!0)},delmarks:function(a,b){if(b.argString&&ta(b.argString))for(var c=a.state.vim,d=new g.StringStream(ta(b.argString));!d.eol();){d.eatSpace();var f=d.pos;if(!d.match(/[a-zA-Z]/,!1)){w(a,"Invalid argument: "+b.argString.substring(f));break}var e=
d.next();if(d.match("-",!0)){if(!d.match(/[a-zA-Z]/,!1)){w(a,"Invalid argument: "+b.argString.substring(f));break}var k=d.next();if(/^[a-z]$/.test(e)&&/^[a-z]$/.test(k)||W(e)&&W(k)){e=e.charCodeAt(0);k=k.charCodeAt(0);if(e>=k){w(a,"Invalid argument: "+b.argString.substring(f));break}for(f=0;f<=k-e;f++){var l=String.fromCharCode(e+f);delete c.marks[l]}}else{w(a,"Invalid argument: "+e+"-");break}}else delete c.marks[e]}else w(a,"Argument required")}},M=new mb;g.keyMap.vim={attach:V,detach:U,call:na};
fa("insertModeEscKeysTimeout",200,"number");g.keyMap["vim-insert"]={fallthrough:["default"],attach:V,detach:U,call:na};g.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:V,detach:U,call:na};Ia();return yb}()});
