@liascript/editor
Version:
An extended Markdown interpreter for the creation of interactive online courses.
1 lines • 117 kB
JavaScript
ace.define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"],(function(e,t,n){"use strict";function r(e,t){function n(e,t,n){if(!(e.length<t)){var r=e.slice(0,t),i=e.slice(t),o=/^(?:(\s+)|(\S+)(\s+))/.exec(i),a=/(?:(\s+)|(\s+)(\S+))$/.exec(r),s=0,l=0;return a&&!a[2]&&(s=t-a[1].length,l=t),o&&!o[2]&&(s||(s=t),l=t+o[1].length),s?{start:s,end:l}:a&&a[2]&&a.index>n?{start:a.index,end:a.index+a[2].length}:o&&o[2]?{start:s=t+o[2].length,end:s+o[3].length}:void 0}}for(var r=t.column||e.getOption("printMarginColumn"),i=0!=t.allowMerge,a=Math.min(t.startRow,t.endRow),s=Math.max(t.startRow,t.endRow),l=e.session;a<=s;){var c=l.getLine(a);if(c.length>r){if(p=n(c,r,5)){var u=/^\s*/.exec(c)[0];l.replace(new o(a,p.start,a,p.end),"\n"+u)}s++}else if(i&&/\S/.test(c)&&a!=s){var h=l.getLine(a+1);if(h&&/\S/.test(h)){var p,d=c.replace(/\s+$/,""),f=h.replace(/^\s+/,""),m=d+" "+f;if((p=n(m,r,5))&&p.start>d.length||m.length<r){var g=new o(a,d.length,a+1,h.length-f.length);l.replace(g," "),a--,s--}else d.length<c.length&&l.remove(new o(a,d.length,a,c.length))}}a++}}function i(e){if("insertstring"==e.command.name&&/\S/.test(e.args)){var t=e.editor,n=t.selection.cursor;if(n.column<=t.renderer.$printMarginColumn)return;var i=t.session.$undoManager.$lastDelta;r(t,{startRow:n.row,endRow:n.row,allowMerge:!1}),i!=t.session.$undoManager.$lastDelta&&t.session.markUndoGroup()}}var o=e("../range").Range,a=e("../editor").Editor;e("../config").defineOptions(a.prototype,"editor",{hardWrap:{set:function(e){e?this.commands.on("afterExec",i):this.commands.off("afterExec",i)},value:!1}}),t.hardWrap=r})),ace.define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/dom","ace/lib/oop","ace/lib/keys","ace/lib/event","ace/search","ace/lib/useragent","ace/search_highlight","ace/commands/multi_select_commands","ace/mode/text","ace/ext/hardwrap","ace/multi_select"],(function(e,t,n){"use strict";function r(e){return{row:e.line,column:e.ch}}function i(e){return new st(e.row,e.column)}function o(e,t,n){if(t.line===n.line&&t.ch>=n.ch-1){var r=e.getLine(t.line).charCodeAt(t.ch);55296<=r&&r<=55551&&(n.ch+=1)}return{start:t,end:n}}function a(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),it.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",Pe),k(e),it.on(e.getInputField(),"paste",l(e))}function s(e){e.setOption("disableInput",!1),e.off("cursorActivity",Pe),it.off(e.getInputField(),"paste",l(e)),e.state.vim=null,_t&&clearTimeout(_t)}function l(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(H(e.getCursor(),0,1)),It.enterInsertMode(e,{},t))}),t.onPasteFn}function c(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function u(e){return/^[a-z]$/.test(e)}function h(e){return-1!="()[]{}".indexOf(e)}function p(e){return pt.test(e)}function d(e){return at.test(e)}function f(e){return/^\s*$/.test(e)}function m(e){return-1!=".?!".indexOf(e)}function g(e,t){for(var n=0;n<t.length;n++)if(t[n]==e)return!0;return!1}function v(e,t,n,r,i){if(void 0===t&&!i)throw Error("defaultValue is required unless callback is provided");if(n||(n="string"),yt[e]={type:n,defaultValue:t,callback:i},r)for(var o=0;o<r.length;o++)yt[r[o]]=yt[e];t&&y(e,t)}function y(e,t,n,r){var i=yt[e],o=(r=r||{}).scope;if(!i)return new Error("Unknown option: "+e);if("boolean"==i.type){if(t&&!0!==t)return new Error("Invalid argument: "+e+"="+t);!1!==t&&(t=!0)}i.callback?("local"!==o&&i.callback(t,void 0),"global"!==o&&n&&i.callback(t,n)):("local"!==o&&(i.value="boolean"==i.type?!!t:t),"global"!==o&&n&&(n.state.vim.options[e]={value:t}))}function C(e,t,n){var r=yt[e],i=(n=n||{}).scope;if(!r)return new Error("Unknown option: "+e);if(r.callback){var o=t&&r.callback(void 0,t);return"global"!==i&&void 0!==o?o:"local"!==i?r.callback():void 0}return((o="global"!==i&&t&&t.state.vim.options[e])||"local"!==i&&r||{}).value}function w(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=wt()}function k(e){return e.state.vim||(e.state.vim={inputState:new T,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{},expectLiteralNext:!1}),e.state.vim}function S(){for(var e in kt={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:Ct(),macroModeState:new w,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new B({}),searchHistoryController:new I,exCommandHistoryController:new I},yt){var t=yt[e];t.value=t.defaultValue}}function x(e){function t(e){"string"==typeof e?xt.value=e:xt=null}if("<"==e[0]){var n=e.toLowerCase().slice(1,-1),r=n.split("-");if("lt"==(n=r.pop()||""))e="<";else if("space"==n)e=" ";else if("cr"==n)e="\n";else if(Et[n]){var i=xt.value,o={key:Et[n],target:{value:i,selectionEnd:i.length,selectionStart:i.length}};return xt.onKeyDown&&xt.onKeyDown(o,xt.value,t),void(xt&&xt.onKeyUp&&xt.onKeyUp(o,xt.value,t))}}if("\n"==e){var a=xt;xt=null,a.onClose&&a.onClose(a.value)}else xt.value=(xt.value||"")+e}function M(e,t,n){var r=At;if(n){if(-1!=bt.indexOf(n))return;bt.push(n),At=0!=n.noremap}try{for(var i,o=k(e),a=/<(?:[CSMA]-)*\w+>|./gi;i=a.exec(t);){var s=i[0],l=o.insertMode;if(xt)x(s);else if(!Mt.handleKey(e,s,"mapping")&&l&&o.insertMode){if("<"==s[0]){var c=s.toLowerCase().slice(1,-1),u=c.split("-");if("lt"==(c=u.pop()||""))s="<";else if("space"==c)s=" ";else if("cr"==c)s="\n";else{if(Et.hasOwnProperty(c)){Ve(e,s=Et[c]);continue}s=s[0],a.lastIndex=i.index+1}}e.replaceSelection(s)}}}finally{if(bt.pop(),At=!!bt.length&&r,!bt.length&&xt){var h=xt;xt=null,Se(e,h)}}}function b(e,t){var n=e.key;if(!Tt[n]){n.length>1&&"n"==n[0]&&(n=n.replace("Numpad","")),n=Lt[n]||n;var r="";if(e.ctrlKey&&(r+="C-"),e.altKey&&(r+="A-"),e.metaKey&&(r+="M-"),it.isMac&&e.altKey&&!e.metaKey&&!e.ctrlKey&&(r=r.slice(2)),(r||n.length>1)&&e.shiftKey&&(r+="S-"),t&&!t.expectLiteralNext&&1==n.length)if(ht.keymap&&n in ht.keymap)0==ht.remapCtrl&&r||(n=ht.keymap[n]);else if(n.charCodeAt(0)>255){var i=e.code&&e.code.slice(-1)||"";e.shiftKey||(i=i.toLowerCase()),i&&(n=i)}return(r+=n).length>1&&(r="<"+r+">"),r}}function A(e,t){ht.string!==e&&(ht=L(e)),ht.remapCtrl=t}function L(e){function t(e){return e.split(/\\?(.)/).filter(Boolean)}var n={};return e?(e.split(/((?:[^\\,]|\\.)+),/).map((function(e){if(e){var r=e.split(/((?:[^\\;]|\\.)+);/);if(3==r.length){var i=t(r[1]),o=t(r[2]);if(i.length!==o.length)return;for(var a=0;a<i.length;++a)n[i[a]]=o[a]}else if(1==r.length){var s=t(e);if(s.length%2!=0)return;for(a=0;a<s.length;a+=2)n[s[a]]=s[a+1]}}})),{keymap:n,string:e}):{keymap:n,string:""}}function T(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=null,this.changeQueue=null}function E(e,t){e.state.vim.inputState=new T,e.state.vim.expectLiteralNext=!1,it.signal(e,"vim-command-done",t)}function O(){this.removed=[],this.inserted=""}function R(e,t,n){this.clear(),this.keyBuffer=[e||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!t,this.blockwise=!!n}function B(e){this.registers=e,this.unnamedRegister=e['"']=new R,e["."]=new R,e[":"]=new R,e["/"]=new R,e["+"]=new R}function I(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}function N(e,t){for(var n=[],r=0;r<t;r++)n.push(e);return n}function K(e,t,n){var r=e.state.vim,i=r.insertMode||r.visualMode,o=Math.min(Math.max(e.firstLine(),t.line),e.lastLine()),a=e.getLine(o),s=a.length-1+Number(!!i),l=Math.min(Math.max(0,t.ch),s),c=a.charCodeAt(l);if(56320<=c&&c<=57343){var u=1;n&&n.line==o&&n.ch>l&&(u=-1),(l+=u)>s&&(l-=2)}return new st(o,l)}function P(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function H(e,t,n){return"object"==typeof t&&(n=t.ch,t=t.line),new st(e.line+t,e.ch+n)}function _(e,t){var n="<character>"==t.slice(-11),r="<register>"==t.slice(-10);if(n||r){var i=t.length-(n?11:10),o=e.slice(0,i),a=t.slice(0,i);return o==a&&e.length>i?"full":0==a.indexOf(o)&&"partial"}return e==t?"full":0==t.indexOf(e)&&"partial"}function $(e,t,n){return function(){for(var r=0;r<n;r++)t(e)}}function D(e){return new st(e.line,e.ch)}function V(e,t){return e.ch==t.ch&&e.line==t.line}function W(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function j(e,t){return arguments.length>2&&(t=j.apply(void 0,Array.prototype.slice.call(arguments,1))),W(e,t)?e:t}function F(e,t){return arguments.length>2&&(t=F.apply(void 0,Array.prototype.slice.call(arguments,1))),W(e,t)?t:e}function U(e,t,n){var r=W(e,t),i=W(t,n);return r&&i}function z(e,t){return e.getLine(t).length}function Q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function q(e,t,n){var r=z(e,t),i=new Array(n-r+1).join(" ");e.setCursor(new st(t,r)),e.replaceRange(i,e.getCursor())}function J(e,t){var n=[],r=e.listSelections(),i=D(e.clipPos(t)),o=!V(t,i),a=function(e,t,n){for(var r=0;r<e.length;r++){var i="head"!=n&&V(e[r].anchor,t),o="anchor"!=n&&V(e[r].head,t);if(i||o)return r}return-1}(r,e.getCursor("head")),s=V(r[a].head,r[a].anchor),l=r.length-1,c=l-a>a?l:0,u=r[c].anchor,h=Math.min(u.line,i.line),p=Math.max(u.line,i.line),d=u.ch,f=i.ch,m=r[c].head.ch-d,g=f-d;m>0&&g<=0?(d++,o||f--):m<0&&g>=0?(d--,s||f++):m<0&&-1==g&&(d--,f++);for(var v=h;v<=p;v++){var y={anchor:new st(v,d),head:new st(v,f)};n.push(y)}return e.setSelections(n),t.ch=f,u.ch=d,u}function G(e,t,n){for(var r=[],i=0;i<n;i++){var o=H(t,i,0);r.push({anchor:o,head:o})}e.setSelections(r,0)}function X(e,t){var n=t.sel.anchor,r=t.sel.head;t.lastPastedText&&(r=e.posFromIndex(e.indexFromPos(n)+t.lastPastedText.length),t.lastPastedText=null),t.lastSelection={anchorMark:e.setBookmark(n),headMark:e.setBookmark(r),anchor:D(n),head:D(r),visualMode:t.visualMode,visualLine:t.visualLine,visualBlock:t.visualBlock}}function Z(e,t,n){var r=e.state.vim,i=Y(e,t=t||r.sel,n=n||r.visualLine?"line":r.visualBlock?"block":"char");e.setSelections(i.ranges,i.primary)}function Y(e,t,n,r){var i=D(t.head),o=D(t.anchor);if("char"==n){var a=r||W(t.head,t.anchor)?0:1,s=W(t.head,t.anchor)?1:0;return i=H(t.head,0,a),{ranges:[{anchor:o=H(t.anchor,0,s),head:i}],primary:0}}if("line"==n){if(W(t.head,t.anchor))i.ch=0,o.ch=z(e,o.line);else{o.ch=0;var l=e.lastLine();i.line>l&&(i.line=l),i.ch=z(e,i.line)}return{ranges:[{anchor:o,head:i}],primary:0}}if("block"==n){var c=Math.min(o.line,i.line),u=o.ch,h=Math.max(o.line,i.line),p=i.ch;u<p?p+=1:u+=1;for(var d=h-c+1,f=i.line==c?0:d-1,m=[],g=0;g<d;g++)m.push({anchor:new st(c+g,u),head:new st(c+g,p)});return{ranges:m,primary:f}}}function ee(e,t){var n=e.state.vim;!1!==t&&e.setCursor(K(e,n.sel.head)),X(e,n),n.visualMode=!1,n.visualLine=!1,n.visualBlock=!1,n.insertMode||it.signal(e,"vim-mode-change",{mode:"normal"})}function te(e){if(!e)return 0;var t=e.search(/\S/);return-1==t?e.length:t}function ne(e,t,n){var r,i=t.inclusive,o=t.innerWord,a=t.bigWord,s=t.noSymbol,l=t.multiline,c=n||function(e){var t=e.getCursor("head");return 1==e.getSelection().length&&(t=j(t,e.getCursor("anchor"))),t}(e),u=e.getLine(c.line),h=u,p=c.line,d=p,f=c.ch,m=s?dt[0]:ft[0];if(o&&/\s/.test(u.charAt(f)))m=function(e){return/\s/.test(e)};else{for(;!m(u.charAt(f));)if(++f>=u.length){if(!l)return null;f--,r=ae(e,c,!0,a,!0);break}a?m=ft[0]:(m=dt[0])(u.charAt(f))||(m=dt[1])}for(var g=f,v=f;m(u.charAt(v))&&v>=0;)v--;if(v++,r)g=r.to,d=r.line,!(h=e.getLine(d))&&0==g&&g++;else for(;m(u.charAt(g))&&g<u.length;)g++;if(i){var y=g,C=c.ch<=v&&/\s/.test(u.charAt(c.ch));if(!C)for(;/\s/.test(h.charAt(g))&&g<h.length;)g++;if(y==g||C){for(var w=v;/\s/.test(u.charAt(v-1))&&v>0;)v--;!v&&!C&&(v=w)}}return{start:new st(p,v),end:new st(d,g)}}function re(e,t,n){var r=t;if(!it.findMatchingTag||!it.findEnclosingTag)return{start:r,end:r};var i=it.findMatchingTag(e,t)||it.findEnclosingTag(e,t);return i&&i.open&&i.close?n?{start:i.open.from,end:i.close.to}:{start:i.open.to,end:i.close.from}:{start:r,end:r}}function ie(e,t,n){V(t,n)||kt.jumpList.add(e,t,n)}function oe(e,t){kt.lastCharacterSearch.increment=e,kt.lastCharacterSearch.forward=t.forward,kt.lastCharacterSearch.selectedCharacter=t.selectedCharacter}function ae(e,t,n,r,i){var o=t.line,a=t.ch,s=e.getLine(o),l=n?1:-1,u=r?ft:dt;if(i&&""==s){if(o+=l,s=e.getLine(o),!c(e,o))return null;a=n?0:s.length}for(;;){if(i&&""==s)return{from:0,to:0,line:o};for(var h=l>0?s.length:-1,p=h,d=h;a!=h;){for(var f=!1,m=0;m<u.length&&!f;++m)if(u[m](s.charAt(a))){for(p=a;a!=h&&u[m](s.charAt(a));)a+=l;if(f=p!=(d=a),p==t.ch&&o==t.line&&d==p+l)continue;return{from:Math.min(p,d+1),to:Math.max(p,d),line:o}}f||(a+=l)}if(!c(e,o+=l))return null;s=e.getLine(o),a=l>0?0:s.length}}function se(e,t,n,r,i){var o=new st(t.line+n.repeat-1,1/0),a=e.clipPos(o);return a.ch--,i||(r.lastHPos=1/0,r.lastHSPos=e.charCoords(a,"div").left),o}function le(e,t,n,r,i){for(var o,a=i||e.getCursor(),s=a.ch,l=0;l<t;l++){if(-1==(o=ue(s,e.getLine(a.line),r,n,!0)))return null;s=o}return new st(e.getCursor().line,o)}function ce(e,t,n,r){(g(n,mt)||vt.test(n))&&(t.marks[n]&&t.marks[n].clear(),t.marks[n]=e.setBookmark(r))}function ue(e,t,n,r,i){var o;return r?-1!=(o=t.indexOf(n,e+1))&&!i&&(o-=1):-1!=(o=t.lastIndexOf(n,e-1))&&!i&&(o+=1),o}function he(e,t,n,r,i){function o(t){return!/\S/.test(e.getLine(t))}function a(e,t,n){return n?o(e)!=o(e+t):!o(e)&&o(e+t)}function s(t){r=r>0?1:-1;var n=e.ace.session.getFoldLine(t);n&&t+r>n.start.row&&t+r<n.end.row&&(r=(r>0?n.end.row:n.start.row)-t)}var l,c=t.line,u=e.firstLine(),h=e.lastLine(),p=c;if(r){for(;u<=p&&p<=h&&n>0;)s(p),a(p,r)&&n--,p+=r;return new st(p,0)}var d=e.state.vim;if(d.visualLine&&a(c,1,!0)){var f=d.sel.anchor;a(f.line,-1,!0)&&(!i||f.line!=c)&&(c+=1)}var m=o(c);for(p=c;p<=h&&n;p++)a(p,1,!0)&&(!i||o(p)!=m)&&n--;for(l=new st(p,0),p>h&&!m?m=!0:i=!1,p=c;p>u&&(i&&o(p)!=m&&p!=c||!a(p,-1,!0));p--);return{start:new st(p,0),end:l}}function pe(e,t,n,r,i){function o(e){e.pos+e.dir<0||e.pos+e.dir>=e.line.length?e.line=null:e.pos+=e.dir}function a(e,t,n,r){var a={line:e.getLine(t),ln:t,pos:n,dir:r};if(""===a.line)return{ln:a.ln,pos:a.pos};var s=a.pos;for(o(a);null!==a.line;){if(s=a.pos,m(a.line[a.pos])){if(!i)return{ln:a.ln,pos:a.pos+1};for(o(a);null!==a.line&&f(a.line[a.pos]);)s=a.pos,o(a);return{ln:a.ln,pos:s+1}}o(a)}return{ln:a.ln,pos:s+1}}function s(e,t,n,r){var a=e.getLine(t),s={line:a,ln:t,pos:n,dir:r};if(""===s.line)return{ln:s.ln,pos:s.pos};var l=s.pos;for(o(s);null!==s.line;){if(f(s.line[s.pos])||m(s.line[s.pos])){if(m(s.line[s.pos]))return i&&f(s.line[s.pos+1])?{ln:s.ln,pos:s.pos+1}:{ln:s.ln,pos:l}}else l=s.pos;o(s)}return s.line=a,i&&f(s.line[s.pos])?{ln:s.ln,pos:s.pos}:{ln:s.ln,pos:l}}for(var l={ln:t.line,pos:t.ch};n>0;)l=r<0?s(e,l.ln,l.pos,r):a(e,l.ln,l.pos,r),n--;return new st(l.ln,l.pos)}function de(e,t,n,r){var i,o,a=t,s={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[n],l={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[n],c=e.getLine(a.line).charAt(a.ch)===l?1:0;if(i=e.scanForBracket(new st(a.line,a.ch+c),-1,void 0,{bracketRegex:s}),o=e.scanForBracket(new st(a.line,a.ch+c),1,void 0,{bracketRegex:s}),!i||!o)return null;if(i=i.pos,o=o.pos,i.line==o.line&&i.ch>o.ch||i.line>o.line){var u=i;i=o,o=u}return r?o.ch+=1:i.ch+=1,{start:i,end:o}}function fe(){}function me(e){var t=e.state.vim;return t.searchState_||(t.searchState_=new fe)}function ge(e,t){var n=ve(e,t)||[];if(!n.length)return[];var r=[];if(0===n[0]){for(var i=0;i<n.length;i++)"number"==typeof n[i]&&r.push(e.substring(n[i]+1,n[i+1]));return r}}function ve(e,t){t||(t="/");for(var n=!1,r=[],i=0;i<e.length;i++){var o=e.charAt(i);!n&&o==t&&r.push(i),n=!n&&"\\"==o}return r}function ye(e){for(var t=new it.StringStream(e),n=[];!t.eol();){for(;t.peek()&&"\\"!=t.peek();)n.push(t.next());var r=!1;for(var i in Ht)if(t.match(i,!0)){r=!0,n.push(Ht[i]);break}r||n.push(t.next())}return n.join("")}function Ce(e,t,n){if(kt.registerController.getRegister("/").setText(e),e instanceof RegExp)return e;var r,i,o=function(e){return ve(e,"/")}(e);o.length?(r=e.substring(0,o[0]),i=-1!=e.substring(o[0]).indexOf("i")):r=e;return r?(C("pcre")||(r=function(e){for(var t=!1,n=[],r=-1;r<e.length;r++){var i=e.charAt(r)||"",o=e.charAt(r+1)||"",a=o&&-1!="|(){".indexOf(o);t?(("\\"!==i||!a)&&n.push(i),t=!1):"\\"===i?(t=!0,o&&-1!="}".indexOf(o)&&(a=!0),(!a||"\\"===o)&&n.push(i)):(n.push(i),a&&"\\"!==o&&n.push("\\"))}return n.join("")}(r)),n&&(t=/^[^A-Z]*$/.test(r)),new RegExp(r,t||i?"im":"m")):null}function we(e){"string"==typeof e&&(e=document.createElement(e));for(var t,n=1;n<arguments.length;n++)if(t=arguments[n])if("object"!=typeof t&&(t=document.createTextNode(t)),t.nodeType)e.appendChild(t);else for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&("$"===r[0]?e.style[r.slice(1)]=t[r]:e.setAttribute(r,t[r]));return e}function ke(e,t){var n=we("div",{$color:"red",$whiteSpace:"pre",class:"cm-vim-message"},t);e.openNotification?e.openNotification(n,{bottom:!0,duration:5e3}):alert(n.innerText)}function Se(e,t){if(bt.length)return t.value||(t.value=""),void(xt=t);var n=function(e,t){return we("div",{$display:"flex"},we("span",{$fontFamily:"monospace",$whiteSpace:"pre",$flex:1},e,we("input",{type:"text",autocorrect:"off",autocapitalize:"off",spellcheck:"false",$width:"100%"})),t&&we("span",{$color:"#888"},t))}(t.prefix,t.desc);if(e.openDialog)e.openDialog(n,t.onClose,{onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,bottom:!0,selectValueOnOpen:!1,value:t.value});else{var r="";"string"!=typeof t.prefix&&t.prefix&&(r+=t.prefix.textContent),t.desc&&(r+=" "+t.desc),t.onClose(prompt(r,""))}}function xe(e,t,n,r){if(t){var i=me(e),o=Ce(t,!!n,!!r);if(o)return Me(e,o),function(e,t){if(e instanceof RegExp&&t instanceof RegExp){for(var n=["global","multiline","ignoreCase","source"],r=0;r<n.length;r++){var i=n[r];if(e[i]!==t[i])return!1}return!0}return!1}(o,i.getQuery())||i.setQuery(o),o}}function Me(e,t){clearTimeout(_t),me(e).highlightTimeout=_t,_t=setTimeout((function(){if(e.state.vim){var n=me(e);n.highlightTimeout=null;var r=n.getOverlay();r&&t==r.query||(r&&e.removeOverlay(r),r=function(e){if("^"==e.source.charAt(0))var t=!0;return{token:function(n){if(!t||n.sol()){var r=n.match(e,!1);if(r)return 0==r[0].length?(n.next(),"searching"):n.sol()||(n.backUp(1),e.exec(n.next()+r[0]))?(n.match(e),"searching"):(n.next(),null);for(;!n.eol()&&(n.next(),!n.match(e,!1)););}else n.skipToEnd()},query:e}}(t),e.addOverlay(r),e.showMatchesOnScrollbar&&(n.getScrollbarAnnotate()&&n.getScrollbarAnnotate().clear(),n.setScrollbarAnnotate(e.showMatchesOnScrollbar(t))),n.setOverlay(r))}}),50)}function be(e,t,n,r){return void 0===r&&(r=1),e.operation((function(){for(var i=e.getCursor(),o=e.getSearchCursor(n,i),a=0;a<r;a++){var s=o.find(t);if(0==a&&s&&V(o.from(),i)){var l=t?o.from():o.to();(s=o.find(t))&&!s[0]&&V(o.from(),l)&&e.getLine(l.line).length==l.ch&&(s=o.find(t))}if(!s&&!(o=e.getSearchCursor(n,t?new st(e.lastLine()):new st(e.firstLine(),0))).find(t))return}return o.from()}))}function Ae(e){var t=me(e);t.highlightTimeout&&(clearTimeout(t.highlightTimeout),t.highlightTimeout=null),e.removeOverlay(me(e).getOverlay()),t.setOverlay(null),t.getScrollbarAnnotate()&&(t.getScrollbarAnnotate().clear(),t.setScrollbarAnnotate(null))}function Le(e,t,n){return"number"!=typeof e&&(e=e.line),t instanceof Array?g(e,t):"number"==typeof n?e>=t&&e<=n:e==t}function Te(e){var t=e.ace.renderer;return{top:t.getFirstFullyVisibleRow(),bottom:t.getLastFullyVisibleRow()}}function Ee(e,t,n){if("'"==n||"`"==n)return kt.jumpList.find(e,-1)||new st(0,0);if("."==n)return Oe(e);var r=t.marks[n];return r&&r.find()}function Oe(e){if(e.getLastEditEnd)return e.getLastEditEnd();for(var t=e.doc.history.done,n=t.length;n--;)if(t[n].changes)return D(t[n].changes[0].to)}function Re(e,t,n,r,i,o,a,s,l){function c(){e.operation((function(){for(;!v;)u(),p();d()}))}function u(){var t=e.getRange(o.from(),o.to()).replace(a,s),n=o.to().line;o.replace(t),m=o.to().line,i+=m-n,g=m<n}function h(){var e=f&&D(o.to()),t=o.findNext();return t&&!t[0]&&e&&V(o.from(),e)&&(t=o.findNext()),t}function p(){for(;h()&&Le(o.from(),r,i);)if(n||o.from().line!=m||g)return e.scrollIntoView(o.from(),30),e.setSelection(o.from(),o.to()),f=o.from(),void(v=!1);v=!0}function d(t){if(t&&t(),e.focus(),f){e.setCursor(f);var n=e.state.vim;n.exMode=!1,n.lastHPos=n.lastHSPos=f.ch}l&&l()}e.state.vim.exMode=!0;var f,m,g,v=!1;if(p(),!v)return t?void Se(e,{prefix:we("span","replace with ",we("strong",s)," (y/n/a/q/l)"),onKeyDown:function(t,n,r){switch(it.e_stop(t),b(t)){case"y":u(),p();break;case"n":p();break;case"a":var i=l;l=void 0,e.operation(c),l=i;break;case"l":u();case"q":case"<Esc>":case"<C-c>":case"<C-[>":d(r)}return v&&d(r),!0}}):(c(),void(l&&l()));ke(e,"No matches for "+a.source)}function Be(e,t){var n=e.state.vim,r=kt.macroModeState,i=kt.registerController.getRegister("."),o=r.isPlaying,a=r.lastInsertModeChanges;o||(e.off("change",Ke),n.insertEnd&&n.insertEnd.clear(),n.insertEnd=null,it.off(e.getInputField(),"keydown",$e)),!o&&n.insertModeRepeat>1&&(De(e,n,n.insertModeRepeat-1,!0),n.lastEditInputState.repeatOverride=n.insertModeRepeat),delete n.insertModeRepeat,n.insertMode=!1,t||e.setCursor(e.getCursor().line,e.getCursor().ch-1),e.setOption("keyMap","vim"),e.setOption("disableInput",!0),e.toggleOverwrite(!1),i.setText(a.changes.join("")),it.signal(e,"vim-mode-change",{mode:"normal"}),r.isRecording&&function(e){if(e.isPlaying)return;var t=e.latestRegister,n=kt.registerController.getRegister(t);n&&n.pushInsertModeChanges&&n.pushInsertModeChanges(e.lastInsertModeChanges)}(r)}function Ie(e){lt.unshift(e)}function Ne(e,t,n,r){var i=kt.registerController.getRegister(r);if(":"==r)return i.keyBuffer[0]&&Vt.processCommand(e,i.keyBuffer[0]),void(n.isPlaying=!1);var o=i.keyBuffer,a=0;n.isPlaying=!0,n.replaySearchQueries=i.searchQueries.slice(0);for(var s=0;s<o.length;s++)for(var l,c,u=o[s];u;)if(c=(l=/<\w+-.+?>|<\w+>|./.exec(u))[0],u=u.substring(l.index+c.length),Mt.handleKey(e,c,"macro"),t.insertMode){var h=i.insertModeChanges[a++].changes;kt.macroModeState.lastInsertModeChanges.changes=h,We(e,h,1),Be(e)}n.isPlaying=!1}function Ke(e,t){var n=kt.macroModeState,r=n.lastInsertModeChanges;if(!n.isPlaying)for(var i=e.state.vim;t;){if(r.expectCursorActivityForChange=!0,r.ignoreCount>1)r.ignoreCount--;else if("+input"==t.origin||"paste"==t.origin||void 0===t.origin){var o=e.listSelections().length;o>1&&(r.ignoreCount=o);var a=t.text.join("\n");if(r.maybeReset&&(r.changes=[],r.maybeReset=!1),a)if(e.state.overwrite&&!/\n/.test(a))r.changes.push([a]);else{if(a.length>1){var s=i&&i.insertEnd&&i.insertEnd.find(),l=e.getCursor();if(s&&s.line==l.line){var c=s.ch-l.ch;c>0&&c<a.length&&(r.changes.push([a,c]),a="")}}a&&r.changes.push(a)}}t=t.next}}function Pe(e){var t=e.state.vim;if(t.insertMode){var n=kt.macroModeState;if(n.isPlaying)return;var r=n.lastInsertModeChanges;r.expectCursorActivityForChange?r.expectCursorActivityForChange=!1:(r.maybeReset=!0,t.insertEnd&&t.insertEnd.clear(),t.insertEnd=e.setBookmark(e.getCursor(),{insertLeft:!0}))}else e.curOp.isVimOp||He(e,t)}function He(e,t,n){var r=e.getCursor("anchor"),i=e.getCursor("head");if(t.visualMode&&!e.somethingSelected()?ee(e,!1):!t.visualMode&&!t.insertMode&&e.somethingSelected()&&(t.visualMode=!0,t.visualLine=!1,it.signal(e,"vim-mode-change",{mode:"visual"})),t.visualMode){var o=W(i,r)?0:-1,a=W(i,r)?-1:0;i=H(i,0,o),r=H(r,0,a),t.sel={anchor:r,head:i},ce(e,t,"<",j(i,r)),ce(e,t,">",F(i,r))}else!t.insertMode&&!n&&(t.lastHPos=e.getCursor().ch)}function _e(e,t){this.keyName=e,this.key=t.key,this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey}function $e(e){var t=kt.macroModeState.lastInsertModeChanges,n=it.keyName?it.keyName(e):e.key;n&&(-1==n.indexOf("Delete")&&-1==n.indexOf("Backspace")||(t.maybeReset&&(t.changes=[],t.maybeReset=!1),t.changes.push(new _e(n,e))))}function De(e,t,n,r){function i(){s?Ot.processAction(e,t,t.lastEditActionCommand):Ot.evalInput(e,t)}function o(n){if(a.lastInsertModeChanges.changes.length>0){n=t.lastEditActionCommand?n:1;var r=a.lastInsertModeChanges;We(e,r.changes,n)}}var a=kt.macroModeState;a.isPlaying=!0;var s=!!t.lastEditActionCommand,l=t.inputState;if(t.inputState=t.lastEditInputState,s&&t.lastEditActionCommand.interlaceInsertRepeat)for(var c=0;c<n;c++)i(),o(1);else r||i(),o(n);t.inputState=l,t.insertMode&&!r&&Be(e),a.isPlaying=!1}function Ve(e,t){it.lookupKey(t,"vim-insert",(function(t){return"string"==typeof t?it.commands[t](e):t(e),!0}))}function We(e,t,n){var r=e.getCursor("head"),i=kt.macroModeState.lastInsertModeChanges.visualBlock;i&&(G(e,r,i+1),n=e.listSelections().length,e.setCursor(r));for(var o=0;o<n;o++){i&&e.setCursor(H(r,o,0));for(var a=0;a<t.length;a++){var s=t[a];if(s instanceof _e)Ve(e,s.keyName);else if("string"==typeof s)e.replaceSelection(s);else{var l=e.getCursor(),c=H(l,0,s[0].length-(s[1]||0));e.replaceRange(s[0],l,s[1]?l:c),e.setCursor(c)}}}i&&e.setCursor(H(r,0,1))}function je(e){var t=new e.constructor;return Object.keys(e).forEach((function(n){if("insertEnd"!=n){var r=e[n];Array.isArray(r)?r=r.slice():r&&"object"==typeof r&&r.constructor!=Object&&(r=je(r)),t[n]=r}})),e.sel&&(t.sel={head:e.sel.head&&D(e.sel.head),anchor:e.sel.anchor&&D(e.sel.anchor)}),t}function Fe(e,t,n){var r=!1,i=Mt.maybeInitVimState_(e),o=i.visualBlock||i.wasInVisualBlock,a=e.ace.inMultiSelectMode;if(i.wasInVisualBlock&&!a?i.wasInVisualBlock=!1:a&&i.visualBlock&&(i.wasInVisualBlock=!0),"<Esc>"!=t||i.insertMode||i.visualMode||!a)if(o||!a||e.ace.inVirtualSelectionMode)r=Mt.handleKey(e,t,n);else{var s=je(i),l=i.inputState.changeQueueList||[];e.operation((function(){e.curOp.isVimOp=!0;var o=0;e.ace.forEachSelection((function(){var i=e.ace.selection;e.state.vim.lastHPos=null==i.$desiredColumn?i.lead.column:i.$desiredColumn,e.state.vim.inputState.changeQueue=l[o];var a=e.getCursor("head"),c=e.getCursor("anchor"),u=W(a,c)?0:-1,h=W(a,c)?-1:0;a=H(a,0,u),c=H(c,0,h),e.state.vim.sel.head=a,e.state.vim.sel.anchor=c,r=jt(e,t,n),i.$desiredColumn=-1==e.state.vim.lastHPos?null:e.state.vim.lastHPos,e.ace.inVirtualSelectionMode&&(l[o]=e.state.vim.inputState.changeQueue),e.virtualSelectionMode()&&(e.state.vim=je(s)),o++})),e.curOp.cursorActivity&&!r&&(e.curOp.cursorActivity=!1),i.status=e.state.vim.status,e.state.vim=i,i.inputState.changeQueueList=l,i.inputState.changeQueue=null}),!0)}else e.ace.exitMultiSelectMode();return r&&!i.visualMode&&!i.insert&&i.visualMode!=e.somethingSelected()&&He(e,i,!0),r}function Ue(e,t){t.off("beforeEndOperation",Ue);var n=t.state.cm.vimCmd;n&&t.execCommand(n.exec?n:n.name,n.args),t.curOp=t.prevOp}var ze=e("../range").Range,Qe=e("../lib/event_emitter").EventEmitter,qe=e("../lib/dom"),Je=e("../lib/oop"),Ge=e("../lib/keys"),Xe=e("../lib/event"),Ze=e("../search").Search,Ye=e("../lib/useragent"),et=e("../search_highlight").SearchHighlight,tt=e("../commands/multi_select_commands"),nt=e("../mode/text").Mode.prototype.tokenRe,rt=e("../ext/hardwrap").hardWrap;e("../multi_select");var it=function(e){this.ace=e,this.state={},this.marks={},this.options={},this.$uid=0,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this),this.onBeforeEndOperation=this.onBeforeEndOperation.bind(this),this.ace.on("change",this.onChange),this.ace.on("changeSelection",this.onSelectionChange),this.ace.on("beforeEndOperation",this.onBeforeEndOperation)};it.Pos=function(e,t){if(!(this instanceof st))return new st(e,t);this.line=e,this.ch=t},it.defineOption=function(e,t,n){},it.commands={redo:function(e){e.ace.redo()},undo:function(e){e.ace.undo()},newlineAndIndent:function(e){e.ace.insert("\n")},goLineLeft:function(e){e.ace.selection.moveCursorLineStart()},goLineRight:function(e){e.ace.selection.moveCursorLineEnd()}},it.keyMap={},it.addClass=it.rmClass=function(){},it.e_stop=it.e_preventDefault=Xe.stopEvent,it.keyName=function(e){var t=Ge[e.keyCode]||e.key||"";return 1==t.length&&(t=t.toUpperCase()),t=Xe.getModifierString(e).replace(/(^|-)\w/g,(function(e){return e.toUpperCase()}))+t,t},it.keyMap.default=function(e){return function(t){var n=t.ace.commands.commandKeyBinding[e.toLowerCase()];return n&&!1!==t.ace.execCommand(n)}},it.lookupKey=function e(t,n,r){n||(n="default"),"string"==typeof n&&(n=it.keyMap[n]||it.keyMap.default);var i="function"==typeof n?n(t):n[t];if(!1===i)return"nothing";if("..."===i)return"multi";if(null!=i&&r(i))return"handled";if(n.fallthrough){if(!Array.isArray(n.fallthrough))return e(t,n.fallthrough,r);for(var o=0;o<n.fallthrough.length;o++){var a=e(t,n.fallthrough[o],r);if(a)return a}}},it.findMatchingTag=function(e,t){return e.findMatchingTag(t)},it.findEnclosingTag=function(e,t){},it.signal=function(e,t,n){return e._signal(t,n)},it.on=Xe.addListener,it.off=Xe.removeListener,it.isWordChar=function(e){return e<""?/^\w$/.test(e):(nt.lastIndex=0,nt.test(e))},function(){Je.implement(it.prototype,Qe),this.destroy=function(){this.ace.off("change",this.onChange),this.ace.off("changeSelection",this.onSelectionChange),this.ace.off("beforeEndOperation",this.onBeforeEndOperation),this.removeOverlay()},this.virtualSelectionMode=function(){return this.ace.inVirtualSelectionMode&&this.ace.selection.index},this.onChange=function(e){this.$lineHandleChanges&&this.$lineHandleChanges.push(e);var t={text:"i"==e.action[0]?e.lines:[]},n=this.curOp=this.curOp||{};n.changeHandlers||(n.changeHandlers=this._eventRegistry.change&&this._eventRegistry.change.slice()),n.lastChange?n.lastChange.next=n.lastChange=t:n.lastChange=n.change=t,this.$updateMarkers(e)},this.onSelectionChange=function(){var e=this.curOp=this.curOp||{};e.cursorActivityHandlers||(e.cursorActivityHandlers=this._eventRegistry.cursorActivity&&this._eventRegistry.cursorActivity.slice()),this.curOp.cursorActivity=!0,this.ace.inMultiSelectMode&&this.ace.keyBinding.removeKeyboardHandler(tt.keyboardHandler)},this.operation=function(e,t){if(!t&&this.curOp||t&&this.curOp&&this.curOp.force)return e();if((t||!this.ace.curOp)&&this.curOp&&this.onBeforeEndOperation(),!this.ace.curOp){var n=this.ace.prevOp;this.ace.startOperation({command:{name:"vim",scrollIntoView:"cursor"}})}var r=this.curOp=this.curOp||{};this.curOp.force=t;var i=e();return this.ace.curOp&&"vim"==this.ace.curOp.command.name&&(this.state.dialog&&(this.ace.curOp.command.scrollIntoView=this.ace.curOp.vimDialogScroll),this.ace.endOperation(),!r.cursorActivity&&!r.lastChange&&n&&(this.ace.prevOp=n)),(t||!this.ace.curOp)&&this.curOp&&this.onBeforeEndOperation(),i},this.onBeforeEndOperation=function(){var e=this.curOp;e&&(e.change&&this.signal("change",e.change,e),e&&e.cursorActivity&&this.signal("cursorActivity",null,e),this.curOp=null)},this.signal=function(e,t,n){var r=n?n[e+"Handlers"]:(this._eventRegistry||{})[e];if(r){r=r.slice();for(var i=0;i<r.length;i++)r[i](this,t)}},this.firstLine=function(){return 0},this.lastLine=function(){return this.ace.session.getLength()-1},this.lineCount=function(){return this.ace.session.getLength()},this.setCursor=function(e,t){"object"==typeof e&&(t=e.ch,e=e.line);var n=!this.curOp&&!this.ace.inVirtualSelectionMode;this.ace.inVirtualSelectionMode||this.ace.exitMultiSelectMode(),this.ace.session.unfold({row:e,column:t}),this.ace.selection.moveTo(e,t),n&&(this.ace.renderer.scrollCursorIntoView(),this.ace.endOperation())},this.getCursor=function(e){var t=this.ace.selection;return i("anchor"==e?t.isEmpty()?t.lead:t.anchor:"head"!=e&&e?t.getRange()[e]:t.lead)},this.listSelections=function(e){var t=this.ace.multiSelect.rangeList.ranges;return!t.length||this.ace.inVirtualSelectionMode?[{anchor:this.getCursor("anchor"),head:this.getCursor("head")}]:t.map((function(e){return{anchor:this.clipPos(i(e.cursor==e.end?e.start:e.end)),head:this.clipPos(i(e.cursor))}}),this)},this.setSelections=function(e,t){var n=this.ace.multiSelect,i=e.map((function(e){var t=r(e.anchor),n=r(e.head),i=ze.comparePoints(t,n)<0?new ze.fromPoints(t,n):new ze.fromPoints(n,t);return i.cursor=ze.comparePoints(i.start,n)?i.end:i.start,i}));if(this.ace.inVirtualSelectionMode)this.ace.selection.fromOrientedRange(i[0]);else{t?i[t]&&i.push(i.splice(t,1)[0]):i=i.reverse(),n.toSingleRange(i[0].clone());for(var o=this.ace.session,a=0;a<i.length;a++){var s=o.$clipRangeToDocument(i[a]);n.addRange(s)}}},this.setSelection=function(e,t,n){var r=this.ace.selection;r.moveTo(e.line,e.ch),r.selectTo(t.line,t.ch),n&&"*mouse"==n.origin&&this.onBeforeEndOperation()},this.somethingSelected=function(e){return!this.ace.selection.isEmpty()},this.clipPos=function(e){return i(this.ace.session.$clipPositionToDocument(e.line,e.ch))},this.foldCode=function(e){this.ace.session.$toggleFoldWidget(e.line,{})},this.markText=function(e){return{clear:function(){},find:function(){}}},this.$updateMarkers=function(e){var t="insert"==e.action,n=e.start,r=e.end,i=(r.row-n.row)*(t?1:-1),o=(r.column-n.column)*(t?1:-1);for(var a in t&&(r=n),this.marks){var s=this.marks[a],l=ze.comparePoints(s,n);if(!(l<0)){if(0===l&&t)if(s.$insertRight){if(1!=s.bias){s.bias=-1;continue}l=1}else l=1;var c=t?l:ze.comparePoints(s,r);c>0?(s.row+=i,s.column+=s.row==r.row?o:0):!t&&c<=0&&(s.row=n.row,s.column=n.column,0===c&&(s.bias=1))}}};var e=function(e,t,n,r){this.cm=e,this.id=t,this.row=n,this.column=r,e.marks[this.id]=this};e.prototype.clear=function(){delete this.cm.marks[this.id]},e.prototype.find=function(){return i(this)},this.setBookmark=function(t,n){var r=new e(this,this.$uid++,t.line,t.ch);return n&&n.insertLeft||(r.$insertRight=!0),this.marks[r.id]=r,r},this.moveH=function(e,t){if("char"==t){var n=this.ace.selection;n.clearSelection(),n.moveCursorBy(0,e)}},this.findPosV=function(e,t,n,r){if("page"==n){var o=this.ace.renderer.layerConfig;t*=Math.floor(o.height/o.lineHeight),n="line"}if("line"==n){var a=this.ace.session.documentToScreenPosition(e.line,e.ch);return null!=r&&(a.column=r),a.row+=t,a.row=Math.min(Math.max(0,a.row),this.ace.session.getScreenLength()-1),i(this.ace.session.screenToDocumentPosition(a.row,a.column))}},this.charCoords=function(e,t){if("div"==t||!t)return{left:(r=this.ace.session.documentToScreenPosition(e.line,e.ch)).column,top:r.row};if("local"==t){var n=this.ace.renderer,r=this.ace.session.documentToScreenPosition(e.line,e.ch),i=n.layerConfig.lineHeight,o=n.layerConfig.characterWidth,a=i*r.row;return{left:r.column*o,top:a,bottom:a+i}}},this.coordsChar=function(e,t){var n=this.ace.renderer;if("local"==t){var r=Math.max(0,Math.floor(e.top/n.lineHeight)),o=Math.max(0,Math.floor(e.left/n.characterWidth));return i(n.session.screenToDocumentPosition(r,o))}if("div"==t)throw"not implemented"},this.getSearchCursor=function(e,t,n){var r=!1,o=!1;e instanceof RegExp&&!e.global&&(r=!e.ignoreCase,e=e.source,o=!0),"\\n"==e&&(e="\n",o=!1);var a=new Ze;null==t.ch&&(t.ch=Number.MAX_VALUE);var s={row:t.line,column:t.ch},l=this,c=null;return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(t){a.setOptions({needle:e,caseSensitive:r,wrap:!1,backwards:t,regExp:o,start:c||s});var n=a.find(l.ace.session);return(c=n)&&[!c.isEmpty()]},from:function(){return c&&i(c.start)},to:function(){return c&&i(c.end)},replace:function(e){c&&(c.end=l.ace.session.doc.replace(c,e))}}},this.scrollTo=function(e,t){var n=this.ace.renderer,r=n.layerConfig,i=r.maxHeight;i-=(n.$size.scrollerHeight-n.lineHeight)*n.$scrollPastEnd,null!=t&&this.ace.session.setScrollTop(Math.max(0,Math.min(t,i))),null!=e&&this.ace.session.setScrollLeft(Math.max(0,Math.min(e,r.width)))},this.scrollInfo=function(){return 0},this.scrollIntoView=function(e,t){if(e){var n=this.ace.renderer,i={top:0,bottom:t};n.scrollCursorIntoView(r(e),2*n.lineHeight/n.$size.scrollerHeight,i)}},this.getLine=function(e){return this.ace.session.getLine(e)},this.getRange=function(e,t){return this.ace.session.getTextRange(new ze(e.line,e.ch,t.line,t.ch))},this.replaceRange=function(e,t,n){n||(n=t);var r=new ze(t.line,t.ch,n.line,n.ch);return this.ace.session.$clipRangeToDocument(r),this.ace.session.replace(r,e)},this.replaceSelection=this.replaceSelections=function(e){var t=Array.isArray(e)&&e,n=this.ace.selection;if(this.ace.inVirtualSelectionMode)this.ace.session.replace(n.getRange(),t?e[0]||"":e);else{n.inVirtualSelectionMode=!0;var r=n.rangeList.ranges;r.length||(r=[this.ace.multiSelect.getRange()]);for(var i=r.length;i--;)this.ace.session.replace(r[i],t?e[i]||"":e);n.inVirtualSelectionMode=!1}},this.getSelection=function(){return this.ace.getSelectedText()},this.getSelections=function(){return this.listSelections().map((function(e){return this.getRange(e.anchor,e.head)}),this)},this.getInputField=function(){return this.ace.textInput.getElement()},this.getWrapperElement=function(){return this.ace.container};var t={indentWithTabs:"useSoftTabs",indentUnit:"tabSize",tabSize:"tabSize",firstLineNumber:"firstLineNumber",readOnly:"readOnly"};this.setOption=function(e,n){switch(this.state[e]=n,e){case"indentWithTabs":e=t[e],n=!n;break;case"keyMap":return void(this.state.$keyMap=n);default:e=t[e]}e&&this.ace.setOption(e,n)},this.getOption=function(e){var n,r=t[e];switch(r&&(n=this.ace.getOption(r)),e){case"indentWithTabs":return e=t[e],!n;case"keyMap":return this.state.$keyMap||"vim"}return r?n:this.state[e]},this.toggleOverwrite=function(e){return this.state.overwrite=e,this.ace.setOverwrite(e)},this.addOverlay=function(e){if(!this.$searchHighlight||!this.$searchHighlight.session){var t=new et(null,"ace_highlight-marker","text"),n=this.ace.session.addDynamicMarker(t);t.id=n.id,t.session=this.ace.session,t.destroy=function(e){t.session.off("change",t.updateOnChange),t.session.off("changeEditor",t.destroy),t.session.removeMarker(t.id),t.session=null},t.updateOnChange=function(e){var n=e.start.row;n==e.end.row?t.cache[n]=void 0:t.cache.splice(n,t.cache.length)},t.session.on("changeEditor",t.destroy),t.session.on("change",t.updateOnChange)}var r=new RegExp(e.query.source,"gmi");this.$searchHighlight=e.highlight=t,this.$searchHighlight.setRegexp(r),this.ace.renderer.updateBackMarkers()},this.removeOverlay=function(e){this.$searchHighlight&&this.$searchHighlight.session&&this.$searchHighlight.destroy()},this.getScrollInfo=function(){var e=this.ace.renderer,t=e.layerConfig;return{left:e.scrollLeft,top:e.scrollTop,height:t.maxHeight,width:t.width,clientHeight:t.height,clientWidth:t.width}},this.getValue=function(){return this.ace.getValue()},this.setValue=function(e){return this.ace.setValue(e,-1)},this.getTokenTypeAt=function(e){var t=this.ace.session.getTokenAt(e.line,e.ch);return t&&/comment|string/.test(t.type)?"string":""},this.findMatchingBracket=function(e){var t=this.ace.session.findMatchingBracket(r(e));return{to:t&&i(t)}},this.findMatchingTag=function(e){var t=this.ace.session.getMatchingTags(r(e));if(t)return{open:{from:i(t.openTag.start),to:i(t.openTag.end)},close:{from:i(t.closeTag.start),to:i(t.closeTag.end)}}},this.indentLine=function(e,t){!0===t?this.ace.session.indentRows(e,e,"\t"):!1===t&&this.ace.session.outdentRows(new ze(e,0,e,0))},this.indexFromPos=function(e){return this.ace.session.doc.positionToIndex(r(e))},this.posFromIndex=function(e){return i(this.ace.session.doc.indexToPosition(e))},this.focus=function(e){return this.ace.textInput.focus()},this.blur=function(e){return this.ace.blur()},this.defaultTextHeight=function(e){return this.ace.renderer.layerConfig.lineHeight},this.scanForBracket=function(e,t,n,o){var a=o.bracketRegex.source,s=/paren|text|operator|tag/;if(1==t)var l=this.ace.session.$findClosingBracket(a.slice(1,2),r(e),s);else!(l=this.ace.session.$findOpeningBracket(a.slice(-2,-1),{row:e.line,column:e.ch+1},s))&&o.bracketRegex&&o.bracketRegex.test(this.getLine(e.line)[e.ch-1])&&(l={row:e.line,column:e.ch-1});return l&&{pos:i(l)}},this.refresh=function(){return this.ace.resize(!0)},this.getMode=function(){return{name:this.getOption("mode")}},this.execCommand=function(e){return it.commands.hasOwnProperty(e)?it.commands[e](this):"indentAuto"==e?this.ace.execCommand("autoindent"):void console.log(e+" is not implemented")},this.getLineNumber=function(e){var t=this.$lineHandleChanges;if(!t)return null;for(var n=e.row,r=0;r<t.length;r++){var i=t[r];if(i.start.row!=i.end.row)if("i"==i.action[0])i.start.row<n&&(n+=i.end.row-i.start.row);else if(i.start.row<n){if(n<i.end.row||n==i.end.row&&i.start.column>0)return null;n-=i.end.row-i.start.row}}return n},this.getLineHandle=function(e){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{text:this.ace.session.getLine(e),row:e}},this.releaseLineHandles=function(){this.$lineHandleChanges=void 0},this.getLastEditEnd=function(){var e=this.ace.session.$undoManager;if(e&&e.$lastDelta)return i(e.$lastDelta.end)}}.call(it.prototype);var ot=it.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};ot.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var n=t==e;else n=t&&(e.test?e.test(t):e(t));if(n)return++this.pos,t},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){throw"not implemented"},indentation:function(){throw"not implemented"},match:function(e,t,n){if("string"!=typeof e){var r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e};if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}},it.defineExtension=function(e,t){it.prototype[e]=t},qe.importCssString(".normal-mode .ace_cursor{\n border: none;\n background-color: rgba(255,0,0,0.5);\n}\n.normal-mode .ace_hidden-cursors .ace_cursor{\n background-color: transparent;\n border: 1px solid red;\n opacity: 0.7\n}\n.ace_dialog {\n position: absolute;\n left: 0; right: 0;\n background: inherit;\n z-index: 15;\n padding: .1em .8em;\n overflow: hidden;\n color: inherit;\n}\n.ace_dialog-top {\n border-bottom: 1px solid #444;\n top: 0;\n}\n.ace_dialog-bottom {\n border-top: 1px solid #444;\n bottom: 0;\n}\n.ace_dialog input {\n border: none;\n outline: none;\n background: transparent;\n width: 20em;\n color: inherit;\n font-family: monospace;\n}","vimMode",!1),function(){function e(e,t,n){var r;return(r=e.ace.container.appendChild(document.createElement("div"))).className=n?"ace_dialog ace_dialog-bottom":"ace_dialog ace_dialog-top","string"==typeof t?r.innerHTML=t:r.appendChild(t),r}function t(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}it.defineExtension("openDialog",(function(n,r,i){function o(e){if("string"==typeof e)u.value=e;else{if(s)return;if(e&&"blur"==e.type&&document.activeElement===u)return;l.state.dialog==a&&(l.state.dialog=null,l.focus()),s=!0,a.remove(),i.onClose&&i.onClose(a);var t=l;t.state.vim&&(t.state.vim.status=null,t.ace._signal("changeStatus"),t.ace.renderer.$loop.schedule(t.ace.renderer.CHANGE_CURSOR))}}if(!this.virtualSelectionMode()){i||(i={}),t(this,null);var a=e(this,n,i.bottom),s=!1,l=this;this.state.dialog=a;var c,u=a.getElementsByTagName("input")[0];return u?(i.value&&(u.value=i.value,!1!==i.selectValueOnOpen&&u.select()),i.onInput&&it.on(u,"input",(function(e){i.onInput(e,u.value,o)})),i.onKeyUp&&it.on(u,"keyup",(function(e){i.onKeyUp(e,u.value,o)})),it.on(u,"keydown",(function(e){i&&i.onKeyDown&&i.onKeyDown(e,u.value,o)||(13==e.keyCode&&r(u.value),(27==e.keyCode||!1!==i.closeOnEnter&&13==e.keyCode)&&(it.e_stop(e),o()))})),!1!==i.closeOnBlur&&it.on(u,"blur",o),u.focus()):(c=a.getElementsByTagName("button")[0])&&(it.on(c,"click",(function(){o(),l.focus()})),!1!==i.closeOnBlur&&it.on(c,"blur",o),c.focus()),o}})),it.defineExtension("openNotification",(function(n,r){function i(){s||(s=!0,clearTimeout(o),a.remove())}if(!this.virtualSelectionMode()){t(this,i);var o,a=e(this,n,r&&r.bottom),s=!1,l=r&&void 0!==r.duration?r.duration:5e3;return it.on(a,"click",(function(e){it.e_preventDefault(e),i()})),l&&(o=setTimeout(i,l)),i}}))}();var at,st=it.Pos,lt=[{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:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{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:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",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:"keyToKey",toKeys:"i",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:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{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:"