@liascript/editor
Version:
An extended Markdown interpreter for the creation of interactive online courses.
2 lines (1 loc) • 47.4 kB
JavaScript
!function(e){if(!(void 0!==e.window&&e.document||e.require&&e.define)){e.console||(e.console=function(){var e=Array.prototype.slice.call(arguments,0);postMessage({type:"log",data:e})},e.console.error=e.console.warn=e.console.log=e.console.trace=e.console),e.window=e,e.ace=e,e.onerror=function(e,t,n,r,o){postMessage({type:"error",data:{message:e,data:o&&o.data,file:t,line:n,col:r,stack:o&&o.stack}})},e.normalizeModule=function(t,n){if(-1!==n.indexOf("!")){var r=n.split("!");return e.normalizeModule(t,r[0])+"!"+e.normalizeModule(t,r[1])}if("."==n.charAt(0)){var o=t.split("/").slice(0,-1).join("/");for(n=(o?o+"/":"")+n;-1!==n.indexOf(".")&&i!=n;){var i=n;n=n.replace(/^\.\//,"").replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return n},e.require=function(t,n){if(n||(n=t,t=null),!n.charAt)throw new Error("worker.js require() accepts only (parentId, id) as arguments");n=e.normalizeModule(t,n);var r=e.require.modules[n];if(r)return r.initialized||(r.initialized=!0,r.exports=r.factory().exports),r.exports;if(!e.require.tlns)return console.log("unable to load "+n);var o=function(e,t){for(var n=e,r="";n;){var o=t[n];if("string"==typeof o)return o+r;if(o)return o.location.replace(/\/*$/,"/")+(r||o.main||o.name);if(!1===o)return"";var i=n.lastIndexOf("/");if(-1===i)break;r=n.substr(i)+r,n=n.slice(0,i)}return e}(n,e.require.tlns);return".js"!=o.slice(-3)&&(o+=".js"),e.require.id=n,e.require.modules[n]={},importScripts(o),e.require(t,n)},e.require.modules={},e.require.tlns={},e.define=function(t,n,r){if(2==arguments.length?(r=n,"string"!=typeof t&&(n=t,t=e.require.id)):1==arguments.length&&(r=t,n=[],t=e.require.id),"function"==typeof r){n.length||(n=["require","exports","module"]);var o=function(n){return e.require(t,n)};e.require.modules[t]={exports:{},factory:function(){var e=this,t=r.apply(this,n.slice(0,r.length).map((function(t){switch(t){case"require":return o;case"exports":return e.exports;case"module":return e;default:return o(t)}})));return t&&(e.exports=t),e}}}else e.require.modules[t]={exports:r,initialized:!0}},e.define.amd={},e.require.tlns={},e.initBaseUrls=function(e){for(var t in e)this.require.tlns[t]=e[t]},e.initSender=function(){var t=e.require("ace/lib/event_emitter").EventEmitter,n=e.require("ace/lib/oop"),r=function(){};return function(){n.implement(this,t),this.callback=function(e,t){postMessage({type:"call",id:t,data:e})},this.emit=function(e,t){postMessage({type:"event",name:e,data:t})}}.call(r.prototype),new r};var t=e.main=null,n=e.sender=null;e.onmessage=function(r){var o=r.data;if(o.event&&n)n._signal(o.event,o.data);else if(o.command)if(t[o.command])t[o.command].apply(t,o.args);else{if(!e[o.command])throw new Error("Unknown command:"+o.command);e[o.command].apply(e,o.args)}else if(o.init){e.initBaseUrls(o.tlns),n=e.sender=e.initSender();var i=this.require(o.module)[o.classname];t=e.main=new i(n)}}}}(this),ace.define("ace/lib/oop",[],(function(e,t,n){"use strict";t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t.mixin=function(e,t){for(var n in t)e[n]=t[n];return e},t.implement=function(e,n){t.mixin(e,n)}})),ace.define("ace/apply_delta",[],(function(e,t,n){"use strict";t.applyDelta=function(e,t,n){var r=t.start.row,o=t.start.column,i=e[r]||"";switch(t.action){case"insert":if(1===t.lines.length)e[r]=i.substring(0,o)+t.lines[0]+i.substring(o);else{var a=[r,1].concat(t.lines);e.splice.apply(e,a),e[r]=i.substring(0,o)+e[r],e[r+t.lines.length-1]+=i.substring(o)}break;case"remove":var s=t.end.column,c=t.end.row;r===c?e[r]=i.substring(0,o)+i.substring(s):e.splice(r,c-r+1,i.substring(0,o)+e[c].substring(s))}}})),ace.define("ace/lib/event_emitter",[],(function(e,t,n){"use strict";var r={},o=function(){this.propagationStopped=!0},i=function(){this.defaultPrevented=!0};r._emit=r._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],r=this._defaultHandlers[e];if(n.length||r){"object"==typeof t&&t||(t={}),t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=o),t.preventDefault||(t.preventDefault=i),n=n.slice();for(var a=0;a<n.length&&(n[a](t,this),!t.propagationStopped);a++);return r&&!t.defaultPrevented?r(t,this):void 0}},r._signal=function(e,t){var n=(this._eventRegistry||{})[e];if(n){n=n.slice();for(var r=0;r<n.length;r++)n[r](t,this)}},r.once=function(e,t){var n=this;if(this.on(e,(function r(){n.off(e,r),t.apply(null,arguments)})),!t)return new Promise((function(e){t=e}))},r.setDefaultHandler=function(e,t){var n=this._defaultHandlers;if(n||(n=this._defaultHandlers={_disabled_:{}}),n[e]){var r=n[e],o=n._disabled_[e];o||(n._disabled_[e]=o=[]),o.push(r);var i=o.indexOf(t);-1!=i&&o.splice(i,1)}n[e]=t},r.removeDefaultHandler=function(e,t){var n=this._defaultHandlers;if(n){var r=n._disabled_[e];if(n[e]==t)r&&this.setDefaultHandler(e,r.pop());else if(r){var o=r.indexOf(t);-1!=o&&r.splice(o,1)}}},r.on=r.addEventListener=function(e,t,n){this._eventRegistry=this._eventRegistry||{};var r=this._eventRegistry[e];return r||(r=this._eventRegistry[e]=[]),-1==r.indexOf(t)&&r[n?"unshift":"push"](t),t},r.off=r.removeListener=r.removeEventListener=function(e,t){this._eventRegistry=this._eventRegistry||{};var n=this._eventRegistry[e];if(n){var r=n.indexOf(t);-1!==r&&n.splice(r,1)}},r.removeAllListeners=function(e){e||(this._eventRegistry=this._defaultHandlers=void 0),this._eventRegistry&&(this._eventRegistry[e]=void 0),this._defaultHandlers&&(this._defaultHandlers[e]=void 0)},t.EventEmitter=r})),ace.define("ace/range",[],(function(e,t,n){"use strict";var r=function(){function e(e,t,n,r){this.start={row:e,column:t},this.end={row:n,column:r}}return e.prototype.isEqual=function(e){return this.start.row===e.start.row&&this.end.row===e.end.row&&this.start.column===e.start.column&&this.end.column===e.end.column},e.prototype.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},e.prototype.contains=function(e,t){return 0==this.compare(e,t)},e.prototype.compareRange=function(e){var t,n=e.end,r=e.start;return 1==(t=this.compare(n.row,n.column))?1==(t=this.compare(r.row,r.column))?2:0==t?1:0:-1==t?-2:-1==(t=this.compare(r.row,r.column))?-1:1==t?42:0},e.prototype.comparePoint=function(e){return this.compare(e.row,e.column)},e.prototype.containsRange=function(e){return 0==this.comparePoint(e.start)&&0==this.comparePoint(e.end)},e.prototype.intersects=function(e){var t=this.compareRange(e);return-1==t||0==t||1==t},e.prototype.isEnd=function(e,t){return this.end.row==e&&this.end.column==t},e.prototype.isStart=function(e,t){return this.start.row==e&&this.start.column==t},e.prototype.setStart=function(e,t){"object"==typeof e?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},e.prototype.setEnd=function(e,t){"object"==typeof e?(this.end.column=e.column,this.end.row=e.row):(this.end.row=e,this.end.column=t)},e.prototype.inside=function(e,t){return 0==this.compare(e,t)&&(!this.isEnd(e,t)&&!this.isStart(e,t))},e.prototype.insideStart=function(e,t){return 0==this.compare(e,t)&&!this.isEnd(e,t)},e.prototype.insideEnd=function(e,t){return 0==this.compare(e,t)&&!this.isStart(e,t)},e.prototype.compare=function(e,t){return this.isMultiLine()||e!==this.start.row?e<this.start.row?-1:e>this.end.row?1:this.start.row===e?t>=this.start.column?0:-1:this.end.row===e?t<=this.end.column?0:1:0:t<this.start.column?-1:t>this.end.column?1:0},e.prototype.compareStart=function(e,t){return this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},e.prototype.compareEnd=function(e,t){return this.end.row==e&&this.end.column==t?1:this.compare(e,t)},e.prototype.compareInside=function(e,t){return this.end.row==e&&this.end.column==t?1:this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},e.prototype.clipRows=function(t,n){if(this.end.row>n)var r={row:n+1,column:0};else if(this.end.row<t)r={row:t,column:0};if(this.start.row>n)var o={row:n+1,column:0};else if(this.start.row<t)o={row:t,column:0};return e.fromPoints(o||this.start,r||this.end)},e.prototype.extend=function(t,n){var r=this.compare(t,n);if(0==r)return this;if(-1==r)var o={row:t,column:n};else var i={row:t,column:n};return e.fromPoints(o||this.start,i||this.end)},e.prototype.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},e.prototype.isMultiLine=function(){return this.start.row!==this.end.row},e.prototype.clone=function(){return e.fromPoints(this.start,this.end)},e.prototype.collapseRows=function(){return 0==this.end.column?new e(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new e(this.start.row,0,this.end.row,0)},e.prototype.toScreenRange=function(t){var n=t.documentToScreenPosition(this.start),r=t.documentToScreenPosition(this.end);return new e(n.row,n.column,r.row,r.column)},e.prototype.moveBy=function(e,t){this.start.row+=e,this.start.column+=t,this.end.row+=e,this.end.column+=t},e}();r.fromPoints=function(e,t){return new r(e.row,e.column,t.row,t.column)},r.comparePoints=function(e,t){return e.row-t.row||e.column-t.column},t.Range=r})),ace.define("ace/anchor",[],(function(e,t,n){"use strict";function r(e,t,n){var r=n?e.column<=t.column:e.column<t.column;return e.row<t.row||e.row==t.row&&r}var o=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,a=function(){function e(e,t,n){this.$onChange=this.onChange.bind(this),this.attach(e),"number"!=typeof t?this.setPosition(t.row,t.column):this.setPosition(t,n)}return e.prototype.getPosition=function(){return this.$clipPositionToDocument(this.row,this.column)},e.prototype.getDocument=function(){return this.document},e.prototype.onChange=function(e){if(!(e.start.row==e.end.row&&e.start.row!=this.row||e.start.row>this.row)){var t=function(e,t,n){var o="insert"==e.action,i=(o?1:-1)*(e.end.row-e.start.row),a=(o?1:-1)*(e.end.column-e.start.column),s=e.start,c=o?s:e.end;return r(t,s,n)?{row:t.row,column:t.column}:r(c,t,!n)?{row:t.row+i,column:t.column+(t.row==c.row?a:0)}:{row:s.row,column:s.column}}(e,{row:this.row,column:this.column},this.$insertRight);this.setPosition(t.row,t.column,!0)}},e.prototype.setPosition=function(e,t,n){var r;if(r=n?{row:e,column:t}:this.$clipPositionToDocument(e,t),this.row!=r.row||this.column!=r.column){var o={row:this.row,column:this.column};this.row=r.row,this.column=r.column,this._signal("change",{old:o,value:r})}},e.prototype.detach=function(){this.document.off("change",this.$onChange)},e.prototype.attach=function(e){this.document=e||this.document,this.document.on("change",this.$onChange)},e.prototype.$clipPositionToDocument=function(e,t){var n={};return e>=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n},e}();a.prototype.$insertRight=!1,o.implement(a.prototype,i),t.Anchor=a})),ace.define("ace/document",[],(function(e,t,n){"use strict";var r=e("./lib/oop"),o=e("./apply_delta").applyDelta,i=e("./lib/event_emitter").EventEmitter,a=e("./range").Range,s=e("./anchor").Anchor,c=function(){function e(e){this.$lines=[""],0===e.length?this.$lines=[""]:Array.isArray(e)?this.insertMergedLines({row:0,column:0},e):this.insert({row:0,column:0},e)}return e.prototype.setValue=function(e){var t=this.getLength()-1;this.remove(new a(0,0,t,this.getLine(t).length)),this.insert({row:0,column:0},e||"")},e.prototype.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},e.prototype.createAnchor=function(e,t){return new s(this,e,t)},e.prototype.$detectNewLine=function(e){var t=e.match(/^.*?(\r\n|\r|\n)/m);this.$autoNewLine=t?t[1]:"\n",this._signal("changeNewLineMode")},e.prototype.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";default:return this.$autoNewLine||"\n"}},e.prototype.setNewLineMode=function(e){this.$newLineMode!==e&&(this.$newLineMode=e,this._signal("changeNewLineMode"))},e.prototype.getNewLineMode=function(){return this.$newLineMode},e.prototype.isNewLine=function(e){return"\r\n"==e||"\r"==e||"\n"==e},e.prototype.getLine=function(e){return this.$lines[e]||""},e.prototype.getLines=function(e,t){return this.$lines.slice(e,t+1)},e.prototype.getAllLines=function(){return this.getLines(0,this.getLength())},e.prototype.getLength=function(){return this.$lines.length},e.prototype.getTextRange=function(e){return this.getLinesForRange(e).join(this.getNewLineCharacter())},e.prototype.getLinesForRange=function(e){var t;if(e.start.row===e.end.row)t=[this.getLine(e.start.row).substring(e.start.column,e.end.column)];else{(t=this.getLines(e.start.row,e.end.row))[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;e.end.row-e.start.row==n&&(t[n]=t[n].substring(0,e.end.column))}return t},e.prototype.insertLines=function(e,t){return console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."),this.insertFullLines(e,t)},e.prototype.removeLines=function(e,t){return console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."),this.removeFullLines(e,t)},e.prototype.insertNewLine=function(e){return console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."),this.insertMergedLines(e,["",""])},e.prototype.insert=function(e,t){return this.getLength()<=1&&this.$detectNewLine(t),this.insertMergedLines(e,this.$split(t))},e.prototype.insertInLine=function(e,t){var n=this.clippedPos(e.row,e.column),r=this.pos(e.row,e.column+t.length);return this.applyDelta({start:n,end:r,action:"insert",lines:[t]},!0),this.clonePos(r)},e.prototype.clippedPos=function(e,t){var n=this.getLength();void 0===e?e=n:e<0?e=0:e>=n&&(e=n-1,t=void 0);var r=this.getLine(e);return null==t&&(t=r.length),{row:e,column:t=Math.min(Math.max(t,0),r.length)}},e.prototype.clonePos=function(e){return{row:e.row,column:e.column}},e.prototype.pos=function(e,t){return{row:e,column:t}},e.prototype.$clipPosition=function(e){var t=this.getLength();return e.row>=t?(e.row=Math.max(0,t-1),e.column=this.getLine(t-1).length):(e.row=Math.max(0,e.row),e.column=Math.min(Math.max(e.column,0),this.getLine(e.row).length)),e},e.prototype.insertFullLines=function(e,t){var n=0;(e=Math.min(Math.max(e,0),this.getLength()))<this.getLength()?(t=t.concat([""]),n=0):(t=[""].concat(t),e--,n=this.$lines[e].length),this.insertMergedLines({row:e,column:n},t)},e.prototype.insertMergedLines=function(e,t){var n=this.clippedPos(e.row,e.column),r={row:n.row+t.length-1,column:(1==t.length?n.column:0)+t[t.length-1].length};return this.applyDelta({start:n,end:r,action:"insert",lines:t}),this.clonePos(r)},e.prototype.remove=function(e){var t=this.clippedPos(e.start.row,e.start.column),n=this.clippedPos(e.end.row,e.end.column);return this.applyDelta({start:t,end:n,action:"remove",lines:this.getLinesForRange({start:t,end:n})}),this.clonePos(t)},e.prototype.removeInLine=function(e,t,n){var r=this.clippedPos(e,t),o=this.clippedPos(e,n);return this.applyDelta({start:r,end:o,action:"remove",lines:this.getLinesForRange({start:r,end:o})},!0),this.clonePos(r)},e.prototype.removeFullLines=function(e,t){e=Math.min(Math.max(0,e),this.getLength()-1);var n=(t=Math.min(Math.max(0,t),this.getLength()-1))==this.getLength()-1&&e>0,r=t<this.getLength()-1,o=n?e-1:e,i=n?this.getLine(o).length:0,s=r?t+1:t,c=r?0:this.getLine(s).length,u=new a(o,i,s,c),l=this.$lines.slice(e,t+1);return this.applyDelta({start:u.start,end:u.end,action:"remove",lines:this.getLinesForRange(u)}),l},e.prototype.removeNewLine=function(e){e<this.getLength()-1&&e>=0&&this.applyDelta({start:this.pos(e,this.getLine(e).length),end:this.pos(e+1,0),action:"remove",lines:["",""]})},e.prototype.replace=function(e,t){return e instanceof a||(e=a.fromPoints(e.start,e.end)),0===t.length&&e.isEmpty()?e.start:t==this.getTextRange(e)?e.end:(this.remove(e),t?this.insert(e.start,t):e.start)},e.prototype.applyDeltas=function(e){for(var t=0;t<e.length;t++)this.applyDelta(e[t])},e.prototype.revertDeltas=function(e){for(var t=e.length-1;t>=0;t--)this.revertDelta(e[t])},e.prototype.applyDelta=function(e,t){var n="insert"==e.action;(n?e.lines.length<=1&&!e.lines[0]:!a.comparePoints(e.start,e.end))||(n&&e.lines.length>2e4?this.$splitAndapplyLargeDelta(e,2e4):(o(this.$lines,e,t),this._signal("change",e)))},e.prototype.$safeApplyDelta=function(e){var t=this.$lines.length;("remove"==e.action&&e.start.row<t&&e.end.row<t||"insert"==e.action&&e.start.row<=t)&&this.applyDelta(e)},e.prototype.$splitAndapplyLargeDelta=function(e,t){for(var n=e.lines,r=n.length-t+1,o=e.start.row,i=e.start.column,a=0,s=0;a<r;a=s){s+=t-1;var c=n.slice(a,s);c.push(""),this.applyDelta({start:this.pos(o+a,i),end:this.pos(o+s,i=0),action:e.action,lines:c},!0)}e.lines=n.slice(a),e.start.row=o+a,e.start.column=i,this.applyDelta(e,!0)},e.prototype.revertDelta=function(e){this.$safeApplyDelta({start:this.clonePos(e.start),end:this.clonePos(e.end),action:"insert"==e.action?"remove":"insert",lines:e.lines.slice()})},e.prototype.indexToPosition=function(e,t){for(var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length,o=t||0,i=n.length;o<i;o++)if((e-=n[o].length+r)<0)return{row:o,column:e+n[o].length+r};return{row:i-1,column:e+n[i-1].length+r}},e.prototype.positionToIndex=function(e,t){for(var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length,o=0,i=Math.min(e.row,n.length),a=t||0;a<i;++a)o+=n[a].length+r;return o+e.column},e.prototype.$split=function(e){return e.split(/\r\n|\r|\n/)},e}();c.prototype.$autoNewLine="",c.prototype.$newLineMode="auto",r.implement(c.prototype,i),t.Document=c})),ace.define("ace/lib/deep_copy",[],(function(e,t,n){t.deepCopy=function e(t){if("object"!=typeof t||!t)return t;var n;if(Array.isArray(t)){n=[];for(var r=0;r<t.length;r++)n[r]=e(t[r]);return n}if("[object Object]"!==Object.prototype.toString.call(t))return t;for(var r in n={},t)n[r]=e(t[r]);return n}})),ace.define("ace/lib/lang",[],(function(e,t,n){"use strict";t.last=function(e){return e[e.length-1]},t.stringReverse=function(e){return e.split("").reverse().join("")},t.stringRepeat=function(e,t){for(var n="";t>0;)1&t&&(n+=e),(t>>=1)&&(e+=e);return n};var r=/^\s\s*/,o=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(r,"")},t.stringTrimRight=function(e){return e.replace(o,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){for(var t=[],n=0,r=e.length;n<r;n++)e[n]&&"object"==typeof e[n]?t[n]=this.copyObject(e[n]):t[n]=e[n];return t},t.deepCopy=e("./deep_copy").deepCopy,t.arrayToMap=function(e){for(var t={},n=0;n<e.length;n++)t[e[n]]=1;return t},t.createMap=function(e){var t=Object.create(null);for(var n in e)t[n]=e[n];return t},t.arrayRemove=function(e,t){for(var n=0;n<=e.length;n++)t===e[n]&&e.splice(n,1)},t.escapeRegExp=function(e){return e.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")},t.escapeHTML=function(e){return(""+e).replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<")},t.getMatchOffsets=function(e,t){var n=[];return e.replace(t,(function(e){n.push({offset:arguments[arguments.length-2],length:e.length})})),n},t.deferredCall=function(e){var t=null,n=function(){t=null,e()},r=function(e){return r.cancel(),t=setTimeout(n,e||0),r};return r.schedule=r,r.call=function(){return this.cancel(),e(),r},r.cancel=function(){return clearTimeout(t),t=null,r},r.isPending=function(){return t},r},t.delayedCall=function(e,t){var n=null,r=function(){n=null,e()},o=function(e){null==n&&(n=setTimeout(r,e||t))};return o.delay=function(e){n&&clearTimeout(n),n=setTimeout(r,e||t)},o.schedule=o,o.call=function(){this.cancel(),e()},o.cancel=function(){n&&clearTimeout(n),n=null},o.isPending=function(){return n},o},t.supportsLookbehind=function(){try{new RegExp("(?<=.)")}catch(e){return!1}return!0},t.skipEmptyMatch=function(e,t,n){return n&&e.codePointAt(t)>65535?2:1}})),ace.define("ace/worker/mirror",[],(function(e,t,n){"use strict";var r=e("../document").Document,o=e("../lib/lang"),i=t.Mirror=function(e){this.sender=e;var t=this.doc=new r(""),n=this.deferredUpdate=o.delayedCall(this.onUpdate.bind(this)),i=this;e.on("change",(function(e){var r=e.data;if(r[0].start)t.applyDeltas(r);else for(var o=0;o<r.length;o+=2){var a,s;if(("insert"==(a=Array.isArray(r[o+1])?{action:"insert",start:r[o],lines:r[o+1]}:{action:"remove",start:r[o],end:r[o+1]}).action?a.start:a.end).row>=t.$lines.length)throw(s=new Error("Invalid delta")).data={path:i.$path,linesLength:t.$lines.length,start:a.start,end:a.end},s;t.applyDelta(a,!0)}if(i.$timeout)return n.schedule(i.$timeout);i.onUpdate()}))};(function(){this.$timeout=500,this.setTimeout=function(e){this.$timeout=e},this.setValue=function(e){this.doc.setValue(e),this.deferredUpdate.schedule(this.$timeout)},this.getValue=function(e){this.sender.callback(this.doc.getValue(),e)},this.onUpdate=function(){},this.isPending=function(){return this.deferredUpdate.isPending()}}).call(i.prototype)})),ace.define("ace/mode/lua/luaparse",[],(function(e,t,n){!function(e){"use strict";function t(e,t){return t=t||0,e<128?String.fromCharCode(e):e<2048?String.fromCharCode(192|t|e>>6,128|t|63&e):e<65536?String.fromCharCode(224|t|e>>12,128|t|e>>6&63,128|t|63&e):e<1114112?String.fromCharCode(240|t|e>>18,128|t|e>>12&63,128|t|e>>6&63,128|t|63&e):null}function n(e,t){for(var n=e.toString(16);n.length<t;)n="0"+n;return n}function r(e){return function(t){var r=e.exec(t);if(!r)return t;c(null,He.invalidCodeUnit,n(r[0].charCodeAt(0),4).toUpperCase())}}function o(e){if(st){var t=ct.pop();t.complete(),t.bless(e)}return Pe.onCreateNode&&Pe.onCreateNode(e),e}function i(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r][t]===n)return r;return-1}function a(e){var t=Ke.call(arguments,1);return e=e.replace(/%(\d)/g,(function(e,n){return""+t[n-1]||""})),e}function s(e){return Object.create?Object.create(e,{line:{writable:!0,value:e.line},index:{writable:!0,value:e.index},column:{writable:!0,value:e.column}}):e}function c(e){var t,n,r=a.apply(null,Ke.call(arguments,1));throw null===e||void 0===e.line?(n=Je-nt+1,(t=s(new SyntaxError(a("[%1:%2] %3",tt,n,r)))).index=Je,t.line=tt,t.column=n):(n=e.range[0]-e.lineStart,(t=s(new SyntaxError(a("[%1:%2] %3",e.line,n,r)))).line=e.line,t.index=e.range[0],t.column=n),t}function u(e){var t=Me.slice(e.range[0],e.range[1]);return t||e.value}function l(e,t){c(t,He.expectedToken,e,u(t))}function p(e){var t=u(Ye);if(void 0!==e.type){var n;switch(e.type){case je:n="string";break;case Ue:n="keyword";break;case Ie:n="identifier";break;case Fe:n="number";break;case qe:n="symbol";break;case Ve:n="boolean";break;case Ge:return c(e,He.unexpected,"symbol","nil",t);case Re:return c(e,He.unexpectedEOF)}return c(e,He.unexpected,n,u(e),t)}return c(e,He.unexpected,"symbol",e,t)}function f(){for(d();45===Me.charCodeAt(Je)&&45===Me.charCodeAt(Je+1);)k(),d();if(Je>=Oe)return{type:Re,value:"<eof>",line:tt,lineStart:nt,range:[Je,Je]};var e=Me.charCodeAt(Je),t=Me.charCodeAt(Je+1);if(et=Je,R(e))return m();switch(e){case 39:case 34:return y();case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return b();case 46:return N(t)?b():46===t?46===Me.charCodeAt(Je+2)?v():g(".."):g(".");case 61:return g(61===t?"==":"=");case 62:return _e.bitwiseOperators&&62===t?g(">>"):g(61===t?">=":">");case 60:return _e.bitwiseOperators&&60===t?g("<<"):g(61===t?"<=":"<");case 126:if(61===t)return g("~=");if(!_e.bitwiseOperators)break;return g("~");case 58:return _e.labels&&58===t?g("::"):g(":");case 91:return 91===t||61===t?w():g("[");case 47:return _e.integerDivision&&47===t?g("//"):g("/");case 38:case 124:if(!_e.bitwiseOperators)break;case 42:case 94:case 37:case 44:case 123:case 125:case 93:case 40:case 41:case 59:case 35:case 45:case 43:return g(Me.charAt(Je))}return p(Me.charAt(Je))}function h(){var e=Me.charCodeAt(Je),t=Me.charCodeAt(Je+1);return!!$(e)&&(10===e&&13===t&&++Je,13===e&&10===t&&++Je,++tt,nt=++Je,!0)}function d(){for(;Je<Oe;)if(_(Me.charCodeAt(Je)))++Je;else if(!h())break}function m(){for(var e,t;j(Me.charCodeAt(++Je)););return U(e=$e.fixup(Me.slice(et,Je)))?t=Ue:"true"===e||"false"===e?(t=Ve,e="true"===e):"nil"===e?(t=Ge,e=null):t=Ie,{type:t,value:e,line:tt,lineStart:nt,range:[et,Je]}}function g(e){return Je+=e.length,{type:qe,value:e,line:tt,lineStart:nt,range:[et,Je]}}function v(){return{type:Be,value:"...",line:tt,lineStart:nt,range:[et,Je+=3]}}function y(){for(var e,t=Me.charCodeAt(Je++),n=tt,r=nt,o=Je,i=$e.discardStrings?null:"";t!==(e=Me.charCodeAt(Je++));)if((Je>Oe||$(e))&&(i+=Me.slice(o,Je-1),c(null,He.unfinishedString,Me.slice(et,Je-1))),92===e){if(!$e.discardStrings){var a=Me.slice(o,Je-1);i+=$e.fixup(a)}var s=A();$e.discardStrings||(i+=s),o=Je}return $e.discardStrings||(i+=$e.encodeByte(null),i+=$e.fixup(Me.slice(o,Je-1))),{type:je,value:i,line:n,lineStart:r,lastLine:tt,lastLineStart:nt,range:[et,Je]}}function w(){var e=tt,t=nt,n=D(!1);return!1===n&&c(Xe,He.expected,"[",u(Xe)),{type:je,value:$e.discardStrings?null:$e.fixup(n),line:e,lineStart:t,lastLine:tt,lastLineStart:nt,range:[et,Je]}}function b(){var e=Me.charAt(Je),t=Me.charAt(Je+1),n="0"===e&&"xX".indexOf(t||null)>=0?S():C(),r=x();return L()&&(r||n.hasFractionPart)&&c(null,He.malformedNumber,Me.slice(et,Je)),{type:Fe,value:n.value,line:tt,lineStart:nt,range:[et,Je]}}function x(){if(_e.imaginaryNumbers)return"iI".indexOf(Me.charAt(Je)||null)>=0&&(++Je,!0)}function L(){if(_e.integerSuffixes)if("uU".indexOf(Me.charAt(Je)||null)>=0)if(++Je,"lL".indexOf(Me.charAt(Je)||null)>=0){if(++Je,"lL".indexOf(Me.charAt(Je)||null)>=0)return++Je,"ULL";c(null,He.malformedNumber,Me.slice(et,Je))}else c(null,He.malformedNumber,Me.slice(et,Je));else if("lL".indexOf(Me.charAt(Je)||null)>=0){if(++Je,"lL".indexOf(Me.charAt(Je)||null)>=0)return++Je,"LL";c(null,He.malformedNumber,Me.slice(et,Je))}}function S(){var e,t,n,r,o=0,i=1,a=1;for(r=Je+=2,T(Me.charCodeAt(Je))||c(null,He.malformedNumber,Me.slice(et,Je));T(Me.charCodeAt(Je));)++Je;e=parseInt(Me.slice(r,Je),16);var s=!1;if("."===Me.charAt(Je)){for(s=!0,t=++Je;T(Me.charCodeAt(Je));)++Je;o=Me.slice(t,Je),o=t===Je?0:parseInt(o,16)/Math.pow(16,Je-t)}var u=!1;if("pP".indexOf(Me.charAt(Je)||null)>=0){for(u=!0,++Je,"+-".indexOf(Me.charAt(Je)||null)>=0&&(a="+"===Me.charAt(Je++)?1:-1),n=Je,N(Me.charCodeAt(Je))||c(null,He.malformedNumber,Me.slice(et,Je));N(Me.charCodeAt(Je));)++Je;i=Me.slice(n,Je),i=Math.pow(2,i*a)}return{value:(e+o)*i,hasFractionPart:s||u}}function C(){for(;N(Me.charCodeAt(Je));)++Je;var e=!1;if("."===Me.charAt(Je))for(e=!0,++Je;N(Me.charCodeAt(Je));)++Je;var t=!1;if("eE".indexOf(Me.charAt(Je)||null)>=0)for(t=!0,++Je,"+-".indexOf(Me.charAt(Je)||null)>=0&&++Je,N(Me.charCodeAt(Je))||c(null,He.malformedNumber,Me.slice(et,Je));N(Me.charCodeAt(Je));)++Je;return{value:parseFloat(Me.slice(et,Je)),hasFractionPart:e||t}}function E(){var e=Je++;for("{"!==Me.charAt(Je++)&&c(null,He.braceExpected,"{","\\"+Me.slice(e,Je)),T(Me.charCodeAt(Je))||c(null,He.hexadecimalDigitExpected,"\\"+Me.slice(e,Je));48===Me.charCodeAt(Je);)++Je;for(var t=Je;T(Me.charCodeAt(Je));)++Je-t>6&&c(null,He.tooLargeCodepoint,"\\"+Me.slice(e,Je));var n=Me.charAt(Je++);"}"!==n&&('"'===n||"'"===n?c(null,He.braceExpected,"}","\\"+Me.slice(e,Je--)):c(null,He.hexadecimalDigitExpected,"\\"+Me.slice(e,Je)));var r=parseInt(Me.slice(t,Je-1)||"0",16),o="\\"+Me.slice(e,Je);return r>1114111&&c(null,He.tooLargeCodepoint,o),$e.encodeUTF8(r,o)}function A(){var e=Je;switch(Me.charAt(Je)){case"a":return++Je,"";case"n":return++Je,"\n";case"r":return++Je,"\r";case"t":return++Je,"\t";case"v":return++Je,"\v";case"b":return++Je,"\b";case"f":return++Je,"\f";case"\r":case"\n":return h(),"\n";case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;N(Me.charCodeAt(Je))&&Je-e<3;)++Je;var t=Me.slice(e,Je),n=parseInt(t,10);return n>255&&c(null,He.decimalEscapeTooLarge,"\\"+n),$e.encodeByte(n,"\\"+t);case"z":if(_e.skipWhitespaceEscape)return++Je,d(),"";break;case"x":if(_e.hexEscapes){if(T(Me.charCodeAt(Je+1))&&T(Me.charCodeAt(Je+2)))return Je+=3,$e.encodeByte(parseInt(Me.slice(e+1,Je),16),"\\"+Me.slice(e,Je));c(null,He.hexadecimalDigitExpected,"\\"+Me.slice(e,Je+2))}break;case"u":if(_e.unicodeEscapes)return E();break;case"\\":case'"':case"'":return Me.charAt(Je++)}return _e.strictEscapes&&c(null,He.invalidEscape,"\\"+Me.slice(e,Je+1)),Me.charAt(Je++)}function k(){et=Je,Je+=2;var e=Me.charAt(Je),t="",n=!1,r=Je,o=nt,i=tt;if("["===e&&(!1===(t=D(!0))?t=e:n=!0),!n){for(;Je<Oe&&!$(Me.charCodeAt(Je));)++Je;Pe.comments&&(t=Me.slice(r,Je))}if(Pe.comments){var a=ze.comment(t,Me.slice(et,Je));Pe.locations&&(a.loc={start:{line:i,column:et-o},end:{line:tt,column:Je-nt}}),Pe.ranges&&(a.range=[et,Je]),Pe.onCreateNode&&Pe.onCreateNode(a),Ze.push(a)}}function D(e){var t,n=0,r="",o=!1,i=tt;for(++Je;"="===Me.charAt(Je+n);)++n;if("["!==Me.charAt(Je+n))return!1;for(Je+=n+1,$(Me.charCodeAt(Je))&&h(),t=Je;Je<Oe;){for(;$(Me.charCodeAt(Je));)h();if("]"===Me.charAt(Je++)){o=!0;for(var a=0;a<n;++a)"="!==Me.charAt(Je+a)&&(o=!1);"]"!==Me.charAt(Je+n)&&(o=!1)}if(o)return r+=Me.slice(t,Je-1),Je+=n+1,r}c(null,e?He.unfinishedLongComment:He.unfinishedLongString,i,"<eof>")}function M(){Qe=Xe,Xe=Ye,Ye=f()}function P(e){return e===Xe.value&&(M(),!0)}function O(e){e===Xe.value?M():c(Xe,He.expected,e,u(Xe))}function _(e){return 9===e||32===e||11===e||12===e}function $(e){return 10===e||13===e}function N(e){return e>=48&&e<=57}function T(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function R(e){return e>=65&&e<=90||e>=97&&e<=122||95===e||!!(_e.extendedIdentifiers&&e>=128)}function j(e){return e>=65&&e<=90||e>=97&&e<=122||95===e||e>=48&&e<=57||!!(_e.extendedIdentifiers&&e>=128)}function U(e){switch(e.length){case 2:return"do"===e||"if"===e||"in"===e||"or"===e;case 3:return"and"===e||"end"===e||"for"===e||"not"===e;case 4:return"else"===e||"then"===e||!(!_e.labels||_e.contextualGoto)&&"goto"===e;case 5:return"break"===e||"local"===e||"until"===e||"while"===e;case 6:return"elseif"===e||"repeat"===e||"return"===e;case 8:return"function"===e}return!1}function I(e){return qe===e.type?"#-~".indexOf(e.value)>=0:Ue===e.type&&"not"===e.value}function F(e){if(Re===e.type)return!0;if(Ue!==e.type)return!1;switch(e.value){case"else":case"elseif":case"end":case"until":return!0;default:return!1}}function q(){var e=ot[it++].slice();ot.push(e),Pe.onCreateScope&&Pe.onCreateScope()}function V(){ot.pop(),--it,Pe.onDestroyScope&&Pe.onDestroyScope()}function G(e){Pe.onLocalDeclaration&&Pe.onLocalDeclaration(e),-1===We(ot[it],e)&&ot[it].push(e)}function B(e){G(e.name),H(e,!0)}function H(e,t){!t&&-1===i(at,"name",e.name)&&at.push(e),e.isLocal=t}function z(e){return-1!==We(ot[it],e)}function K(){return new W(Xe)}function W(e){Pe.locations&&(this.loc={start:{line:e.line,column:e.range[0]-e.lineStart},end:{line:0,column:0}}),Pe.ranges&&(this.range=[e.range[0],0])}function J(){st&&ct.push(K())}function X(e){st&&ct.push(e)}function Q(){this.scopes=[],this.pendingGotos=[]}function Y(){this.level=0,this.loopLevels=[]}function Z(){return _e.labels?new Q:new Y}function ee(){M(),J(),Pe.scope&&q();var e=Z();e.allowVararg=!0,e.pushScope();var t=te(e);return e.popScope(),Pe.scope&&V(),Re!==Xe.type&&p(Xe),st&&!t.length&&(Qe=Xe),o(ze.chunk(t))}function te(e){for(var t,n=[];!F(Xe);){if("return"===Xe.value||!_e.relaxedBreak&&"break"===Xe.value){n.push(ne(e));break}t=ne(e),P(";"),t&&n.push(t)}return n}function ne(e){if(J(),qe===Xe.type&&P("::"))return re(e);if(!_e.emptyStatement||!P(";")){if(e.raiseDeferredErrors(),Ue===Xe.type)switch(Xe.value){case"local":return M(),fe(e);case"if":return M(),le(e);case"return":return M(),ue(e);case"function":return M(),me(ge());case"while":return M(),se(e);case"for":return M(),pe(e);case"repeat":return M(),ce(e);case"break":return M(),e.isInLoop()||c(Xe,He.noLoopToBreak,Xe.value),oe();case"do":return M(),ae(e);case"goto":return M(),ie(e)}return _e.contextualGoto&&Xe.type===Ie&&"goto"===Xe.value&&Ye.type===Ie&&"goto"!==Ye.value?(M(),ie(e)):(st&&ct.pop(),he(e))}st&&ct.pop()}function re(e){var t=Xe,n=de();return Pe.scope&&(G("::"+t.value+"::"),H(n,!0)),O("::"),e.addLabel(t.value,t),o(ze.labelStatement(n))}function oe(){return o(ze.breakStatement())}function ie(e){var t=Xe.value,n=Qe,r=de();return e.addGoto(t,n),o(ze.gotoStatement(r))}function ae(e){Pe.scope&&q(),e.pushScope();var t=te(e);return e.popScope(),Pe.scope&&V(),O("end"),o(ze.doStatement(t))}function se(e){var t=we(e);O("do"),Pe.scope&&q(),e.pushScope(!0);var n=te(e);return e.popScope(),Pe.scope&&V(),O("end"),o(ze.whileStatement(t,n))}function ce(e){Pe.scope&&q(),e.pushScope(!0);var t=te(e);O("until"),e.raiseDeferredErrors();var n=we(e);return e.popScope(),Pe.scope&&V(),o(ze.repeatStatement(n,t))}function ue(e){var t=[];if("end"!==Xe.value){var n=ye(e);for(null!=n&&t.push(n);P(",");)n=we(e),t.push(n);P(";")}return o(ze.returnStatement(t))}function le(e){var t,n,r,i=[];for(st&&(r=ct[ct.length-1],ct.push(r)),t=we(e),O("then"),Pe.scope&&q(),e.pushScope(),n=te(e),e.popScope(),Pe.scope&&V(),i.push(o(ze.ifClause(t,n))),st&&(r=K());P("elseif");)X(r),t=we(e),O("then"),Pe.scope&&q(),e.pushScope(),n=te(e),e.popScope(),Pe.scope&&V(),i.push(o(ze.elseifClause(t,n))),st&&(r=K());return P("else")&&(st&&(r=new W(Qe),ct.push(r)),Pe.scope&&q(),e.pushScope(),n=te(e),e.popScope(),Pe.scope&&V(),i.push(o(ze.elseClause(n)))),O("end"),o(ze.ifStatement(i))}function pe(e){var t,n=de();if(Pe.scope&&(q(),B(n)),P("=")){var r=we(e);O(",");var i=we(e),a=P(",")?we(e):null;return O("do"),e.pushScope(!0),t=te(e),e.popScope(),O("end"),Pe.scope&&V(),o(ze.forNumericStatement(n,r,i,a,t))}for(var s=[n];P(",");)n=de(),Pe.scope&&B(n),s.push(n);O("in");var c=[];do{var u=we(e);c.push(u)}while(P(","));return O("do"),e.pushScope(!0),t=te(e),e.popScope(),O("end"),Pe.scope&&V(),o(ze.forGenericStatement(s,c,t))}function fe(e){var t,n=Qe;if(Ie===Xe.type){var r=[],i=[];do{t=de(),r.push(t),e.addLocal(t.name,n)}while(P(","));if(P("="))do{var a=we(e);i.push(a)}while(P(","));if(Pe.scope)for(var s=0,c=r.length;s<c;++s)B(r[s]);return o(ze.localStatement(r,i))}if(P("function"))return t=de(),e.addLocal(t.name,n),Pe.scope&&(B(t),q()),me(t,!0);l("<name>",Xe)}function he(e){var t,n,r,i,a,s=[];for(st&&(n=K());;){if(st&&(t=K()),Ie===Xe.type)a=Xe.value,i=de(),Pe.scope&&H(i,z(a)),r=!0;else{if("("!==Xe.value)return p(Xe);M(),i=we(e),O(")"),r=!1}e:for(;;){switch(je===Xe.type?'"':Xe.value){case".":case"[":r=!0;break;case":":case"(":case"{":case'"':r=null;break;default:break e}i=Le(i,t,e)}if(s.push(i),","!==Xe.value)break;if(!r)return p(Xe);M()}if(1===s.length&&null===r)return X(t),o(ze.callStatement(s[0]));if(!r)return p(Xe);O("=");var c=[];do{c.push(we(e))}while(P(","));return X(n),o(ze.assignmentStatement(s,c))}function de(){J();var e=Xe.value;return Ie!==Xe.type&&l("<name>",Xe),M(),o(ze.identifier(e))}function me(e,t){var n=Z();n.pushScope();var r=[];if(O("("),!P(")"))for(;;){if(Ie===Xe.type){var i=de();if(Pe.scope&&B(i),r.push(i),P(","))continue}else Be===Xe.type?(n.allowVararg=!0,r.push(Ee(n))):l("<name> or '...'",Xe);O(")");break}var a=te(n);return n.popScope(),O("end"),Pe.scope&&V(),t=t||!1,o(ze.functionStatement(e,r,t,a))}function ge(){var e,t,n;for(st&&(n=K()),e=de(),Pe.scope&&(H(e,z(e.name)),q());P(".");)X(n),t=de(),e=o(ze.memberExpression(e,".",t));return P(":")&&(X(n),t=de(),e=o(ze.memberExpression(e,":",t)),Pe.scope&&G("self")),e}function ve(e){for(var t,n,r=[];;){if(J(),qe===Xe.type&&P("["))t=we(e),O("]"),O("="),n=we(e),r.push(o(ze.tableKey(t,n)));else if(Ie===Xe.type)"="===Ye.value?(t=de(),M(),n=we(e),r.push(o(ze.tableKeyString(t,n)))):(n=we(e),r.push(o(ze.tableValue(n))));else{if(null==(n=ye(e))){ct.pop();break}r.push(o(ze.tableValue(n)))}if(!(",;".indexOf(Xe.value)>=0))break;M()}return O("}"),o(ze.tableConstructorExpression(r))}function ye(e){return xe(0,e)}function we(e){var t=ye(e);if(null!=t)return t;l("<expression>",Xe)}function be(e){var t=e.charCodeAt(0),n=e.length;if(1===n)switch(t){case 94:return 12;case 42:case 47:case 37:return 10;case 43:case 45:return 9;case 38:return 6;case 126:return 5;case 124:return 4;case 60:case 62:return 3}else if(2===n)switch(t){case 47:return 10;case 46:return 8;case 60:case 62:return"<<"===e||">>"===e?7:3;case 61:case 126:return 3;case 111:return 1}else if(97===t&&"and"===e)return 2;return 0}function xe(e,t){var n,r,i,a=Xe.value;if(st&&(r=K()),I(Xe)){J(),M();var s=xe(10,t);null==s&&l("<expression>",Xe),n=o(ze.unaryExpression(a,s))}if(null==n&&null==(n=Ee(t))&&(n=Se(t)),null==n)return null;for(;a=Xe.value,!(0===(i=qe===Xe.type||Ue===Xe.type?be(a):0)||i<=e);){("^"===a||".."===a)&&--i,M();var c=xe(i,t);null==c&&l("<expression>",Xe),st&&ct.push(r),n=o(ze.binaryExpression(a,n,c))}return n}function Le(e,t,n){var r,i;if(qe===Xe.type)switch(Xe.value){case"[":return X(t),M(),r=we(n),O("]"),o(ze.indexExpression(e,r));case".":return X(t),M(),i=de(),o(ze.memberExpression(e,".",i));case":":return X(t),M(),i=de(),e=o(ze.memberExpression(e,":",i)),X(t),Ce(e,n);case"(":case"{":return X(t),Ce(e,n)}else if(je===Xe.type)return X(t),Ce(e,n);return null}function Se(e){var t,n,r;if(st&&(r=K()),Ie===Xe.type)n=Xe.value,t=de(),Pe.scope&&H(t,z(n));else{if(!P("("))return null;t=we(e),O(")")}for(;;){var o=Le(t,r,e);if(null===o)break;t=o}return t}function Ce(e,t){if(qe===Xe.type)switch(Xe.value){case"(":_e.emptyStatement||Xe.line!==Qe.line&&c(null,He.ambiguousSyntax,Xe.value),M();var n=[],r=ye(t);for(null!=r&&n.push(r);P(",");)r=we(t),n.push(r);return O(")"),o(ze.callExpression(e,n));case"{":J(),M();var i=ve(t);return o(ze.tableCallExpression(e,i))}else if(je===Xe.type)return o(ze.stringCallExpression(e,Ee(t)));l("function arguments",Xe)}function Ee(e){var t,n=je|Fe|Ve|Ge|Be,r=Xe.value,i=Xe.type;if(st&&(t=K()),i===Be&&!e.allowVararg&&c(Xe,He.cannotUseVararg,Xe.value),i&n){X(t);var a=Me.slice(Xe.range[0],Xe.range[1]);return M(),o(ze.literal(i,r,a))}return Ue===i&&"function"===r?(X(t),M(),Pe.scope&&q(),me(null)):P("{")?(X(t),ve(e)):void 0}function Ae(t,n){if(void 0===n&&"object"==typeof t&&(n=t,t=void 0),n||(n={}),Me=t||"",Pe=rt({},Ne,n),Je=0,tt=1,nt=0,Oe=Me.length,ot=[[]],it=0,at=[],ct=[],!Object.prototype.hasOwnProperty.call(ut,Pe.luaVersion))throw new Error(a("Lua version '%1' not supported",Pe.luaVersion));if(_e=rt({},ut[Pe.luaVersion]),void 0!==Pe.extendedIdentifiers&&(_e.extendedIdentifiers=!!Pe.extendedIdentifiers),!Object.prototype.hasOwnProperty.call(Te,Pe.encodingMode))throw new Error(a("Encoding mode '%1' not supported",Pe.encodingMode));return $e=Te[Pe.encodingMode],Pe.comments&&(Ze=[]),Pe.wait?e:De()}function ke(t){return Me+=String(t),Oe=Me.length,e}function De(e){void 0!==e&&ke(e),Me&&"#!"===Me.substr(0,2)&&(Me=Me.replace(/^.*/,(function(e){return e.replace(/./g," ")}))),Oe=Me.length,st=Pe.locations||Pe.ranges,Ye=f();var t=ee();if(Pe.comments&&(t.comments=Ze),Pe.scope&&(t.globals=at),ct.length>0)throw new Error("Location tracking failed. This is most likely a bug in luaparse");return t}e.version="0.3.1";var Me,Pe,Oe,_e,$e,Ne=e.defaultOptions={wait:!1,comments:!0,scope:!1,locations:!1,ranges:!1,onCreateNode:null,onCreateScope:null,onDestroyScope:null,onLocalDeclaration:null,luaVersion:"5.3",encodingMode:"none"},Te={"pseudo-latin1":{fixup:r(/[^\x00-\xff]/),encodeByte:function(e){return null===e?"":String.fromCharCode(e)},encodeUTF8:function(e){return t(e)}},"x-user-defined":{fixup:r(/[^\x00-\x7f\uf780-\uf7ff]/),encodeByte:function(e){return null===e?"":e>=128?String.fromCharCode(63232|e):String.fromCharCode(e)},encodeUTF8:function(e){return t(e,63232)}},none:{discardStrings:!0,fixup:function(e){return e},encodeByte:function(e){return""},encodeUTF8:function(e){return""}}},Re=1,je=2,Ue=4,Ie=8,Fe=16,qe=32,Ve=64,Ge=128,Be=256;e.tokenTypes={EOF:Re,StringLiteral:je,Keyword:Ue,Identifier:Ie,NumericLiteral:Fe,Punctuator:qe,BooleanLiteral:Ve,NilLiteral:Ge,VarargLiteral:Be};var He=e.errors={unexpected:"unexpected %1 '%2' near '%3'",unexpectedEOF:"unexpected symbol near '<eof>'",expected:"'%1' expected near '%2'",expectedToken:"%1 expected near '%2'",unfinishedString:"unfinished string near '%1'",malformedNumber:"malformed number near '%1'",decimalEscapeTooLarge:"decimal escape too large near '%1'",invalidEscape:"invalid escape sequence near '%1'",hexadecimalDigitExpected:"hexadecimal digit expected near '%1'",braceExpected:"missing '%1' near '%2'",tooLargeCodepoint:"UTF-8 value too large near '%1'",unfinishedLongString:"unfinished long string (starting at line %1) near '%2'",unfinishedLongComment:"unfinished long comment (starting at line %1) near '%2'",ambiguousSyntax:"ambiguous syntax (function call x new statement) near '%1'",noLoopToBreak:"no loop to break near '%1'",labelAlreadyDefined:"label '%1' already defined on line %2",labelNotVisible:"no visible label '%1' for <goto>",gotoJumpInLocalScope:"<goto %1> jumps into the scope of local '%2'",cannotUseVararg:"cannot use '...' outside a vararg function near '%1'",invalidCodeUnit:"code unit U+%1 is not allowed in the current encoding mode"},ze=e.ast={labelStatement:function(e){return{type:"LabelStatement",label:e}},breakStatement:function(){return{type:"BreakStatement"}},gotoStatement:function(e){return{type:"GotoStatement",label:e}},returnStatement:function(e){return{type:"ReturnStatement",arguments:e}},ifStatement:function(e){return{type:"IfStatement",clauses:e}},ifClause:function(e,t){return{type:"IfClause",condition:e,body:t}},elseifClause:function(e,t){return{type:"ElseifClause",condition:e,body:t}},elseClause:function(e){return{type:"ElseClause",body:e}},whileStatement:function(e,t){return{type:"WhileStatement",condition:e,body:t}},doStatement:function(e){return{type:"DoStatement",body:e}},repeatStatement:function(e,t){return{type:"RepeatStatement",condition:e,body:t}},localStatement:function(e,t){return{type:"LocalStatement",variables:e,init:t}},assignmentStatement:function(e,t){return{type:"AssignmentStatement",variables:e,init:t}},callStatement:function(e){return{type:"CallStatement",expression:e}},functionStatement:function(e,t,n,r){return{type:"FunctionDeclaration",identifier:e,isLocal:n,parameters:t,body:r}},forNumericStatement:function(e,t,n,r,o){return{type:"ForNumericStatement",variable:e,start:t,end:n,step:r,body:o}},forGenericStatement:function(e,t,n){return{type:"ForGenericStatement",variables:e,iterators:t,body:n}},chunk:function(e){return{type:"Chunk",body:e}},identifier:function(e){return{type:"Identifier",name:e}},literal:function(e,t,n){return{type:e=e===je?"StringLiteral":e===Fe?"NumericLiteral":e===Ve?"BooleanLiteral":e===Ge?"NilLiteral":"VarargLiteral",value:t,raw:n}},tableKey:function(e,t){return{type:"TableKey",key:e,value:t}},tableKeyString:function(e,t){return{type:"TableKeyString",key:e,value:t}},tableValue:function(e){return{type:"TableValue",value:e}},tableConstructorExpression:function(e){return{type:"TableConstructorExpression",fields:e}},binaryExpression:function(e,t,n){return{type:"and"===e||"or"===e?"LogicalExpression":"BinaryExpression",operator:e,left:t,right:n}},unaryExpression:function(e,t){return{type:"UnaryExpression",operator:e,argument:t}},memberExpression:function(e,t,n){return{type:"MemberExpression",indexer:t,identifier:n,base:e}},indexExpression:function(e,t){return{type:"IndexExpression",base:e,index:t}},callExpression:function(e,t){return{type:"CallExpression",base:e,arguments:t}},tableCallExpression:function(e,t){return{type:"TableCallExpression",base:e,arguments:t}},stringCallExpression:function(e,t){return{type:"StringCallExpression",base:e,argument:t}},comment:function(e,t){return{type:"Comment",value:e,raw:t}}},Ke=Array.prototype.slice,We=(Object.prototype.toString,function(e,t){for(var n=0,r=e.length;n<r;++n)if(e[n]===t)return n;return-1});Array.prototype.indexOf&&(We=function(e,t){return e.indexOf(t)});var Je,Xe,Qe,Ye,Ze,et,tt,nt,rt=function(e){for(var t,n,r=Ke.call(arguments,1),o=0,i=r.length;o<i;++o)for(n in t=r[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e};Object.assign&&(rt=Object.assign),e.SyntaxError=SyntaxError,e.lex=f;var ot,it,at,st,ct=[];W.prototype.complete=function(){Pe.locations&&(this.loc.end.line=Qe.lastLine||Qe.line,this.loc.end.column=Qe.range[1]-(Qe.lastLineStart||Qe.lineStart)),Pe.ranges&&(this.range[1]=Qe.range[1])},W.prototype.bless=function(e){if(this.loc){var t=this.loc;e.loc={start:{line:t.start.line,column:t.start.column},end:{line:t.end.line,column:t.end.column}}}this.range&&(e.range=[this.range[0],this.range[1]])},Q.prototype.isInLoop=function(){for(var e=this.scopes.length;e-- >0;)if(this.scopes[e].isLoop)return!0;return!1},Q.prototype.pushScope=function(e){var t={labels:{},locals:[],deferredGotos:[],isLoop:!!e};this.scopes.push(t)},Q.prototype.popScope=function(){for(var e=0;e<this.pendingGotos.length;++e){var t=this.pendingGotos[e];t.maxDepth>=this.scopes.length&&--t.maxDepth<=0&&c(t.token,He.labelNotVisible,t.target)}this.scopes.pop()},Q.prototype.addGoto=function(e,t){for(var n=[],r=0;r<this.scopes.length;++r){var o=this.scopes[r];if(n.push(o.locals.length),Object.prototype.hasOwnProperty.call(o.labels,e))return}this.pendingGotos.push({maxDepth:this.scopes.length,target:e,token:t,localCounts:n})},Q.prototype.addLabel=function(e,t){var n=this.currentScope();if(Object.prototype.hasOwnProperty.call(n.labels,e))c(t,He.labelAlreadyDefined,e,n.labels[e].line);else{for(var r=[],o=0;o<this.pendingGotos.length;++o){var i=this.pendingGotos[o];i.maxDepth>=this.scopes.length&&i.target===e?i.localCounts[this.scopes.length-1]<n.locals.length&&n.deferredGotos.push(i):r.push(i)}this.pendingGotos=r}n.labels[e]={localCount:n.locals.length,line:t.line}},Q.prototype.addLocal=function(e,t){this.currentScope().locals.push({name:e,token:t})},Q.prototype.currentScope=function(){return this.scopes[this.scopes.length-1]},Q.prototype.raiseDeferredErrors=function(){for(var e=this.currentScope(),t=e.deferredGotos,n=0;n<t.length;++n){var r=t[n];c(r.token,He.gotoJumpInLocalScope,r.target,e.locals[r.localCounts[this.scopes.length-1]].name)}},Y.prototype.isInLoop=function(){return!!this.loopLevels.length},Y.prototype.pushScope=function(e){++this.level,e&&this.loopLevels.push(this.level)},Y.prototype.popScope=function(){var e=this.loopLevels,t=e.length;t&&e[t-1]===this.level&&e.pop(),--this.level},Y.prototype.addGoto=Y.prototype.addLabel=function(){throw new Error("This should never happen")},Y.prototype.addLocal=Y.prototype.raiseDeferredErrors=function(){},e.parse=Ae;var ut={5.1:{},5.2:{labels:!0,emptyStatement:!0,hexEscapes:!0,skipWhitespaceEscape:!0,strictEscapes:!0,relaxedBreak:!0},5.3:{labels:!0,emptyStatement:!0,hexEscapes:!0,skipWhitespaceEscape:!0,strictEscapes:!0,unicodeEscapes:!0,bitwiseOperators:!0,integerDivision:!0,relaxedBreak:!0},LuaJIT:{labels:!0,contextualGoto:!0,hexEscapes:!0,skipWhitespaceEscape:!0,strictEscapes:!0,unicodeEscapes:!0,imaginaryNumbers:!0,integerSuffixes:!0}};e.write=ke,e.end=De}(t)})),ace.define("ace/mode/lua_worker",[],(function(e,t,n){"use strict";var r=e("../lib/oop"),o=e("../worker/mirror").Mirror,i=e("../mode/lua/luaparse"),a=t.Worker=function(e){o.call(this,e),this.setTimeout(500)};r.inherits(a,o),function(){this.onUpdate=function(){var e=this.doc.getValue(),t=[];try{i.parse(e)}catch(e){e instanceof i.SyntaxError&&t.push({row:e.line-1,column:e.column,text:e.message,type:"error"})}this.sender.emit("annotate",t)}}.call(a.prototype)}));