text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).rexcsvscenarioplugin=t()}(this,function(){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function e(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),e}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function u(n){return function(){var e,t=a(n);if(function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),1}catch(e){return}}}()){var i=a(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return o(this,e)}}var t={setEventEmitter:function(e,t){return void 0===t&&(t=Phaser.Events.EventEmitter),this._privateEE=void 0===e,this._eventEmitter=this._privateEE?new t:e,this},destroyEventEmitter:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(e){return this._eventEmitter&&e&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]}},h=function(e,t,i){if(e&&"number"!=typeof e){if(e.hasOwnProperty(t))return e[t];if(-1===t.indexOf("."))return i;for(var n=t.split("."),r=e,s=i,a=0;a<n.length;a++){if(!r.hasOwnProperty(n[a])){s=i;break}s=r[n[a]],r=r[n[a]]}return s}return i};function l(e){if(Array.isArray(e))e.length=0;else for(var t in e)delete e[t]}function c(e,t){var i=Array.isArray(e);if(void 0===t?t=i?[]:{}:l(t),i){t.length=e.length;for(var n=0,r=e.length;n<r;n++)t[n]=e[n]}else for(var s in e)t[s]=e[s];return t}function f(e){return"string"!=typeof e||(""===e?e=null:_.test(e)?e=parseFloat(e):"false"===screen?e=!1:"true"===e&&(e=!0)),e}function d(e,t,i){var n,r,s=k(i,"reverse",!1);if(r=e[0],"[object Array]"===Object.prototype.toString.call(r))if(s)for(a=(o=e.length)-1;0<=a;a--)n=d(e[a],t,i);else for(var a=0,o=e.length;a<o;a++)n=d(e[a],t,i);else n=b(e,t,i);return n}var p,v=(function(e){Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),e.exports=function(){var s,e,l="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==l?l:{},r=!l.document&&!!l.postMessage,o=r&&/(\?|&)papaworker(=|&|$)/.test(l.location.search),a=!1,u={},h=0,k={parse:function(e,t){var i=(t=t||{}).dynamicTyping||!1;M(i)&&(t.dynamicTypingFunction=i,i={});if(t.dynamicTyping=i,t.transform=!!M(t.transform)&&t.transform,t.worker&&k.WORKERS_SUPPORTED){var n=function(){if(!k.WORKERS_SUPPORTED)return!1;if(!a&&null===k.SCRIPT_PATH)throw new Error("Script path cannot be determined automatically when Papa Parse is loaded asynchronously. You need to set Papa.SCRIPT_PATH manually.");var e=k.SCRIPT_PATH||s;e+=(-1!==e.indexOf("?")?"&":"?")+"papaworker";var t=new l.Worker(e);return t.onmessage=g,t.id=h++,u[t.id]=t}();return n.userStep=t.step,n.userChunk=t.chunk,n.userComplete=t.complete,n.userError=t.error,t.step=M(t.step),t.chunk=M(t.chunk),t.complete=M(t.complete),t.error=M(t.error),delete t.worker,void n.postMessage({input:e,config:t,workerId:n.id})}var r=null;"string"==typeof e?r=t.download?new d(t):new v(t):!0===e.readable&&M(e.read)&&M(e.on)?r=new m(t):(l.File&&e instanceof File||e instanceof Object)&&(r=new p(t));return r.stream(e)},unparse:function(e,t){var n=!1,m=!0,g=",",y="\r\n",r='"',i=!1;!function(){if("object"!=typeof t)return;"string"!=typeof t.delimiter||k.BAD_DELIMITERS.filter(function(e){return-1!==t.delimiter.indexOf(e)}).length||(g=t.delimiter);("boolean"==typeof t.quotes||Array.isArray(t.quotes))&&(n=t.quotes);"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(i=t.skipEmptyLines);"string"==typeof t.newline&&(y=t.newline);"string"==typeof t.quoteChar&&(r=t.quoteChar);"boolean"==typeof t.header&&(m=t.header)}();var s=new RegExp(F(r),"g");"string"==typeof e&&(e=JSON.parse(e));if(Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return o(null,e,i);if("object"==typeof e[0])return o(a(e[0]),e,i)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:a(e.data[0])),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),o(e.fields||[],e.data||[],i);throw"exception: Unable to serialize unrecognized input";function a(e){if("object"!=typeof e)return[];var t=[];for(var i in e)t.push(i);return t}function o(e,t,i){var n="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var r=Array.isArray(e)&&0<e.length,s=!Array.isArray(t[0]);if(r&&m){for(var a=0;a<e.length;a++)0<a&&(n+=g),n+=_(e[a],a);0<t.length&&(n+=y)}for(var o=0;o<t.length;o++){var u=r?e.length:t[o].length,h=!1,l=r?0===Object.keys(t[o]).length:0===t[o].length;if(i&&!r&&(h="greedy"===i?""===t[o].join("").trim():1===t[o].length&&0===t[o][0].length),"greedy"===i&&r){for(var c=[],f=0;f<u;f++){var d=s?e[f]:f;c.push(t[o][d])}h=""===c.join("").trim()}if(!h){for(var p=0;p<u;p++){0<p&&!l&&(n+=g);var v=r&&s?e[p]:p;n+=_(t[o][v],p)}o<t.length-1&&(!i||0<u&&!l)&&(n+=y)}}return n}function _(e,t){if(null==e)return"";if(e.constructor===Date)return JSON.stringify(e).slice(1,25);e=e.toString().replace(s,r+r);var i="boolean"==typeof n&&n||Array.isArray(n)&&n[t]||function(e,t){for(var i=0;i<t.length;i++)if(-1<e.indexOf(t[i]))return!0;return!1}(e,k.BAD_DELIMITERS)||-1<e.indexOf(g)||" "===e.charAt(0)||" "===e.charAt(e.length-1);return i?r+e+r:e}}};if(k.RECORD_SEP=String.fromCharCode(30),k.UNIT_SEP=String.fromCharCode(31),k.BYTE_ORDER_MARK="\ufeff",k.BAD_DELIMITERS=["\r","\n",'"',k.BYTE_ORDER_MARK],k.WORKERS_SUPPORTED=!r&&!!l.Worker,k.SCRIPT_PATH=null,k.NODE_STREAM_INPUT=1,k.LocalChunkSize=10485760,k.RemoteChunkSize=5242880,k.DefaultDelimiter=",",k.Parser=_,k.ParserHandle=i,k.NetworkStreamer=d,k.FileStreamer=p,k.StringStreamer=v,k.ReadableStreamStreamer=m,l.jQuery){var c=l.jQuery;c.fn.parse=function(o){var i=o.config||{},u=[];return this.each(function(e){if(!("INPUT"===c(this).prop("tagName").toUpperCase()&&"file"===c(this).attr("type").toLowerCase()&&l.FileReader)||!this.files||0===this.files.length)return!0;for(var t=0;t<this.files.length;t++)u.push({file:this.files[t],inputElem:this,instanceConfig:c.extend({},i)})}),e(),this;function e(){if(0!==u.length){var e,t,i,n,r=u[0];if(M(o.before)){var s=o.before(r.file,r.inputElem);if("object"==typeof s){if("abort"===s.action)return e="AbortError",t=r.file,i=r.inputElem,n=s.reason,void(M(o.error)&&o.error({name:e},t,i,n));if("skip"===s.action)return void h();"object"==typeof s.config&&(r.instanceConfig=c.extend(r.instanceConfig,s.config))}else if("skip"===s)return void h()}var a=r.instanceConfig.complete;r.instanceConfig.complete=function(e){M(a)&&a(e,r.file,r.inputElem),h()},k.parse(r.file,r.instanceConfig)}else M(o.complete)&&o.complete()}function h(){u.splice(0,1),e()}}}function f(e){this._handle=null,this._finished=!1,this._completed=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(e){var t=E(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null);this._handle=new i(t),(this._handle.streamer=this)._config=t}.call(this,e),this.parseChunk=function(e,t){if(this.isFirstChunk&&M(this._config.beforeFirstChunk)){var i=this._config.beforeFirstChunk(e);void 0!==i&&(e=i)}this.isFirstChunk=!1;var n=this._partialLine+e;this._partialLine="";var r=this._handle.parse(n,this._baseIndex,!this._finished);if(!this._handle.paused()&&!this._handle.aborted()){var s=r.meta.cursor;this._finished||(this._partialLine=n.substring(s-this._baseIndex),this._baseIndex=s),r&&r.data&&(this._rowCount+=r.data.length);var a=this._finished||this._config.preview&&this._rowCount>=this._config.preview;if(o)l.postMessage({results:r,workerId:k.WORKER_ID,finished:a});else if(M(this._config.chunk)&&!t){if(this._config.chunk(r,this._handle),this._handle.paused()||this._handle.aborted())return;r=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(r.data),this._completeResults.errors=this._completeResults.errors.concat(r.errors),this._completeResults.meta=r.meta),this._completed||!a||!M(this._config.complete)||r&&r.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),a||r&&r.meta.paused||this._nextChunk(),r}},this._sendError=function(e){M(this._config.error)?this._config.error(e):o&&this._config.error&&l.postMessage({workerId:k.WORKER_ID,error:e,finished:!1})}}function d(e){var n;(e=e||{}).chunkSize||(e.chunkSize=k.RemoteChunkSize),f.call(this,e),this._nextChunk=r?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(n=new XMLHttpRequest,this._config.withCredentials&&(n.withCredentials=this._config.withCredentials),r||(n.onload=w(this._chunkLoaded,this),n.onerror=w(this._chunkError,this)),n.open("GET",this._input,!r),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var t in e)n.setRequestHeader(t,e[t])}if(this._config.chunkSize){var i=this._start+this._config.chunkSize-1;n.setRequestHeader("Range","bytes="+this._start+"-"+i),n.setRequestHeader("If-None-Match","webkit-no-cache")}try{n.send()}catch(e){this._chunkError(e.message)}r&&0===n.status?this._chunkError():this._start+=this._config.chunkSize}},this._chunkLoaded=function(){4===n.readyState&&(n.status<200||400<=n.status?this._chunkError():(this._finished=!this._config.chunkSize||this._start>function(e){var t=e.getResponseHeader("Content-Range");if(null===t)return-1;return parseInt(t.substr(t.lastIndexOf("/")+1))}(n),this.parseChunk(n.responseText)))},this._chunkError=function(e){var t=n.statusText||e;this._sendError(new Error(t))}}function p(e){var n,r;(e=e||{}).chunkSize||(e.chunkSize=k.LocalChunkSize),f.call(this,e);var s="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,r=e.slice||e.webkitSlice||e.mozSlice,s?((n=new FileReader).onload=w(this._chunkLoaded,this),n.onerror=w(this._chunkError,this)):n=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var e=this._input;if(this._config.chunkSize){var t=Math.min(this._start+this._config.chunkSize,this._input.size);e=r.call(e,this._start,t)}var i=n.readAsText(e,this._config.encoding);s||this._chunkLoaded({target:{result:i}})},this._chunkLoaded=function(e){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(n.error)}}function v(e){var i;f.call(this,e=e||{}),this.stream=function(e){return i=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e=this._config.chunkSize,t=e?i.substr(0,e):i;return i=e?i.substr(e):"",this._finished=!i,this.parseChunk(t)}}}function m(e){f.call(this,e=e||{});var t=[],i=!0,n=!1;this.pause=function(){f.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){f.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){n&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):i=!0},this._streamData=w(function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),i&&(i=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}},this),this._streamError=w(function(e){this._streamCleanUp(),this._sendError(e)},this),this._streamEnd=w(function(){this._streamCleanUp(),n=!0,this._streamData("")},this),this._streamCleanUp=w(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function i(m){var a,o,u,n=/^\s*-?(\d*\.?\d+|\d+\.?\d*)(e[-+]?\d+)?\s*$/i,r=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,t=this,i=0,s=0,h=!1,e=!1,l=[],c={data:[],errors:[],meta:{}};if(M(m.step)){var f=m.step;m.step=function(e){if(c=e,p())d();else{if(d(),0===c.data.length)return;i+=e.data.length,m.preview&&i>m.preview?o.abort():f(c,t)}}}function g(e){return"greedy"===m.skipEmptyLines?""===e.join("").trim():1===e.length&&0===e[0].length}function d(){if(c&&u&&(y("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+k.DefaultDelimiter+"'"),u=!1),m.skipEmptyLines)for(var e=0;e<c.data.length;e++)g(c.data[e])&&c.data.splice(e--,1);return p()&&function(){if(!c)return;for(var e=0;p()&&e<c.data.length;e++)for(var t=0;t<c.data[e].length;t++){var i=c.data[e][t];m.trimHeaders&&(i=i.trim()),l.push(i)}c.data.splice(0,1)}(),function(){if(!c||!m.header&&!m.dynamicTyping&&!m.transform)return c;for(var e=0;e<c.data.length;e++){var t,i=m.header?{}:[];for(t=0;t<c.data[e].length;t++){var n=t,r=c.data[e][t];m.header&&(n=t>=l.length?"__parsed_extra":l[t]),m.transform&&(r=m.transform(r,n)),r=v(n,r),"__parsed_extra"===n?(i[n]=i[n]||[],i[n].push(r)):i[n]=r}c.data[e]=i,m.header&&(t>l.length?y("FieldMismatch","TooManyFields","Too many fields: expected "+l.length+" fields but parsed "+t,s+e):t<l.length&&y("FieldMismatch","TooFewFields","Too few fields: expected "+l.length+" fields but parsed "+t,s+e))}m.header&&c.meta&&(c.meta.fields=l);return s+=c.data.length,c}()}function p(){return m.header&&0===l.length}function v(e,t){return i=e,m.dynamicTypingFunction&&void 0===m.dynamicTyping[i]&&(m.dynamicTyping[i]=m.dynamicTypingFunction(i)),!0===(m.dynamicTyping[i]||m.dynamicTyping)?"true"===t||"TRUE"===t||"false"!==t&&"FALSE"!==t&&(n.test(t)?parseFloat(t):r.test(t)?new Date(t):""===t?null:t):t;var i}function y(e,t,i,n){c.errors.push({type:e,code:t,message:i,row:n})}this.parse=function(e,t,i){var n=m.quoteChar||'"';if(m.newline||(m.newline=function(e,t){e=e.substr(0,1048576);var i=new RegExp(F(t)+"([^]*?)"+F(t),"gm"),n=(e=e.replace(i,"")).split("\r"),r=e.split("\n"),s=1<r.length&&r[0].length<n[0].length;if(1===n.length||s)return"\n";for(var a=0,o=0;o<n.length;o++)"\n"===n[o][0]&&a++;return a>=n.length/2?"\r\n":"\r"}(e,n)),u=!1,m.delimiter)M(m.delimiter)&&(m.delimiter=m.delimiter(e),c.meta.delimiter=m.delimiter);else{var r=function(e,t,i,n){for(var r,s,a,o=[",","\t","|",";",k.RECORD_SEP,k.UNIT_SEP],u=0;u<o.length;u++){var h=o[u],l=0,c=0,f=0;a=void 0;for(var d=new _({comments:n,delimiter:h,newline:t,preview:10}).parse(e),p=0;p<d.data.length;p++)if(i&&g(d.data[p]))f++;else{var v=d.data[p].length;c+=v,void 0!==a?1<v&&(l+=Math.abs(v-a),a=v):a=0}0<d.data.length&&(c/=d.data.length-f),(void 0===s||s<l)&&1.99<c&&(s=l,r=h)}return{successful:!!(m.delimiter=r),bestDelimiter:r}}(e,m.newline,m.skipEmptyLines,m.comments);r.successful?m.delimiter=r.bestDelimiter:(u=!0,m.delimiter=k.DefaultDelimiter),c.meta.delimiter=m.delimiter}var s=E(m);return m.preview&&m.header&&s.preview++,a=e,o=new _(s),c=o.parse(a,t,i),d(),h?{meta:{paused:!0}}:c||{meta:{paused:!1}}},this.paused=function(){return h},this.pause=function(){h=!0,o.abort(),a=a.substr(o.getCharIndex())},this.resume=function(){h=!1,t.streamer.parseChunk(a,!0)},this.aborted=function(){return e},this.abort=function(){e=!0,o.abort(),c.meta.aborted=!0,M(m.complete)&&m.complete(c),a=""}}function F(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _(e){var S,O=(e=e||{}).delimiter,R=e.newline,L=e.comments,I=e.step,P=e.preview,T=e.fastMode,A=S=void 0===e.quoteChar?'"':e.quoteChar;if(void 0!==e.escapeChar&&(A=e.escapeChar),("string"!=typeof O||-1<k.BAD_DELIMITERS.indexOf(O))&&(O=","),L===O)throw"Comment character same as delimiter";!0===L?L="#":("string"!=typeof L||-1<k.BAD_DELIMITERS.indexOf(L))&&(L=!1),"\n"!==R&&"\r"!==R&&"\r\n"!==R&&(R="\n");var D=0,N=!1;this.parse=function(n,t,i){if("string"!=typeof n)throw"Input must be a string";var r=n.length,e=O.length,s=R.length,a=L.length,o=M(I),u=[],h=[],l=[],c=D=0;if(!n)return C();if(T||!1!==T&&-1===n.indexOf(S)){for(var f=n.split(R),d=0;d<f.length;d++){if(l=f[d],D+=l.length,d!==f.length-1)D+=R.length;else if(i)return C();if(!L||l.substr(0,a)!==L){if(o){if(u=[],k(l.split(O)),x(),N)return C()}else k(l.split(O));if(P&&P<=d)return u=u.slice(0,P),C(!0)}}return C()}for(var p,v=n.indexOf(O,D),m=n.indexOf(R,D),g=new RegExp(F(A)+F(S),"g");;)if(n[D]!==S)if(L&&0===l.length&&n.substr(D,a)===L){if(-1===m)return C();D=m+s,m=n.indexOf(R,D),v=n.indexOf(O,D)}else if(-1!==v&&(v<m||-1===m))l.push(n.substring(D,v)),D=v+e,v=n.indexOf(O,D);else{if(-1===m)break;if(l.push(n.substring(D,m)),w(m+s),o&&(x(),N))return C();if(P&&u.length>=P)return C(!0)}else for(p=D,D++;;){if(-1===(p=n.indexOf(S,p+1)))return i||h.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:u.length,index:D}),E();if(p===r-1)return E(n.substring(D,p).replace(g,S));if(S!==A||n[p+1]!==A){if(S===A||0===p||n[p-1]!==A){var y=b(-1===m?v:Math.min(v,m));if(n[p+1+y]===O){l.push(n.substring(D,p).replace(g,S)),D=p+1+y+e,v=n.indexOf(O,D),m=n.indexOf(R,D);break}var _=b(m);if(n.substr(p+1+_,s)===R){if(l.push(n.substring(D,p).replace(g,S)),w(p+1+_+s),v=n.indexOf(O,D),o&&(x(),N))return C();if(P&&u.length>=P)return C(!0);break}h.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:u.length,index:D}),p++}}else p++}return E();function k(e){u.push(e),c=D}function b(e){var t=0;if(-1!==e){var i=n.substring(p+1,e);i&&""===i.trim()&&(t=i.length)}return t}function E(e){return i||(void 0===e&&(e=n.substr(D)),l.push(e),D=r,k(l),o&&x()),C()}function w(e){D=e,k(l),l=[],m=n.indexOf(R,D)}function C(e){return{data:u,errors:h,meta:{delimiter:O,linebreak:R,aborted:N,truncated:!!e,cursor:c+(t||0)}}}function x(){I(C()),u=[],h=[]}},this.abort=function(){N=!0},this.getCharIndex=function(){return D}}function g(e){var t=e.data,i=u[t.workerId],n=!1;if(t.error)i.userError(t.error,t.file);else if(t.results&&t.results.data){var r={abort:function(){n=!0,y(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:b,resume:b};if(M(i.userStep)){for(var s=0;s<t.results.data.length&&(i.userStep({data:[t.results.data[s]],errors:t.results.errors,meta:t.results.meta},r),!n);s++);delete t.results}else M(i.userChunk)&&(i.userChunk(t.results,r,t.file),delete t.results)}t.finished&&!n&&y(t.workerId,t.results)}function y(e,t){var i=u[e];M(i.userComplete)&&i.userComplete(t),i.terminate(),delete u[e]}function b(){throw"Not implemented."}function E(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e)t[i]=E(e[i]);return t}function w(e,t){return function(){e.apply(t,arguments)}}function M(e){return"function"==typeof e}return o?l.onmessage=function(e){var t=e.data;void 0===k.WORKER_ID&&t&&(k.WORKER_ID=t.workerId);if("string"==typeof t.input)l.postMessage({workerId:k.WORKER_ID,results:k.parse(t.input,t.config),finished:!0});else if(l.File&&t.input instanceof File||t.input instanceof Object){var i=k.parse(t.input,t.config);i&&l.postMessage({workerId:k.WORKER_ID,results:i,finished:!0})}}:k.WORKERS_SUPPORTED&&(e=document.getElementsByTagName("script"),s=e.length?e[e.length-1].src:"",document.body?document.addEventListener("DOMContentLoaded",function(){a=!0},!0):a=!0),(d.prototype=Object.create(f.prototype)).constructor=d,(p.prototype=Object.create(f.prototype)).constructor=p,(v.prototype=Object.create(v.prototype)).constructor=v,(m.prototype=Object.create(f.prototype)).constructor=m,k}()}(p={exports:{}}),p.exports),m=Phaser.Utils.Objects.GetValue,g=function(){function t(e){r(this,t),this.scenario=e,this.queue=[],this.currentIdx=-1,this.nextIdx=0}return e(t,[{key:"resetFromJSON",value:function(e){var t=m(e,"queue",void 0);return void 0===t?l(this.queue):c(t,this.queue),this.currentIdx=m(e,"curIdx",-1),this.nextIdx=m(e,"nextIdx",0),this}},{key:"clear",value:function(){return this.currentIdx=-1,this.nextIdx=0,this.queue.length=0,this}},{key:"append",value:function(e){return this.queue.push(e),this}},{key:"setNextIndex",value:function(e){return void 0===e&&(e=this.currentIdx+1),this.nextIdx=e,this}},{key:"get",value:function(e){return void 0===e&&(e=this.nextIdx),this.currentIdx=e,this.queue[e]}},{key:"length",get:function(){return this.queue.length}}]),t}(),y=function(){function i(e,t){r(this,i),this.scenario=e,this.type=t}return e(i,[{key:"resetFromJSON",value:function(){}},{key:"toJSON",value:function(){return{}}},{key:"parse",value:function(e){return e}},{key:"run",value:function(){}}]),i}(),_=/^\s*-?(\d*\.?\d+|\d+\.?\d*)(e[-+]?\d+)?\s*$/i,k=Phaser.Utils.Objects.GetValue,b=function(e,t,i){var n,r=k(i,"argsConvert",void 0),s=k(i,"argsConvertScope",void 0),a=e[0];if(E=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=t.length),e.length=n-i;for(var r=0,s=e.length;r<s;r++)e[r]=t[r+i];return e}(E,e,1),r){!0===r&&(r=f,s=void 0);for(var o=0,u=E.length;o<u;o++)E[o]=s?r.call(s,E[o],e):r(E[o],e)}return"string"==typeof a?null==(n=t[a])&&(n=k(t,a,null)):n=a,n.apply(t,E)},E=[],w=Phaser.Utils.Array.SpliceOne,C=function(){s(n,y);var i=u(n);function n(e){var t;return r(this,n),(t=i.call(this,e,"-")).task=void 0,t}return e(n,[{key:"resetFromJSON",value:function(){this.task&&(this.task.off("complete",this.resume,this),this.task=void 0)}},{key:"parse",value:function(e){var t=w(e,0),i=this.scenario,n=i.argsConvert,r=i.argsConvertScope;if(n){!0===n&&(n=f,r=void 0);for(var s=1,a=e.length;s<a;s++)e[s]=r?n.call(r,e[s],e):n(e[s],e)}return e=[t,e]}},{key:"run",value:function(e){var t=this.scenario,i=d(e[1],t.scope);i&&"function"==typeof i.once?(i.once("complete",this.resume,this),this.pause(),this.task=i):this.task=void 0}},{key:"pause",value:function(){this.scenario.pause()}},{key:"resume",value:function(){this.task=void 0;var e=this.scenario;e.resume(),e.runNextCmd()}}]),n}(),x=function(){s(i,y);var t=u(i);function i(e){return r(this,i),t.call(this,e,"wait")}return e(i,[{key:"parse",value:function(e){e.length=2;var t=this.getEventName(e);return isNaN(t)||(e[1]=parseFloat(t)),e}},{key:"run",value:function(e){var t=this.getEventName(e);"number"==typeof t?this.waitTime(t):this.waitEvent(t)}},{key:"waitTime",value:function(e){e>this.scenario.offset?(e-=this.scenario.offset,this.scenario.offset=0,this.scenario.isDebugMode&&this.scenario.log("#WAIT: "+e),this.scenario.wait(e)):this.scenario.offset-=e}},{key:"waitEvent",value:function(e){this.scenario.isDebugMode&&this.scenario.log("#WAIT: "+e),this.scenario.wait(e)}},{key:"getEventName",value:function(e){var t=e[1];return null==t&&(t="",e[1]=t),t}}]),i}(),S=Phaser.Utils.Objects.GetValue,O=function(){s(n,y);var i=u(n);function n(e){var t;return r(this,n),(t=i.call(this,e,"label")).labels={},t.prevLabel="",t.lastLabel="",t}return e(n,[{key:"resetFromJSON",value:function(e){this.prevLabel=S(e,"preLabel",""),this.lastLabel=S(e,"lastLabel","");var t=S(e,"labels",void 0);void 0===t?l(this.labels):c(t,this.labels)}},{key:"toJSON",value:function(){return{preLabel:this.prevLabel,lastLabel:this.lastLabel,labels:this.labels}}},{key:"parse",value:function(e,t){e.length=2;var i=this.getLabel(e);return this.addLabel(i,t),e}},{key:"run",value:function(e){var t=this.getLabel(e);this.scenario.isDebugMode&&this.scenario.log("#LABEL: "+t),this.prevLabel=this.lastLabel,this.lastLabel=t;var i=this.scenario;i.emit("labelchange",this.lastLabel,this.prevLabel,i)}},{key:"getLabel",value:function(e){var t=e[1];return null==t&&(t="",e[1]=t),t}},{key:"addLabel",value:function(e,t){this.labels[e]=t}},{key:"getIndex",value:function(e){return""!==e&&this.hasLabel(e)?this.labels[e]:0}},{key:"hasLabel",value:function(e){return this.labels.hasOwnProperty(e)}}]),n}(),R=function(){s(i,y);var t=u(i);function i(e){return r(this,i),t.call(this,e,"exit")}return e(i,[{key:"parse",value:function(e){return e.length=1,e}},{key:"run",value:function(){this.scenario.log("#EXIT"),this.scenario.complete()}}]),i}(),L=function(){s(i,y);var t=u(i);function i(e){return r(this,i),t.call(this,e,"goto")}return e(i,[{key:"parse",value:function(e){return e.length=2,e}},{key:"run",value:function(e){var t=this.getLabel(e);this.scenario.isDebugMode&&this.scenario.log("#GOTO label: "+t),this.scenario.goto(t)}},{key:"getLabel",value:function(e){var t=e[1];return null==t&&(t="",e[1]=t),t}}]),i}(),I=function(){s(i,y);var t=u(i);function i(e){return r(this,i),t.call(this,e,"if")}return e(i,[{key:"parse",value:function(e){e.length=4;var t="("+this.getCond(e)+")";return e[1]=new Function("return "+t),e}},{key:"run",value:function(e){var t=this.getCond(e).call(this.scenario.scope),i=t?this.getTrueLabel(e):this.getFalseLabel(e);""!==i&&(this.scenario.isDebugMode&&this.scenario.log("#IF "+t+"- GOTO label: "+i),this.scenario.goto(i))}},{key:"getCond",value:function(e){var t=e[1];return null!=t&&""!==t||(t="true",e[1]=t),t}},{key:"getTrueLabel",value:function(e){var t=e[2];return null==t&&(t="",e[2]=t),t}},{key:"getFalseLabel",value:function(e){var t=e[3];return null==t&&(t="",e[3]=t),t}}]),i}(),P=Phaser.Utils.Objects.GetValue,T=function(){function t(e){r(this,t),this.cmds={"-":new C(e),wait:new x(e),label:new O(e),exit:new R(e),goto:new L(e),if:new I(e)}}return e(t,[{key:"resetFromJSON",value:function(e){for(var t in this.cmds)this.cmds[t].resetFromJSON(P(e,t,void 0));return this}},{key:"toJSON",value:function(){var e={};for(var t in this.cmds)e[t]=this.cmds[t].toJSON();return e}},{key:"get",value:function(e){return this.cmds[e]}},{key:"isValidCmdName",value:function(e){return this.cmds.hasOwnProperty(e)}}]),t}(),A=function(){function i(e,t){r(this,i),this.setEventEmitter(h(t,"eventEmitter",void 0)),this.scene=e,this.timer=void 0,this.instMem=new g(this),this.cmdHandlers=new T(this),this.resetFromJSON(t),this.boot()}return e(i,[{key:"resetFromJSON",value:function(e){return this._inRunCmdLoop=!1,this.isRunning=h(e,"state",!1),this.isPaused=h(e,"pause",!1),this.waitEvent=h(e,"wait",void 0),this.scope=h(e,"scope",void 0),this.timeUnit=h(e,"timeUnit",0),this.cmdPrefix=h(e,"prefix",N),this.argsConvert=h(e,"argsConvert",!0),this.argsConvertScope=h(e,"argsConvertScope",void 0),this.cmdHandlers.resetFromJSON(h(e,"handlers",void 0)),this.instMem.resetFromJSON(h(e,"instMem",void 0)),this}},{key:"toJSON",value:function(){return{state:this.isRunning,pause:this.isPaused,wait:this.waitEvent,scope:this.scope,timeUnit:this.timeUnit,prefix:this.cmdPrefix,argsConvert:this.argsConvert,argsConvertScope:this.argsConvertScope,handlers:this.cmdHandlers.toJSON(),instMem:this.instMem.toJSON()}}},{key:"boot",value:function(){this.scene.events.once("shutdown",this.destroy,this)}},{key:"shutdown",value:function(){this.destroyEventEmitter(),this.clear(),this.scene=void 0}},{key:"destroy",value:function(){this.shutdown()}},{key:"load",value:function(e,t,i){return this.clear(),this.timeUnit=h(i,"timeUnit",this.timeUnit),"string"==typeof this.timeUnit&&(this.timeUnit=D[this.timeUnit]),this.cmdPrefix=h(i,"prefix",this.cmdPrefix),"string"==typeof this.cmdPrefix&&(this.cmdPrefix=new RegExp(this.cmdPrefix)),this.argsConvert=h(i,"argsConvert",this.argsConvert),this.argsConvertScope=h(i,"argsConvertScope",this.argsConvertScope),this.scope=t,this.append(e),this}},{key:"clear",value:function(){this.stop(),this.instMem.resetFromJSON(),this.cmdHandlers.resetFromJSON()}},{key:"start",value:function(e){this.stop();var t=h(e,"label","");return this.offset=h(e,"offset",0),this.isDebugMode&&this.log("Start at Label: "+t),!!this.goto(t)&&(this.isRunning=!0,this.runNextCmd(),!0)}},{key:"getIndex",value:function(e){var t=this.getCmdHandler("label").getIndex(e);return null==t&&this.error("Label: "+e+" is not found"),t}},{key:"goto",value:function(e){var t;return null!=(t="string"==typeof e?this.getIndex(e):e)&&(this.instMem.setNextIndex(t),!0)}},{key:"wait",value:function(e){if("number"==typeof(this.waitEvent=e)){var t=e;1===this.timeUnit&&(t*=1e3),this.timer=this.scene.time.delayedCall(t,this.continue,[e],this)}return this}},{key:"stop",value:function(){return this.isRunning&&(this.isRunning=!1,this.isPaused=!1,this.waitEvent=void 0,this.timer&&(this.timer.remove(),this.timer=void 0)),this}},{key:"complete",value:function(){return this.emit("complete",this),this.stop(),this}},{key:"append",value:function(e,t){void 0===t&&(t=",");var i=v.parse(e,{delimiter:t}).data;return this.parse(i),this}},{key:"pause",value:function(){return this.isRunning&&(this.isPaused||(this.isPaused=!0,this.timer&&(this.timer.paused=!0))),this}},{key:"resume",value:function(){return this.isRunning&&this.isPaused&&(this.isPaused=!1,this.timer&&(this.timer.paused=!1)),this}},{key:"continue",value:function(e){return!this.isRunning||this.isPaused||void 0===this.waitEvent||e===this.waitEvent&&(this.timer=void 0,this.waitEvent=void 0,this.runNextCmd()),this}},{key:"getCmdHandler",value:function(e){return"string"!=typeof e&&(e=e[0]),this.cmdHandlers.get(e)}},{key:"parse",value:function(e){for(var t,i,n=this.cmdPrefix,r=0,s=e.length;r<s;r++)if("-"===(i=(t=e[r])[0]))this.appendCommand(t);else if(isNaN(i))if(n.test(i)){var a=i.match(n);t[0]=a[1].toLowerCase(),this.appendCommand(t)||this.error("Line "+r+": "+JSON.stringify(t)+" is not a valid command")}else this.appendCommand(["wait",i]),t[0]="-",this.appendCommand(t);else{var o=parseFloat(i);0<o&&this.appendCommand(["wait",o]),t[0]="-",this.appendCommand(t)}return this}},{key:"appendCommand",value:function(e){var t=this.getCmdHandler(e);return null!=t&&((e=t.parse(e,this.instMem.length))&&this.instMem.append(e),!0)}},{key:"runNextCmd",value:function(){if(!this._inRunCmdLoop){this.threadId;var e,t=this.instMem;for(this._inRunCmdLoop=!0;this.isRunning&&!this.isPaused&&void 0===this.waitEvent;){if(e=t.get(),t.setNextIndex(),null==e){this.complete();break}this.getCmdHandler(e).run(e)}return this._inRunCmdLoop=!1,this}}},{key:"log",value:function(e){return this.emit("log",e,this),this}},{key:"error",value:function(e){return this.emit("error",e,this),this}},{key:"lastLabel",get:function(){return this.cmdHandlers.labelCmd.lastLabel}},{key:"previousLabel",get:function(){return this.cmdHandlers.labelCmd.preLabel}},{key:"isDebugMode",get:function(){return 0<this.listenerCount("log")}}]),i}();Object.assign(A.prototype,t);var D={ms:0,s:1,sec:1},N=/^#([a-zA-Z]+)/;return function(){s(i,Phaser.Plugins.BasePlugin);var t=u(i);function i(e){return r(this,i),t.call(this,e)}return e(i,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this)}},{key:"add",value:function(e,t){return new A(e,t)}}]),i}()});
  