ace.define("ace/keyboard/emacs",["require","exports","module","ace/lib/dom","ace/keyboard/hash_handler","ace/lib/keys"],function(e,t,n){var r=e("../lib/dom");var i=function(e,t){var n=this.scroller.getBoundingClientRect();var i=Math.floor((e+this.scrollLeft-n.left-this.$padding-r.getPageScrollLeft())/this.characterWidth);var s=Math.floor((t+this.scrollTop-n.top-r.getPageScrollTop())/this.lineHeight);return this.session.screenToDocumentPosition(s,i)};var s=e("./hash_handler").HashHandler;t.handler=
new s;var o=!1;t.handler.attach=function(e){o||(o=!0,r.importCssString("            .emacs-mode .ace_cursor{                border: 2px rgba(50,250,50,0.8) solid!important;                -moz-box-sizing: border-box!important;                -webkit-box-sizing: border-box!important;                box-sizing: border-box!important;                background-color: rgba(0,250,0,0.9);                opacity: 0.5;            }            .emacs-mode .ace_cursor.ace_hidden{                opacity: 1;                background-color: transparent;            }            .emacs-mode .ace_overwrite-cursors .ace_cursor {                opacity: 1;                background-color: transparent;                border-width: 0 0 2px 2px !important;            }            .emacs-mode .ace_text-layer {                z-index: 4            }            .emacs-mode .ace_cursor-layer {                z-index: 2            }",
"emacsMode")),e.renderer.screenToTextCoordinates=i,e.setStyle("emacs-mode")},t.handler.detach=function(e){delete e.renderer.screenToTextCoordinates,e.unsetStyle("emacs-mode")};var u=e("../lib/keys").KEY_MODS;var a={C:"ctrl",S:"shift",M:"alt"};["S-C-M","S-C","S-M","C-M","S","C","M"].forEach(function(e$$0){var t=0;e$$0.split("-").forEach(function(e){t|=u[a[e]]}),a[t]=e$$0.toLowerCase()+"-"}),t.handler.bindKey=function(e$$0,t){if(!e$$0)return;var n=this.commmandKeyBinding;e$$0.split("|").forEach(function(e){e=
e.toLowerCase(),n[e]=t,e=e.split(" ")[0],n[e]||(n[e]="null")},this)},t.handler.handleKeyboard=function(e$$0,t$$0,n$$0,r){if(t$$0==-1&&e$$0.count){var i=Array(e$$0.count+1).join(n$$0);return e$$0.count=null,{command:"insertstring",args:i}}if(n$$0=="\x00")return;var s=a[t$$0];if(s=="c-"||e$$0.universalArgument){var o=parseInt(n$$0[n$$0.length-1]);if(o)return e$$0.count=o,{command:"null"}}e$$0.universalArgument=!1,s&&(n$$0=s+n$$0),e$$0.keyChain&&(n$$0=e$$0.keyChain+=" "+n$$0);var u=this.commmandKeyBinding[n$$0];
e$$0.keyChain=u=="null"?n$$0:"";if(!u)return;if(u=="null")return{command:"null"};if(u=="universalArgument")return e$$0.universalArgument=!0,{command:"null"};if(typeof u!="string"){var f=u.args;u=u.command}typeof u=="string"&&(u=this.commands[u]||e$$0.editor.commands.commands[u]),!u.readonly&&!u.isYank&&(e$$0.lastCommand=null);if(e$$0.count){o=e$$0.count;return e$$0.count=0,{args:f,command:{exec:function(e,t){for(var n=0;n<o;n++)u.exec(e,t)}}}}return{command:u,args:f}},t.emacsKeys={"Up|C-p":"golineup",
"Down|C-n":"golinedown","Left|C-b":"gotoleft","Right|C-f":"gotoright","C-Left|M-b":"gotowordleft","C-Right|M-f":"gotowordright","Home|C-a":"gotolinestart","End|C-e":"gotolineend","C-Home|S-M-,":"gotostart","C-End|S-M-.":"gotoend","S-Up|S-C-p":"selectup","S-Down|S-C-n":"selectdown","S-Left|S-C-b":"selectleft","S-Right|S-C-f":"selectright","S-C-Left|S-M-b":"selectwordleft","S-C-Right|S-M-f":"selectwordright","S-Home|S-C-a":"selecttolinestart","S-End|S-C-e":"selecttolineend","S-C-Home":"selecttostart",
"S-C-End":"selecttoend","C-l":"recenterTopBottom","M-s":"centerselection","M-g":"gotoline","C-x C-p":"selectall","C-Down":"gotopagedown","C-Up":"gotopageup","PageDown|C-v":"gotopagedown","PageUp|M-v":"gotopageup","S-C-Down":"selectpagedown","S-C-Up":"selectpageup","C-s":"findnext","C-r":"findprevious","M-C-s":"findnext","M-C-r":"findprevious","S-M-5":"replace",Backspace:"backspace","Delete|C-d":"del","Return|C-m":{command:"insertstring",args:"\n"},"C-o":"splitline","M-d|C-Delete":{command:"killWord",
args:"right"},"C-Backspace|M-Backspace|M-Delete":{command:"killWord",args:"left"},"C-k":"killLine","C-y|S-Delete":"yank","M-y":"yankRotate","C-g":"keyboardQuit","C-w":"killRegion","M-w":"killRingSave","C-Space":"setMark","C-x C-x":"exchangePointAndMark","C-t":"transposeletters","M-u":"touppercase","M-l":"tolowercase","M-/":"autocomplete","C-u":"universalArgument","M-;":"togglecomment","C-/|C-x u|S-C--|C-z":"undo","S-C-/|S-C-x u|C--|S-C-z":"redo","C-x r":"selectRectangularRegion"},t.handler.bindKeys(t.emacsKeys),
t.handler.addCommands({recenterTopBottom:function(e){var t=e.renderer;var n=t.$cursorLayer.getPixelPosition();var r=t.$size.scrollerHeight-t.lineHeight;var i=t.scrollTop;Math.abs(n.top-i)<2?i=n.top-r:Math.abs(n.top-i-r*0.5)<2?i=n.top:i=n.top-r*0.5,e.session.setScrollTop(i)},selectRectangularRegion:function(e){e.multiSelect.toggleBlockSelection()},setMark:function(){},exchangePointAndMark:{exec:function(e){var t=e.selection.getRange();e.selection.setSelectionRange(t,!e.selection.isBackwards())},readonly:!0,
multiselectAction:"forEach"},killWord:{exec:function(e,n){e.clearSelection(),n=="left"?e.selection.selectWordLeft():e.selection.selectWordRight();var r=e.getSelectionRange();var i=e.session.getTextRange(r);t.killRing.add(i),e.session.remove(r),e.clearSelection()},multiselectAction:"forEach"},killLine:function(e){e.selection.selectLine();var n=e.getSelectionRange();var r=e.session.getTextRange(n);t.killRing.add(r),e.session.remove(n),e.clearSelection()},yank:function(e){e.onPaste(t.killRing.get()),
e.keyBinding.$data.lastCommand="yank"},yankRotate:function(e){if(e.keyBinding.$data.lastCommand!="yank")return;e.undo(),e.onPaste(t.killRing.rotate()),e.keyBinding.$data.lastCommand="yank"},killRegion:function(e){t.killRing.add(e.getCopyText()),e.commands.byName.cut.exec(e)},killRingSave:function(e){t.killRing.add(e.getCopyText())}});var f=t.handler.commands;f.yank.isYank=!0,f.yankRotate.isYank=!0,t.killRing={$data:[],add:function(e){e&&this.$data.push(e),this.$data.length>30&&this.$data.shift()},
get:function(){return this.$data[this.$data.length-1]||""},pop:function(){return this.$data.length>1&&this.$data.pop(),this.get()},rotate:function(){return this.$data.unshift(this.$data.pop()),this.get()}}});